Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r764 - in trunk: Model/Primitives SwigInterface


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r764 - in trunk: Model/Primitives SwigInterface
  • Date: Sat, 10 Dec 2005 13:31:46 -0700 (MST)

Author: bigler
Date: Sat Dec 10 13:31:42 2005
New Revision: 764

Added:
   trunk/Model/Primitives/Plane.cc
   trunk/Model/Primitives/Plane.h
Modified:
   trunk/Model/Primitives/CMakeLists.txt
   trunk/SwigInterface/manta.i
   trunk/SwigInterface/runmanta.py
Log:

Model/Primitives/CMakeLists.txt
Model/Primitives/Plane.cc
Model/Primitives/Plane.h

  Added Plane class.

SwigInterface/manta.i

  Extern createDefaultScene in the Swig scope.  It wasn't needed
  before, but now it is.

  Added Plane class.

SwigInterface/runmanta.py

  Uncomment plane geometry.  Looking a little better now.


Modified: trunk/Model/Primitives/CMakeLists.txt
==============================================================================
--- trunk/Model/Primitives/CMakeLists.txt       (original)
+++ trunk/Model/Primitives/CMakeLists.txt       Sat Dec 10 13:31:42 2005
@@ -18,6 +18,8 @@
      Primitives/Parallelogram.h
      Primitives/ParticleBVH.cc
      Primitives/ParticleBVH.h
+     Primitives/Plane.cc
+     Primitives/Plane.h
      Primitives/PrimitiveCommon.cc
      Primitives/PrimitiveCommon.h
      Primitives/Sphere.cc

Added: trunk/Model/Primitives/Plane.cc
==============================================================================
--- (empty file)
+++ trunk/Model/Primitives/Plane.cc     Sat Dec 10 13:31:42 2005
@@ -0,0 +1,89 @@
+/*
+  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/Primitives/Plane.h>
+#include <Interface/RayPacket.h>
+#include <Core/Geometry/BBox.h>
+#include <Core/Math/MiscMath.h>
+#include <Core/Math/Trig.h>
+
+using namespace Manta;
+using namespace std;
+//using SCIRun::Clamp;
+
+Plane::Plane(Material* material, const Vector& normal, const Point& center):
+  PrimitiveCommon(material), normal(normal), center(center)
+{
+  this->normal.normalize();
+}
+
+Plane::~Plane()
+{
+}
+
+void
+Plane::computeBounds(const PreprocessContext& context,
+                     BBox& bbox) const
+{
+  // Since the plane is infinate, this doesn't make much sense.  I'm
+  // inclined to at least extend the bounding box by the center, so it
+  // would at least show up somehow.
+  bbox.extendByPoint(center);
+}
+
+void
+Plane::intersect(const RenderContext& context, RayPacket& rays) const
+{
+  // This is a simple first pass.  We should do different
+  // optimizations in the future.
+  rays.normalizeDirections();
+  for(int i = 0;i<rays.getSize();i++){
+    RayPacket::Element& e = rays.get(i);
+    Real dn = Dot( e.ray.direction(), normal );
+    if (dn != 0) {
+      // Ray isn't parallel to the plane.
+      Real ao = Dot( (center-e.ray.origin()), normal );
+      Real t = ao/dn;
+      e.hitInfo.hit(t, material, this, tex);
+    }
+  }
+}
+
+void
+Plane::computeNormal(const RenderContext& context, RayPacket& rays) const
+{
+  // We don't need to do anything except stuff the normal in the the
+  // RayPacket.
+  for(int i = 0;i<rays.getSize();i++){
+    RayPacket::Element& e = rays.get(i);
+    e.normal = normal;
+  }
+  rays.setFlag(RayPacket::HaveUnitNormals);
+}
+
+

Added: trunk/Model/Primitives/Plane.h
==============================================================================
--- (empty file)
+++ trunk/Model/Primitives/Plane.h      Sat Dec 10 13:31:42 2005
@@ -0,0 +1,51 @@
+/*
+  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.
+*/
+
+#ifndef Manta_Model_Plane_h
+#define Manta_Model_Plane_h
+
+#include <Model/Primitives/PrimitiveCommon.h>
+#include <Core/Geometry/PointVector.h>
+
+namespace Manta {
+  class Plane : public PrimitiveCommon {
+  public:
+    Plane(Material* material, const Vector& normal, const Point& center);
+    virtual ~Plane();
+
+    virtual void computeBounds(const PreprocessContext& context,
+                               BBox& bbox) const;
+    virtual void intersect(const RenderContext& context, RayPacket& rays) 
const;
+    virtual void computeNormal(const RenderContext& context, RayPacket& 
rays) const;
+  private:
+    Vector normal;
+    Point center;
+  };
+}
+
+#endif

Modified: trunk/SwigInterface/manta.i
==============================================================================
--- trunk/SwigInterface/manta.i (original)
+++ trunk/SwigInterface/manta.i Sat Dec 10 13:31:42 2005
@@ -88,6 +88,10 @@
 
 extern Manta::Scene* createDefaultScene();
 
+%{
+  extern Manta::Scene* createDefaultScene();
+%}
+
 %exception;
 
 /////////////////////////////////////////////////
@@ -206,6 +210,7 @@
 #include <Interface/TexCoordMapper.h>
 #include <Model/Primitives/Parallelogram.h>
 #include <Model/Primitives/Sphere.h>
+#include <Model/Primitives/Plane.h>
 #include <Model/TexCoordMappers/UniformMapper.h>
 %}
 
@@ -228,6 +233,7 @@
 %include <Interface/TexCoordMapper.h>
 %include <Model/Primitives/Parallelogram.h>
 %include <Model/Primitives/Sphere.h>
+%include <Model/Primitives/Plane.h>
 %include <Model/TexCoordMappers/UniformMapper.h>
 
 namespace Manta {

Modified: trunk/SwigInterface/runmanta.py
==============================================================================
--- trunk/SwigInterface/runmanta.py     (original)
+++ trunk/SwigInterface/runmanta.py     Sat Dec 10 13:31:42 2005
@@ -40,7 +40,7 @@
     scene.setBackground(manta_new(ConstantBackground(Color(RGBColor(0.5, 
0.8, 0.9)))))
     world = manta_new(Group())
     groundmatl = manta_new(Lambertian(Color(RGBColor(0.95, 0.65, 0.35))))
-#    world.add(manta_new(Plane(groundmatl, Vector(0,0,1), Point(0,0,2.5))))
+    world.add(manta_new(Plane(groundmatl, Vector(0,0,1), Point(0,0,2.5))))
 
     ball_matl = manta_new(MetalMaterial(Color(RGBColor(0.8, 0.8, 0.8)), 100))
     world.add(manta_new(Sphere(ball_matl, Point(-6, 3.5, 3.5), 1.0)))




  • [MANTA] r764 - in trunk: Model/Primitives SwigInterface, bigler, 12/10/2005

Archive powered by MHonArc 2.6.16.

Top of page