Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r378 - in trunk: . Core/Color Core/Geometry Core/Math Engine/PixelSamplers Interface Model/AmbientLights SwigInterface


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r378 - in trunk: . Core/Color Core/Geometry Core/Math Engine/PixelSamplers Interface Model/AmbientLights SwigInterface
  • Date: Fri, 10 Jun 2005 18:48:24 -0600 (MDT)

Author: bigler
Date: Fri Jun 10 18:48:21 2005
New Revision: 378

Added:
   trunk/SwigInterface/
      - copied from r377, swig/SwigInterface/
   trunk/SwigInterface/CMakeLists.txt
      - copied unchanged from r377, swig/SwigInterface/CMakeLists.txt
   trunk/SwigInterface/example.cc
      - copied unchanged from r377, swig/SwigInterface/example.cc
   trunk/SwigInterface/example.i
      - copied unchanged from r377, swig/SwigInterface/example.i
   trunk/SwigInterface/manta-run.py
      - copied unchanged from r377, swig/SwigInterface/manta-run.py
   trunk/SwigInterface/manta.cc
      - copied unchanged from r377, swig/SwigInterface/manta.cc
   trunk/SwigInterface/manta.i
      - copied unchanged from r377, swig/SwigInterface/manta.i
Modified:
   trunk/CMakeLists.txt
   trunk/Core/Color/ColorDB.cc
   trunk/Core/Color/ColorDB.h
   trunk/Core/Color/ColorSpace.h
   trunk/Core/Geometry/PointVector.cc
   trunk/Core/Geometry/PointVector.h
   trunk/Core/Geometry/Ray.h
   trunk/Core/Math/MT_RNG.cc
   trunk/Core/Math/MT_RNG.h
   trunk/Core/Math/vector2d.h
   trunk/Engine/PixelSamplers/HammersleySampler.cc
   trunk/Engine/PixelSamplers/InterLeaveSampler.cc
   trunk/Engine/PixelSamplers/JitterSampler.cc
   trunk/Engine/PixelSamplers/JitterSampler.h
   trunk/Engine/PixelSamplers/MultiJitterSampler.cc
   trunk/Engine/PixelSamplers/NRooksSampler.cc
   trunk/Engine/PixelSamplers/Sample.cc
   trunk/Engine/PixelSamplers/Sample.h
   trunk/Engine/PixelSamplers/SingleSampler.cc
   trunk/Interface/AmbientLight.h
   trunk/Interface/LightSet.cc
   trunk/Interface/LightSet.h
   trunk/Interface/RayPacket.h
   trunk/Interface/TValue.h
   trunk/Model/AmbientLights/ArcAmbient.cc
   trunk/Model/AmbientLights/ArcAmbient.h
   trunk/Model/AmbientLights/ConstantAmbient.cc
   trunk/Model/AmbientLights/ConstantAmbient.h
Log:
Merge from swig branch.  Has a few fixes in non SWIG code (sampler code for 
one).

Modified: trunk/CMakeLists.txt
==============================================================================
--- trunk/CMakeLists.txt        (original)
+++ trunk/CMakeLists.txt        Fri Jun 10 18:48:21 2005
@@ -46,15 +46,26 @@
                     ${CMAKE_SOURCE_DIR}/SCIRun 
                     ${CMAKE_SOURCE_DIR}/SCIRun/include)
 
-SUBDIRS( SCIRun/Core
-         Core
-         Interface
-         Image
-         Model
-         UserInterface
-         Engine
-         StandAlone
-         Readers
-         scenes )
+SET(MAIN_SUBDIRS
+  SCIRun/Core
+  Core
+  Interface
+  Image
+  Model
+  UserInterface
+  Engine
+  StandAlone
+  Readers
+  scenes
+  )
+
+# Only process the swig directory if we have swig stuff
+FIND_PACKAGE(SWIG)
+IF (SWIG_FOUND)
+  SET(MAIN_SUBDIRS ${MAIN_SUBDIRS} SwigInterface)
+ENDIF (SWIG_FOUND)
+
+SUBDIRS( ${MAIN_SUBDIRS} )
+
 
 

Modified: trunk/Core/Color/ColorDB.cc
==============================================================================
--- trunk/Core/Color/ColorDB.cc (original)
+++ trunk/Core/Color/ColorDB.cc Fri Jun 10 18:48:21 2005
@@ -1,13 +1,25 @@
 
 #include <Core/Color/ColorDB.h>
 #include <Core/Exceptions/UnknownColor.h>
+
+#include <sgi_stl_warnings_off.h>
+#include <iostream>
+#include <sgi_stl_warnings_on.h>
+
 using namespace Manta;
+using namespace std;
 
 struct RGBData {
   char* name;
   unsigned char r, g, b;
 };
 
+// If you add a color, remember that the emacs's sort doesn't do the
+// right thing.  Emacs places "lavender blush" before "lavender",
+// however the std::string::operator< places it the other way.  After
+// you add a color, run the provided test function to make sure that
+// everything is sorted properly.
+
 static RGBData namedColors[] = {
   {"AliceBlue", 240, 248, 255},
   {"AntiqueWhite", 250, 235, 215},
@@ -292,8 +304,8 @@
   {"bisque4", 139, 125, 107},
   {"black", 0, 0, 0},
   {"blanched almond", 255, 235, 205},
-  {"blue violet", 138, 43, 226},
   {"blue", 0, 0, 255},
+  {"blue violet", 138, 43, 226},
   {"blue1", 0, 0, 255},
   {"blue2", 0, 0, 238},
   {"blue3", 0, 0, 205},
@@ -480,8 +492,8 @@
   {"gray97", 247, 247, 247},
   {"gray98", 250, 250, 250},
   {"gray99", 252, 252, 252},
-  {"green yellow", 173, 255, 47},
   {"green", 0, 255, 0},
+  {"green yellow", 173, 255, 47},
   {"green1", 0, 255, 0},
   {"green2", 0, 238, 0},
   {"green3", 0, 205, 0},
@@ -605,15 +617,15 @@
   {"khaki2", 238, 230, 133},
   {"khaki3", 205, 198, 115},
   {"khaki4", 139, 134, 78},
-  {"lavender blush", 255, 240, 245},
   {"lavender", 230, 230, 250},
+  {"lavender blush", 255, 240, 245},
   {"lawn green", 124, 252, 0},
   {"lemon chiffon", 255, 250, 205},
   {"light blue", 173, 216, 230},
   {"light coral", 240, 128, 128},
   {"light cyan", 224, 255, 255},
-  {"light goldenrod yellow", 250, 250, 210},
   {"light goldenrod", 238, 221, 130},
+  {"light goldenrod yellow", 250, 250, 210},
   {"light gray", 211, 211, 211},
   {"light green", 144, 238, 144},
   {"light grey", 211, 211, 211},
@@ -652,12 +664,12 @@
   {"misty rose", 255, 228, 225},
   {"moccasin", 255, 228, 181},
   {"navajo white", 255, 222, 173},
-  {"navy blue", 0, 0, 128},
   {"navy", 0, 0, 128},
+  {"navy blue", 0, 0, 128},
   {"old lace", 253, 245, 230},
   {"olive drab", 107, 142, 35},
-  {"orange red", 255, 69, 0},
   {"orange", 255, 165, 0},
+  {"orange red", 255, 69, 0},
   {"orange1", 255, 165, 0},
   {"orange2", 238, 154, 0},
   {"orange3", 205, 133, 0},
@@ -746,17 +758,17 @@
   {"turquoise2", 0, 229, 238},
   {"turquoise3", 0, 197, 205},
   {"turquoise4", 0, 134, 139},
-  {"violet red", 208, 32, 144},
   {"violet", 238, 130, 238},
+  {"violet red", 208, 32, 144},
   {"wheat", 245, 222, 179},
   {"wheat1", 255, 231, 186},
   {"wheat2", 238, 216, 174},
   {"wheat3", 205, 186, 150},
   {"wheat4", 139, 126, 102},
-  {"white smoke", 245, 245, 245},
   {"white", 255, 255, 255},
-  {"yellow green", 154, 205, 50},
+  {"white smoke", 245, 245, 245},
   {"yellow", 255, 255, 0},
+  {"yellow green", 154, 205, 50},
   {"yellow1", 255, 255, 0},
   {"yellow2", 238, 238, 0},
   {"yellow3", 205, 205, 0},
@@ -765,14 +777,16 @@
 
 Color ColorDB::getNamedColor(const std::string& name)
 {
+  // A simple binary search of our namedColors array.
   int l = 0;
-  int h = sizeof(namedColors)/sizeof(RGBData)-1;
+  int h = sizeof(namedColors)/sizeof(RGBData);
   while(h > l+1){
     int m = (h+l)/2;
-    if(name < namedColors[m].name)
+    if(name < namedColors[m].name) {
       h = m;
-    else
+    } else {
       l = m;
+    }
   }
   if(name != namedColors[l].name)
     throw UnknownColor(name);
@@ -780,4 +794,30 @@
   float scale = 1.f/255.f;
   RGBData& nc = namedColors[l];
   return Color(RGBColor(nc.r*scale, nc.g*scale, nc.b*scale));
+}
+
+bool ColorDB::test() {
+  bool passed_all = true;
+  size_t num_entries = sizeof(namedColors)/sizeof(RGBData);
+  //  cerr << "num_entries = "<<num_entries<<"\n";
+
+  // Test to make sure the array is ordered.
+  for(size_t i = 0; i < num_entries-1; i++) {
+    if (string(namedColors[i+1].name) < string(namedColors[i].name)) {
+      cerr << "namedColors[i="<<i<<"].name("<<namedColors[i].name<<") is not 
< namedColors[i+1="<<i+1<<"].name("<<namedColors[i+1].name<<")\n";
+      passed_all = false;
+    }
+  }
+
+  // Test to make sure that we can find all the entries using the
+  // getNamedColor fuction.
+  for(size_t i = 0; i < num_entries; i++) {
+    try {
+      Color t = getNamedColor(string(namedColors[i].name));
+    } catch (UnknownColor& e) {
+      cerr << "Didn't find color \""<<e.message() << "\"\n";
+      passed_all = false;
+    }
+  }
+  return passed_all;
 }

Modified: trunk/Core/Color/ColorDB.h
==============================================================================
--- trunk/Core/Color/ColorDB.h  (original)
+++ trunk/Core/Color/ColorDB.h  Fri Jun 10 18:48:21 2005
@@ -11,6 +11,11 @@
   class ColorDB {
   public:
     static Color getNamedColor(const std::string& name);
+
+    // Tests to make sure the namedColors array is sorted properly and
+    // that you can find all the entries.  Return true if everything
+    // is in order, false otherwise with some errors going to cerr.
+    static bool  test();
   private:
     // Prevent instantiation
     ColorDB(const ColorDB&);

Modified: trunk/Core/Color/ColorSpace.h
==============================================================================
--- trunk/Core/Color/ColorSpace.h       (original)
+++ trunk/Core/Color/ColorSpace.h       Fri Jun 10 18:48:21 2005
@@ -22,11 +22,13 @@
       for(int i=0;i<3;i++)
        data[i]=copy.data[i];
     }
+#ifndef SWIG
     ColorSpace& operator=(const ColorSpace<Traits> &copy) {
       for(int i=0;i<NumComponents;i++)
         data[i] = copy.data[i];
       return *this;
     }
+#endif
     ~ColorSpace() {
     }
 

Modified: trunk/Core/Geometry/PointVector.cc
==============================================================================
--- trunk/Core/Geometry/PointVector.cc  (original)
+++ trunk/Core/Geometry/PointVector.cc  Fri Jun 10 18:48:21 2005
@@ -1,17 +1,20 @@
 
 #include <Core/Geometry/PointVector.h>
+
+#include <sgi_stl_warnings_off.h>
 #include <iostream>
+#include <sgi_stl_warnings_on.h>
 
 namespace Manta {
   template<typename T, int Dim>
-  inline std::ostream &operator<< (std::ostream &os, const VectorT<T,Dim> 
&v) {
+  std::ostream &operator<< (std::ostream &os, const VectorT<T,Dim> &v) {
     for (int i=0;i<Dim;++i)
       os << v[i] << " ";
     return os;
   }
 
   template<typename T, int Dim>
-  inline std::ostream &operator<< (std::ostream &os, const PointT<T,Dim> &v) 
{
+  std::ostream &operator<< (std::ostream &os, const PointT<T,Dim> &v) {
     for (int i=0;i<Dim;++i)
       os << v[i] << " ";
     return os;

Modified: trunk/Core/Geometry/PointVector.h
==============================================================================
--- trunk/Core/Geometry/PointVector.h   (original)
+++ trunk/Core/Geometry/PointVector.h   Fri Jun 10 18:48:21 2005
@@ -15,10 +15,12 @@
   public:
     VectorT() {
     }
+#ifndef SWIG
     VectorT(T x, T y) {
       typedef char unnamed[ Dim == 2 ? 1 : 0 ];
       data[0] = x; data[1] = y;
     }
+#endif      
     VectorT(T x, T y, T z) {
       typedef char unnamed[ Dim == 3 ? 1 : 0 ];
       data[0] = x; data[1] = y; data[2] = z;
@@ -34,11 +36,13 @@
         data[i] = copy[i];
     }
 
+#ifndef SWIG
     VectorT<T, Dim>& operator=(const VectorT<T, Dim>& copy) {
       for(int i=0;i<Dim;i++)
         data[i] = copy.data[i];
       return *this;
     }
+#endif
 
     ~VectorT() {
     }
@@ -54,12 +58,20 @@
       typedef char unnamed[ Dim >= 3 ? 1 : 0 ];
       return data[2];
     }
+#ifndef SWIG
     const T &operator[](int i) const {
       return data[i];
     }
     T &operator[] ( int i ) {
       return data[i];
     }
+#else
+    %extend {
+      T& __getitem__( int i ) {
+        return self->operator[](i);
+      }
+    }
+#endif
     VectorT<T, Dim> operator+(const VectorT<T, Dim>& v) const {
       VectorT<T, Dim> result;
       for(int i=0;i<Dim;i++)
@@ -221,10 +233,12 @@
     PointT() {
     }
 
+#ifndef SWIG
     PointT(T x, T y) {
       typedef char unnamed[ Dim == 2 ? 1 : 0 ];
       data[0] = x; data[1] = y;
     }
+#endif
     PointT(T x, T y, T z) {
       typedef char unnamed[ Dim == 3 ? 1 : 0 ];
       data[0] = x; data[1] = y; data[2] = z;
@@ -239,12 +253,14 @@
       for (int i=0;i<Dim;++i)
         data[i] = copy[i];
     }
-               
+
+#ifndef SWIG
     PointT<T, Dim>& operator=(const PointT<T, Dim>& copy) {
       for(int i=0;i<Dim;i++)
         data[i] = copy.data[i];
       return *this;
     }
+#endif
 
     ~PointT() {
     }
@@ -259,12 +275,20 @@
       typedef char unnamed[ Dim == 3 ? 1 : 0 ];
       return data[2];
     }
+#ifndef SWIG
     T operator[](int i) const {
       return data[i];
     }
     T &operator[](int i) {
       return data[i];
     }
+#else
+    %extend {
+      T& __getitem__( int i ) {
+        return self->operator[](i);
+      }
+    }
+#endif
 
     VectorT<T, Dim> operator-(const PointT<T, Dim>& p) const {
       VectorT<T, Dim> result;

Modified: trunk/Core/Geometry/Ray.h
==============================================================================
--- trunk/Core/Geometry/Ray.h   (original)
+++ trunk/Core/Geometry/Ray.h   Fri Jun 10 18:48:21 2005
@@ -15,12 +15,14 @@
     {
     }
 
+#ifndef SWIG
     Ray& operator=(const Ray& copy)
     {
       orig=copy.orig;
       dir=copy.dir;
       return *this;
     }
+#endif
 
     void set(const Point& origin, const Vector& direction)
     {

Modified: trunk/Core/Math/MT_RNG.cc
==============================================================================
--- trunk/Core/Math/MT_RNG.cc   (original)
+++ trunk/Core/Math/MT_RNG.cc   Fri Jun 10 18:48:21 2005
@@ -29,7 +29,9 @@
 /* matumoto@math.keio.ac.jp                                        */
 
 #include <stdio.h> // used only for test_print
-#include "MT_RNG.h"
+#include <Core/Math/MT_RNG.h>
+
+using namespace Manta;
 
 /* Period parameters */  
 #define MATRIX_A 0x9908b0df   /* constant vector a */
@@ -110,5 +112,17 @@
     if (j%8==7) printf("\n");
   }
   printf("\n");
+}
+
+template<>
+float MT_RNG::genRealRand<float>()
+{
+  return genfrand();
+}
+
+template<>
+double MT_RNG::genRealRand<double>()
+{
+  return gendrand();
 }
 

Modified: trunk/Core/Math/MT_RNG.h
==============================================================================
--- trunk/Core/Math/MT_RNG.h    (original)
+++ trunk/Core/Math/MT_RNG.h    Fri Jun 10 18:48:21 2005
@@ -31,7 +31,7 @@
 #ifndef __MT19937_H__
 #define __MT19937_H__
 
-
+namespace Manta {
 
 // Period parameters
 #define MT_RNG_N 624
@@ -47,7 +47,21 @@
   double gendrand();
   float genfrand();
 
+  // Default to returning a double.  In actuallity this should never
+  // be used.
+  template<class T>
+  T genRealRand() { return static_cast<T>(gendrand()); }
+
+  
   void test_print(); // prints some random numbers to the console
 };
+
+template<>
+float MT_RNG::genRealRand<float>();
+
+template<>
+double MT_RNG::genRealRand<double>();
+
+} // end namespace Manta
 
 #endif // __MT19937_H__

Modified: trunk/Core/Math/vector2d.h
==============================================================================
--- trunk/Core/Math/vector2d.h  (original)
+++ trunk/Core/Math/vector2d.h  Fri Jun 10 18:48:21 2005
@@ -4,47 +4,13 @@
 #ifndef Manta_Core_vector2d_h
 #define Manta_Core_vector2d_h
 
-class vector2d  {
-public:
-  vector2d()
-  {
-    e[0] = 0.0;
-    e[1] = 0.0;
-  }
-
-
-  vector2d(float a, float b)
-    {
-      e[0] = a;
-      e[1] = b;
-    }
-
-  //vector3d(double e0, double e1, double e2);
-
-  void setX(float num)
-  {
-    e[0] = num;
-  }
-
-  void setY(float num)
-  {
-    e[1] = num;
-  }
-
-  float x()
-  {
-    return e[0];
-  }
-
-  float y()
-  {
-    return e[1];
-  }
-
-  float e[2];
-};
+#include <MantaTypes.h>
+#include <Core/Geometry/PointVector.h>
 
+namespace Manta {
+  typedef VectorT<Real, 2> vector2d;
 
+} // end namespace Manta
 
 #endif
 

Modified: trunk/Engine/PixelSamplers/HammersleySampler.cc
==============================================================================
--- trunk/Engine/PixelSamplers/HammersleySampler.cc     (original)
+++ trunk/Engine/PixelSamplers/HammersleySampler.cc     Fri Jun 10 18:48:21 
2005
@@ -123,8 +123,8 @@
        
        for(int x = 0; x < num_samples; x++)
          {
-           px = 
((fe0.x+samples[x].e[0])*ci.xscale+ci.xoffset)+count*ci.xscale;
-           py = (fe0.y+samples[x].e[1])*ci.yscale+ci.yoffset;
+           px = ((fe0.x+samples[x][0])*ci.xscale+ci.xoffset)+count*ci.xscale;
+           py = (fe0.y+samples[x][1])*ci.yscale+ci.yoffset;
            rays.setPixel(i, 0, px, py, &result[i]);
            
            i++;
@@ -152,8 +152,8 @@
        Sample::hammersley(samples, num_samples, random[thd_num]);
        for(int x = 0; x < num_samples; x++)
          {
-          px = 
((fe0.x+samples[x].e[0])*ci.xscale+ci.xoffset)+count*ci.xscale;
-          py = (fe0.y+samples[x].e[1])*ci.yscale+ci.yoffset;
+          px = ((fe0.x+samples[x][0])*ci.xscale+ci.xoffset)+count*ci.xscale;
+          py = (fe0.y+samples[x][1])*ci.yscale+ci.yoffset;
            rays.setPixel(i, 1, px, py, &result[i]);
            
            i++;

Modified: trunk/Engine/PixelSamplers/InterLeaveSampler.cc
==============================================================================
--- trunk/Engine/PixelSamplers/InterLeaveSampler.cc     (original)
+++ trunk/Engine/PixelSamplers/InterLeaveSampler.cc     Fri Jun 10 18:48:21 
2005
@@ -128,8 +128,8 @@
       while(i < size){
        for(int x = 0; x < num_samples; x++)
          {
-           px = 
((fe0.x+interLeavedSamples[i%num_grid][x].e[0])*ci.xscale+ci.xoffset)+count*ci.xscale;
-           py = 
(fe0.y+interLeavedSamples[i%num_grid][x].e[1])*ci.yscale+ci.yoffset;
+           px = 
((fe0.x+interLeavedSamples[i%num_grid][x][0])*ci.xscale+ci.xoffset)+count*ci.xscale;
+           py = 
(fe0.y+interLeavedSamples[i%num_grid][x][1])*ci.yscale+ci.yoffset;
            rays.setPixel(i, 0, px, py, &result[i]);
            
            i++;
@@ -154,8 +154,8 @@
        Fragment::Element& fe0 = fragment.get(f+i);
        for(int x = 0; x < num_samples; x++)
          {
-          px = 
((fe0.x+interLeavedSamples[i%num_grid][x].e[0])*ci.xscale+ci.xoffset)+count*ci.xscale;
-           py = 
(fe0.y+interLeavedSamples[i%num_grid][x].e[1])*ci.yscale+ci.yoffset;
+          px = 
((fe0.x+interLeavedSamples[i%num_grid][x][0])*ci.xscale+ci.xoffset)+count*ci.xscale;
+           py = 
(fe0.y+interLeavedSamples[i%num_grid][x][1])*ci.yscale+ci.yoffset;
            rays.setPixel(i, 1, px, py, &result[i]);
            
            i++;

Modified: trunk/Engine/PixelSamplers/JitterSampler.cc
==============================================================================
--- trunk/Engine/PixelSamplers/JitterSampler.cc (original)
+++ trunk/Engine/PixelSamplers/JitterSampler.cc Fri Jun 10 18:48:21 2005
@@ -13,6 +13,11 @@
 
 using namespace Manta;
 
+#include <sgi_stl_warnings_off.h>
+#include <iostream>
+#include <sgi_stl_warnings_on.h>
+using namespace std;
+
 PixelSampler* JitterSampler::create(const vector<string>& args)
 {
   
@@ -22,42 +27,35 @@
 JitterSampler::JitterSampler(const vector<string>& args)
 {
   num_samples = 4;
-  samples = 0;
   int argc = static_cast<int>(args.size());
   for(int i = 0; i<argc;i++){
     string arg = args[i];
     if(arg == "-numberOfSamples"){
       if(!getIntArg(i, args, num_samples))
        throw IllegalArgument("JitterSampler -numberOfSamples", i, args);
+      if (num_samples < 1)
+        throw IllegalArgument("-numberOfSamples must be greater than 0",
+                              i, args);
     }
    
     else {
       throw IllegalArgument("JitterSampler", i, args);
     }
   }
-  if (num_samples > 25)
-    {
-      printf("Maximum number of samples allowed is 25\n\n");
-      exit(0);
-    }
+
+  // Compute nx and ny
+  Sample::nearest_square_finder(num_samples, nx, ny);
 }
 
 JitterSampler::~JitterSampler()
 {
-  delete [] samples;
+  if (random) delete[] random;
 }
 
 void JitterSampler::setupBegin(const SetupContext& context, int numChannels)
 {
   channelInfo.resize(numChannels);
   random = new MT_RNG[context.numProcs];
-  for(int i = 0; i < context.numProcs; i++)
-    {
-      random[i] = MT_RNG();
-      random[i].seed_rng((unsigned long) i);
-    }
-  if(samples == 0)
-    samples = new vector2d[num_samples];
   context.renderer->setupBegin(context, numChannels);
 }
 
@@ -65,14 +63,13 @@
 {
   ChannelInfo& ci = channelInfo[context.channelIndex];
   bool stereo;
-  int xres, yres;
-  context.getResolution(stereo, xres, yres);
+  context.getResolution(stereo, ci.xres, ci.yres);
 
   // Set up the scale from -1 to 1
-  ci.xscale = 2./xres;
+  ci.xscale = (Real)2/ci.xres;
   ci.yscale = ci.xscale;
-  ci.xoffset = (-xres/2.+0.5)*ci.xscale; // Offset to pixel center
-  ci.yoffset = (-yres/2.+0.5)*ci.yscale;
+  ci.xoffset = (-ci.xres+1)*(Real)0.5*ci.xscale; // Offset to pixel center
+  ci.yoffset = (-ci.yres+1)*(Real)0.5*ci.yscale;
   
   context.renderer->setupDisplayChannel(context);
 }
@@ -83,6 +80,63 @@
 }
 
 
+// Ohh, man.  Is this code wacked or what?  Anyway, the point of this
+// code it to gather up all the samples that belong to a single
+// fragment, then update the color in the fragment.  Fagments' samples
+// can exists across multiple RayPackets, so we have to be careful
+// here.  Also with the way the loop works you have to make sure you
+// pick up the last sample if it is part of a newrun (see
+// compute_last_ave below).  Anyway, I know there is probably a more
+// elegant solution out there, but this works for all sorts of
+// combinations of fragment sizes and number of samples.
+void JitterSampler::computeAverages(Fragment& fragment, RayPacket& rays,
+                                    Color* sample_color,
+                                    int* fragment_owning_sample) {
+  // At this point we have rays.getSize() number of samples
+  // that can belong to at most fragment.getSize() number of
+  // fragments.  We need to sum the colors from the samples
+  // for a single fragment then divide it by the total
+  // number of samples and add it to the fragment's total.
+  int slot_index = 0;
+  int num_samples_per_fragment = 1;
+  int current_fragment = fragment_owning_sample[slot_index];
+  Color fragment_color = sample_color[slot_index];
+  // If the last sample is a new run, you need to add it after the for loop.
+  bool compute_last_ave = false; 
+  for(int slot_index = 1; slot_index < rays.getSize(); slot_index++){
+    bool compute_average = false;
+    if (current_fragment == fragment_owning_sample[slot_index]) {
+      fragment_color += sample_color[slot_index];
+      num_samples_per_fragment++;
+      // Now the case where the last sample is has been
+      // reached, we must force it to be averaged.
+      if (slot_index == rays.getSize()-1)
+        compute_average = true;
+    } else {
+      // Now we have a break in the fragment, so time to
+      // compute the average.
+      compute_average = true;
+      // If however we have a break at the last pixel, we need to
+      // signal to pick up that extra sample.
+      if (slot_index == rays.getSize()-1)
+        compute_last_ave = true;
+    }
+    if (compute_average) {
+      // Divide the color by the number of samples and
+      // increment it with the fragment.
+      fragment.get(current_fragment).color +=
+        fragment_color / num_samples;
+      // Now update for the next fragment run
+      fragment_color = sample_color[slot_index];
+      current_fragment = fragment_owning_sample[slot_index];
+      num_samples_per_fragment = 1;
+    }
+  } // end slot_index loop
+
+  // Pick up the last sample if we need to
+  if (compute_last_ave)
+    fragment.get(current_fragment).color += fragment_color / num_samples;
+}
 
 void JitterSampler::renderFragment(const RenderContext& context,
                                   Fragment& fragment)
@@ -93,91 +147,77 @@
   int flags = RayPacket::HaveImageCoordinates;
   if(fragment.getFlags() & Fragment::ConstantEye)
     flags |= RayPacket::ConstantEye;
-  
 
-  for(int f=0;f<fragment.getSize();f+=(RayPacket::MaxSize)/num_samples){
-    int size = RayPacket::MaxSize;
+  int next_slot = 0;
+  Color sample_color[RayPacket::MaxSize];
+  int fragment_owning_sample[RayPacket::MaxSize];
+
+  int consecutivex_flag = fragment.getFlags() & Fragment::ConsecutiveX;
+
+  if (consecutivex_flag) {
+    Fragment::Element& fe = fragment.get(0);
+    random[thd_num].seed_rng(fe.x*ci.xres+fe.y);
+  }
 
-    // Create a ray packet
-    int depth = 0;
-    RayPacketData raydata;
-    RayPacket rays(raydata, size, depth, flags);
-    Color result[RayPacket::MaxSize];
-    if(fragment.getFlags() & Fragment::ConsecutiveX){
-      Fragment::Element& fe0 = fragment.get(f);
-      int i = 0;
-      int count = 0;
-      double px, py;
-      while(i < size){
-       Sample::jitter(samples, num_samples, random[thd_num]);
-       
-       for(int x = 0; x < num_samples; x++)
-         {
-           px = 
((fe0.x+(samples[x].e[0]))*ci.xscale+ci.xoffset)+count*ci.xscale;
-           py = (fe0.y+(samples[x].e[1]))*ci.yscale+ci.yoffset;
-           rays.setPixel(i, 0, px, py, &result[i]);
-           i++;
-         } 
-       
-       if(i%num_samples == 0){
-         count++;
-       }
-       
-      }
-      
-    }
-    
-    else {
-      
-      int i = 0;
-      int count = 0;
-      
-      double px, py;
-      while(i < size){
-       Fragment::Element& fe0 = fragment.get(f+i);
-       
-       
-       Sample::jitter(samples, num_samples, random[thd_num]);
-       for(int x = 0; x < num_samples; x++)
-         {
-           px = 
((fe0.x+samples[x].e[0])*ci.xscale+ci.xoffset)+count*ci.xscale;
-           py = (fe0.y+samples[x].e[1])*ci.yscale+ci.yoffset;
-           rays.setPixel(i, 1, px, py, &result[i]);
-           
-           i++;
-         } 
-       
-       if(i%num_samples == 0){
-         count++;
-       }
-       
-      }
-    }
-    
-    // Trace the rays.  The results will automatically go into the fragment
-    (context.renderer->traceEyeRays(context, rays));
-    
-    int element_index = 0;
-    
-    float inv_num_samples = 1.0f/num_samples;
-    for(int k = 0; k < size; k+=num_samples)
-      {
-       Color final_col = Color::black();
-       for(int l = 0; l < num_samples; l++)
-         {
-           final_col += result[k+l];
-         }
-       
-       Fragment::Element& fe = fragment.get(f+element_index);
-       fe.color = final_col * inv_num_samples;
-       element_index++;
-       
-      }
+  int depth = 0;
+  RayPacketData raydata;
+  RayPacket rays(raydata, RayPacket::MaxSize, depth, flags);
+
+  Real inx = (Real)1/nx;
+  Real iny = (Real)1/ny;
+  Real px, py;
+  
+  // We can compute at most RayPacket::MaxSize number of rays at time.
+  for(int frag_index = 0; frag_index < fragment.getSize(); frag_index++) {
+    // Initialize the color
+    fragment.get(frag_index).color = Color::black();
+
+    Fragment::Element& fe0 = fragment.get(frag_index);
+
+    if (!consecutivex_flag) {
+      random[thd_num].seed_rng(fe0.x*ci.xres+fe0.y);
+    }
+    
+    // For each fragment start filling up the RayPacket with samples.
+    // When you filled up the empty_slots compute the rays, do the
+    // average, and store the results in the fragment.
+    for(int xs = 0; xs < nx; xs++)
+      for(int ys = 0; ys  < ny; ys++)
+        {
+          Real x_sample = (xs + random[thd_num].genRealRand<Real>()) * inx;
+          Real y_sample = (ys + random[thd_num].genRealRand<Real>()) * iny;
+          px = (fe0.x+(x_sample))*ci.xscale+ci.xoffset;
+          py = (fe0.y+(y_sample))*ci.yscale+ci.yoffset;
+          rays.setPixel(next_slot, 0, px, py, &sample_color[next_slot]);
+          fragment_owning_sample[next_slot] = frag_index;
+          next_slot++;
+          
+          if (next_slot == RayPacket::MaxSize) {
+            // Filled up the ray packet, so send them off!
+            rays.resize(next_slot);
+            context.renderer->traceEyeRays(context, rays);
+
+            computeAverages(fragment, rays,
+                            sample_color, fragment_owning_sample);
+            
+            // Now reset the index, so that we can start filling up
+            // the RayPacket again.
+            next_slot = 0;
+            // Make sure we start with a fresh slate
+            rays.resetHit();
+            //            rays.resetFlag(flags);
+          }
+        } // end sample filling loops
+  } // end fragment loop
+
+  // Pick up any stragling samples
+  if (next_slot > 0) {
+    rays.resize(next_slot);
+    context.renderer->traceEyeRays(context, rays);
     
+    computeAverages(fragment, rays, sample_color, fragment_owning_sample);
   }
-  
-
-}
+}  
 
 
 

Modified: trunk/Engine/PixelSamplers/JitterSampler.h
==============================================================================
--- trunk/Engine/PixelSamplers/JitterSampler.h  (original)
+++ trunk/Engine/PixelSamplers/JitterSampler.h  Fri Jun 10 18:48:21 2005
@@ -14,6 +14,8 @@
 
 namespace Manta {
   using namespace std;
+  class RayPacket;
+  
   class JitterSampler : public PixelSampler {
   public:
     JitterSampler(const vector<string>& args);
@@ -28,15 +30,22 @@
   private:
     JitterSampler(const JitterSampler&);
     JitterSampler& operator=(const JitterSampler&);
+
+    void computeAverages(Fragment& fragment, RayPacket& rays,
+                         Color* sample_color, int* fragment_owning_sample);
+    
     int num_samples;
+    // nx*ny == num_samples where nx~=ny (or as close as you can get it).
+    int nx, ny;
+    
     struct ChannelInfo {
-      double xscale;
-      double xoffset;
-      double yscale;
-      double yoffset;
+      Real xscale;
+      Real xoffset;
+      Real yscale;
+      Real yoffset;
+      int xres, yres;
     };
 
-    vector2d *samples;
     MT_RNG *random;
     vector<ChannelInfo> channelInfo;
   };

Modified: trunk/Engine/PixelSamplers/MultiJitterSampler.cc
==============================================================================
--- trunk/Engine/PixelSamplers/MultiJitterSampler.cc    (original)
+++ trunk/Engine/PixelSamplers/MultiJitterSampler.cc    Fri Jun 10 18:48:21 
2005
@@ -120,8 +120,8 @@
        
        for(int x = 0; x < num_samples; x++)
          {
-           px = 
((fe0.x+((samples[x].e[0]*2.0)-1.0))*ci.xscale+ci.xoffset)+count*ci.xscale;
-           py = (fe0.y+((samples[x].e[1]*2.0)-1.0))*ci.yscale+ci.yoffset;
+           px = 
((fe0.x+((samples[x][0]*2.0)-1.0))*ci.xscale+ci.xoffset)+count*ci.xscale;
+           py = (fe0.y+((samples[x][1]*2.0)-1.0))*ci.yscale+ci.yoffset;
            rays.setPixel(i, 0, px, py, &result[i]);
            
            i++;
@@ -149,8 +149,8 @@
        Sample::multiJitter(samples, num_samples, random[thd_num]);
        for(int x = 0; x < num_samples; x++)
          {
-          px = 
((fe0.x+samples[x].e[0])*ci.xscale+ci.xoffset)+count*ci.xscale;
-          py = (fe0.y+samples[x].e[1])*ci.yscale+ci.yoffset;
+          px = ((fe0.x+samples[x][0])*ci.xscale+ci.xoffset)+count*ci.xscale;
+          py = (fe0.y+samples[x][1])*ci.yscale+ci.yoffset;
            rays.setPixel(i, 1, px, py, &result[i]);
            
            i++;

Modified: trunk/Engine/PixelSamplers/NRooksSampler.cc
==============================================================================
--- trunk/Engine/PixelSamplers/NRooksSampler.cc (original)
+++ trunk/Engine/PixelSamplers/NRooksSampler.cc Fri Jun 10 18:48:21 2005
@@ -124,8 +124,8 @@
        
        for(int x = 0; x < num_samples; x++)
          {
-           px = 
((fe0.x+(samples[x].e[0]))*ci.xscale+ci.xoffset)+count*ci.xscale;
-           py = (fe0.y+(samples[x].e[1]))*ci.yscale+ci.yoffset;
+           px = 
((fe0.x+(samples[x][0]))*ci.xscale+ci.xoffset)+count*ci.xscale;
+           py = (fe0.y+(samples[x][1]))*ci.yscale+ci.yoffset;
            rays.setPixel(i, 0, px, py, &result[i]);
            
            i++;
@@ -152,8 +152,8 @@
        Sample::nrooks(samples, num_samples, random[thd_num]);
        for(int x = 0; x < num_samples; x++)
          {
-          px = 
((fe0.x+samples[x].e[0])*ci.xscale+ci.xoffset)+count*ci.xscale;
-          py = (fe0.y+samples[x].e[1])*ci.yscale+ci.yoffset;
+          px = ((fe0.x+samples[x][0])*ci.xscale+ci.xoffset)+count*ci.xscale;
+          py = (fe0.y+samples[x][1])*ci.yscale+ci.yoffset;
            rays.setPixel(i, 1, px, py, &result[i]);
            
            i++;

Modified: trunk/Engine/PixelSamplers/Sample.cc
==============================================================================
--- trunk/Engine/PixelSamplers/Sample.cc        (original)
+++ trunk/Engine/PixelSamplers/Sample.cc        Fri Jun 10 18:48:21 2005
@@ -5,28 +5,27 @@
 #include <math.h>
 #include <stdio.h>
 
-
+using namespace Manta;
 
 void Sample::random(vector2d *samples, int num_samples, MT_RNG seed)
 {
   for (int i = 0; i < num_samples; i++)
     {
-      samples[i].setX(seed.gendrand());
-      samples[i].setY(seed.gendrand());
+      samples[i][0] = seed.genRealRand<Real>();
+      samples[i][1] = seed.genRealRand<Real>();
     }
 }
 
 
-void Sample::jitter(vector2d *samples, int num_samples, MT_RNG seed)
+void Sample::jitter(vector2d *samples, int nx, int ny, MT_RNG seed)
 {
-  int sqrt_samples = (int)(sqrt(float(num_samples)));
-  for(int i = 0; i < sqrt_samples; i++)
-    for(int j = 0; j < sqrt_samples; j++)
+  for(int i = 0; i < nx; i++)
+    for(int j = 0; j < ny; j++)
       {
-       float x = ((double)i + seed.gendrand()) / (double)sqrt_samples;
-       float y = ((double)j + seed.gendrand()) / (double)sqrt_samples;
-       (samples[i*sqrt_samples +j]).setX(x);
-       (samples[i*sqrt_samples +j]).setY(y);
+        Real x = ((Real)i + seed.genRealRand<Real>()) / (Real)nx;
+        Real y = ((Real)j + seed.genRealRand<Real>()) / (Real)ny;
+        samples[i*nx +j][0] = x;
+        samples[i*nx +j][1] = y;
       }
 }
 
@@ -35,16 +34,16 @@
 {
   for (int i = 0; i < num_samples; i++)
     {
-      samples[i].setX(((double)i + seed.gendrand()) / (double)num_samples);
-      samples[i].setY(((double)i + seed.gendrand()) / (double)num_samples);
+      samples[i][0] = ((Real)i + seed.genRealRand<Real>()) / 
(Real)num_samples;
+      samples[i][1] = ((Real)i + seed.genRealRand<Real>()) / 
(Real)num_samples;
     }
   // shuffle the x coords
   for (int i = num_samples - 2; i >= 0; i--)
     {
-      int target = int(seed.gendrand() * (double)i);
+      int target = int(seed.genRealRand<Real>() * (Real)i);
       float temp = samples[i+1].x();
-      samples[i+1].setX(samples[target].x());
-      samples[target].setX(temp);
+      samples[i+1][0] = samples[target].x();
+      samples[target][0] = temp;
     }
 }
 
@@ -62,10 +61,10 @@
   for(int i = 0; i < sqrt_samples; i++)
     for(int j = 0; j < sqrt_samples; j++)
       {
-       samples[i*sqrt_samples + j].e[0] = i*sqrt_samples*subcell_width +
-         j*subcell_width + seed.gendrand() * subcell_width;
-       samples[i*sqrt_samples + j].e[1] = j*sqrt_samples *subcell_width +
-         i*subcell_width + seed.gendrand() * subcell_width;
+       samples[i*sqrt_samples + j][0] = i*sqrt_samples*subcell_width +
+         j*subcell_width + seed.genRealRand<Real>() * subcell_width;
+       samples[i*sqrt_samples + j][1] = j*sqrt_samples *subcell_width +
+         i*subcell_width + seed.genRealRand<Real>() * subcell_width;
 
       }
 
@@ -73,15 +72,15 @@
   for(int i = 0; i < sqrt_samples; i++)
     for(int j = 0; j < sqrt_samples; j++)
       {
-       int k = j + int(seed.gendrand() * (sqrt_samples - j - 1));
-       float t = samples[i*sqrt_samples + j].e[0];
-       samples[i*sqrt_samples + j].e[0] = samples[i*sqrt_samples + k].e[0];
-       samples[i*sqrt_samples + k].e[0] = t;
-
-       k = j+int(seed.gendrand() * (sqrt_samples - j - 1));
-       t = samples[j*sqrt_samples + i].e[1];
-       samples[j*sqrt_samples + i].e[1] = samples[k*sqrt_samples + i].e[1];
-       samples[k*sqrt_samples + i].e[1] = t;
+       int k = j + int(seed.genRealRand<Real>() * (sqrt_samples - j - 1));
+       float t = samples[i*sqrt_samples + j][0];
+       samples[i*sqrt_samples + j][0] = samples[i*sqrt_samples + k][0];
+       samples[i*sqrt_samples + k][0] = t;
+
+       k = j+int(seed.genRealRand<Real>() * (sqrt_samples - j - 1));
+       t = samples[j*sqrt_samples + i][1];
+       samples[j*sqrt_samples + i][1] = samples[k*sqrt_samples + i][1];
+       samples[k*sqrt_samples + i][1] = t;
       }
 }
 
@@ -90,8 +89,8 @@
 {
   double p, u, v;
   int k, kk;
-  double offu = (seed.gendrand() +.75f) / 2.0f;
-  double offv = (seed.gendrand() +.75f) / 2.0f;
+  double offu = (seed.genRealRand<Real>() +.75f) / 2.0f;
+  double offv = (seed.genRealRand<Real>() +.75f) / 2.0f;
 
   for (k=0 ; k<num_samples ; k++)
   {
@@ -114,7 +113,7 @@
 {
   for (int i = num_samples - 2; i >= 0; i--)
     {
-      int target = int(seed.gendrand() * (double)i);
+      int target = int(seed.genRealRand<Real>() * (double)i);
       vector2d temp = samples[i+1];
       samples[i+1] = samples[target];
       samples[target] = temp;
@@ -127,8 +126,8 @@
 {
   for (int i = 0; i < num_samples; i++)
     {
-      samples[i].setX(samples[i].x() - 0.5f);
-      samples[i].setY(samples[i].y() - 0.5f);
+      samples[i][0] = samples[i][0] - (Real)0.5;
+      samples[i][1] = samples[i][1] - (Real)0.5;
     }
 }
 
@@ -138,12 +137,16 @@
 
   for (int i = 0; i < num_samples; i++)
     {
-      float x = samples[i].x();
-      float y = samples[i].y();
-      if (x < 0.5f) samples[i].setX((float)sqrt(2.0*(double)x) - 1.0f);
-      else samples[i].setX(1.0f - (float)sqrt(2.0 - 2.0 * (double)x));
-      if (y < 0.5f) samples[i].setY((float)sqrt(2.0*(double)y) - 1.0f);
-      else samples[i].setY(1.0f - (float)sqrt(2.0 - 2.0 * (double)y));
+      Real x = samples[i].x();
+      Real y = samples[i].y();
+      if (x < 0.5f)
+        samples[i][0] = (Real)sqrt(2.0*(Real)x) - 1.0f;
+      else
+        samples[i][0] = 1.0f - (Real)sqrt(2.0 - 2.0 * x);
+      if (y < 0.5f)
+        samples[i][1] = (Real)sqrt(2.0*(Real)y) - 1.0f;
+      else
+        samples[i][1] = 1.0f - (Real)sqrt(2.0 - 2.0 * y);
     }
 }
 
@@ -153,10 +156,10 @@
 
   for (int i = 0; i < num_samples; i++)
     {
-      float x = samples[i].x();
-      float y = samples[i].y();
-      samples[i].e[0] = cubicFilter(x);
-      samples[i].e[1] = cubicFilter(y);
+      Real x = samples[i].x();
+      Real y = samples[i].y();
+      samples[i][0] = cubicFilter(x);
+      samples[i][1] = cubicFilter(y);
     }
   
 }
@@ -188,6 +191,26 @@
     }
 }
 
+
+void Sample::nearest_square_finder(const int size, int &nx, int &ny) {
+  int x,y;
+  x = y = (int) sqrt((double)size);
+  // now we are basically looking for a pair of multiples that are closest to
+  // the square root.
+  while ((x * y) != size) {
+    // look for another multiple
+    for(int i = x+1; i <= size; i++) {
+      if (size%i == 0) {
+       // we've found a root
+       x = i;
+       y = size/x;
+       break;
+      }
+    }
+  }
+  nx = x;
+  ny = y;
+}
 
 
 

Modified: trunk/Engine/PixelSamplers/Sample.h
==============================================================================
--- trunk/Engine/PixelSamplers/Sample.h (original)
+++ trunk/Engine/PixelSamplers/Sample.h Fri Jun 10 18:48:21 2005
@@ -11,15 +11,17 @@
 #include <Core/Math/MT_RNG.h>
 #include <math.h>
 
-class Sample{
+namespace Manta {
+  
+class Sample {
 
  public:
   //2D sampling
   
   static void random(vector2d *samples, int num_samples, MT_RNG seed);
   
-  //jitter assumes num_samples is a perfect square
-  static void jitter(vector2d* samples, int num_samples, MT_RNG seed);
+  // This Assums you have nx*ny samples available in samples.
+  static void jitter(vector2d* samples, int nx, int ny, MT_RNG seed);
   
   static void nrooks(vector2d* samples, int num_samples, MT_RNG seed);
   //multiJitter assumes num_samples is a perfect square
@@ -66,10 +68,13 @@
        return 2 - pow(24.0f * (1.0f-x), 0.25f);
     }
 
-
+  static void nearest_square_finder(const int size, int &nx, int &ny);
   
   
 };
+
+} // end namespace Manta
+
 #endif
 
             

Modified: trunk/Engine/PixelSamplers/SingleSampler.cc
==============================================================================
--- trunk/Engine/PixelSamplers/SingleSampler.cc (original)
+++ trunk/Engine/PixelSamplers/SingleSampler.cc Fri Jun 10 18:48:21 2005
@@ -54,8 +54,13 @@
   if(fragment.getFlags() & Fragment::ConstantEye)
     flags |= RayPacket::ConstantEye;
   for(int f=0;f<fragment.getSize();f+=RayPacket::MaxSize){
+    // We want to fill our RayPacket with as many as
+    // RayPacket::MaxSize rays.
     int size = RayPacket::MaxSize;
     if(size >= fragment.getSize()-f)
+      // We don't have enough fragments left to fill a ray packet, so
+      // set the size of the RayPacket to the number of fragments we
+      // have left.
       size = fragment.getSize()-f;
     // Create a ray packet
     int depth = 0;

Modified: trunk/Interface/AmbientLight.h
==============================================================================
--- trunk/Interface/AmbientLight.h      (original)
+++ trunk/Interface/AmbientLight.h      Fri Jun 10 18:48:21 2005
@@ -2,6 +2,10 @@
 #ifndef Manta_Interface_AmbientLight_h
 #define Manta_Interface_AmbientLight_h
 
+#include <sgi_stl_warnings_off.h>
+#include <string>
+#include <sgi_stl_warnings_on.h>
+
 namespace Manta {
   class PreprocessContext;
   class RenderContext;
@@ -14,6 +18,9 @@
     virtual void preprocess(const PreprocessContext& context) = 0;
     virtual void computeAmbient(const RenderContext& context, RayPacket& 
rays) const = 0;
 
+    // This function will return a newly allocated pointer of a string
+    // representation of the object.  You should delete it yourself.
+    virtual std::string toString() const = 0;
   private:
     AmbientLight(const AmbientLight&);
     AmbientLight& operator=(const AmbientLight&);

Modified: trunk/Interface/LightSet.cc
==============================================================================
--- trunk/Interface/LightSet.cc (original)
+++ trunk/Interface/LightSet.cc Fri Jun 10 18:48:21 2005
@@ -3,7 +3,14 @@
 #include <Interface/AmbientLight.h>
 #include <Interface/Light.h>
 #include <Core/Util/Assert.h>
+
+#include <sgi_stl_warnings_off.h>
+#include <iostream>
+#include <sstream>
+#include <sgi_stl_warnings_on.h>
+
 using namespace Manta;
+using namespace std;
 
 LightSet* LightSet::merge(LightSet* l1, LightSet* l2)
 {
@@ -24,8 +31,13 @@
 {
   // This won't work in many of the shadow algorithms
   ASSERT(static_cast<int>(lights.size()) <= RayPacket::MaxSize);
-  if(ambientLight)
-    ambientLight->preprocess(context);
+  if(ambientLight){
+    AmbientLight* test = dynamic_cast<AmbientLight*>(ambientLight);
+    if (test)
+      ambientLight->preprocess(context);
+    else
+      cerr << "ambientLight is not an AmbientLight\n";
+  }
   for(int i=0;i<static_cast<int>(lights.size());i++){
     lights[i]->preprocess(context);
     centers[i] = lights[i]->getCenter();
@@ -33,3 +45,15 @@
   }
 }
 
+string LightSet::toString() {
+  ostringstream out;
+  out << "ambientLight = "<<ambientLight<<"\n";
+  if (ambientLight)
+    out << ambientLight->toString();
+  out << "Num lights = "<<lights.size()<<"\n";
+  for(int i = 0; i < static_cast<int>(lights.size()); i++) {
+    out << "lights["<<i<<"] = "<<lights[i]<<"\n";
+    //    if (lights[i]) lights[i]->printme();
+  }
+  return out.str();
+}

Modified: trunk/Interface/LightSet.h
==============================================================================
--- trunk/Interface/LightSet.h  (original)
+++ trunk/Interface/LightSet.h  Fri Jun 10 18:48:21 2005
@@ -3,8 +3,10 @@
 #define Manta_Interface_LightSet_h
 
 #include <Interface/RayPacket.h>
+
 #include <sgi_stl_warnings_off.h>
 #include <vector>
+#include <string>
 #include <sgi_stl_warnings_on.h>
 
 namespace Manta {
@@ -52,6 +54,8 @@
     static LightSet* merge(LightSet* l1, LightSet* l2);
 
     void preprocess(const PreprocessContext&);
+
+    string toString();
 
     Point centers[RayPacket::MaxSize];
     Color colors[RayPacket::MaxSize];

Modified: trunk/Interface/RayPacket.h
==============================================================================
--- trunk/Interface/RayPacket.h (original)
+++ trunk/Interface/RayPacket.h Fri Jun 10 18:48:21 2005
@@ -63,6 +63,7 @@
       size = newSize;
     }
 
+#ifndef SWIG // SWIG doesn't support nested structs/classes.
     struct Element {
       Color localColor;
       Color* color;
@@ -87,6 +88,8 @@
     Element& get(int which) {
       return data[which];
     }
+#endif // SWIG
+    
     void setPixel(int which, int whichEye, double imageX, double imageY,
                  Color* color) {
       data[which].color = color;

Modified: trunk/Interface/TValue.h
==============================================================================
--- trunk/Interface/TValue.h    (original)
+++ trunk/Interface/TValue.h    Fri Jun 10 18:48:21 2005
@@ -15,11 +15,13 @@
       {
       }
 
+#ifndef SWIG
     void operator=(const T& newvalue)
       {
        value = newvalue;
       }
-
+#endif
+    
     operator T() const
       {
        return value;

Modified: trunk/Model/AmbientLights/ArcAmbient.cc
==============================================================================
--- trunk/Model/AmbientLights/ArcAmbient.cc     (original)
+++ trunk/Model/AmbientLights/ArcAmbient.cc     Fri Jun 10 18:48:21 2005
@@ -1,7 +1,13 @@
 
 #include <Model/AmbientLights/ArcAmbient.h>
 #include <Interface/RayPacket.h>
+
+#include <sgi_stl_warnings_off.h>
+#include <sstream>
+#include <sgi_stl_warnings_on.h>
+
 using namespace Manta;
+using namespace std;
 
 ArcAmbient::ArcAmbient(const Color& cup, const Color& cdown,
                       const Vector& up)
@@ -35,4 +41,15 @@
     }
     rays.get(i).ambientLight = cup*w1 + cdown*w0;
   }
+}
+
+string ArcAmbient::toString() const {
+  ostringstream out;
+  out << "--------  ArcAmbient  ---------\n";
+  RGB cu(cup.convertRGB()), cd(cdown.convertRGB());
+  out << "(cup, cdown) = ";
+  out << "("<<cu.r()<<", "<<cu.g()<<", "<<cu.b()<<"), ";
+  out << "("<<cd.r()<<", "<<cd.g()<<", "<<cd.b()<<")\n";
+  out << "up = "<<up<<"\n";
+  return out.str();
 }

Modified: trunk/Model/AmbientLights/ArcAmbient.h
==============================================================================
--- trunk/Model/AmbientLights/ArcAmbient.h      (original)
+++ trunk/Model/AmbientLights/ArcAmbient.h      Fri Jun 10 18:48:21 2005
@@ -6,6 +6,10 @@
 #include <Core/Color/Color.h>
 #include <Core/Geometry/PointVector.h>
 
+#include <sgi_stl_warnings_off.h>
+#include <string>
+#include <sgi_stl_warnings_on.h>
+
 namespace Manta {
 
   class ArcAmbient : public AmbientLight {
@@ -16,6 +20,8 @@
 
     virtual void preprocess(const PreprocessContext&);
     virtual void computeAmbient(const RenderContext& context, RayPacket& 
rays) const;
+
+    virtual std::string toString() const;
   private:
     Color cup;
     Color cdown;

Modified: trunk/Model/AmbientLights/ConstantAmbient.cc
==============================================================================
--- trunk/Model/AmbientLights/ConstantAmbient.cc        (original)
+++ trunk/Model/AmbientLights/ConstantAmbient.cc        Fri Jun 10 18:48:21 
2005
@@ -2,7 +2,12 @@
 #include <Model/AmbientLights/ConstantAmbient.h>
 #include <Interface/RayPacket.h>
 
+#include <sgi_stl_warnings_off.h>
+#include <sstream>
+#include <sgi_stl_warnings_on.h>
+
 using namespace Manta;
+using namespace std;
 
 ConstantAmbient::ConstantAmbient(const Color& color)
   : color(color)
@@ -24,3 +29,10 @@
     rays.get(i).ambientLight = color;
 }
 
+string ConstantAmbient::toString() const {
+  ostringstream out;
+  out << "--------  ConstantAmbient  ---------\n";
+  RGB c(color.convertRGB());
+  out << "color = ("<<c.r()<<", "<<c.g()<<", "<<c.b()<<")\n";
+  return out.str();
+}

Modified: trunk/Model/AmbientLights/ConstantAmbient.h
==============================================================================
--- trunk/Model/AmbientLights/ConstantAmbient.h (original)
+++ trunk/Model/AmbientLights/ConstantAmbient.h Fri Jun 10 18:48:21 2005
@@ -5,6 +5,10 @@
 #include <Interface/AmbientLight.h>
 #include <Core/Color/Color.h>
 
+#include <sgi_stl_warnings_off.h>
+#include <string>
+#include <sgi_stl_warnings_on.h>
+
 namespace Manta{
   class ConstantAmbient : public AmbientLight {
   public:
@@ -13,6 +17,8 @@
 
     virtual void preprocess(const PreprocessContext&);
     virtual void computeAmbient(const RenderContext& context, RayPacket& 
rays) const;
+
+    virtual std::string toString() const;
   private:
     Color color;
   };




  • [MANTA] r378 - in trunk: . Core/Color Core/Geometry Core/Math Engine/PixelSamplers Interface Model/AmbientLights SwigInterface, bigler, 06/10/2005

Archive powered by MHonArc 2.6.16.

Top of page