Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r689 - in branches/itanium2: Core/Geometry Model Model/Backgrounds Model/Groups StandAlone


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r689 - in branches/itanium2: Core/Geometry Model Model/Backgrounds Model/Groups StandAlone
  • Date: Wed, 2 Nov 2005 16:28:19 -0700 (MST)

Author: bigler
Date: Wed Nov  2 16:28:18 2005
New Revision: 689

Added:
   branches/itanium2/Model/Backgrounds/TextureBackground.cc
   branches/itanium2/Model/Backgrounds/TextureBackground.h
Modified:
   branches/itanium2/Core/Geometry/BBox.h
   branches/itanium2/Model/Backgrounds/CMakeLists.txt
   branches/itanium2/Model/CMakeLists.txt
   branches/itanium2/Model/Groups/VolumeGrid.h
   branches/itanium2/StandAlone/manta.cc
Log:

Core/Geometry/BBox.h

  Changed the implementation of center to not use subtraction.
  Because of the current set of operators defined (or not defined as
  it happens to be) the code looks a little unglier.

Model/Backgrounds/CMakeLists.txt
Model/Backgrounds/TextureBackground.cc
Model/Backgrounds/TextureBackground.h

  Added TextureBackground that uses a Texture class to color the
  background.

Model/CMakeLists.txt

  Goodbye tabs.

Model/Groups/VolumeGrid.h

  Disambiguate the parameters to SCIRun::Max by casting T_EPSILON to
  Real.

StandAlone/manta.cc

  Added 3 different uses of the TextureBackground class.  It defaults
  to using the old ConstantBackground class.


Modified: branches/itanium2/Core/Geometry/BBox.h
==============================================================================
--- branches/itanium2/Core/Geometry/BBox.h      (original)
+++ branches/itanium2/Core/Geometry/BBox.h      Wed Nov  2 16:28:18 2005
@@ -40,7 +40,14 @@
     }
     Point center() const {
       // return SCIRun::Interpolate(bounds[0], bounds[1], 
(Point::ScalarType)0.5);
-                       return 
Point(bounds[0]+Vector(bounds[1]-bounds[0])*0.5);
+
+      // The code used to be writen as b[0]+(b[1]-b[0])*0.5.  Using
+      // some algebra you can write this as (b[0]+b[1])*0.5.  You save
+      // having to do the subtraction which introduces additional
+      // inaccuracy and computation.
+      Point result(bounds[0]+Vector(bounds[1]));
+      result.multiplyBy((Point::ScalarType)0.5);
+      return result;
     }
 
                void extendByBox( const BBox &box ) {

Modified: branches/itanium2/Model/Backgrounds/CMakeLists.txt
==============================================================================
--- branches/itanium2/Model/Backgrounds/CMakeLists.txt  (original)
+++ branches/itanium2/Model/Backgrounds/CMakeLists.txt  Wed Nov  2 16:28:18 
2005
@@ -2,5 +2,5 @@
 SET (Manta_Backgrounds_SRCS
      Backgrounds/ConstantBackground.cc
      Backgrounds/LinearBackground.cc
-     
+     Backgrounds/TextureBackground.cc
      )

Added: branches/itanium2/Model/Backgrounds/TextureBackground.cc
==============================================================================
--- (empty file)
+++ branches/itanium2/Model/Backgrounds/TextureBackground.cc    Wed Nov  2 
16:28:18 2005
@@ -0,0 +1,117 @@
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005
+  Scientific Computing and Imaging Institue, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
+#include <Model/Backgrounds/TextureBackground.h>
+#include <Interface/RayPacket.h>
+#include <MantaTypes.h>
+#include <Core/Math/MiscMath.h>
+#include <Core/Math/Trig.h>
+
+using namespace Manta;
+using namespace SCIRun;
+
+TextureBackground::TextureBackground(const Texture<Color>* colortex,
+                                     const Vector& up)
+  : colortex(colortex), up(up.normal())
+{
+}
+
+TextureBackground::~TextureBackground()
+{
+}
+
+void TextureBackground::preprocess(const PreprocessContext&)
+{
+}
+
+// Globe mapping
+void TextureBackground::computeTexCoords2(const RenderContext&,
+                                          RayPacket& rays) const
+{
+  for(int i = 0;i<rays.getSize();i++){
+    RayPacket::Element& e = rays.get(i);
+    Vector n = e.ray.direction();
+    Real angle = Clamp(n.z(), (Real)-1, (Real)1);
+    Real theta = Acos(angle);
+    Real phi = Atan2(n.x(), n.y());
+    Real x = (phi+(Real)M_PI)*((Real)0.5*(Real)M_1_PI);
+    Real y = theta*(Real)M_1_PI;
+    e.texCoords = Point(x, y, 0);
+  }
+  rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
+}
+
+// Same code as computeTexCoords2
+void TextureBackground::computeTexCoords3(const RenderContext&,
+                                          RayPacket& rays) const
+{
+  for(int i = 0;i<rays.getSize();i++){
+    RayPacket::Element& e = rays.get(i);
+    Vector n = e.ray.direction();
+    Real angle = Clamp(n.z(), (Real)-1, (Real)1);
+    Real theta = Acos(angle);
+    Real phi = Atan2(n.x(), n.y());
+    Real x = (phi+(Real)M_PI)*((Real)0.5*(Real)M_1_PI);
+    Real y = theta*(Real)M_1_PI;
+    e.texCoords = Point(x, y, 0);
+  }
+  rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
+}
+
+void TextureBackground::shade(const RenderContext& context,
+                              RayPacket& rays) const
+{
+  // Create a dummy RayPacket
+  RayPacketData tdata;
+  RayPacket bg_rays(tdata, rays.getSize(), rays.getDepth(),
+                        RayPacket::NormalizedDirections);
+
+  rays.normalizeDirections();
+
+  // Copy the ray directions and set the TexCoordMapper pointer back
+  // to this class for each ray.
+  for(int i=0;i<rays.getSize();i++){
+    RayPacket::Element& source_e = rays.get(i);
+    RayPacket::Element& bg_e =  bg_rays.get(i);
+    // Set the TexCoordMapper pointer to this class.
+    bg_e.hitInfo.set_hit(0,0,0, this);
+    // Copy the direction from the old ray to the new one.
+    bg_e.ray.setDirection(source_e.ray.direction());
+  }
+
+  // Now get the colors from the texture.
+  Color bg_color[RayPacket::MaxSize];
+  colortex->mapValues(context, bg_rays, bg_color);
+
+  // Copy the colors over.
+  for(int i=0;i<rays.getSize();i++){
+    RayPacket::Element& e = rays.get(i);
+    rays.setResult(i, bg_color[i]);
+  }
+}
+

Added: branches/itanium2/Model/Backgrounds/TextureBackground.h
==============================================================================
--- (empty file)
+++ branches/itanium2/Model/Backgrounds/TextureBackground.h     Wed Nov  2 
16:28:18 2005
@@ -0,0 +1,67 @@
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005
+  Scientific Computing and Imaging Institue, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
+/*
+  This maps a texture onto an imaginary globe that surround the scene.
+ */
+
+#ifndef Manta_Model_TextureBackground_h
+#define Manta_Model_TextureBackground_h
+
+#include <Interface/Background.h>
+#include <Interface/TexCoordMapper.h>
+#include <Interface/Texture.h>
+#include <Core/Color/Color.h>
+#include <Core/Geometry/PointVector.h>
+
+namespace Manta {
+
+  class TextureBackground : public Background, public TexCoordMapper {
+  public:
+    TextureBackground(const Texture<Color>* colortex, const Vector& up);
+    virtual ~TextureBackground();
+
+    // Interface to Background
+    virtual void preprocess(const PreprocessContext& context);
+    virtual void shade(const RenderContext& context, RayPacket& rays) const;
+
+    // Interface to TexCoordMapper
+    virtual void computeTexCoords2(const RenderContext& context,
+                                  RayPacket& rays) const;
+    virtual void computeTexCoords3(const RenderContext& context,
+                                  RayPacket& rays) const;
+  private:
+    // This is the texture to be mapped
+    const Texture<Color>* colortex;
+    // This was intented to be used to change the orientation of the
+    // texture, but it isn't implemented yet.
+    Vector up;
+  };
+}
+
+#endif

Modified: branches/itanium2/Model/CMakeLists.txt
==============================================================================
--- branches/itanium2/Model/CMakeLists.txt      (original)
+++ branches/itanium2/Model/CMakeLists.txt      Wed Nov  2 16:28:18 2005
@@ -26,7 +26,7 @@
              ${Manta_Lights_SRCS}
              ${Manta_Materials_SRCS}
              ${Manta_Primitives_SRCS}
-                                    ${Manta_Primitives_Volume_SRCS}
+            ${Manta_Primitives_Volume_SRCS}
              ${Manta_TexCoordMappers_SRCS}
              ${Manta_Instances_SRCS}
              ${Manta_MiscObjects_SRCS}

Modified: branches/itanium2/Model/Groups/VolumeGrid.h
==============================================================================
--- branches/itanium2/Model/Groups/VolumeGrid.h (original)
+++ branches/itanium2/Model/Groups/VolumeGrid.h Wed Nov  2 16:28:18 2005
@@ -527,7 +527,7 @@
                                                                
e.inverseDirection )) {
 
                                                // Determine the actual 
minimum distance.
-                                               minDist = SCIRun::Max( 
minDist, T_EPSILON );
+                                               minDist = SCIRun::Max( 
minDist, (Real)T_EPSILON );
                                                maxDist = SCIRun::Min( 
maxDist, e.hitInfo.minT() );
 
                                                // March the ray through the 
volume

Modified: branches/itanium2/StandAlone/manta.cc
==============================================================================
--- branches/itanium2/StandAlone/manta.cc       (original)
+++ branches/itanium2/StandAlone/manta.cc       Wed Nov  2 16:28:18 2005
@@ -336,9 +336,11 @@
 #include <Interface/LightSet.h>
 #include <Model/AmbientLights/ConstantAmbient.h>
 #include <Model/Backgrounds/ConstantBackground.h>
+#include <Model/Backgrounds/TextureBackground.h>
 #include <Model/Lights/PointLight.h>
 #include <Model/Textures/Constant.h>
 #include <Model/Textures/CheckerTexture.h>
+#include <Model/Textures/MarbleTexture.h>
 #include <Model/Materials/Phong.h>
 #include <Model/Materials/Flat.h>
 #include <Model/Groups/Group.h>
@@ -351,7 +353,28 @@
   // Create a default scene.  This scene is used for benchmarks, so
   // please do not change it.  Please create a new scene instead
   Scene* scene = new Scene();
+
+  // Set only one of these #ifs to 1.
+#if 1
   scene->setBackground(new 
ConstantBackground(ColorDB::getNamedColor("SkyBlue3")*0.5));
+#elif 0
+  scene->setBackground(new TextureBackground(new 
Constant<Color>(Color(RGBColor(.2,1,1))), Vector(0,1,0)));
+#elif 0
+   scene->setBackground(new TextureBackground
+                        (new MarbleTexture<Color>(Color(RGB(0.1,0.2,0.5)),
+                                                  Color(RGB(0.7,0.8,1.0)),
+                                                  10.0, 1.0, 15.0,
+                                                  6, 2.0, 0.6 ),
+                         Vector(0,1,0)));
+#elif 0
+   scene->setBackground(new TextureBackground
+                        (new CheckerTexture<Color>(Color(RGBColor(1,0,0)),
+                                                   Color(RGBColor(0,0,1)),
+                                                   Vector(10,0,0),
+                                                   Vector(0,10,0)),
+                         Vector(0,1,0)));
+#endif
+
   Material* red=new Phong(Color(RGBColor(.6,0,0)),
                           Color(RGBColor(.6,.6,.6)), 32, 
(ColorComponent)0.4);
        




  • [MANTA] r689 - in branches/itanium2: Core/Geometry Model Model/Backgrounds Model/Groups StandAlone, bigler, 11/02/2005

Archive powered by MHonArc 2.6.16.

Top of page