Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r703 - in branches/itanium2/Model: Materials Textures


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r703 - in branches/itanium2/Model: Materials Textures
  • Date: Tue, 8 Nov 2005 15:04:08 -0700 (MST)

Author: bigler
Date: Tue Nov  8 15:04:08 2005
New Revision: 703

Modified:
   branches/itanium2/Model/Materials/Phong.cc
   branches/itanium2/Model/Textures/ImageTexture.h
Log:

Model/Materials/Phong.cc

  You can now pass in a null pointer for the reflection texture.

Model/Textures/ImageTexture.h

  Added some comments.

  setScale now takes two scalar parameters instead of a vector.  I
  think this will be easier to use then trying to pack your parameters
  into a VectorT<T, 2>.

  Negative values are now properly handled for the
  NearestNeighbor/Wrap case.  It would crash previously.


Modified: branches/itanium2/Model/Materials/Phong.cc
==============================================================================
--- branches/itanium2/Model/Materials/Phong.cc  (original)
+++ branches/itanium2/Model/Materials/Phong.cc  Tue Nov  8 15:04:08 2005
@@ -31,10 +31,14 @@
     specpow(specpow)
 {
   do_refl=true;
-  const Constant<ColorComponent>* rtest =
-    dynamic_cast<const Constant<ColorComponent>*>(refltex);
-  if(rtest && rtest->getValue() == 0)
-    do_refl =false;
+  if (refltex) {
+    const Constant<ColorComponent>* rtest =
+      dynamic_cast<const Constant<ColorComponent>*>(refltex);
+    if(rtest && rtest->getValue() == 0)
+      do_refl =false;
+  } else {
+    do_refl = false;
+  }
 }
 
 Phong::~Phong()

Modified: branches/itanium2/Model/Textures/ImageTexture.h
==============================================================================
--- branches/itanium2/Model/Textures/ImageTexture.h     (original)
+++ branches/itanium2/Model/Textures/ImageTexture.h     Tue Nov  8 15:04:08 
2005
@@ -26,6 +26,23 @@
   DEALINGS IN THE SOFTWARE.
 */
 
+/*
+  Author: James Bigler
+  Date: Nov. 2005
+
+  This class is used for 2D texturing.  The constructor takes an Image
+  class and makes a copy of it while converting it to type Color.  No
+  sense in converting everytime you want to do lookups.
+
+  Some basic texturing parameters are supported.  Bilinear and nearest
+  neighbor interpolation methods can be selected after construction.
+  You can also select to wrap boundaries or clamp them.  You should
+  also be able to set these via a transaction as well.
+
+  With bilinear interpolation with wrapped boundaries will interpolate
+  across the edges.
+*/
+
 #ifndef Manta_Model_ImageTexture_h
 #define Manta_Model_ImageTexture_h
 
@@ -41,6 +58,11 @@
   class RenderContext;
   class Image;
 
+  // Whatever type ValueType ends up being, it needs to have
+  // ValueType::ScalarType defined.  I'm not sure what to do for
+  // things that aren't.  If the occasion arrises such that you need
+  // something else, then you should make this a double template on
+  // ScalarType.
   template< typename ValueType >
   class ImageTexture : public Texture< ValueType > {
   public:
@@ -51,13 +73,13 @@
                            RayPacket &rays,
                            ValueType results[] ) const;
 
-    template<class T>
-    void setScale(const VectorT<T, 2>& scale_in) {
+    template<class TU, class TV>
+    void setScale(const TU& u_scale, const TV& v_scale) {
       // We don't know if T will match ValueType::ScalarType, so we
       // need to copy the components over one at a time to do the
       // implicit cast.
-      scale[0] = scale_in[0];
-      scale[1] = scale_in[1];
+      scale[0] = static_cast<ScalarType>(u_scale);
+      scale[1] = static_cast<ScalarType>(v_scale);
     }
 
     enum {
@@ -135,7 +157,13 @@
       int result;
       switch (behavior) {
       case Wrap:
-        result = val % size;
+        if (val >= 0)
+          // result will be [0,size-1]
+          result = val % size;
+        else
+          // val%size -> [-(size-1),0]
+          // val%size+size-1 -> [0,size-1]
+          result = val%size + size-1;
         break;
       case Clamp:
         result = SCIRun::Clamp(val, 0, size-1);




  • [MANTA] r703 - in branches/itanium2/Model: Materials Textures, bigler, 11/08/2005

Archive powered by MHonArc 2.6.16.

Top of page