/* * 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. */ // Demo scene for Ray++ #include "kernel/globals.h" #include "kernel/handle.h" #include "worlds/scene.h" #include "renderers/raytracer.h" #include "outputs/tga_output.h" #include "shapes/sphere.h" #include "surfaces/matte.h" #include "objects/simple_object.h" #include "lights/pointlight.h" #include "lights/ambient_light.h" #include "cameras/std_camera.h" #include "worlds/hmakers/pov_hmaker.h" int main () { using namespace RAYPP; HANDLE Output; Output = Cnew TGA_OUTPUT (640, 480, "second.tga"); Output->Init(); SCENE *Scn = Cnew SCENE; RAYTRACER *Raytracer = Cnew RAYTRACER; Raytracer->Add (Cnew STD_CAMERA (VECTOR (0,9,-14.5), VECTOR (0,0,0))); SIMPLE_OBJECT *obj, *ob2; // define two surfaces (one white, one pink) HANDLE hmat = Cnew MATTE (0.2, 1.0, COLOUR(1,1,1)); HANDLE hmat2 = Cnew MATTE (0.2, 1.0, COLOUR(1,0.7,0.7)); uint4 Priority = 1; // now create all the spheres for (float4 angle=0; angle<360; angle+=0.1) { obj = Cnew SIMPLE_OBJECT; obj->Set_Shape (Cnew SPHERE); obj->Scale(VECTOR(0.5,1,0.5)); obj->Translate(VECTOR(1,0,0)); obj->Rotate(VECTOR(0,0,3*angle)); obj->Translate(VECTOR(3,0,0)); obj->Rotate(VECTOR(0,angle,0)); obj->Set_Surface (hmat); obj->Set_Priority (Priority); Scn->Add (obj); ob2 = Cnew SIMPLE_OBJECT; ob2->Set_Shape (Cnew SPHERE); ob2->Scale(VECTOR(0.5,1,0.5)); ob2->Translate(VECTOR(1,0,0)); ob2->Rotate(VECTOR(0,0,3*angle)); ob2->Translate(VECTOR(3,0,0)); ob2->Rotate(VECTOR(0,angle+60,0)); ob2->Set_Surface (hmat2); ob2->Set_Priority (Priority); Scn->Add (ob2); } // add some lightsources to the scene Scn->Add (Cnew POINTLIGHT (VECTOR (10,30,-20), COLOUR (700,700,700))); Scn->Add (Cnew POINTLIGHT (VECTOR (-10,10,-20), COLOUR (300,300,700))); Scn->Add (Cnew AMBIENT_LIGHT (COLOUR (0.5,0.5,0.5))); // in this scene we definitely need a hierarchy maker // (or the computation would take some weeks) Scn->Set_HMaker (Cnew POV_HMAKER); World = Scn; World->Init(); Renderer = Raytracer; Renderer->Init(); Output->Render(); }