Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1630 - in trunk/Model: Cameras Groups Groups/private


Chronological Thread 
  • From: thiago@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1630 - in trunk/Model: Cameras Groups Groups/private
  • Date: Mon, 13 Aug 2007 23:08:58 -0600 (MDT)

Author: thiago
Date: Mon Aug 13 23:08:55 2007
New Revision: 1630

Modified:
   trunk/Model/Cameras/PinholeCamera.cc
   trunk/Model/Cameras/PinholeCamera.h
   trunk/Model/Groups/ObjGroup.cc
   trunk/Model/Groups/ObjGroup.h
   trunk/Model/Groups/private/CGT.cc
Log:
Model/Cameras/PinholeCamera:
  -Added a -createCornerRays flag.
  -camera output will now also include the normalizeRays and
   createCornerRays flags.
  -Simplified the code by using templates. Took some of the
   optimizations in the non-normalized version and put them in the
   normalized code path, so that now the normalized path is faster.

Model/Groups/ObjGroup: Can supply a default material if desired.


Modified: trunk/Model/Cameras/PinholeCamera.cc
==============================================================================
--- trunk/Model/Cameras/PinholeCamera.cc        (original)
+++ trunk/Model/Cameras/PinholeCamera.cc        Mon Aug 13 23:08:55 2007
@@ -34,7 +34,7 @@
 {
   haveCamera = false;
   normalizeRays = false;
-
+  createCornerRays = false;
   stereo_offset = 0;
 
   // pinhole(-eye 3 3 2 -lookat 0 0 0.3 -up 0 0 1 -fov 60
@@ -75,6 +75,8 @@
       haveCamera = true;
     } else if(arg == "-normalizeRays"){
       normalizeRays = true;
+    } else if(arg == "-createCornerRays"){
+      createCornerRays = true;
     } else {
       throw IllegalArgument("PinholeCamera", i, args);
     }
@@ -101,6 +103,14 @@
     os << " -offset " << stereo_offset;
   }
 
+  if (normalizeRays) {
+    os << " -normalizeRays";
+  }
+
+  if (createCornerRays) {
+    os << " -createCornerRays"; 
+  }
+
   os << " )" << std::endl;
 }
 
@@ -148,55 +158,78 @@
   ASSERT(rays.getFlag(RayPacket::ConstantEye));
   rays.setFlag(RayPacket::ConstantOrigin);
 
-  if(normalizeRays) {
-#ifdef MANTA_SSE
+  if (normalizeRays)
+    if (createCornerRays)
+      makeRaysSpecialized<true, true>(rays);
+    else
+      makeRaysSpecialized<true, false>(rays);
+  else
+    if (createCornerRays)
+      makeRaysSpecialized<false, true>(rays);
+    else
+      makeRaysSpecialized<false, false>(rays);
+}
 
-    //we need to find the max ray extents so that we can calculate the
-    //corner rays.  These are used by the WaldTriangle intersector and
-    //CGT acceleration structure to do frustum culling/traversal, and
-    //possibly elsewhere.
-    float min_v = std::numeric_limits<float>::max();
-    float max_v = -std::numeric_limits<float>::max();
-    float min_u = std::numeric_limits<float>::max();
-    float max_u = -std::numeric_limits<float>::max();
+template <bool NORMALIZE_RAYS, bool CREATE_CORNER_RAYS>
+void PinholeCamera::makeRaysSpecialized(RayPacket& rays) const
+{
+  //we need to find the max ray extents so that we can calculate the
+  //corner rays.  These are used by the WaldTriangle intersector and
+  //CGT acceleration structure to do frustum culling/traversal, and
+  //possibly elsewhere.
+  float min_v = std::numeric_limits<float>::max();
+  float max_v = -std::numeric_limits<float>::max();
+  float min_u = std::numeric_limits<float>::max();
+  float max_u = -std::numeric_limits<float>::max();
+
+#ifdef MANTA_SSE
 
     int b = (rays.rayBegin + 3) & (~3);
     int e = rays.rayEnd & (~3);
     if(b >= e){
       for(int i = rays.begin(); i < rays.end(); i++){
         Vector raydir(v*rays.getImageCoordinates(i, 
0)+u*rays.getImageCoordinates(i, 1)+direction);
-        raydir.normalize();
+        if (NORMALIZE_RAYS)
+          raydir.normalize();
         rays.setRay(i, eye, raydir);
 
-        //find max ray extents
-        min_v = SCIRun::Min(min_v, rays.getImageCoordinates(i, 0));
-        max_v = SCIRun::Max(max_v, rays.getImageCoordinates(i, 0));
-        min_u = SCIRun::Min(min_u, rays.getImageCoordinates(i, 1));
-        max_u = SCIRun::Max(max_u, rays.getImageCoordinates(i, 1));
+        if (CREATE_CORNER_RAYS) {
+          //find max ray extents
+          min_v = SCIRun::Min(min_v, rays.getImageCoordinates(i, 0));
+          max_v = SCIRun::Max(max_v, rays.getImageCoordinates(i, 0));
+          min_u = SCIRun::Min(min_u, rays.getImageCoordinates(i, 1));
+          max_u = SCIRun::Max(max_u, rays.getImageCoordinates(i, 1));
+        }
       }
     } else {
       int i = rays.rayBegin;
       for(;i<b;i++){
         Vector raydir(v*rays.getImageCoordinates(i, 
0)+u*rays.getImageCoordinates(i, 1)+direction);
-        raydir.normalize();
+        if (NORMALIZE_RAYS)
+          raydir.normalize();
         rays.setRay(i, eye, raydir);
 
-        //find max ray extents
-        min_v = SCIRun::Min(min_v, rays.getImageCoordinates(i, 0));
-        max_v = SCIRun::Max(max_v, rays.getImageCoordinates(i, 0));
-        min_u = SCIRun::Min(min_u, rays.getImageCoordinates(i, 1));
-        max_u = SCIRun::Max(max_u, rays.getImageCoordinates(i, 1));
+        if (CREATE_CORNER_RAYS) {
+          //find max ray extents
+          min_v = SCIRun::Min(min_v, rays.getImageCoordinates(i, 0));
+          max_v = SCIRun::Max(max_v, rays.getImageCoordinates(i, 0));
+          min_u = SCIRun::Min(min_u, rays.getImageCoordinates(i, 1));
+          max_u = SCIRun::Max(max_u, rays.getImageCoordinates(i, 1));
+        }
       }
       for(i=e;i<rays.rayEnd;i++){
         Vector raydir(v*rays.getImageCoordinates(i, 
0)+u*rays.getImageCoordinates(i, 1)+direction);
-        raydir.normalize();
+        if (NORMALIZE_RAYS)
+          raydir.normalize();
         rays.setRay(i, eye, raydir);
 
-        //find max ray extents
-        min_v = SCIRun::Min(min_v, rays.getImageCoordinates(i, 0));
-        max_v = SCIRun::Max(max_v, rays.getImageCoordinates(i, 0));
-        min_u = SCIRun::Min(min_u, rays.getImageCoordinates(i, 1));
-        max_u = SCIRun::Max(max_u, rays.getImageCoordinates(i, 1));
+        if (CREATE_CORNER_RAYS) {
+          //find max ray extents
+          min_v = SCIRun::Min(min_v, rays.getImageCoordinates(i, 0));
+          max_v = SCIRun::Max(max_v, rays.getImageCoordinates(i, 0));
+          min_u = SCIRun::Min(min_u, rays.getImageCoordinates(i, 1));
+          max_u = SCIRun::Max(max_u, rays.getImageCoordinates(i, 1));
+        }
       }
 
       sse_t min_vs = set4(min_v);
@@ -204,207 +237,88 @@
       sse_t min_us = set4(min_u);
       sse_t max_us = set4(max_u);
 
+      const sse_t eyex = set4(eye.data[0]);
+      const sse_t eyey = set4(eye.data[1]);
+      const sse_t eyez = set4(eye.data[2]);
+
+      const sse_t v0 = set4(v[0]);
+      const sse_t v1 = set4(v[1]);
+      const sse_t v2 = set4(v[2]);
+
+      const sse_t u0 = set4(u[0]);
+      const sse_t u1 = set4(u[1]);
+      const sse_t u2 = set4(u[2]);
+
+      const sse_t dirx = set4(direction[0]);
+      const sse_t diry = set4(direction[1]);
+      const sse_t dirz = set4(direction[2]);
+
       RayPacketData* data = rays.data;
       for(i=b;i<e;i+=4){
-        __m128 imagev = _mm_load_ps(&data->image[0][i]);
-        __m128 imageu = _mm_load_ps(&data->image[1][i]);
-        __m128 xd = _mm_add_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(v[0]), 
imagev), _mm_mul_ps(_mm_set1_ps(u[0]), imageu)), _mm_set1_ps(direction[0]));
-        __m128 yd = _mm_add_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(v[1]), 
imagev), _mm_mul_ps(_mm_set1_ps(u[1]), imageu)), _mm_set1_ps(direction[1]));
-        __m128 zd = _mm_add_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(v[2]), 
imagev), _mm_mul_ps(_mm_set1_ps(u[2]), imageu)), _mm_set1_ps(direction[2]));
-        __m128 length2 = _mm_add_ps(_mm_add_ps(_mm_mul_ps(xd, xd), 
_mm_mul_ps(yd, yd)), _mm_mul_ps(zd, zd));
-        __m128 scale =  _mm_rsqrt_ps(length2);
-        // Do one newton-raphson iteration to get the accuracy we need
-        scale = _mm_mul_ps(_mm_mul_ps(scale, _mm_sub_ps(_mm_set1_ps(3.f), 
_mm_mul_ps(length2, _mm_mul_ps(scale, scale)))), _mm_set1_ps(0.5f));
-        _mm_store_ps(&data->direction[0][i], _mm_mul_ps(xd, scale));
-        _mm_store_ps(&data->direction[1][i], _mm_mul_ps(yd, scale));
-        _mm_store_ps(&data->direction[2][i], _mm_mul_ps(zd, scale));
-
-        _mm_store_ps(&data->origin[0][i], _mm_set1_ps(eye[0]));
-        _mm_store_ps(&data->origin[1][i], _mm_set1_ps(eye[1]));
-        _mm_store_ps(&data->origin[2][i], _mm_set1_ps(eye[2]));
-
-        min_vs = min4(min_vs, imagev);
-        max_vs = max4(max_vs, imagev);
-        min_us = min4(min_us, imageu);
-        max_us = max4(max_us, imageu);
+        const sse_t imagev = load44(&data->image[0][i]);
+        const sse_t imageu = load44(&data->image[1][i]);
+        const sse_t xd = add4(add4(mul4(v0, imagev), mul4(u0, imageu)), 
dirx);
+        const sse_t yd = add4(add4(mul4(v1, imagev), mul4(u1, imageu)), 
diry);
+        const sse_t zd = add4(add4(mul4(v2, imagev), mul4(u2, imageu)), 
dirz);
+        if (NORMALIZE_RAYS) {
+          const sse_t length2 = add4(add4(mul4(xd, xd), mul4(yd, yd)), 
mul4(zd, zd));
+          const sse_t scale = accurateReciprocalSqrt(length2);
+          store44(&data->direction[0][i], mul4(xd, scale));
+          store44(&data->direction[1][i], mul4(yd, scale));
+          store44(&data->direction[2][i], mul4(zd, scale));
+        }
+        else {
+          store44(&data->direction[0][i], xd);
+          store44(&data->direction[1][i], yd);
+          store44(&data->direction[2][i], zd);
+        }
+        store44(&data->origin[0][i], eyex);
+        store44(&data->origin[1][i], eyey);
+        store44(&data->origin[2][i], eyez);
+
+        if (CREATE_CORNER_RAYS) {
+          min_vs = min4(min_vs, imagev);
+          max_vs = max4(max_vs, imagev);
+          min_us = min4(min_us, imageu);
+          max_us = max4(max_us, imageu);
+        }
+      }
+
+      if (CREATE_CORNER_RAYS) {
+        min_v = min4f(min_vs);
+        max_v = max4f(max_vs);
+        min_u = min4f(min_us);
+        max_u = max4f(max_us);
+        const sse_t imageu = set44(max_u, max_u, min_u, min_u);
+        const sse_t imagev = set44(max_v, min_v, max_v, min_v);
+        const sse_t xd = add4(add4(mul4(v0, imagev), mul4(u0, imageu)), 
dirx);
+        const sse_t yd = add4(add4(mul4(v1, imagev), mul4(u1, imageu)), 
diry);
+        const sse_t zd = add4(add4(mul4(v2, imagev), mul4(u2, imageu)), 
dirz);
+        if (NORMALIZE_RAYS) {
+          const sse_t length2 = add4(add4(mul4(xd, xd), mul4(yd, yd)), 
mul4(zd, zd));
+          const sse_t scale = accurateReciprocalSqrt(length2);
+          data->corner_dir[0] = mul4(xd, scale);
+          data->corner_dir[1] = mul4(yd, scale);
+          data->corner_dir[2] = mul4(zd, scale);
+        }
+        else {
+          data->corner_dir[0] = xd;
+          data->corner_dir[1] = yd;
+          data->corner_dir[2] = zd;
+        }
+        rays.setFlag(RayPacket::HaveCornerRays);
       }
-
-      min_v = min4f(min_vs);
-      max_v = max4f(max_vs);
-      min_u = min4f(min_us);
-      max_u = max4f(max_us);
-      const sse_t imageu = set44(max_u, max_u, min_u, min_u);
-      const sse_t imagev = set44(max_v, min_v, max_v, min_v);
-      const sse_t xd = add4(add4(mul4(set4(v[0]), imagev), mul4(set4(u[0]), 
imageu)), set4(direction[0]));
-      const sse_t yd = add4(add4(mul4(set4(v[1]), imagev), mul4(set4(u[1]), 
imageu)), set4(direction[1]));
-      const sse_t zd = add4(add4(mul4(set4(v[2]), imagev), mul4(set4(u[2]), 
imageu)), set4(direction[2]));
-      const sse_t length2 = add4(add4(mul4(xd, xd), mul4(yd, yd)), mul4(zd, 
zd));
-      sse_t scale =  _mm_rsqrt_ps(length2);
-      // Do one newton-raphson iteration to get the accuracy we need
-      scale = mul4(mul4(scale, _mm_sub_ps(set4(3.f), mul4(length2, 
mul4(scale, scale)))), set4(0.5f));
-      data->corner_dir[0] = mul4(xd, scale);
-      data->corner_dir[1] = mul4(yd, scale);
-      data->corner_dir[2] = mul4(zd, scale);
-      rays.setFlag(RayPacket::HaveCornerRays);
     }
 #else
     for(int i = rays.begin(); i < rays.end(); i++){
       Vector raydir(v*rays.getImageCoordinates(i, 
0)+u*rays.getImageCoordinates(i, 1)+direction);
-      raydir.normalize();
+      if (NORMALIZE_RAYS)
+        raydir.normalize();
       rays.setRay(i, eye, raydir);
     }
 #endif
-    rays.setFlag(RayPacket::NormalizedDirections);
-  } else {
-#if MANTA_SSE
-    RayPacketData* data = rays.data;
-    // Only enabled if the packet starts and ends on a multiple of 4
-    if(((rays.rayBegin | rays.rayEnd) & 0x3) == 0){
-#define VERSION2
-#ifdef VERSION0
-      RayPacketData* data = rays.data;
-      Real u_vec[3] = { u[0], u[1], u[2] };
-      Real v_vec[3] = { v[0], v[1], v[2] };
-      Real d_vec[3] = { direction[0], direction[1], direction[2] };
-
-      for(int i=rays.begin();i<rays.end();i++)
-      {
-        data->origin[0][i] = eye.data[0];
-        data->origin[1][i] = eye.data[1];
-        data->origin[2][i] = eye.data[2];
-
-        const Real u_coord = data->image[1][i];
-        const Real v_coord = data->image[0][i];
-
-        data->direction[0][i] = d_vec[0] + u_coord * u_vec[0] + v_coord * 
v_vec[0];
-        data->direction[1][i] = d_vec[1] + u_coord * u_vec[1] + v_coord * 
v_vec[1];
-        data->direction[2][i] = d_vec[2] + u_coord * u_vec[2] + v_coord * 
v_vec[2];
-      }
-#endif
-#ifdef VERSION1
-      __m128 eyex = _mm_set1_ps(eye.data[0]);
-      __m128 eyey = _mm_set1_ps(eye.data[1]);
-      __m128 eyez = _mm_set1_ps(eye.data[2]);
-      __m128 dirx = _mm_set1_ps(direction[0]);
-      __m128 diry = _mm_set1_ps(direction[1]);
-      __m128 dirz = _mm_set1_ps(direction[2]);
-      __m128 ux = _mm_set1_ps(u[0]);
-      __m128 uy = _mm_set1_ps(u[1]);
-      __m128 uz = _mm_set1_ps(u[2]);
-      __m128 vx = _mm_set1_ps(v[0]);
-      __m128 vy = _mm_set1_ps(v[1]);
-      __m128 vz = _mm_set1_ps(v[2]);
-      for(int i=rays.rayBegin; i < rays.rayEnd; i+=4){
-        _mm_store_ps(&data->origin[0][i], eyex);
-        _mm_store_ps(&data->origin[1][i], eyey);
-        _mm_store_ps(&data->origin[2][i], eyez);
-
-        __m128 u_coord = _mm_load_ps(&data->image[1][i]);
-        __m128 v_coord = _mm_load_ps(&data->image[0][i]);
-
-        __m128 dx = _mm_add_ps(dirx, _mm_add_ps(_mm_mul_ps(u_coord, ux), 
_mm_mul_ps(v_coord, vx)));
-        _mm_store_ps(&data->direction[0][i], dx);
-        __m128 dy = _mm_add_ps(diry, _mm_add_ps(_mm_mul_ps(u_coord, uy), 
_mm_mul_ps(v_coord, vy)));
-        _mm_store_ps(&data->direction[1][i], dy);
-        __m128 dz = _mm_add_ps(dirz, _mm_add_ps(_mm_mul_ps(u_coord, uz), 
_mm_mul_ps(v_coord, vz)));
-        _mm_store_ps(&data->direction[2][i], dz);
-      }
-#endif
-#ifdef VERSION2
-      __m128 eyex = _mm_set1_ps(eye.data[0]);
-      __m128 eyey = _mm_set1_ps(eye.data[1]);
-      __m128 eyez = _mm_set1_ps(eye.data[2]);
-      for(int i=rays.rayBegin; i < rays.rayEnd; i+=4){
-        _mm_store_ps(&data->origin[0][i], eyex);
-        _mm_store_ps(&data->origin[1][i], eyey);
-        _mm_store_ps(&data->origin[2][i], eyez);
-      }
-      __m128 dirx = _mm_set1_ps(direction[0]);
-      __m128 diry = _mm_set1_ps(direction[1]);
-      __m128 dirz = _mm_set1_ps(direction[2]);
-      __m128 ux = _mm_set1_ps(u[0]);
-      __m128 uy = _mm_set1_ps(u[1]);
-      __m128 uz = _mm_set1_ps(u[2]);
-      __m128 vx = _mm_set1_ps(v[0]);
-      __m128 vy = _mm_set1_ps(v[1]);
-      __m128 vz = _mm_set1_ps(v[2]);
-      for(int i=rays.rayBegin; i < rays.rayEnd; i+=4){
-        __m128 u_coord = _mm_load_ps(&data->image[1][i]);
-        __m128 v_coord = _mm_load_ps(&data->image[0][i]);
-
-        __m128 dx = _mm_add_ps(dirx, _mm_add_ps(_mm_mul_ps(u_coord, ux), 
_mm_mul_ps(v_coord, vx)));
-        _mm_store_ps(&data->direction[0][i], dx);
-        __m128 dy = _mm_add_ps(diry, _mm_add_ps(_mm_mul_ps(u_coord, uy), 
_mm_mul_ps(v_coord, vy)));
-        _mm_store_ps(&data->direction[1][i], dy);
-        __m128 dz = _mm_add_ps(dirz, _mm_add_ps(_mm_mul_ps(u_coord, uz), 
_mm_mul_ps(v_coord, vz)));
-        _mm_store_ps(&data->direction[2][i], dz);
-      }
-#endif
-#ifdef VERSION3
-      __m128 eyex = _mm_set1_ps(eye.data[0]);
-      __m128 eyey = _mm_set1_ps(eye.data[1]);
-      __m128 eyez = _mm_set1_ps(eye.data[2]);
-      for(int i=rays.rayBegin; i < rays.rayEnd; i+=4){
-        _mm_store_ps(&data->origin[0][i], eyex);
-        _mm_store_ps(&data->origin[1][i], eyey);
-        _mm_store_ps(&data->origin[2][i], eyez);
-      }
-      __m128 dirx = _mm_set1_ps(direction[0]);
-      __m128 ux = _mm_set1_ps(u[0]);
-      __m128 vx = _mm_set1_ps(v[0]);
-      for(int i=rays.rayBegin; i < rays.rayEnd; i+=4){
-        __m128 u_coord = _mm_load_ps(&data->image[1][i]);
-        __m128 v_coord = _mm_load_ps(&data->image[0][i]);
-
-        __m128 dx = _mm_add_ps(dirx, _mm_add_ps(_mm_mul_ps(u_coord, ux), 
_mm_mul_ps(v_coord, vx)));
-        _mm_store_ps(&data->direction[0][i], dx);
-      }
-
-      __m128 diry = _mm_set1_ps(direction[1]);
-      __m128 uy = _mm_set1_ps(u[1]);
-      __m128 vy = _mm_set1_ps(v[1]);
-      for(int i=rays.rayBegin; i < rays.rayEnd; i+=4){
-        __m128 u_coord = _mm_load_ps(&data->image[1][i]);
-        __m128 v_coord = _mm_load_ps(&data->image[0][i]);
-
-        __m128 dy = _mm_add_ps(diry, _mm_add_ps(_mm_mul_ps(u_coord, uy), 
_mm_mul_ps(v_coord, vy)));
-        _mm_store_ps(&data->direction[1][i], dy);
-      }
-
-      __m128 dirz = _mm_set1_ps(direction[2]);
-      __m128 uz = _mm_set1_ps(u[2]);
-      __m128 vz = _mm_set1_ps(v[2]);
-      for(int i=rays.rayBegin; i < rays.rayEnd; i+=4){
-        __m128 u_coord = _mm_load_ps(&data->image[1][i]);
-        __m128 v_coord = _mm_load_ps(&data->image[0][i]);
-
-        __m128 dz = _mm_add_ps(dirz, _mm_add_ps(_mm_mul_ps(u_coord, uz), 
_mm_mul_ps(v_coord, vz)));
-        _mm_store_ps(&data->direction[2][i], dz);
-      }
-#endif
-    } else
-#endif
-    {
-      RayPacketData* data = rays.data;
-      Real u_vec[3] = { u[0], u[1], u[2] };
-      Real v_vec[3] = { v[0], v[1], v[2] };
-      Real d_vec[3] = { direction[0], direction[1], direction[2] };
-
-      for(int i=rays.begin();i<rays.end();i++)
-      {
-        data->origin[0][i] = eye.data[0];
-        data->origin[1][i] = eye.data[1];
-        data->origin[2][i] = eye.data[2];
-
-        const Real u_coord = data->image[1][i];
-        const Real v_coord = data->image[0][i];
-
-        data->direction[0][i] = d_vec[0] + u_coord * u_vec[0] + v_coord * 
v_vec[0];
-        data->direction[1][i] = d_vec[1] + u_coord * u_vec[1] + v_coord * 
v_vec[1];
-        data->direction[2][i] = d_vec[2] + u_coord * u_vec[2] + v_coord * 
v_vec[2];
-      }
-    }
-  }
+    if (NORMALIZE_RAYS)
+      rays.setFlag(RayPacket::NormalizedDirections);
 }
 
 void PinholeCamera::scaleFOV(Real scale)

Modified: trunk/Model/Cameras/PinholeCamera.h
==============================================================================
--- trunk/Model/Cameras/PinholeCamera.h (original)
+++ trunk/Model/Cameras/PinholeCamera.h Mon Aug 13 23:08:55 2007
@@ -49,6 +49,9 @@
     Real getStereoOffset() const { return stereo_offset; }
 
   protected:
+    template <bool NORMALIZE_RAYS, bool CREATE_CORNER_RAYS>
+    void makeRaysSpecialized(RayPacket& rays) const;
+
     Vector direction;
     Vector u,v;
     Vector eye;
@@ -60,6 +63,7 @@
                                             // distance from eye to image 
plane
     void setup();
     bool normalizeRays;
+    bool createCornerRays;
     bool haveCamera;
   };
 }

Modified: trunk/Model/Groups/ObjGroup.cc
==============================================================================
--- trunk/Model/Groups/ObjGroup.cc      (original)
+++ trunk/Model/Groups/ObjGroup.cc      Mon Aug 13 23:08:55 2007
@@ -161,7 +161,9 @@
 
 
 
-ObjGroup::ObjGroup( const char *filename ) throw (InputError) {
+ObjGroup::ObjGroup( const char *filename, 
+                    Material *defaultMaterial) throw (InputError)
+{
 
   // Load the model.
   GLMmodel *model = glmReadOBJ( filename );
@@ -192,9 +194,9 @@
 //                                  model->facetnorms[i*3+1],
 //                                  model->facetnorms[i*3+2]));
 
-//   Material *default_material = new Flat( new NormalTexture() );
-  Material *default_material = new Lambertian( new NormalTexture() );
-  materials.push_back(default_material);
+  if (defaultMaterial == NULL)
+    defaultMaterial = new Lambertian( new NormalTexture() );
+  materials.push_back(defaultMaterial);
   for (unsigned int i=0; i < model->nummaterials; ++i)
     materials.push_back(material_array[i]);
 

Modified: trunk/Model/Groups/ObjGroup.h
==============================================================================
--- trunk/Model/Groups/ObjGroup.h       (original)
+++ trunk/Model/Groups/ObjGroup.h       Mon Aug 13 23:08:55 2007
@@ -12,7 +12,8 @@
   
   class ObjGroup : public Mesh {
   public:
-    ObjGroup( const char *filename ) throw (InputError);
+    ObjGroup( const char *filename,
+              Material *defaultMaterial=NULL ) throw (InputError);
     virtual ~ObjGroup();
     
   private:

Modified: trunk/Model/Groups/private/CGT.cc
==============================================================================
--- trunk/Model/Groups/private/CGT.cc   (original)
+++ trunk/Model/Groups/private/CGT.cc   Mon Aug 13 23:08:55 2007
@@ -276,7 +276,6 @@
 
   for (int i = startObject; i < endObject; i++) {
     BBox bbox;
-    PreprocessContext blah;
     currGroup->get(i)->computeBounds(blah, bbox);
     Box4 objectBounds;
     objectBounds.min = set44(0.0f, bbox[0][2], bbox[0][1], bbox[0][0]);
@@ -417,7 +416,7 @@
     cout << "grid built in " 
          << (SCIRun::Time::currentSeconds() - startGlobalBuildTime)*1e3 << 
"ms\n\n";
   firstTime = false;
-};
+}
 
 
 
@@ -505,7 +504,7 @@
       minDv = min(minDv, dv);
       maxDv = max(maxDv, dv);
     }
-      
+    
     const sse_t inv_scaleN = accurateReciprocal(scaleN);
       
     minDu *= DK;
@@ -1111,7 +1110,7 @@
 #endif
     continue;
   }
-};
+}
 
 template<bool SHADOWS_ONLY, bool COMMON_ORIGIN, bool SQUARE_PACKETS>
 void Grid::traverse(RayPacket &packet, const RenderContext& context) const




  • [MANTA] r1630 - in trunk/Model: Cameras Groups Groups/private, thiago, 08/14/2007

Archive powered by MHonArc 2.6.16.

Top of page