/* * 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 for gaseous volume This is a simple program which creates an image of gaseous sphere with varying density around a solid sphere. */ #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 "shapes/plane.h" #include "surfaces/matte.h" #include "volumes/fog.h" #include "volumes/gas2.h" #include "objects/simple_object.h" #include "lights/pointlight.h" #include "lights/ambient_light.h" #include "cameras/std_camera.h" namespace RAYPP { class Dens1: public GAS2::OPACITY_FUNCTOR { public: COLOUR Get_Opacity (const VECTOR &) const { return COLOUR(0.5,0.5,0.5); } }; } // namespace RAYPP int main () { using namespace RAYPP; HANDLE Output; Output = Cnew TGA_OUTPUT (640, 480, "gastest.tga"); Output->Init(); RAYTRACER *Raytracer = Cnew RAYTRACER; SCENE *Scn = Cnew SCENE; Raytracer->Add (Cnew STD_CAMERA (VECTOR (0,1.5,-4.5), VECTOR (0,0,0))); SIMPLE_OBJECT *obj; uint4 Priority = 1; //create a gaseous sphere obj = Cnew SIMPLE_OBJECT; obj->Set_Shape (Cnew SPHERE); obj->Set_Priority (Priority); //Set volume to Gas obj->Set_Volume (Cnew GAS2 (GAS2::RAYLEIGH, Cnew Dens1)); Scn->Add (obj); //create a smaller sphere inside the gaseous sphere obj = Cnew SIMPLE_OBJECT; obj->Set_Shape (Cnew SPHERE); obj->Scale (0.6); obj->Set_Surface (Cnew MATTE (0.2, 0.8, COLOUR(1,0.5,0.5))); obj->Set_Priority (Priority); Scn->Add (obj); Scn->Add (Cnew POINTLIGHT (VECTOR (15,10,-5), COLOUR (350,350,350))); World = Scn; World->Init(); Renderer = Raytracer; Renderer->Init(); Output->Render(); }