/* * Ray++ - Object-oriented ray tracing library * Copyright (C) 1998-2001 Martin Reinecke and others. * See the AUTHORS file for more information. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * See the README file for more information. */ #include "kernel/globals.h" #include "kernel/handle.h" #include "worlds/scene.h" #include "renderers/raytracer.h" #include "outputs/tga_output.h" #include "shapes/parametric.h" #include "surfaces/matte.h" #include "objects/simple_object.h" #include "lights/pointlight.h" #include "cameras/std_camera.h" namespace RAYPP { class HELIX: public PARAMETRIC::PARFUNC { public: virtual AXISBOX Get_Extent (const IV8 &u, const IV8 &v) const { return AXISBOX (u.cos()*v, u, u.sin()*v); } virtual VECTOR Get_Point (float8 u, float8 v) const { return VECTOR (cos(u)*v, u, sin(u)*v); } virtual void Get_Ranges (IV8 &u, IV8 &v) const { u.Set (-4*Pi, 4*Pi); v.Set (0.3, 1); } }; class MOEBIUS: public PARAMETRIC::PARFUNC { public: virtual AXISBOX Get_Extent (const IV8 &u, const IV8 &v) const { IV8 u2 = u*2; IV8 vcosu3 = v*u.cos()+3; return AXISBOX (vcosu3*u2.cos(), vcosu3*u2.sin(), v*u.sin()); } virtual VECTOR Get_Point (float8 u, float8 v) const { float8 u2 = u*2; float8 vcosu3 = v*cos(u)+3; return VECTOR (vcosu3*cos(u2), vcosu3*sin(u2), v*sin(u)); } virtual void Get_Ranges (IV8 &u, IV8 &v) const { u.Set (0, Pi); v.Set (-1, 1); } }; } // namespace RAYPP int main () { using namespace RAYPP; HANDLE Output; Output = Cnew TGA_OUTPUT (640, 480, "paramtest.tga"); Output->Init(); RAYTRACER *Raytracer = Cnew RAYTRACER; SCENE *Scn = Cnew SCENE; Raytracer->Add (Cnew STD_CAMERA (VECTOR (0,0.75,-18.75), VECTOR (0,0,0))); SIMPLE_OBJECT *obj; uint4 Priority = 1; PARAMETRIC *Parm = Cnew PARAMETRIC (Cnew HELIX); Parm->Set_Resolution (0.05, 0.02); Parm->Scale(VECTOR(2,0.25,2)); Parm->Rotate(VECTOR(-45,0,0)); Parm->Translate(VECTOR(-4,0,0)); obj = Cnew SIMPLE_OBJECT; obj->Set_Shape (Parm); obj->Set_Surface (Cnew MATTE (0.2, 1.0, COLOUR(1,1,1))); obj->Set_Priority (Priority); Scn->Add (obj); Parm = Cnew PARAMETRIC (Cnew MOEBIUS); Parm->Set_Resolution (0.01, 0.1); Parm->Scale(0.9); Parm->Rotate(VECTOR(70,0,0)); Parm->Translate(VECTOR(3.5,0,0)); obj = Cnew SIMPLE_OBJECT; obj->Set_Shape (Parm); obj->Set_Surface (Cnew MATTE (0.2, 1.0, COLOUR(1,1,1))); obj->Set_Priority (Priority); Scn->Add (obj); Scn->Add (Cnew POINTLIGHT (VECTOR (0,10,-18.75), COLOUR (200,200,200))); Scn->Add (Cnew POINTLIGHT (VECTOR (5,0,-20), COLOUR (0,0,100))); Scn->Add (Cnew POINTLIGHT (VECTOR (0,0.75,-18.75), COLOUR (100,100,100))); World = Scn; World->Init(); Renderer = Raytracer; Renderer->Init(); Output->Render(); }