/* * 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/box.h" #include "shapes/sphere.h" #include "shapes/plane.h" #include "surfaces/matte.h" #include "surfaces/phong.h" #include "surfaces/pigments/pure_colour.h" #include "surfaces/pigments/std_pigments.h" #include "objects/simple_object.h" #include "lights/pointlight.h" #include "lights/ambient_light.h" #include "cameras/std_camera.h" #include "volumes/clear_glass.h" int main () { using namespace RAYPP; HANDLE Output; TGA_OUTPUT *MyOutput = Cnew TGA_OUTPUT (640, 480, "reflect_test.tga"); Output = MyOutput; Output->Init(); RAYTRACER *Raytracer = Cnew RAYTRACER; SCENE *Scn = Cnew SCENE; Raytracer->Add (Cnew STD_CAMERA (VECTOR (-2.0,2.0,-4.0), VECTOR (0,0,0))); SIMPLE_OBJECT *obj; uint4 Priority = 1; // glass PHONG GlassP(0, 0, 0.1, 0.1, 0.7, 300, COLOUR(1,1,1)); HANDLE Glass = Cnew PHONG(GlassP); HANDLE GlassVol = Cnew CLEAR_GLASS(1.1); // glass cube obj = Cnew SIMPLE_OBJECT; obj->Set_Shape (Cnew BOX); obj->Translate (VECTOR(-0.5,-0.5,-0.5)); obj->Rotate (VECTOR(0,45,0)); obj->Rotate (VECTOR(-10,0,0)); obj->Translate (VECTOR(-1,0,0.5)); obj->Set_Surface (Glass); obj->Set_Volume(GlassVol); obj->Set_Priority (Priority); Scn->Add (obj); // glass sphere obj = Cnew SIMPLE_OBJECT; obj->Set_Shape (Cnew SPHERE(VECTOR(1,0,0), 1)); obj->Set_Surface (Glass); obj->Set_Volume(GlassVol); obj->Set_Priority (Priority); Scn->Add (obj); // marble sphere MARBLE STex; STex.Set_CMap(COLOURMAP(COLOUR(0.5,1,0.5), COLOUR(0,0.5,0))); STex.Scale(0.3); STex.Set_Turb(1.0); HANDLE SPig = Cnew MARBLE(STex); obj = Cnew SIMPLE_OBJECT; obj->Set_Shape (Cnew SPHERE(VECTOR(0.4,0,1.7), 1)); obj->Set_Surface (Cnew PHONG (0.2, 0.4, 0.4, 0.4, 0.0, 300, SPig)); obj->Set_Priority (Priority); Scn->Add (obj); // sky sphere obj = Cnew SIMPLE_OBJECT; obj->Set_Shape (Cnew SPHERE(VECTOR(0,0,0), 1000)); obj->Set_Surface (Cnew MATTE (0.8, 0.2, COLOUR(0.9,0.9,1))); obj->Set_Priority (Priority); Scn->Add (obj); // floor CHECKER FloorTex; FloorTex.Set_CMap(COLOURMAP(COLOUR(0,0,0), COLOUR(1,1,1))); HANDLE FloorPig = Cnew CHECKER(FloorTex); obj = Cnew SIMPLE_OBJECT; obj->Set_Shape (Cnew PLANE); obj->Set_Surface (Cnew MATTE (0.7, 0.5, FloorPig)); obj->Set_Priority (Priority); obj->Translate (VECTOR (0,-1,0)); Scn->Add (obj); Scn->Add (Cnew POINTLIGHT (VECTOR (0,20,-10), COLOUR (600,600,600))); Scn->Add (Cnew AMBIENT_LIGHT (COLOUR (0.9,0.9,0.9))); World = Scn; World->Init(); Renderer = Raytracer; Renderer->Init(); Output->Render(); }