Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r765 - in trunk: Model/Materials Model/Primitives SwigInterface
- Date: Sun, 11 Dec 2005 22:41:59 -0700 (MST)
Author: bigler
Date: Sun Dec 11 22:41:56 2005
New Revision: 765
Modified:
trunk/Model/Materials/Dielectric.cc
trunk/Model/Primitives/CMakeLists.txt
trunk/Model/Primitives/Ring.cc
trunk/Model/Primitives/Ring.h
trunk/SwigInterface/example.i
trunk/SwigInterface/manta.i
trunk/SwigInterface/runmanta.py
Log:
Model/Materials/Dielectric.cc
You need to call useLocalColors after you determine the size of the
RayPacket, otherwise you will not actually do anything
(RayPacket::size == 0, means you don't set any pointers).
Model/Primitives/CMakeLists.txt
Added Ring to the source list.
Model/Primitives/Ring.cc
Model/Primitives/Ring.h
Hey, a functional implementation.
Added MIT license.
Removed inheritance from TexCoordMapper. If you want it, add it
back.
Renamed some variables:
cen -> center
n -> normal
d -> normal_dot_center
Store radius2 (radius*radius) and outer_radius2 (radius+thickness)^2
instead of radius and thickness. Since we weren't actually using
radius and thickness directly, but rather computing radius2 and
outer_radius2, I thought I would save us the trouble of computing
them.
SwigInterface/example.i
Externed variables need to be brought in the %{ %} scope.
SwigInterface/manta.i
Added Ring, Cube, and Dielectric classes.
I did some moving around to get rid of some SWIG warning about
ColorComponent not being known, but it didn't work. It doesn't
matter, I like the rearrangement better anyway.
SwigInterface/runmanta.py
Added dielectric boxes and lambertian rings.
Set the max depth to 2. Still looks funky. I'm guessing there are
more bugs in Dielectric.
Modified: trunk/Model/Materials/Dielectric.cc
==============================================================================
--- trunk/Model/Materials/Dielectric.cc (original)
+++ trunk/Model/Materials/Dielectric.cc Sun Dec 11 22:41:56 2005
@@ -84,10 +84,6 @@
RayPacket reflected_rays(reflected_data, 0, rays.getDepth()+1,
RayPacket::NormalizedDirections);
RayPacket refracted_rays(refracted_data, 0, rays.getDepth()+1,
RayPacket::NormalizedDirections);
- reflected_rays.useLocalColors();
- refracted_rays.useLocalColors();
-
-
Color refl_attenuation[RayPacket::MaxSize];
Color refr_attenuation[RayPacket::MaxSize];
@@ -169,9 +165,14 @@
}
}
- // fire them off
+ // Resize the packets.
reflected_rays.resize(num_refl);
refracted_rays.resize(num_refr);
+ // Use the local storage of the colors. We need to call this after
+ // we figure out the size of our ray packet.
+ reflected_rays.useLocalColors();
+ refracted_rays.useLocalColors();
+ // Trace the rays.
context.renderer->traceRays(context, reflected_rays);
context.renderer->traceRays(context, refracted_rays);
Modified: trunk/Model/Primitives/CMakeLists.txt
==============================================================================
--- trunk/Model/Primitives/CMakeLists.txt (original)
+++ trunk/Model/Primitives/CMakeLists.txt Sun Dec 11 22:41:56 2005
@@ -22,6 +22,8 @@
Primitives/Plane.h
Primitives/PrimitiveCommon.cc
Primitives/PrimitiveCommon.h
+ Primitives/Ring.cc
+ Primitives/Ring.h
Primitives/Sphere.cc
Primitives/Sphere.h
Primitives/SuperEllipsoid.cc
Modified: trunk/Model/Primitives/Ring.cc
==============================================================================
--- trunk/Model/Primitives/Ring.cc (original)
+++ trunk/Model/Primitives/Ring.cc Sun Dec 11 22:41:56 2005
@@ -1,16 +1,48 @@
-#include <Packages/manta/Model/Primitives/Ring.h>
-#include <Packages/manta/Interface/RayPacket.h>
+/*
+ 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/Ring.h>
+#include <Interface/RayPacket.h>
#include <Core/Geometry/BBox.h>
+#include <SCIRun/Core/Math/Expon.h>
using namespace Manta;
using namespace std;
-Ring::Ring(Material* mat, const Point& cen, const Vector& n, double radius,
- double thickness)
- : PrimitiveCommon(mat, this), cen(cen), n(n), radius(radius),
thickness(thickness)
+Ring::Ring(Material* material, const Point& center, const Vector& normal,
+ Real radius, Real thickness)
+ : PrimitiveCommon(material), center(center), normal(normal),
+ radius2(radius*radius)
{
- this->n.normalize();
- d=Dot(this->n, cen);
+ this->normal.normalize();
+ normal_dot_center = Dot(this->normal, center);
+ Real outer_radius = radius+thickness;
+ outer_radius2 = outer_radius * outer_radius;
}
Ring::~Ring()
@@ -19,27 +51,31 @@
void Ring::computeBounds(const PreprocessContext&, BBox& bbox) const
{
- bbox.extend_disc(cen, n, radius);
+ bbox.extendByDisc(center, normal, SCIRun::Sqrt(radius2));
}
void Ring::intersect(const RenderContext&, RayPacket& rays) const
{
- int nrays = rays.getSize();
- for(int i=0; i<nrays; i++)
+ rays.normalizeDirections();
+ for(int i=0; i<rays.getSize(); i++)
{
RayPacket::Element& e = rays.get(i);
Vector dir(e.ray.direction());
Point orig(e.ray.origin());
- double dt=Dot(dir, n);
- if(dt < 1.e-6 && dt > -1.e-6)
- return;
- double t=(d-Dot(n, orig))/dt;
- if(e.hitInfo.wasHit() && t>e.hitInfo.minT())
- return;
- Point p(orig+dir*t);
- double l=(p-cen).length2();
- double outer_radius=radius+thickness;
- if(l > radius*radius && l < outer_radius*outer_radius)
+ Real dt = Dot(dir, normal);
+// // Check for when the ray is parallel to the plane of the ring.
+// if(dt < 1.e-6 && dt > -1.e-6)
+// return;
+// // Compute the hit location on the plane and see if it would
+// // generate a hit.
+ Real t = (normal_dot_center-Dot(normal, orig))/dt;
+// if(e.hitInfo.wasHit() && t>e.hitInfo.minT())
+// return;
+ // Compute the location of the hit point and then see if the point
+ // is inside the ring extents.
+ Point hitPosition(orig+dir*t);
+ Real l = (hitPosition-center).length2();
+ if(l > radius2 && l < outer_radius2)
e.hitInfo.hit(t, material, this, tex);
}
}
@@ -47,10 +83,8 @@
void Ring::computeNormal(const RenderContext&, RayPacket& rays) const
{
- //rays.computeHitPositions();
- int nrays = rays.getSize();
- for(int i=0; i<nrays; i++) {
+ for(int i=0; i<rays.getSize(); i++) {
RayPacket::Element& e = rays.get(i);
- e.normal = n;
+ e.normal = normal;
}
}
Modified: trunk/Model/Primitives/Ring.h
==============================================================================
--- trunk/Model/Primitives/Ring.h (original)
+++ trunk/Model/Primitives/Ring.h Sun Dec 11 22:41:56 2005
@@ -1,30 +1,57 @@
+/*
+ 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_Ring_h
#define Manta_Model_Ring_h
-#include <Packages/manta/Model/Primitives/PrimitiveCommon.h>
-#include <Packages/manta/Interface/TexCoordMapper.h>
-#include <Core/Geometry/Point.h>
-#include <Core/Geometry/Vector.h>
+#include <Model/Primitives/PrimitiveCommon.h>
+#include <Core/Geometry/PointVector.h>
namespace Manta
{
- class Ring : public PrimitiveCommon, public TexCoordMapper {
+ class Ring : public PrimitiveCommon {
public:
- Ring(Material* mat, const Point& cen, const Vector& n, double radius,
- double thicknes);
+ Ring(Material* material, const Point& center, const Vector& normal,
+ Real radius, Real thicknes);
virtual ~Ring();
-
+
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;
-
+ virtual void intersect(const RenderContext& context,
+ RayPacket& rays) const ;
+ virtual void computeNormal(const RenderContext& context,
+ RayPacket &rays) const;
+
private:
- Point cen;
- Vector n;
- double d, radius, thickness;
+ Point center;
+ Vector normal;
+ Real normal_dot_center, radius2, outer_radius2;
};
}
Modified: trunk/SwigInterface/example.i
==============================================================================
--- trunk/SwigInterface/example.i (original)
+++ trunk/SwigInterface/example.i Sun Dec 11 22:41:56 2005
@@ -8,5 +8,12 @@
extern int fact(int n);
extern int my_mod(int x, int y);
extern char *get_time();
-
+
+%{
+ extern double My_variable;
+ extern int fact(int n);
+ extern int my_mod(int x, int y);
+ extern char *get_time();
+%}
+
Modified: trunk/SwigInterface/manta.i
==============================================================================
--- trunk/SwigInterface/manta.i (original)
+++ trunk/SwigInterface/manta.i Sun Dec 11 22:41:56 2005
@@ -197,21 +197,10 @@
#include <Interface/Background.h>
#include <Model/Backgrounds/ConstantBackground.h>
#include <Model/Lights/PointLight.h>
+
#include <Interface/Texture.h>
#include <Model/Textures/Constant.h>
#include <Model/Textures/CheckerTexture.h>
-#include <Interface/Material.h>
-#include <Model/Materials/LitMaterial.h>
-#include <Model/Materials/Phong.h>
-#include <Model/Materials/Lambertian.h>
-#include <Model/Materials/MetalMaterial.h>
-#include <Model/Groups/Group.h>
-#include <Model/Primitives/PrimitiveCommon.h>
-#include <Interface/TexCoordMapper.h>
-#include <Model/Primitives/Parallelogram.h>
-#include <Model/Primitives/Sphere.h>
-#include <Model/Primitives/Plane.h>
-#include <Model/TexCoordMappers/UniformMapper.h>
%}
%include <Interface/AmbientLight.h>
@@ -223,18 +212,6 @@
%include <Interface/Texture.h>
%include <Model/Textures/Constant.h>
%include <Model/Textures/CheckerTexture.h>
-%include <Interface/Material.h>
-%include <Model/Materials/LitMaterial.h>
-%include <Model/Materials/Phong.h>
-%include <Model/Materials/Lambertian.h>
-%include <Model/Materials/MetalMaterial.h>
-%include <Model/Groups/Group.h>
-%include <Model/Primitives/PrimitiveCommon.h>
-%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 {
// This tells SWIG to deallocate the memory from toString functions.
@@ -261,6 +238,42 @@
%template(CheckerTexture_ColorComponent)
CheckerTexture<Manta::ColorComponent>;
%template(Constant_Color) Constant<Color>;
}
+
+// Materials and Primitivs
+%{
+#include <Interface/Material.h>
+#include <Model/Materials/LitMaterial.h>
+#include <Model/Materials/Phong.h>
+#include <Model/Materials/Lambertian.h>
+#include <Model/Materials/MetalMaterial.h>
+#include <Model/Materials/Dielectric.h>
+#include <Model/Groups/Group.h>
+#include <Model/Primitives/PrimitiveCommon.h>
+#include <Interface/TexCoordMapper.h>
+#include <Model/Primitives/Parallelogram.h>
+#include <Model/Primitives/Sphere.h>
+#include <Model/Primitives/Plane.h>
+#include <Model/Primitives/Ring.h>
+#include <Model/Primitives/Cube.h>
+#include <Model/TexCoordMappers/UniformMapper.h>
+%}
+
+%include <Interface/Material.h>
+%include <Model/Materials/LitMaterial.h>
+%include <Model/Materials/Phong.h>
+%include <Model/Materials/Lambertian.h>
+%include <Model/Materials/MetalMaterial.h>
+%include <Model/Materials/Dielectric.h>
+%include <Model/Groups/Group.h>
+%include <Model/Primitives/PrimitiveCommon.h>
+%include <Interface/TexCoordMapper.h>
+%include <Model/Primitives/Parallelogram.h>
+%include <Model/Primitives/Sphere.h>
+%include <Model/Primitives/Plane.h>
+%include <Model/Primitives/Ring.h>
+%include <Model/Primitives/Cube.h>
+%include <Model/TexCoordMappers/UniformMapper.h>
+
%pythoncode %{
# This code is to do crazy stuff like
Modified: trunk/SwigInterface/runmanta.py
==============================================================================
--- trunk/SwigInterface/runmanta.py (original)
+++ trunk/SwigInterface/runmanta.py Sun Dec 11 22:41:56 2005
@@ -39,12 +39,35 @@
scene = manta_new(Scene())
scene.setBackground(manta_new(ConstantBackground(Color(RGBColor(0.5,
0.8, 0.9)))))
world = manta_new(Group())
+ # The gound plane
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))))
+ # Metal sphere
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)))
+ for i in range(4):
+ eta = 1 + i*0.5 + .05
+ transp_matl = manta_new(Dielectric(eta, 1, Color.black()))
+# transp_matl = manta_new(Lambertian(Color(RGBColor(0.3,0.1,0.1))))
+ corner = Point(i*1.3 - 4, -3, 2.5+1.e-4);
+ size = Vector(0.20, 2.5, 1.4);
+ world.add(manta_new(Cube(transp_matl, corner, corner+size)))
+
+ # Line of rings
+ ringmatl = manta_new(Lambertian(Color(RGBColor(.6, .6, .9))))
+ r = .30
+ inner_radius = r*0.5
+ center = Point(-6, 0, 2.5+r)
+ offset = Vector(2.25*r, 0, 0);
+ ring = Ring(ringmatl, center, Vector(0.2, -1, -0.2), 0.5, 1)
+ for i in range(9):
+ world.add(manta_new(Ring(ringmatl,
+ center+offset*i,
+ Vector(0.2, -1, -0.2),
+ inner_radius, r-inner_radius)))
+
scene.setObject(world)
lights = manta_new(LightSet())
@@ -54,7 +77,7 @@
print lights
scene.setLights(lights)
- scene.getRenderParameters().maxDepth = 25
+ scene.getRenderParameters().maxDepth = 2
scene.getRenderParameters().importanceCutoff = 0.01
return scene
- [MANTA] r765 - in trunk: Model/Materials Model/Primitives SwigInterface, bigler, 12/11/2005
Archive powered by MHonArc 2.6.16.