Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1355 - in trunk: Core/Math Interface Model/Groups Model/Materials Model/Textures SwigInterface


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1355 - in trunk: Core/Math Interface Model/Groups Model/Materials Model/Textures SwigInterface
  • Date: Tue, 24 Apr 2007 11:17:27 -0600 (MDT)

Author: bigler
Date: Tue Apr 24 11:17:26 2007
New Revision: 1355

Added:
   trunk/Core/Math/ReflectRefract.h
   trunk/Model/Materials/ThinDielectric.cc
      - copied, changed from r1353, trunk/Model/Materials/Dielectric.cc
   trunk/Model/Materials/ThinDielectric.h
      - copied, changed from r1353, trunk/Model/Materials/Dielectric.h
Modified:
   trunk/Interface/AccelerationStructure.h
   trunk/Model/Groups/DynBVH.h
   trunk/Model/Materials/CMakeLists.txt
   trunk/Model/Materials/Dielectric.cc
   trunk/Model/Textures/CheckerTexture.cc
   trunk/SwigInterface/manta.cc
   trunk/SwigInterface/manta.i
   trunk/SwigInterface/mantainterface.i
   trunk/SwigInterface/pycallback.i
   trunk/SwigInterface/runmanta.py
Log:

Interface/AccelerationStructure.h

  Don't include files from outside of Interface.  This can cause
  circular dependencies.

Model/Groups/DynBVH.h

  Swig get confused by all all the internal classes.  I made a few
  things protected to reduce exposure of these structures and
  interfaces.

Model/Materials/CMakeLists.txt

  Added ThinDielectric.

Model/Materials/Dielectric.cc
Core/Math/ReflectRefract.h

  Move SchlickReflection and FresnelReflection to its own file.

Model/Materials/ThinDielectric.cc
Model/Materials/ThinDielectric.h

  Dielectric material that assumes a planar thickness from a single
  manifold.

Model/Textures/CheckerTexture.cc

  Put code into Manta namespace where it should have been.

SwigInterface/manta.cc

  Add the default camera bookmark.

SwigInterface/manta.i

  Added ThinDielectric.

  Rearranged Group and RealisticBvh includes.

  Added DynBVH.

  
SwigInterface/mantainterface.i

  Added Clonable and AccelerationStructure.

SwigInterface/pycallback.i

  Added CallbackHandle.

SwigInterface/runmanta.py

  Added doAddDebugRays global variable.

  Added addBookmarkFromString and each scene now sets bookmarks
  instead of changing the global camara.

  Moved getVectorFromTokens and addDebugRays to the top of the file to
  be accessible by others.


Added: trunk/Core/Math/ReflectRefract.h
==============================================================================
--- (empty file)
+++ trunk/Core/Math/ReflectRefract.h    Tue Apr 24 11:17:26 2007
@@ -0,0 +1,57 @@
+#include <MantaTypes.h>
+#include <SCIRun/Core/Math/MinMax.h>
+#include <Core/Geometry/Vector.h>
+
+namespace Manta {
+  // Given eta         = eta_t/eta_i (or eta2/eta1)
+  //       eta_inverse = eta_i/eta_t (or eta1/eta2)
+  // r0 = (1 - eta_inverse) / (1 + eta_inverse);
+  // r0 = (eta - 1)         / (1 + eta);
+  // r0 = (eta_t - eta_i)   / (eta_t - eta_i);
+  //
+  // Note that because r0 is squared, eta_t and eta_i can be swapped and
+  // get the same result.
+  //
+  // (eta_t - eta_i)^2 = eta_t^2 - 2*eta_t*eta_i + eta_i^2
+  // (eta_i - eta_t)^2 = eta_i^2 - 2*eta_i*eta_t + eta_t^2
+  //
+  // We can conclude that the reflection coefficient is not dependent on
+  // wether the ray is entering or leaving the dielectric, but rather
+  // the relative angles.
+
+  inline Real SchlickReflection(Real costheta, Real costheta2,
+                                Real eta_inverse)
+  {
+    Real k = 1 - SCIRun::Min(costheta, costheta2);
+    Real k5 = (k*k)*(k*k)*k;
+    Real r0 = (1 - eta_inverse) / (1 + eta_inverse);
+    r0 *= r0;
+    return r0*(1-k5) + k5;
+  }
+
+  // Similarly to the Schlick approximation to the reflection, eta1 and
+  // eta2 can be swapped and get the same result.
+  inline Real FresnelReflection(Real costheta, Real costheta2,
+                                Real eta1, Real eta2)
+  {
+    Real r_parallel = (((eta2 * costheta) - (eta1 * costheta2)) /
+                       ((eta2 * costheta) + (eta1 * costheta2)));
+    Real r_perp     = (((eta1 * costheta) - (eta2 * costheta2)) /
+                       ((eta1 * costheta) + (eta2 * costheta2)));
+    return (Real)(.5)*(r_parallel*r_parallel + r_perp*r_perp);
+  }
+
+  inline Vector ReflectRay(const Vector& v, const Vector& normal,
+                           Real costheta)
+  {
+    return v + 2*costheta*normal;
+  }
+
+  inline Vector RefractRay(const Vector& v, const Vector& normal,
+                           Real eta_inverse, Real costheta, Real costheta2)
+  {
+    return (eta_inverse * v +
+            (eta_inverse * costheta - costheta2) * normal);
+  }
+
+} // end namespace Manta

Modified: trunk/Interface/AccelerationStructure.h
==============================================================================
--- trunk/Interface/AccelerationStructure.h     (original)
+++ trunk/Interface/AccelerationStructure.h     Tue Apr 24 11:17:26 2007
@@ -2,9 +2,11 @@
 #define Manta_Interface_AccelerationStructure_h
 
 #include <Interface/Object.h>
-#include <Model/Groups/Group.h>
 
 namespace Manta {
+
+  class Group;
+  
   class AccelerationStructure : public Object {
   public:
 

Modified: trunk/Model/Groups/DynBVH.h
==============================================================================
--- trunk/Model/Groups/DynBVH.h (original)
+++ trunk/Model/Groups/DynBVH.h Tue Apr 24 11:17:26 2007
@@ -10,7 +10,7 @@
 {
     class DynBVH : public AccelerationStructure
     {
-    public:
+    protected:
         struct IAData
         {
             Real min_rcp[3];
@@ -59,11 +59,13 @@
         int num_nodes;
         Group* currGroup;
 
+    public:
         DynBVH() : currGroup(NULL)
         {}
 
         void preprocess(const PreprocessContext&);
         void intersect(const RenderContext& context, RayPacket& rays) const;
+    protected:
         void intersectNode(int nodeID, const RenderContext& context, 
RayPacket& rays, const IAData& ia_data) const;
 
 
@@ -72,6 +74,7 @@
         // return the last index which hits the box
         int lastIntersects(const BBox& box, const RayPacket& rays) const;
 
+    public:
         void computeBounds(const PreprocessContext&,
                            BBox& bbox) const
         {
@@ -93,6 +96,7 @@
         void updateBounds(const PreprocessContext& context, int ID = 0);
 
 
+    protected:
         int partitionSAH(const PreprocessContext& context,
                          int objBegin, int objEnd, int& output_axis);
 

Modified: trunk/Model/Materials/CMakeLists.txt
==============================================================================
--- trunk/Model/Materials/CMakeLists.txt        (original)
+++ trunk/Model/Materials/CMakeLists.txt        Tue Apr 24 11:17:26 2007
@@ -24,6 +24,8 @@
      Materials/OpaqueShadower.cc
      Materials/Phong.h
      Materials/Phong.cc
+     Materials/ThinDielectric.h
+     Materials/ThinDielectric.cc
      Materials/Transparent.cc
      Materials/Transparent.h
      Materials/CopyColorMaterial.cc

Modified: trunk/Model/Materials/Dielectric.cc
==============================================================================
--- trunk/Model/Materials/Dielectric.cc (original)
+++ trunk/Model/Materials/Dielectric.cc Tue Apr 24 11:17:26 2007
@@ -39,6 +39,7 @@
 #include <Interface/ShadowAlgorithm.h>
 #include <Core/Math/Expon.h>
 #include <Core/Color/ColorSpace_fancy.h>
+#include <Core/Math/ReflectRefract.h>
 
 #include <iostream>
 using namespace Manta;
@@ -56,44 +57,6 @@
 {
 }
 
-// Given eta         = eta_t/eta_i (or eta2/eta1)
-//       eta_inverse = eta_i/eta_t (or eta1/eta2)
-// r0 = (1 - eta_inverse) / (1 + eta_inverse);
-// r0 = (eta - 1)         / (1 + eta);
-// r0 = (eta_t - eta_i)   / (eta_t - eta_i);
-//
-// Note that because r0 is squared, eta_t and eta_i can be swapped and
-// get the same result.
-//
-// (eta_t - eta_i)^2 = eta_t^2 - 2*eta_t*eta_i + eta_i^2
-// (eta_i - eta_t)^2 = eta_i^2 - 2*eta_i*eta_t + eta_t^2
-//
-// We can conclude that the reflection coefficient is not dependent on
-// wether the ray is entering or leaving the dielectric, but rather
-// the relative angles.
-
-static inline Real SchlickReflection(Real costheta, Real costheta2,
-                                     Real eta_inverse)
-{
-  Real k = 1 - SCIRun::Min(costheta, costheta2);
-  Real k5 = (k*k)*(k*k)*k;
-  Real r0 = (1 - eta_inverse) / (1 + eta_inverse);
-  r0 *= r0;
-  return r0*(1-k5) + k5;
-}
-
-// Similarly to the Schlick approximation to the reflection, eta1 and
-// eta2 can be swapped and get the same result.
-static inline Real FresnelReflection(Real costheta, Real costheta2,
-                                     Real eta1, Real eta2)
-{
-  Real r_parallel = (((eta2 * costheta) - (eta1 * costheta2)) /
-                     ((eta2 * costheta) + (eta1 * costheta2)));
-  Real r_perp     = (((eta1 * costheta) - (eta2 * costheta2)) /
-                     ((eta1 * costheta) + (eta2 * costheta2)));
-  return (Real)(.5)*(r_parallel*r_parallel + r_perp*r_perp);
-}
-
 void Dielectric::shade(const RenderContext& context, RayPacket& rays) const
 {
   int debugFlag = rays.getAllFlags() & RayPacket::DebugPacket;
@@ -226,6 +189,7 @@
         Vector refr_dir = (eta_inverse * rayD +
                            (eta_inverse * costheta - costheta2) * normal);
         refracted_rays.setRay(num_refr, hitpos, refr_dir);
+        if (debugFlag) { cerr << "refr_dir.length() = 
"<<refr_dir.length()<<"\n"; }
         refr_source[num_refr] = i;
         num_refr++;
       }

Copied: trunk/Model/Materials/ThinDielectric.cc (from r1353, 
trunk/Model/Materials/Dielectric.cc)
==============================================================================
--- trunk/Model/Materials/Dielectric.cc (original)
+++ trunk/Model/Materials/ThinDielectric.cc     Tue Apr 24 11:17:26 2007
@@ -26,7 +26,7 @@
  DEALINGS IN THE SOFTWARE.
  */
 
-#include <Model/Materials/Dielectric.h>
+#include <Model/Materials/ThinDielectric.h>
 #include <Core/Math/ipow.h>
 #include <Interface/AmbientLight.h>
 #include <Interface/Context.h>
@@ -39,62 +39,41 @@
 #include <Interface/ShadowAlgorithm.h>
 #include <Core/Math/Expon.h>
 #include <Core/Color/ColorSpace_fancy.h>
+#include <Core/Math/ReflectRefract.h>
 
 #include <iostream>
 using namespace Manta;
 using namespace SCIRun;
 using std::cerr;
 
-Dielectric::Dielectric(const Texture<Real>* n, const Texture<Real>* nt,
-                       const Texture<Color>* sigma_a,
-                       Real cutoff)
-  : n(n), nt(nt), sigma_a(sigma_a), doSchlick(false)
+ThinDielectric::ThinDielectric(Real eta, const Color& sigma_a,
+                               Real thickness,
+                               Real localCutoffScale)
+  : eta(new Constant<Real>(eta)),
+    sigma_a(new Constant<Color>(sigma_a)),
+    thickness(thickness),
+    localCutoffScale(localCutoffScale),
+    doSchlick(false)
 {
 }
 
-Dielectric::~Dielectric()
+ThinDielectric::ThinDielectric(const Texture<Real>* eta,
+                               const Texture<Color>* sigma_a,
+                               Real thickness,
+                               Real localCutoffScale)
+  : eta(eta),
+    sigma_a(sigma_a),
+    thickness(thickness),
+    localCutoffScale(localCutoffScale),
+    doSchlick(false)
 {
 }
 
-// Given eta         = eta_t/eta_i (or eta2/eta1)
-//       eta_inverse = eta_i/eta_t (or eta1/eta2)
-// r0 = (1 - eta_inverse) / (1 + eta_inverse);
-// r0 = (eta - 1)         / (1 + eta);
-// r0 = (eta_t - eta_i)   / (eta_t - eta_i);
-//
-// Note that because r0 is squared, eta_t and eta_i can be swapped and
-// get the same result.
-//
-// (eta_t - eta_i)^2 = eta_t^2 - 2*eta_t*eta_i + eta_i^2
-// (eta_i - eta_t)^2 = eta_i^2 - 2*eta_i*eta_t + eta_t^2
-//
-// We can conclude that the reflection coefficient is not dependent on
-// wether the ray is entering or leaving the dielectric, but rather
-// the relative angles.
-
-static inline Real SchlickReflection(Real costheta, Real costheta2,
-                                     Real eta_inverse)
-{
-  Real k = 1 - SCIRun::Min(costheta, costheta2);
-  Real k5 = (k*k)*(k*k)*k;
-  Real r0 = (1 - eta_inverse) / (1 + eta_inverse);
-  r0 *= r0;
-  return r0*(1-k5) + k5;
-}
-
-// Similarly to the Schlick approximation to the reflection, eta1 and
-// eta2 can be swapped and get the same result.
-static inline Real FresnelReflection(Real costheta, Real costheta2,
-                                     Real eta1, Real eta2)
+ThinDielectric::~ThinDielectric()
 {
-  Real r_parallel = (((eta2 * costheta) - (eta1 * costheta2)) /
-                     ((eta2 * costheta) + (eta1 * costheta2)));
-  Real r_perp     = (((eta1 * costheta) - (eta2 * costheta2)) /
-                     ((eta1 * costheta) + (eta2 * costheta2)));
-  return (Real)(.5)*(r_parallel*r_parallel + r_perp*r_perp);
 }
 
-void Dielectric::shade(const RenderContext& context, RayPacket& rays) const
+void ThinDielectric::shade(const RenderContext& context, RayPacket& rays) 
const
 {
   int debugFlag = rays.getAllFlags() & RayPacket::DebugPacket;
   if(rays.getDepth() >= context.scene->getRenderParameters().maxDepth) {
@@ -103,19 +82,17 @@
     return;
   }
   if (debugFlag) {
-    cerr << "Dielectric::shade: depth = "<< rays.getDepth() << "\n";
+    cerr << "ThinDielectric::shade: depth = "<< rays.getDepth() << "\n";
   }
 
   rays.computeHitPositions();
   rays.normalizeDirections();
-  rays.computeNormals(context);
+  rays.computeFFNormals(context);
 
-  Packet<Real> n_values;
-  Packet<Real> nt_values;
+  Packet<Real> eta_values;
   Packet<Color> sigma_a_values;
 
-  n->mapValues(n_values, context, rays);
-  nt->mapValues(nt_values, context, rays);
+  eta->mapValues(eta_values, context, rays);
   sigma_a->mapValues(sigma_a_values, context, rays);
 
   RayPacketData reflected_data;
@@ -142,63 +119,38 @@
     results[i] = Color::black();
 
     Vector rayD = rays.getDirection(i);
-    Vector normal = rays.getNormal(i);
+    Vector normal = rays.getFFNormal(i);
+    // The dot product needs to be negated, because the ray direction
+    // points towards the surface and the normal points away.
     Real costheta = -Dot(normal, rayD);
     if (debugFlag) {
       cerr << "ray      = "<<rayD<<"\n";
       cerr << "normal   = "<<normal<<"\n";
       cerr << "costheta = "<<costheta<<"\n";
     }
-    Real eta_inverse;
-    Color beers_color;
-    bool exiting;
-    if ( costheta < 0 ) {
-      // Exiting surface
-      normal = -normal;
-      costheta = -costheta;
-      eta_inverse = n_values.data[i]/nt_values.data[i];
-      exiting = true;
-      beers_color = sigma_a_values.get(i).Pow(rays.getMinT(i));
-    } else {
-      eta_inverse = nt_values.data[i]/n_values.data[i];
-      exiting = false;
-      beers_color = Color::white();
-    }
 
-    Vector refl_dir = rayD + 2*costheta*normal;
+    Real eta_inverse = 1/eta_values.data[i];
+    Vector refl_dir = ReflectRay(rayD, normal, costheta);
     Real costheta2squared = 
1+(costheta*costheta-1)*(eta_inverse*eta_inverse);
     Color in_importance = rays.getImportance(i);
     Vector hitpos = rays.getHitPosition(i);
-    if ( costheta2squared < 0 ) {
-      // total internal reflection - no attenuation
-#if 1
-      Color refl_importance = in_importance * beers_color;
-      if(refl_importance.luminance() > cutoff){
-        reflected_rays.setImportance(num_refl, refl_importance);
-        reflected_rays.setRay(num_refl, hitpos, refl_dir);
-        refl_source[num_refl] = i;
-        refl_attenuation[num_refl] = beers_color;
-        num_refl++;
-      }
-#endif
-      if (debugFlag) cerr << "Total internal reflection: " << 
costheta2squared << "\n";
-    } else {
+    if ( costheta2squared >= 0 ) {
       Real costheta2 = Sqrt(costheta2squared);
       Real refl;
 
-      if (doSchlick) {
-        refl = SchlickReflection(costheta, costheta2, eta_inverse);
-      } else {
+      if (!doSchlick) {
         refl = FresnelReflection(costheta, costheta2,
-                                 n_values.data[i], nt_values.data[i]);
+                                 eta_inverse, 1);
+      } else {
+        refl = SchlickReflection(costheta, costheta2, eta_inverse);
       }
+      
       if (debugFlag) {
         Real schlick_refl, fresnel_refl;
         if (doSchlick) {
           schlick_refl = refl;
           fresnel_refl = FresnelReflection(costheta, costheta2,
-                                           n_values.data[i],
-                                           nt_values.data[i]);
+                                           eta_inverse, 1);
         } else {
           schlick_refl = SchlickReflection(costheta, costheta2, eta_inverse);
           fresnel_refl = refl;
@@ -206,9 +158,8 @@
         cerr << "schlick_refl = "<<schlick_refl<<", fresnel_refl = 
"<<fresnel_refl<<", refl = "<<refl<<"\n";
       }
 
-#if 1
       // Possibly create reflection ray
-      refl_attenuation[num_refl] = beers_color * refl;
+      refl_attenuation[num_refl] = Color(RGBColor(refl, refl, refl));
       Color refl_importance = in_importance * refl_attenuation[num_refl];
       if(refl_importance.luminance() > cutoff){
         reflected_rays.setImportance(num_refl, refl_importance);
@@ -216,19 +167,39 @@
         refl_source[num_refl] = i;
         num_refl++;
       }
-#endif
 
+      // Now compute the refraction contribution
+      Real refraction_ray_length = thickness / costheta2;
+      Color beers_color = sigma_a_values.get(i).Pow(refraction_ray_length);
       // Possibly create refraction ray
       refr_attenuation[num_refr] = beers_color * (1-refl);
       Color refr_importance = in_importance * refr_attenuation[num_refr];
       if(refr_importance.luminance() > cutoff){
+        Vector refr_dir = RefractRay(rayD, normal,
+                                     eta_inverse, costheta, costheta2);
         refracted_rays.setImportance(num_refr, refr_importance);
-        Vector refr_dir = (eta_inverse * rayD +
-                           (eta_inverse * costheta - costheta2) * normal);
-        refracted_rays.setRay(num_refr, hitpos, refr_dir);
+        Vector refr_orig = hitpos + refr_dir * refraction_ray_length;
+        refracted_rays.setRay(num_refr, refr_orig, refr_dir);
+        if (debugFlag) { cerr << "refr_dir.length() = 
"<<refr_dir.length()<<"\n"; }
         refr_source[num_refr] = i;
         num_refr++;
       }
+    } else {
+      // total internal reflection - no attenuation
+      //
+      // Since this is a thin dielectric that you should never be
+      // inside of, I'm not sure what I should do in this case.  You
+      // should only get in here if you specified an eta less than
+      // one.
+      Color refl_importance = in_importance; // * beers_color = 
Color::white();
+      if(refl_importance.luminance() > cutoff){
+        reflected_rays.setImportance(num_refl, refl_importance);
+        reflected_rays.setRay(num_refl, hitpos, refl_dir);
+        refl_source[num_refl] = i;
+        refl_attenuation[num_refl] = Color::white();
+        num_refl++;
+      }
+      if (debugFlag) cerr << "Total internal reflection: " << 
costheta2squared << "\n";
     }
   }
 
@@ -254,7 +225,7 @@
     rays.setColor(i, results[i]);
 }
 
-void Dielectric::attenuateShadows(const RenderContext& context,
+void ThinDielectric::attenuateShadows(const RenderContext& context,
                                   RayPacket& shadowRays) const
 {
   // This is basically a hack for now.

Copied: trunk/Model/Materials/ThinDielectric.h (from r1353, 
trunk/Model/Materials/Dielectric.h)
==============================================================================
--- trunk/Model/Materials/Dielectric.h  (original)
+++ trunk/Model/Materials/ThinDielectric.h      Tue Apr 24 11:17:26 2007
@@ -1,6 +1,6 @@
 
-#ifndef Manta_Model_Dielectric_h
-#define Manta_Model_Dielectric_h
+#ifndef Manta_Model_ThinDielectric_h
+#define Manta_Model_ThinDielectric_h
 
 /*
  For more information, please see: http://software.sci.utah.edu
@@ -39,22 +39,18 @@
 {
   class LightSet;
 
-  class Dielectric : public LitMaterial
+  class ThinDielectric : public LitMaterial
   {
   public:
-    Dielectric(const Real n, const Real nt, const Color &sigma_a,
-               Real localCutoffScale = 1)
-      : n(new Constant<Real>(n)),
-        nt(new Constant<Real>(nt)),
-        sigma_a(new Constant<Color>(sigma_a)),
-        localCutoffScale(localCutoffScale),
-        doSchlick(false)
-        { }
-
-    Dielectric(const Texture<Real>* n, const Texture<Real>* nt,
-               const Texture<Color>* sigma_a,
-               Real localCutoffScale = 1);
-    ~Dielectric();
+    ThinDielectric(Real eta, const Color& sigma_a,
+                   Real thickness,
+                   Real localCutoffScale = 1);
+
+    ThinDielectric(const Texture<Real>* n,
+                   const Texture<Color>* sigma_a,
+                   Real thickness,
+                   Real localCutoffScale = 1);
+    ~ThinDielectric();
 
     void shade(const RenderContext& context, RayPacket& rays) const;
     virtual void attenuateShadows(const RenderContext& context,
@@ -62,9 +58,9 @@
 
     void setDoSchlick(bool new_val) { doSchlick = new_val; }
   private:
-    const Texture<Real>* n;
-    const Texture<Real>* nt;
+    const Texture<Real>* eta;
     const Texture<Color>* sigma_a;
+    Real thickness;
     Real localCutoffScale;
     bool doSchlick;
   };

Modified: trunk/Model/Textures/CheckerTexture.cc
==============================================================================
--- trunk/Model/Textures/CheckerTexture.cc      (original)
+++ trunk/Model/Textures/CheckerTexture.cc      Tue Apr 24 11:17:26 2007
@@ -1,8 +1,9 @@
 
 #include <Model/Textures/CheckerTexture.h>
-using namespace Manta;
 
 #ifdef MANTA_SSE
+namespace Manta {
+  
 template<>
 void CheckerTexture<Color>::mapValues(Packet<Color>& results,
                                       const RenderContext& context,
@@ -153,6 +154,8 @@
       }
     }
 }
+
+} // end namespace Manta
 #endif
 
 

Modified: trunk/SwigInterface/manta.cc
==============================================================================
--- trunk/SwigInterface/manta.cc        (original)
+++ trunk/SwigInterface/manta.cc        Tue Apr 24 11:17:26 2007
@@ -57,5 +57,6 @@
   lights->setAmbientLight(new ConstantAmbient(Color::black()));
   scene->setLights(lights);
   scene->getRenderParameters().maxDepth = 5;
+  scene->addBookmark("default view", Vector(3, 3, 2), Vector(0, 0, 0.3), 
Vector(0, 0, 1), 60);
   return scene;
 }

Modified: trunk/SwigInterface/manta.i
==============================================================================
--- trunk/SwigInterface/manta.i (original)
+++ trunk/SwigInterface/manta.i Tue Apr 24 11:17:26 2007
@@ -174,9 +174,9 @@
 #include <Model/Materials/Lambertian.h>
 #include <Model/Materials/MetalMaterial.h>
 #include <Model/Materials/Dielectric.h>
+#include <Model/Materials/ThinDielectric.h>
 #include <Model/Materials/Flat.h>
 #include <Model/Materials/Transparent.h>
-#include <Model/Groups/Group.h>
 #include <Model/Primitives/PrimitiveCommon.h>
 #include <Model/Primitives/Cylinder.h>
 #include <Model/Primitives/Cube.h>
@@ -185,7 +185,6 @@
 #include <Model/Primitives/Ring.h>
 #include <Model/Primitives/Sphere.h>
 #include <Model/TexCoordMappers/UniformMapper.h>
-#include <Model/Groups/RealisticBvh.h>
 %}
 
 %include <Model/Materials/OpaqueShadower.h>
@@ -194,9 +193,9 @@
 %include <Model/Materials/Lambertian.h>
 %include <Model/Materials/MetalMaterial.h>
 %include <Model/Materials/Dielectric.h>
+%include <Model/Materials/ThinDielectric.h>
 %include <Model/Materials/Flat.h>
 %include <Model/Materials/Transparent.h>
-%include <Model/Groups/Group.h>
 %include <Model/Primitives/PrimitiveCommon.h>
 %include <Model/Primitives/Cylinder.h>
 %include <Model/Primitives/Cube.h>
@@ -205,16 +204,17 @@
 %include <Model/Primitives/Ring.h>
 %include <Model/Primitives/Sphere.h>
 %include <Model/TexCoordMappers/UniformMapper.h>
-%include <Model/Groups/RealisticBvh.h>
 
 
///////////////////////////////////////////////////////////////////////////////
 // Groups
 
 %{
+#include <Model/Groups/Group.h>
 #include <Model/Textures/NormalTexture.h>
 #include <Model/Groups/KDTree.h>
 %}
 
+%include <Model/Groups/Group.h>
 %include <Model/Textures/NormalTexture.h>
 
 namespace Manta {
@@ -227,12 +227,16 @@
 #include <Model/Groups/Load_OBJ_KDTreeDyn.h>
 #include <Model/Groups/Build_OnLogn_cc.h>
 #include <Model/Groups/Build_Approx_cc.h>
+#include <Model/Groups/RealisticBvh.h>
+#include <Model/Groups/DynBVH.h>
 %}
 
 %include <Model/Groups/KDTreeDyn.h>
 %include <Model/Groups/Load_OBJ_KDTreeDyn.h>
 %include <Model/Groups/Build_OnLogn_cc.h>
 %include <Model/Groups/Build_Approx_cc.h>
+%include <Model/Groups/RealisticBvh.h>
+%include <Model/Groups/DynBVH.h>
 
 /////////////////////////////////////////////////
 // GLM.

Modified: trunk/SwigInterface/mantainterface.i
==============================================================================
--- trunk/SwigInterface/mantainterface.i        (original)
+++ trunk/SwigInterface/mantainterface.i        Tue Apr 24 11:17:26 2007
@@ -145,23 +145,29 @@
 #include <Core/Geometry/Ray.h>
 #include <Interface/CallbackHandle.h>
 #include <Interface/Context.h>
+#include <Interface/Clonable.h>
 #include <Interface/Object.h>
 #include <Interface/Primitive.h>
 #include <Interface/TexCoordMapper.h>
 #include <Core/Util/Align.h>
 #include <Core/Util/About.h>
 #include <Interface/RayPacket.h>
+#include <Interface/AccelerationStructure.h>
 %}
 
+typedef int CloneDepth;
+
 %include <Core/Geometry/Ray.h>
 %include <Interface/CallbackHandle.h>
 %include <Interface/Context.h>
+%include <Interface/Clonable.h>
 %include <Interface/Object.h>
 %include <Interface/Primitive.h>
 %include <Interface/TexCoordMapper.h>
 %include <Core/Util/Align.h>
 %include <Core/Util/About.h>
 %include <Interface/RayPacket.h>
+%include <Interface/AccelerationStructure.h>
 
 
 

Modified: trunk/SwigInterface/pycallback.i
==============================================================================
--- trunk/SwigInterface/pycallback.i    (original)
+++ trunk/SwigInterface/pycallback.i    Tue Apr 24 11:17:26 2007
@@ -26,11 +26,13 @@
 
 %{
 #include <SwigInterface/pycallback.h>
+#include <Interface/CallbackHandle.h>
 #include <Interface/Callback.h>
 #include <Interface/CallbackHelpers.h>
 %}
 
 %include <SwigInterface/pycallback.h>
+%include <Interface/CallbackHandle.h>
 %include <Interface/CallbackHelpers.h>
 
 namespace Manta {

Modified: trunk/SwigInterface/runmanta.py
==============================================================================
--- trunk/SwigInterface/runmanta.py     (original)
+++ trunk/SwigInterface/runmanta.py     Tue Apr 24 11:17:26 2007
@@ -4,6 +4,54 @@
 
 import string
 
+doAddDebugRays = False
+
+def getVectorFromTokens(tokens, index):
+    return Vector(string.atof(tokens[index+1]),
+                  string.atof(tokens[index+2]),
+                  string.atof(tokens[index+3]))
+
+def addDebugRays(objs, infilename, radius, deadEndRayLength = 2):
+    materials = [manta_new(Lambertian(Color(RGBColor(1,0,0)))),
+                 manta_new(Lambertian(Color(RGBColor(1,1,0)))),
+                 manta_new(Lambertian(Color(RGBColor(0,1,0)))),
+                 manta_new(Lambertian(Color(RGBColor(0,1,1)))),
+                 manta_new(Lambertian(Color(RGBColor(0,0,1)))),
+                 manta_new(Lambertian(Color(RGBColor(1,0,1))))]
+    infile = open(infilename, "rU")
+    # Now read the lines
+    lines = map( lambda x: string.strip(x, string.whitespace),
+                 infile.readlines() )
+    infile.close()
+    # Loop over all the lines and pull out the relevant stuff
+    for l in lines[0:]:
+        tokens = l.split()
+        if ("raytree:" in tokens):
+            originIndex = tokens.index("origin")
+            origin = getVectorFromTokens(tokens, originIndex)
+            raydepth = string.atoi(tokens[tokens.index("depth")+1])
+            matl = materials[raydepth%len(materials)]
+            # Try and get the hitpos
+            if ("hitpos" in tokens):
+                print "Normal ray"
+                hitposIndex = tokens.index("hitpos")
+                hitpos = getVectorFromTokens(tokens, hitposIndex)
+            else:
+                print "Computing stub"
+                # Get the direction and compute a distance
+                directionIndex = tokens.index("direction")
+                direction = getVectorFromTokens(tokens, directionIndex)
+                hitpos = origin + (direction.normal() * deadEndRayLength)
+            objs.add(manta_new(Cylinder(matl, origin, hitpos, radius)))
+
+def addBookmarkFromString(scene, parameters):
+    tokens = parameters.split()
+    eye    = getVectorFromTokens(tokens, tokens.index("-eye"))
+    lookat = getVectorFromTokens(tokens, tokens.index("-lookat"))
+    up     = getVectorFromTokens(tokens, tokens.index("-up"))
+    fov    = string.atof(tokens[tokens.index("-fov")+1])
+    scene.addBookmark(parameters, eye, lookat, up, fov)
+    
 def createDefaultScenePython():
     scene = manta_new(Scene())
     
scene.setBackground(manta_new(ConstantBackground(ColorDB.getNamedColor("SkyBlue3").scaled(0.5))))
@@ -26,6 +74,15 @@
     floor.setTexCoordMapper(uniformmap)
     world.add(floor)
     world.add(manta_new(Sphere(red, Vector(0,0,1.2), 1.0)))
+
+    if (doAddDebugRays):
+        objs = manta_new(Group())
+        addDebugRays(objs, "raytree", 0.025)
+        objs.add(world)
+        dynbvh = manta_new(DynBVH())
+        dynbvh.rebuild(objs)
+        world = dynbvh
+        
     scene.setObject(world)
     #
     lights = manta_new(LightSet())
@@ -37,6 +94,7 @@
     #
     scene.setLights(lights)
     scene.getRenderParameters().maxDepth = 5
+    addBookmarkFromString(scene, "pinhole( -eye 3 3 2 -lookat 0 0 0.3 -up 0 
0 1 -fov 60 )")
     return scene
 
 def createDielectricTestScene():
@@ -91,6 +149,7 @@
     scene.getRenderParameters().maxDepth = 25
     scene.getRenderParameters().importanceCutoff = 0.01
     #
+    addBookmarkFromString(scene, "pinhole( -eye 8 -18 8.5 -lookat -4.7 2.5 
2.5 -up 0 0 1 -fov 15 )")
     return scene
 
 def createProg4TestScene():
@@ -156,46 +215,9 @@
     scene.getRenderParameters().maxDepth = 25
     scene.getRenderParameters().importanceCutoff = 0.01
     #
+    addBookmarkFromString(scene, "pinhole( -eye 8.3 -18 7 -lookat -4.7 2.5 3 
-up 0 0 1 -fov 15 )")
     return scene
 
-def getVectorFromTokens(tokens, index):
-    return Vector(string.atof(tokens[index+1]),
-                  string.atof(tokens[index+2]),
-                  string.atof(tokens[index+3]))
-
-def addDebugRays(objs, infilename, radius, deadEndRayLength = 2):
-    materials = [manta_new(Lambertian(Color(RGBColor(1,0,0)))),
-                 manta_new(Lambertian(Color(RGBColor(1,1,0)))),
-                 manta_new(Lambertian(Color(RGBColor(0,1,0)))),
-                 manta_new(Lambertian(Color(RGBColor(0,1,1)))),
-                 manta_new(Lambertian(Color(RGBColor(0,0,1)))),
-                 manta_new(Lambertian(Color(RGBColor(1,0,1))))]
-    infile = open(infilename, "rU")
-    # Now read the lines
-    lines = map( lambda x: string.strip(x, string.whitespace),
-                 infile.readlines() )
-    infile.close()
-    # Loop over all the lines and pull out the relevant stuff
-    for l in lines[0:]:
-        tokens = l.split()
-        if ("raytree:" in tokens):
-            originIndex = tokens.index("origin")
-            origin = getVectorFromTokens(tokens, originIndex)
-            raydepth = string.atoi(tokens[tokens.index("depth")+1])
-            matl = materials[raydepth%len(materials)]
-            # Try and get the hitpos
-            if ("hitpos" in tokens):
-                print "Normal ray"
-                hitposIndex = tokens.index("hitpos")
-                hitpos = getVectorFromTokens(tokens, hitposIndex)
-            else:
-                print "Computing stub"
-                # Get the direction and compute a distance
-                directionIndex = tokens.index("direction")
-                direction = getVectorFromTokens(tokens, directionIndex)
-                hitpos = origin + (direction.normal() * deadEndRayLength)
-            objs.add(manta_new(Cylinder(matl, origin, hitpos, radius)))
-    
 def createTransparentShadowScene():
     scene = manta_new(Scene())
     scene.setBackground(manta_new(ConstantBackground(Color(RGBColor(0.5, 
0.8, 0.9)))))
@@ -216,19 +238,24 @@
     #
     lenscale = 2.5
     glass = Color(RGBColor(pow(0.80, lenscale), pow(0.93, lenscale), 
pow(0.87, lenscale)))
-    transp_matl = manta_new(Dielectric(1.1, 1.0, glass))
+    if (doAddDebugRays):
+        transp_matl = manta_new(Dielectric(1.0, 1.0, glass))
+    else:
+        transp_matl = manta_new(Dielectric(1.5, 1.0, glass))
 #    transp_matl.setDoSchlick(True)
     print transp_matl
     objs.add(manta_new(Cube(transp_matl,
                             Vector(-5, -2, 2.95 ),
                             Vector(-1, 2, 3.36))))
-#     objs.add(manta_new(Cube(manta_new(Dielectric(1.1, 1, glass)),
-#                             Vector(-5, -2, 2.95 ),
-#                             Vector(-1, 2, 3.05))))
 
     objs.add(manta_new(Sphere(transp_matl,
                               Vector( -3, 0, 4.5), 0.5)))
-                              
+
+#     objs.add(manta_new(Parallelogram(manta_new(ThinDielectric(1.2, 
Color(RGBColor(0.7, 0.2, 0.4)), 0.1)),
+#                                      Vector(-1, -2, 4.0),
+#                                      Vector(2, 0, 0),
+#                                      Vector(0, 2, 0))))
+    
     ringmatl = manta_new(Lambertian(Color(RGBColor(.9, .3, .2))))
     print ringmatl
     r = .30
@@ -241,7 +268,8 @@
 #                                 Vector(0, 0, 1),
 #                                 inner_radius, r-inner_radius)))
 
-    #addDebugRays(objs, "raytree", 0.025)
+    if (doAddDebugRays):
+        addDebugRays(objs, "raytree", 0.025)
     # Create a BVH
     world.add(manta_new(RealisticBvh(objs.get_objs(), objs.size())))
     scene.setObject(world)
@@ -254,6 +282,11 @@
     scene.setLights(lights)
     scene.getRenderParameters().maxDepth = 25
     scene.getRenderParameters().importanceCutoff = 0.01
+    scene.addBookmark("createTransparentShadowScene camera",
+                      Vector(8.3, -18, 7),
+                      Vector(-4.7, 2.5, 3), Vector(0, 0, 1), 15)
+    addBookmarkFromString(scene, "pinhole( -eye 8.06072 -17.7429 8.73358 
-lookat -4.98977 2.23422 2.74486 -up -0.0793095 0.0464671 0.995767 -fov 15 
)");
+    addBookmarkFromString(scene, "pinhole( -eye 7.92503 -16.4782 12.1826 
-lookat -4.42502 2.59203 2.7444 -up -0.216459 0.129008 0.967731 -fov 15 )")
     #
     return scene
 
@@ -306,17 +339,13 @@
 
 engine = setupDefaultEngine(1)
 
-#defaultCamera = factory.createCamera("pinhole(-eye 3 3 2 -lookat 0 0 0.3 
-up 0 0 1 -fov 60)")
-#defaultCamera = factory.createCamera("pinhole(-eye 8 -18 8.5 -lookat -4.7 
2.5 2.5 -up 0 0 1 -fov 15)")
-#defaultCamera = factory.createCamera("pinhole(-eye 8.3 -18 7 -lookat -4.7 
2.5 3 -up 0 0 1 -fov 15)")
-#defaultCamera = factory.createCamera("pinhole( -eye 8.06072 -17.7429 
8.73358 -lookat -4.98977 2.23422 2.74486 -up -0.0793095 0.0464671 0.995767 
-fov 15 )")
-defaultCamera = factory.createCamera("pinhole( -eye 7.92503 -16.4782 12.1826 
-lookat -4.42502 2.59203 2.7444 -up -0.216459 0.129008 0.967731 -fov 15 )")
+defaultCamera = factory.createCamera("pinhole(-normalizeRays)");
 
 addXInterface(engine, defaultCamera, 512, 512)
 #addNullInterface(engine, defaultCamera, 512, 512)
 #addFileInterface(engine, defaultCamera, 512, 512)
 
-# scene = createDefaultScene()
+#scene = createDefaultScene()
 #scene = createDefaultScenePython()
 #scene = createDielectricTestScene()
 #scene = createProg4TestScene()




  • [MANTA] r1355 - in trunk: Core/Math Interface Model/Groups Model/Materials Model/Textures SwigInterface, bigler, 04/24/2007

Archive powered by MHonArc 2.6.16.

Top of page