Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r371 - in branches/itanium2: Core/Geometry Interface Model/Intersections Model/Lights Model/MiscObjects scenes


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r371 - in branches/itanium2: Core/Geometry Interface Model/Intersections Model/Lights Model/MiscObjects scenes
  • Date: Thu, 9 Jun 2005 00:07:36 -0600 (MDT)

Author: abe
Date: Thu Jun  9 00:07:27 2005
New Revision: 371

Added:
   branches/itanium2/Model/Intersections/Plane.h
   branches/itanium2/Model/Lights/HeadLight.cc
   branches/itanium2/Model/Lights/HeadLight.h
   branches/itanium2/Model/MiscObjects/CuttingPlane.cc
   branches/itanium2/Model/MiscObjects/CuttingPlane.h
   branches/itanium2/scenes/cube.cc
Modified:
   branches/itanium2/Core/Geometry/BBox.h
   branches/itanium2/Interface/CMakeLists.txt
   branches/itanium2/Interface/HitInfo.h
   branches/itanium2/Model/Intersections/CMakeLists.txt
   branches/itanium2/Model/MiscObjects/CMakeLists.txt
   branches/itanium2/scenes/CMakeLists.txt
   branches/itanium2/scenes/boeing777.cc
Log:
Added CuttingPlane, Intersection::intersectPlane, remembered to add 
HeadLight, added even simpler scene "cube"

Modified: branches/itanium2/Core/Geometry/BBox.h
==============================================================================
--- branches/itanium2/Core/Geometry/BBox.h      (original)
+++ branches/itanium2/Core/Geometry/BBox.h      Thu Jun  9 00:07:27 2005
@@ -21,7 +21,7 @@
     }
     Point center() const {
       // return SCIRun::Interpolate(bounds[0], bounds[1], 
(Point::ScalarType)0.5);
-                       return Point(Vector(bounds[1]-bounds[0])*0.5);
+                       return 
Point(bounds[0]+Vector(bounds[1]-bounds[0])*0.5);
     }
 
                void extendByBox( const BBox &box ) {

Modified: branches/itanium2/Interface/CMakeLists.txt
==============================================================================
--- branches/itanium2/Interface/CMakeLists.txt  (original)
+++ branches/itanium2/Interface/CMakeLists.txt  Thu Jun  9 00:07:27 2005
@@ -6,6 +6,8 @@
         Background.cc
         Camera.h
         Camera.cc
+        Fragment.h
+        HitInfo.h
         IdleMode.h
         IdleMode.cc
         Image.h
@@ -28,6 +30,7 @@
         PixelSampler.cc
         Primitive.h
         Primitive.cc
+        RayPacket.h
         Renderer.h
         Renderer.cc
         RTRTInterface.h

Modified: branches/itanium2/Interface/HitInfo.h
==============================================================================
--- branches/itanium2/Interface/HitInfo.h       (original)
+++ branches/itanium2/Interface/HitInfo.h       Thu Jun  9 00:07:27 2005
@@ -16,19 +16,19 @@
   class Material;
   class Primitive;
   class TexCoordMapper;
-
+       
   // Convenience struct to hold a material, primitive and texcoordmapper
   struct MPT {
     const Material* material;
     const Primitive* primitive;
     const TexCoordMapper* tex;
     MPT(const Material* material, const Primitive* primitive,
-       const TexCoordMapper* tex)
+                               const TexCoordMapper* tex)
       : material(material), primitive(primitive), tex(tex)
     {
     }
   };
-
+       
   // Convenience struct to hold a material, primitive and texcoordmapper
   // and a scale/inverse scale
   struct MPTscale {
@@ -38,23 +38,23 @@
     double scale;
     double inv_scale;
     MPTscale(const Material* material, const Primitive* primitive,
-            const TexCoordMapper* tex, double scale, double inv_scale)
+                                                const TexCoordMapper* tex, 
double scale, double inv_scale)
       : material(material), primitive(primitive), tex(tex),
-       scale(scale), inv_scale(inv_scale)
+                       scale(scale), inv_scale(inv_scale)
     {
     }
   };
-
+       
   class HitInfo {
-  public:
+public:
     HitInfo()
-    {
-    }
-
+       {
+       }
+               
     ~HitInfo()
-    {
-    }
-      
+       {
+       }
+               
     inline void reset() {
       hitMatl = 0;
       min_t = MAXT;
@@ -80,28 +80,33 @@
     }
     void scaleT(double scale) {
       if(hitMatl != 0)
-       min_t *= scale;
+                               min_t *= scale;
     }
     void overrideT(double new_mint) {
       min_t = new_mint;
     }
-
+               
     bool hit(double t, const Material* matl, const Primitive* prim,
-            const TexCoordMapper* tex) {
+                                                const TexCoordMapper* tex) {
       if(t<T_EPSILON)
-               return false;
+                               return false;
       if(t < min_t){
-               min_t=t;
-               hitMatl = matl;
-               hitPrim = prim;
-               hitTex = tex;
-               return true;
+                               min_t=t;
+                               hitMatl = matl;
+                               hitPrim = prim;
+                               hitTex = tex;
+                               return true;
       } else {
-       return false;
+                               return false;
       }
     }
     static const size_t MaxScratchpadSize = 128;
-
+               
+               void copyScratchpad( const HitInfo &info ) {
+                       for (int i=0;i<MaxScratchpadSize;++i)
+                               scratchpad_data[i] = info.scratchpad_data[i];
+               }
+               
     template<class T> T& scratchpad() {
       
       // This pragma relates to the following expression being
@@ -119,10 +124,10 @@
       return *(T*)scratchpad_data;
     }
     
-  private:
-    HitInfo(const HitInfo&);
+private:
+                       HitInfo(const HitInfo&);
     HitInfo& operator=(const HitInfo&);
-
+               
     const Primitive* hitPrim;
     const Material* hitMatl;
     const TexCoordMapper* hitTex;

Modified: branches/itanium2/Model/Intersections/CMakeLists.txt
==============================================================================
--- branches/itanium2/Model/Intersections/CMakeLists.txt        (original)
+++ branches/itanium2/Model/Intersections/CMakeLists.txt        Thu Jun  9 
00:07:27 2005
@@ -1,4 +1,5 @@
 SET(Manta_Intersections_SRCS
     Intersections/AxisAlignedBox.h
     # Intersections/AxisAlignedBox.cc
+    Intersections/Plane.h
 )

Added: branches/itanium2/Model/Intersections/Plane.h
==============================================================================
--- (empty file)
+++ branches/itanium2/Model/Intersections/Plane.h       Thu Jun  9 00:07:27 
2005
@@ -0,0 +1,28 @@
+
+
+#ifndef Manta_Model_Intersections_Plane__H
+#define Manta_Model_Intersections_Plane__H
+
+namespace Manta {
+       namespace Intersection {
+       
+               template< typename Scalar >
+               inline bool intersectPlane( const Point &point, 
+                                           const Vector &normal,
+                                                                             
                                                  Scalar &t,
+                                                                             
                                                  const Ray &ray ) {
+                                                                             
                                                  
+                       Scalar dn = Dot( ray.direction(), normal );
+                       if (dn != 0.0) {
+                               Scalar ao = Dot( (point-ray.origin()), normal 
);
+                               t = ao/dn;
+                               return true;
+                       }
+                       return true;
+               }
+               
+               
+       }
+};
+
+#endif
\ No newline at end of file

Added: branches/itanium2/Model/Lights/HeadLight.cc
==============================================================================
--- (empty file)
+++ branches/itanium2/Model/Lights/HeadLight.cc Thu Jun  9 00:07:27 2005
@@ -0,0 +1,22 @@
+
+
+#include <Model/Lights/HeadLight.h>
+#include <Interface/Context.h>
+#include <Interface/Camera.h>
+
+using namespace Manta;
+
+void HeadLight::computeLight( Color &resultColor, Vector &lightDirection,
+                                                                        
const RenderContext &context, RayPacket::Element &e ) const {
+                                                                        
+       // Determine the camera position.
+       Point camera = context.camera->getPosition();
+       
+       // Determine light position.
+       Point position = camera + offset;
+       
+       // Finally compute light direction.
+       lightDirection = position - e.hitPosition;
+       
+       resultColor = color;
+}
\ No newline at end of file

Added: branches/itanium2/Model/Lights/HeadLight.h
==============================================================================
--- (empty file)
+++ branches/itanium2/Model/Lights/HeadLight.h  Thu Jun  9 00:07:27 2005
@@ -0,0 +1,24 @@
+
+#ifndef Manta_Model_HeadLight_h
+#define Manta_Model_HeadLight_h
+
+#include <Interface/Light.h>
+#include <Core/Geometry/PointVector.h>
+#include <Core/Color/Color.h>
+
+namespace Manta {
+  class HeadLight : public Light {
+public:
+    HeadLight(const Vector &offset_, const Color &color_) : offset( offset_ 
), color( color_ ) {  };
+               
+    virtual void preprocess(const PreprocessContext&) { /* Does Nothing. */ 
};
+               virtual void computeLight( Color &resultColor, Vector 
&lightDirection,
+                                          const RenderContext &context, 
RayPacket::Element &e ) const;
+               
+private:
+               Vector offset;
+    Color  color;
+  };
+}
+
+#endif
\ No newline at end of file

Modified: branches/itanium2/Model/MiscObjects/CMakeLists.txt
==============================================================================
--- branches/itanium2/Model/MiscObjects/CMakeLists.txt  (original)
+++ branches/itanium2/Model/MiscObjects/CMakeLists.txt  Thu Jun  9 00:07:27 
2005
@@ -1,4 +1,8 @@
 SET (Manta_MiscObjects_SRCS
+  MiscObjects/Difference.h
   MiscObjects/Difference.cc
+  MiscObjects/Intersection.h
   MiscObjects/Intersection.cc
+  MiscObjects/CuttingPlane.h
+  MiscObjects/CuttingPlane.cc
 )

Added: branches/itanium2/Model/MiscObjects/CuttingPlane.cc
==============================================================================
--- (empty file)
+++ branches/itanium2/Model/MiscObjects/CuttingPlane.cc Thu Jun  9 00:07:27 
2005
@@ -0,0 +1,123 @@
+#include <Model/MiscObjects/CuttingPlane.h>
+#include <Model/Intersections/AxisAlignedBox.h>
+#include <Model/Intersections/Plane.h>
+
+using namespace Manta;
+
+void CuttingPlane::intersect(const RenderContext& context, RayPacket& rays) 
const {
+
+       // Send a new ray packet with new ray origins.
+       RayPacketData new_data;
+       RayPacket     new_rays( new_data, rays.getSize(), rays.getDepth(), 
rays.getFlags() );
+       
+       rays.normalizeDirections();
+       rays.computeInverseDirections();
+       
+       // Map between rays in original packet and new packet in case some 
rays are skipped.
+       int packet_map[RayPacket::MaxSize];
+       
+       // Keep track of which new rays intersect the front face of the plane.
+       bool front_facing[RayPacket::MaxSize];
+       
+       // Keep track of the plane_t offset for each ray.
+       Real plane_t[RayPacket::MaxSize];
+        
+       
/////////////////////////////////////////////////////////////////////////////
+       // Create the new rays.
+       int new_i = 0, i;
+       for (i=0;i<rays.getSize();++i) {
+               RayPacket::Element &e = rays.get( i );
+               
+               Real box_min, box_max;
+               
+               // Check to see if the ray intersects the bounding box.
+               if (Intersection::intersectAaBox( bounds, box_min, box_max,
+                                                                             
                                                                          
e.ray, e.signMask, e.inverseDirection )) {
+                       
+                       // Intersect the ray with the plane.
+                       Intersection::intersectPlane( plane_point, 
plane_normal, plane_t[new_i], e.ray );
+                       
+                       RayPacket::Element &n = new_rays.get( new_i );
+                       
+                       // Record which original ray this new ray maps to.
+                       packet_map[new_i] = i;
+               
+                       // Check to see if the ray origin is on the front or 
back facing side of
+                       // the cutting plane (the front facing side is cut 
away).
+                       if (front_facing[new_i] = (Dot(plane_normal, 
(e.ray.origin()-plane_point)) > 0.0)) {
+                                       
+                                       // If plane_t is negative, the ray 
can't possibly hit the cut model.
+                                       // because the ray is pointing away 
from the plane.
+                                       if (plane_t[new_i] > 0.0) {
+                                               
+                                               // If front facing, move the 
new ray to the cutting plane.
+                                               
n.ray.set(e.ray.origin()+(e.ray.direction()*plane_t[new_i]),e.ray.direction());
+                                               
+                                               // Subtract the distance from 
the hit t.
+                                               n.hitInfo.reset( 
e.hitInfo.minT() - plane_t[new_i] );
+                                               
+                                               ++new_i;
+                                       }
+                       }
+                       else {
+                               
+                               // Otherwise if back facing, move the hit t 
in the hit record to the plane
+                               // (it will need to be moved back afterwards)
+                               n.ray = e.ray;
+                               //n.hitInfo.reset( plane_t[new_i] );
+                               n.hitInfo.reset( e.hitInfo.minT() );
+                       
+                               ++new_i;        
+                       }
+                       
+               
+               }
+       }
+       
+       // Check to see if all of the rays miss the bounds.
+       if (new_i == 0) {
+               return;
+       }
+       
+       // Specify the number of new rays.
+       new_rays.resize( new_i );
+       
+       
/////////////////////////////////////////////////////////////////////////////
+       // Intersect the new ray packet with the internal object.
+       internal_object->intersect( context, new_rays );
+       
+       
/////////////////////////////////////////////////////////////////////////////
+       // Map the results back to the old rays.
+       for (new_i=0; new_i<new_rays.getSize(); ++new_i) {
+       
+               RayPacket::Element &n = new_rays.get(new_i);
+               
+               // Check to see if the new ray hit something.
+               if (n.hitInfo.wasHit()) {
+
+                       // Determine which old ray this maps to.
+                       RayPacket::Element &e = rays.get( packet_map[new_i] );
+                       
+                       // Check to see if the old ray is front or back 
facing.
+                       if (front_facing[new_i]) {
+                               // If so, then translate the hit t back into 
the old hit record.
+                               if (e.hitInfo.hit( 
n.hitInfo.minT()+plane_t[new_i], 
+                                                                             
           n.hitInfo.hitMaterial(),
+                                                                             
           n.hitInfo.hitPrimitive(),
+                                                                             
           n.hitInfo.hitTexCoordMapper() ))
+                                       e.hitInfo.copyScratchpad( n.hitInfo );
+                       }
+                       else {
+                               // Otherwise, if the original ray is back 
facing check to see if the hit
+                               // is closer then the cutting plane.
+                               if ((plane_t[new_i] < 0.0) || 
(n.hitInfo.minT() < plane_t[new_i])) {
+                                       if (e.hitInfo.hit( n.hitInfo.minT(), 
+                                                                             
                   n.hitInfo.hitMaterial(),
+                                                                             
                   n.hitInfo.hitPrimitive(),
+                                                                             
                   n.hitInfo.hitTexCoordMapper() ))
+                                               e.hitInfo.copyScratchpad( 
n.hitInfo );
+                               }
+                       }
+               }
+       }
+}
\ No newline at end of file

Added: branches/itanium2/Model/MiscObjects/CuttingPlane.h
==============================================================================
--- (empty file)
+++ branches/itanium2/Model/MiscObjects/CuttingPlane.h  Thu Jun  9 00:07:27 
2005
@@ -0,0 +1,46 @@
+
+#ifndef Manta_Model_CuttingPlane_h
+#define Manta_Model_CuttinPlane_h
+
+#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/BBox.h>
+#include <Interface/Object.h>
+#include <Interface/RayPacket.h>
+
+
+// Cutting plane for intersections. 
+// Abe Stephens abe@sgi.com
+
+namespace Manta {
+       
+  class CuttingPlane : public Object {
+       private:
+               BBox bounds;             // Bounds of the internal object.
+               Object *internal_object; // Object to be cut.
+               
+               Point  plane_point;
+               Vector plane_normal;
+               
+       public:
+    CuttingPlane( const Point &point_, const Vector &normal_, Object 
*internal_object_ ) :
+                       plane_point( point_ ), plane_normal( normal_ ), 
internal_object( internal_object_ ) {  }
+               
+               // Preprocess the internal object and compute its bounds.
+    void preprocess( const PreprocessContext &context ) {
+                       
+                       // Call preprocess on the object.
+                       internal_object->preprocess( context );
+                       
+                       // Compute its bounds.
+                       internal_object->computeBounds( context, bounds );
+               }
+               
+               // Return the bounds of the object.
+    void computeBounds(const PreprocessContext& context, BBox& bbox) const { 
bbox.extendByBox( bounds ); };
+    
+               // Intersection method.
+               void intersect(const RenderContext& context, RayPacket& rays) 
const;
+  };
+}
+
+#endif
\ No newline at end of file

Modified: branches/itanium2/scenes/CMakeLists.txt
==============================================================================
--- branches/itanium2/scenes/CMakeLists.txt     (original)
+++ branches/itanium2/scenes/CMakeLists.txt     Thu Jun  9 00:07:27 2005
@@ -22,6 +22,13 @@
    TARGET_LINK_LIBRARIES(scene_0 ${manta_scene_link})
 ENDIF(SCENE_0)
 
+# Just a cube.
+SET(SCENE_CUBE 0 CACHE BOOL "Just a Cube")
+IF(SCENE_CUBE)
+   ADD_LIBRARY(scene_cube cube.cc)
+   TARGET_LINK_LIBRARIES(scene_cube ${manta_scene_link})
+ENDIF(SCENE_CUBE)
+
 # Read in a BART scene.
 SET(SCENE_BARTREADER 0 CACHE BOOL "BART Reader")
 IF(SCENE_BARTREADER)

Modified: branches/itanium2/scenes/boeing777.cc
==============================================================================
--- branches/itanium2/scenes/boeing777.cc       (original)
+++ branches/itanium2/scenes/boeing777.cc       Thu Jun  9 00:07:27 2005
@@ -29,6 +29,7 @@
 #include <Core/Geometry/AffineTransform.h>
 #include <Core/Util/NotFinished.h>
 #include <Model/AmbientLights/ConstantAmbient.h>
+#include <Model/MiscObjects/CuttingPlane.h>
 
 #include <SCIRun/Core/Thread/Time.h>
 
@@ -73,9 +74,6 @@
        std::cout << "Total load time: " << (end_time-start_time)/60.0 << " 
minutes." 
                  << std::endl << std::endl;
        
-       // Add the kdtree to the world group.
-       group->add( kdtree );
-       
        // min = (0, -1200 -7)
        // max = (2606, 1200, 716)
        
@@ -83,6 +81,17 @@
        BBox bounds;
        kdtree->computeBounds( bounds );
        
+       // Compute the middle of the model for a cutting plane.
+       Point  plane_point = bounds.center();
+       Vector plane_normal( 0.0, -1.0, 0.0 );
+       
+       std::cout << "Cutting plane point: "  << plane_point  << std::endl;
+       std::cout << "Cutting plane normal: " << plane_normal << std::endl;
+       
+       // Add the kdtree to the world group.
+       group->add( new CuttingPlane( plane_point, plane_normal, kdtree ) );
+       // group->add( kdtree );
+
        LightSet *lights = new LightSet();
        
        // Add lights at each corner of the model.

Added: branches/itanium2/scenes/cube.cc
==============================================================================
--- (empty file)
+++ branches/itanium2/scenes/cube.cc    Thu Jun  9 00:07:27 2005
@@ -0,0 +1,210 @@
+
+#include <Core/Geometry/PointVector.h>
+#include <Core/Exceptions/IllegalArgument.h>
+#include <Core/Util/Args.h>
+#include <Interface/Context.h>
+#include <Interface/LightSet.h>
+#include <Interface/RTRTInterface.h>
+#include <Interface/Scene.h>
+#include <Model/AmbientLights/ArcAmbient.h>
+#include <Model/Backgrounds/LinearBackground.h>
+#include <Model/Backgrounds/ConstantBackground.h>
+#include <Model/Groups/Group.h>
+#include <Model/Lights/PointLight.h>
+#include <Model/Materials/Lambertian.h>
+#include <Model/Materials/MetalMaterial.h>
+#include <Model/Materials/NormalMaterial.h>
+#include <Model/Primitives/Parallelogram.h>
+#include <Model/Primitives/Sphere.h>
+#include <Model/Primitives/Cube.h>
+#include <Model/Textures/CheckerTexture.h>
+#include <Core/Geometry/AffineTransform.h>
+#include <Core/Util/NotFinished.h>
+
+#include <Model/MiscObjects/CuttingPlane.h>
+
+#include <sgi_stl_warnings_off.h>
+#include <iostream>
+#include <sgi_stl_warnings_on.h>
+
+#include <math.h>
+#include <string.h>
+
+using namespace Manta;
+using namespace std;
+
+static const double SCALE = 1./3.;
+static const double BV_RADIUS = 1.0;
+
+static void create_dirs(Vector* objset)
+{
+  double dist=1./sqrt(2.0);
+  Vector dir[3];
+  dir[0]=Vector(dist, dist, 0);
+  dir[1]=Vector(dist, 0, -dist);
+  dir[2]=Vector(0, dist, -dist);
+
+  Vector axis(1, -1, 0);
+  axis.normalize();
+
+  double rot=asin(2.0/sqrt(6.0));
+  AffineTransform t;
+  t.initWithRotation(axis, rot);
+
+  for(int n=0;n<3;n++){
+    dir[n] = t * dir[n];
+  }
+
+  for(int ns=0;ns<3;ns++){
+    AffineTransform t;
+    t.initWithRotation(Vector(0,0,1), ns*2.*M_PI/3.);
+    for(int nv=0;nv<3;nv++){
+      objset[ns*3+nv] = t * dir[nv];
+    }
+  }
+}
+
+static void create_objs(Group* group, const Point& center,
+                       double radius, const Vector& dir, int depth,
+                       Vector* objset, Material* matl)
+{
+  group->add(new Sphere(matl, center, radius));
+
+  // Check if children should be generated
+  if(depth > 0){
+    depth--;
+    
+    // Rotation matrix to new axis from +Z axis
+    AffineTransform mx;
+    mx.initWithIdentity();
+    mx.rotate(Vector(0,0,1), dir);
+    
+    double scale = radius * (1+SCALE);
+    
+    for(int n=0;n<9;n++){
+      Vector child_vec(mx * objset[n]);
+      Point child_pt(center+child_vec*scale);
+      double child_rad=radius*SCALE; Vector child_dir = child_pt-center;
+      child_dir *= 1./scale;
+      create_objs(group, child_pt, child_rad, child_dir, depth, objset, 
matl);
+    }
+  }
+}
+
+static void make_box(Group* group, Material* matl,
+                    const Point& corner, const Vector& x, const Vector& y, 
const Vector& z)
+{
+  // group->add(new Parallelogram(matl, corner, x*2, z*2));
+  // group->add(new Parallelogram(matl, corner+y*2, z*2, x*2));
+  // group->add(new Parallelogram(matl, corner, y*2, z*2));
+  // group->add(new Parallelogram(matl, corner+x*2, z*2, y*2));
+  // group->add(new Parallelogram(matl, corner+z*2, x*2, y*2));
+
+  Point corner1 = corner + x + y + z;
+  
+  group->add( new Cube( matl, corner, corner1 ) );
+}
+
+static void make_obj(Group* world, int size)
+{
+  Vector objset[9];
+  create_dirs(objset);
+  Material* matl0=new Lambertian(Color(RGBColor(.4,.4,.4)));
+  //create_objs(world, Point(0,0,.5), BV_RADIUS/2.0, Vector(0,0,1),
+       //      size, objset, matl0);
+
+       // Just make a box....
+  Material* matl1=new Lambertian(Color(RGBColor(.2,.4,.2)));
+       NormalMaterial* normal_material = new NormalMaterial();
+       
+       // Add a box.
+       Point point( 0.5,0,0 );
+       Vector normal( 1,0,0 );
+       
+       world->add( new CuttingPlane( point, normal, 
+                                                       //new Cube( 
normal_material, Point(-1,-1,-1), Point(1,1,1) ) ) );
+                                                       new Sphere( 
normal_material, Point(0.0,0.0,0.00), 1.0 ) ) );
+       // Make a sphere where we think the box should be
+       // world->add(new Sphere( normal_material, Point(0.0,0.0,0.00), 1.0 ) 
);
+       
+  /*
+  Material* matl3=new MetalMaterial( Color(RGBColor(.7,.7,.7)));
+  world->add(new Sphere(matl3, 
corner+diag1*1.25+diag2*.6+z*2+Vector(0,0,.6), .6));
+  double planesize=15;
+  double scale = 2*planesize;
+  Material* matl2 = new Lambertian(new 
CheckerTexture<Color>(Color(RGBColor(.95,.95,.95)),
+                                                            
Color(RGBColor(.7,.3,.3)),
+                                                            
Vector(1,1.1,0)*scale,
+                                                            
Vector(-1.1,1,0)*scale));
+  Vector edge1(planesize, planesize*1.1, 0);
+  Vector edge2(-planesize*1.1, planesize, 0);
+  Object* obj1=new Parallelogram(matl2, Point(0,0,0)-edge1-edge2, edge1*2, 
edge2*2);
+  world->add(obj1);
+        */
+}
+
+extern "C" 
+Scene* make_scene(const ReadContext& context, const vector<string>& args)
+{
+  int scenesize=2;
+  double light_radius=0.8;
+  int argc = static_cast<int>(args.size());
+  Group* world = 0;
+  for(int i=0;i<argc;i++){
+    string arg = args[i];
+    if(arg == "-size"){
+      if(!getIntArg(i, args, scenesize))
+       throw IllegalArgument("scene 0 -size", i, args);
+    } else if(arg == "-light"){
+      if(!getDoubleArg(i, args, light_radius))
+       throw IllegalArgument("scene 0 -light", i, args);
+    } else if(arg == "-bv"){
+      string s;
+      if(!getStringArg(i, args, s))
+        throw IllegalArgument("scene 0 -bv", i, args);
+      world = context.rtrt_int->makeGroup(s);
+    } else {
+      cerr << "Valid options for scene 0:\n";
+      cerr << " -size n   - Sets depth of sphereflake\n";
+      cerr << " -light r  - Sets radius of light source for soft shadows\n";
+      throw IllegalArgument("scene 0", i, args);
+    }
+  }
+
+  if(!world)
+    world = new Group();
+       
+  NOT_FINISHED("scene 0");
+  make_obj(world, scenesize);
+       
+#if 0
+  Camera cam(Point(1.8,-5.53,1.25), Point(0.0,-.13,1.22),
+            Vector(0,0,1), 28.2);
+
+  double ambient_scale=1.0;
+  Color bgcolor(RGB(0.1, 0.2, 0.45));
+  Color cdown(RGB(0.82, 0.62, 0.62));
+  Color cup(RGB(0.1, 0.3, 0.8));
+  
+
+  rtrt::Plane groundplane ( Point(0, 0, 0), Vector(0, 0, 300) );
+  Scene* scene=new Scene(obj, cam,
+                        bgcolor, cdown, cup, groundplane,
+                        ambient_scale, Arc_Ambient);
+  
+  scene->select_shadow_mode( Single_Soft_Shadow );
+#endif
+  Scene* scene = new Scene();
+  scene->setBackground(new ConstantBackground(Color::white()));
+  scene->setObject(world);
+
+  NOT_FINISHED("soft shadows/area lights for scene 0");
+  LightSet* lights = new LightSet();
+  lights->add(new PointLight(Point(5,-3,3), Color(RGB(1,1,.8))*2));
+  Color cup(RGB(0.1, 0.3, 0.8));
+  Color cdown(RGB(0.82, 0.62, 0.62));
+  Vector up(0,0,1);
+  lights->setAmbientLight(new ArcAmbient(cup, cdown, up));
+  scene->setLights(lights);
+  return scene;
+}




  • [MANTA] r371 - in branches/itanium2: Core/Geometry Interface Model/Intersections Model/Lights Model/MiscObjects scenes, abe, 06/09/2005

Archive powered by MHonArc 2.6.16.

Top of page