Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r351 - in branches/itanium2: Core/Geometry Model/Groups Model/Materials scenes
- Date: Thu, 26 May 2005 15:34:20 -0600 (MDT)
Author: abe
Date: Thu May 26 15:34:19 2005
New Revision: 351
Modified:
branches/itanium2/Core/Geometry/PointVector.h
branches/itanium2/Model/Groups/kdtree.cc
branches/itanium2/Model/Materials/LambertianAlt.cc
branches/itanium2/scenes/boeing777.cc
Log:
Got one data set working on mac moving to altix
Modified: branches/itanium2/Core/Geometry/PointVector.h
==============================================================================
--- branches/itanium2/Core/Geometry/PointVector.h (original)
+++ branches/itanium2/Core/Geometry/PointVector.h Thu May 26 15:34:19
2005
@@ -61,6 +61,9 @@
T &operator[] ( int i ) {
return data[i];
}
+
+ const T *operator &() const { return data; }
+
VectorT<T, Dim> operator+(const VectorT<T, Dim>& v) const {
VectorT<T, Dim> result;
for(int i=0;i<Dim;i++)
@@ -268,6 +271,8 @@
T &operator[](int i) {
return data[i];
}
+
+ const T *operator& () const { return data; };
VectorT<T, Dim> operator-(const PointT<T, Dim>& p) const {
VectorT<T, Dim> result;
Modified: branches/itanium2/Model/Groups/kdtree.cc
==============================================================================
--- branches/itanium2/Model/Groups/kdtree.cc (original)
+++ branches/itanium2/Model/Groups/kdtree.cc Thu May 26 15:34:19 2005
@@ -13,15 +13,19 @@
using std::cerr;
using std::endl;
-#if 0
+
// From Tomas Akenine-Mˆller's code, included below in this file.
-int intersect_triangle3_edge(const float orig[3],
+int intersect_triangle3(const float orig[3],
+
const float dir[3],
+
const float vert0[3], const float
vert1[3], const float vert2[3],
+
float *t, float *u, float *v );
+
+int intersect_triangle3_edge( const float orig[3],
const float dir[3],
const float vert0[3], const float
vert1[3], const float vert2[3],
float *t, float *u, float *v,
-
float *edge1, float *edge2);
+
const float *edge1, const float *edge2);
-#endif
inline int intersectTriangle3Edge(const Ray &ray, const Triangle &tri,
float &t, float &u,
float &v );
@@ -48,23 +52,17 @@
char line_buffer[128];
// Read in the file.
- while (! feof(f)) {
+ while (fgets( line_buffer, 127, f ) != NULL) {
// Read in a triangle.
Triangle tri;
- // bool error=false;
- // char colorString[32];
- // unsigned int color;
-
- // Read in the current line.
- fgets( line_buffer, 127, f );
// Parse the triangle description from the file.
int num_parsed = sscanf( line_buffer,
"%f %f %f %f %f %f %f %f %f 0x%X",
- &tri[0][1],
&tri[0][1], &tri[0][2],
- &tri[1][1],
&tri[1][1], &tri[1][2],
- &tri[2][1],
&tri[2][1], &tri[2][2],
+ &tri[0][0],
&tri[0][1], &tri[0][2],
+ &tri[1][0],
&tri[1][1], &tri[1][2],
+ &tri[2][0],
&tri[2][1], &tri[2][2],
&tri.payload
);
if (num_parsed != 10) {
cerr << "Only parsed " << num_parsed << " components
for line "
@@ -253,7 +251,17 @@
Triangle &tri = tris->get(triIdx);
float t, u, v;
- if (intersectTriangle3Edge( *ray, tri, t, u, v )) {
+ // if (intersectTriangle3Edge( *ray, tri, t, u, v )) {
+
+ Vectorf direction = ray->direction();
+ Pointf origin = ray->origin();
+
+ if(intersect_triangle3(
+ &origin, &direction,
+ &tri[0], &tri[1], &tri[2],
+ &t, &u, &v/*,
+ &tri.edge1, &tri.edge2*/)) {
+
if (t < maxDist) {
maxDist = t;
nearest_u= u;
@@ -286,6 +294,8 @@
///////////////////////////////////////////////////////////////////////////////
void KDTree::intersect(const RenderContext& context, RayPacket& rays) const
{
+
+ rays.normalizeDirections();
rays.computeInverseDirections();
RayTriIntersectUserData isectData;
@@ -293,24 +303,24 @@
for(int i=0;i<rays.getSize();i++) {
RayPacket::Element& e = rays.get(i);
- Real minDist=0, maxDist=0;
-
+ Real minDist, maxDist;
+
// Intersect the ray with the bounding box for the group.
if (Intersection::intersectAaBox( bbox,
-
minDist,
maxDist, e.ray,
+
minDist,
maxDist,
+
e.ray,
e.signMask,
e.inverseDirection )) {
- e.hitInfo.hit(minDist,lambMat,this,0);
// Send the ray to the _intersect function.
- isectData.rayHitTriIndex = 0;
+ isectData.rayHitTriIndex = -1;
_intersect( &e.ray, e, &isectData, (float)minDist,
(float)maxDist);
// Check to see if the ray hit any triangles.
if (isectData.rayHitTriIndex >= 0) {
- // e.normal =
normals[isectData.rayHitTriIndex*3]; // Is this safe??? What if the hit()
function fails?
+ e.normal =
normals[isectData.rayHitTriIndex*3]; // Is this safe??? What if the hit()
function fails?
// Check against the hit record, Note that
tex coord mapper is null.
if (e.hitInfo.hit(isectData.rayHit.t,
lambMat, this, 0 )) {
@@ -319,6 +329,24 @@
}
}
}
+#if 0
+
+ // Send the ray to the _intersect function.
+ isectData.rayHitTriIndex = -1;
+ _intersect( &e.ray, e, &isectData, 0,
numeric_limits<float>::max());
+
+ // Check to see if the ray hit any triangles.
+ if (isectData.rayHitTriIndex >= 0) {
+
+ e.normal = normals[isectData.rayHitTriIndex*3]; // Is
this safe??? What if the hit() function fails?
+
+ // Check against the hit record, Note that tex coord
mapper is null.
+ if (e.hitInfo.hit(isectData.rayHit.t, lambMat, this,
0 )) {
+ e.hitInfo.scratchpad<ScratchPadInfo>().normal
= normals[isectData.rayHitTriIndex*3];
+
e.hitInfo.scratchpad<ScratchPadInfo>().payload =
tris->get(isectData.rayHitTriIndex).payload;
+ }
+ }
+#endif
}
}
@@ -437,10 +465,10 @@
/* suggestions and discussions on how to optimize code. */
/* Thanks to David Hunt for finding a ">="-bug! */
/********************************************************/
-#if 0
-#include <math.h>
-#include <stdio.h>
+
+// #include <math.h>
+// #include <stdio.h>
#define EPSILON 0.000001
@@ -453,6 +481,7 @@
(dest)[0]=(v1)[0]-(v2)[0]; \
(dest)[1]=(v1)[1]-(v2)[1]; \
(dest)[2]=(v1)[2]-(v2)[2];
+#if 0
/* the original jgt code */
inline int intersect_triangle(const float orig[3], const float dir[3],
@@ -634,6 +663,8 @@
return 1;
}
+#endif
+
/* code rewritten to do tests on the sign of the determinant */
/* the division is before the test of the sign of the det */
/* and one CROSS has been moved out from the if-else if-else */
@@ -697,8 +728,7 @@
inline int intersect_triangle3_edge(const float orig[3], const float dir[3],
const float
vert0[3], const float vert1[3], const float vert2[3],
-
float *t,
float *u, float *v,
-
float
*edge1, float *edge2)
+
float *t,
float *u, float *v, const float *edge1, const float *edge2 )
{
// float edge1[3], edge2[3];
float tvec[3], pvec[3], qvec[3];
@@ -753,7 +783,6 @@
return 1;
}
-#endif
inline int intersectTriangle3Edge(const Ray &ray, const Triangle &tri,
float &t, float &u,
float &v )
Modified: branches/itanium2/Model/Materials/LambertianAlt.cc
==============================================================================
--- branches/itanium2/Model/Materials/LambertianAlt.cc (original)
+++ branches/itanium2/Model/Materials/LambertianAlt.cc Thu May 26 15:34:19
2005
@@ -15,11 +15,10 @@
void LambertianAlt::shade(const RenderContext& context, RayPacket& rays)
const {
- for (int i=0;i<rays.getSize();++i) {
- rays.setResult(i,Color(RGBColor(1.0,0.0,0.0)));
- }
+ // for (int i=0;i<rays.getSize();++i) {
+ // rays.setResult(i,Color(RGBColor(1.0,0.0,0.0)));
+ // }
-#if 0
// Shade a bunch of rays. We know that they all have the same intersected
// object and are all of the same material
@@ -88,5 +87,4 @@
}
start = end;
} while(start < rays.getSize());
-#endif
}
Modified: branches/itanium2/scenes/boeing777.cc
==============================================================================
--- branches/itanium2/scenes/boeing777.cc (original)
+++ branches/itanium2/scenes/boeing777.cc Thu May 26 15:34:19 2005
@@ -71,7 +71,7 @@
// Set other important scene properties.
// Background.
- scene->setBackground( new ConstantBackground(Color(RGB(1.0, 1.0, 1.0))) );
+ scene->setBackground( new ConstantBackground(Color(RGB(0.8, 0.8, 0.8))) );
return scene;
}
- [MANTA] r351 - in branches/itanium2: Core/Geometry Model/Groups Model/Materials scenes, abe, 05/26/2005
Archive powered by MHonArc 2.6.16.