Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r708 - in branches/itanium2: Model/Groups StandAlone fox
- Date: Mon, 14 Nov 2005 12:19:58 -0700 (MST)
Author: abe
Date: Mon Nov 14 12:19:56 2005
New Revision: 708
Added:
branches/itanium2/StandAlone/manta_scaling_plot.pl
Modified:
branches/itanium2/Model/Groups/KDTree.cc
branches/itanium2/Model/Groups/TransparentKDTree.cc
branches/itanium2/Model/Groups/TransparentKDTree.h
branches/itanium2/fox/FMantaRecorder.cc
branches/itanium2/fox/FMantaWindow.cc
Log:
Sanity commit from the show floor.
Several UI changes, added group name functions to kdtrees
A StandAlone/manta_scaling_plot.pl
M fox/FMantaRecorder.cc
M fox/FMantaWindow.cc
M Model/Groups/TransparentKDTree.cc
M Model/Groups/TransparentKDTree.h
M Model/Groups/KDTree.cc
Modified: branches/itanium2/Model/Groups/KDTree.cc
==============================================================================
--- branches/itanium2/Model/Groups/KDTree.cc (original)
+++ branches/itanium2/Model/Groups/KDTree.cc Mon Nov 14 12:19:56 2005
@@ -1,32 +1,32 @@
/*
- For more information, please see:
http://software.sci.utah.edu
+ For more information, please see:
http://software.sci.utah.edu
- The MIT License
+ The MIT License
- Copyright (c) 2005
- Silicon Graphics Inc. Mountain View California.
+ Copyright (c) 2005
+ Silicon Graphics Inc. Mountain View California.
- 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:
+ 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 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.
- */
+ 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 <iostream>
@@ -92,29 +92,29 @@
const RenderContext& /*context*/,
RayTriangleMailbox &mailbox ) const
{
- int i;
- RayTriIntersectUserData *ud = (RayTriIntersectUserData*)userData;
+ int i;
+ RayTriIntersectUserData *ud = (RayTriIntersectUserData*)userData;
float nearest_u, nearest_v;
- int nearest_tri = -1;
+ int nearest_tri = -1;
- Vectorf direction = ray->direction();
- Pointf origin = ray->origin();
+ Vectorf direction = ray->direction();
+ Pointf origin = ray->origin();
- // Intersect the ray with all the triangles.
- int listEnd = listBegin+listSize;
+ // Intersect the ray with all the triangles.
+ int listEnd = listBegin+listSize;
// if (listSize < 40)
// ud->duplicate = 4;
- #pragma swp
- for (i = listBegin; i < listEnd; i++) {
- int triIdx = triIndices->get(i);
- Triangle &tri = tris->get(triIdx);
- float t, u, v;
+#pragma swp
+ for (i = listBegin; i < listEnd; i++) {
+ int triIdx = triIndices->get(i);
+ Triangle &tri = tris->get(triIdx);
+ float t, u, v;
#if SHOW_DUPLICATES
//if (!mailbox.only_check( ray, triIdx )) {
- // global_counter++;
+ // global_counter++;
//ud->duplicate++;
//}
#endif
@@ -126,28 +126,28 @@
if(/*mailbox.not_mapped( ray, triIdx ) &&*/ intersect_triangle3_edge(
&origin, &direction, &tri[0], &t, &u, &v, &tri.edge1, &tri.edge2 )) {
- // Check to see if the t value is closer.
- if (t < maxDist) {
- maxDist = t;
- nearest_u = u;
- nearest_v = v;
- nearest_tri = triIdx;
- }
+ // Check to see if the t value is closer.
+ if (t < maxDist) {
+ maxDist = t;
+ nearest_u = u;
+ nearest_v = v;
+ nearest_tri = triIdx;
+ }
}
}
- }
+ }
- if (nearest_tri >= 0) {
- ud->rayHit.t = maxDist;
- ud->rayHit.u = nearest_u;
- ud->rayHit.v = nearest_v;
- ud->rayHitTriIndex = nearest_tri;
- return 1;
-
- } else {
- return 0;
- }
+ if (nearest_tri >= 0) {
+ ud->rayHit.t = maxDist;
+ ud->rayHit.u = nearest_u;
+ ud->rayHit.v = nearest_v;
+ ud->rayHitTriIndex = nearest_tri;
+ return 1;
+
+ } else {
+ return 0;
+ }
}
///////////////////////////////////////////////////////////////////////////////
@@ -158,36 +158,36 @@
void KDTree::intersect(const RenderContext& context, RayPacket& rays) const
{
- // Normalize and compute inverse directions,
- // As a side effect this also computes the sign mask for the box
intersection.
+ // Normalize and compute inverse directions,
+ // As a side effect this also computes the sign mask for the box
intersection.
rays.normalizeDirections();
- rays.computeInverseDirections();
+ rays.computeInverseDirections();
- RayTriIntersectUserData isectData;
+ RayTriIntersectUserData isectData;
- for(int i=0;i<rays.getSize();i++) {
+ for(int i=0;i<rays.getSize();i++) {
- RayPacket::Element& e = rays.get(i);
- Real minDist, maxDist;
+ RayPacket::Element& e = rays.get(i);
+ Real minDist, maxDist;
- // Intersect the ray with the bounding box for the group.
- if (Intersection::intersectAaBox( bbox,
-
minDist, maxDist,
-
e.ray,
-
e.signMask,
-
e.inverseDirection )) {
+ // Intersect the ray with the bounding box for the group.
+ if (Intersection::intersectAaBox( bbox,
+ minDist, maxDist,
+ e.ray,
+ e.signMask,
+ e.inverseDirection )) {
- // Determine the actual minimum distance.
- minDist = SCIRun::Max( minDist, (Real)T_EPSILON );
- maxDist = SCIRun::Min( maxDist, e.hitInfo.minT() );
+ // Determine the actual minimum distance.
+ minDist = SCIRun::Max( minDist, (Real)T_EPSILON );
+ maxDist = SCIRun::Min( maxDist, e.hitInfo.minT() );
- // Send the ray to the _intersect function.
- isectData.rayHitTriIndex = -1;
+ // Send the ray to the _intersect function.
+ isectData.rayHitTriIndex = -1;
isectData.duplicate = 0;
- intersect_node( rootNode, &e.ray, e, isectData,
context, (float)minDist, (float)maxDist);
+ intersect_node( rootNode, &e.ray, e, isectData, context,
(float)minDist, (float)maxDist);
- }
- }
+ }
+ }
}
///////////////////////////////////////////////////////////////////////////////
@@ -196,10 +196,10 @@
void KDTree::computeNormal(const RenderContext& /*context*/,
RayPacket& rays) const {
- // Copy the normal out of the KDTree::ScratchPadInfo structure.
- for (int i=0;i<rays.getSize();++i) {
- rays.get(i).normal =
rays.get(i).hitInfo.scratchpad<ScratchPadInfo>().normal;
- }
+ // Copy the normal out of the KDTree::ScratchPadInfo structure.
+ for (int i=0;i<rays.getSize();++i) {
+ rays.get(i).normal =
rays.get(i).hitInfo.scratchpad<ScratchPadInfo>().normal;
+ }
}
///////////////////////////////////////////////////////////////////////////////
@@ -210,142 +210,142 @@
// Traversal Stack Entry.
struct TravStackEntry {
- KDTreeNode* node; // 8 bytes
- float t; // 4 bytes
- int prev; // 4 bytes
+ KDTreeNode* node; // 8 bytes
+ float t; // 4 bytes
+ int prev; // 4 bytes
};
void KDTree::intersect_node( KDTreeNode *startNode,
const Ray* ray, RayPacket::Element &e,
RayTriIntersectUserData &isectData,
const RenderContext &context,
-
float minDist, float maxDist) const
+ float minDist, float maxDist) const
{
// Mailbox for this traversal.
RayTriangleMailbox mailbox;
mailbox.clear();
- KDTreeNode *nearNode, *farNode;
- float split;
- int axis, entryPos, exitPos;
- int tmp;
+ KDTreeNode *nearNode, *farNode;
+ float split;
+ int axis, entryPos, exitPos;
+ int tmp;
Pointf origin = ray->origin();
Vectorf direction = ray->direction();
// Keep a stack of entry and exit positions into the traversal nodes.
#ifdef __ia64__
- __declspec(align(128))
+ __declspec(align(128))
#endif
TravStackEntry travStack[128];
- // Initialize the first two entries on the stack.
- entryPos = 0;
- nearNode = startNode;
- travStack[0].node = startNode;
- travStack[0].prev = 1;
-
- // Check for the case that the minimum intersection point is behind
the origin.
- travStack[entryPos].t = minDist < 0.0f ? 0.0f : minDist;
-
- exitPos = 1;
- travStack[1].node = NULL;
- travStack[1].t = maxDist;
- travStack[1].prev = 0;
-
- while (travStack[entryPos].prev) {
-
- // Traverse down until we find a leaf node.
- #pragma swp
- while (nearNode && nearNode->isInternal()) {
+ // Initialize the first two entries on the stack.
+ entryPos = 0;
+ nearNode = startNode;
+ travStack[0].node = startNode;
+ travStack[0].prev = 1;
+
+ // Check for the case that the minimum intersection point is behind the
origin.
+ travStack[entryPos].t = minDist < 0.0f ? 0.0f : minDist;
+
+ exitPos = 1;
+ travStack[1].node = NULL;
+ travStack[1].t = maxDist;
+ travStack[1].prev = 0;
+
+ while (travStack[entryPos].prev) {
+
+ // Traverse down until we find a leaf node.
+#pragma swp
+ while (nearNode && nearNode->isInternal()) {
- // Determine the axis and the split point.
- axis = nearNode->axis();
- split = nearNode->split();
+ // Determine the axis and the split point.
+ axis = nearNode->axis();
+ split = nearNode->split();
- // Find where along the axis the ray enters and
exits.
- float entryPos_coord_on_axis =
-
travStack[entryPos].t*direction[axis] + origin[axis];
+ // Find where along the axis the ray enters and exits.
+ float entryPos_coord_on_axis =
+ travStack[entryPos].t*direction[axis] + origin[axis];
- float exitPos_coord_on_axis =
-
travStack[exitPos].t*direction[axis] + origin[axis];
+ float exitPos_coord_on_axis =
+ travStack[exitPos].t*direction[axis] + origin[axis];
- // Check to see which side of the split the ray
enters first.
- if (entryPos_coord_on_axis <= split) {
+ // Check to see which side of the split the ray enters first.
+ if (entryPos_coord_on_axis <= split) {
- // Check to see if entry and exit are on the
- // same side of the split.
- if (exitPos_coord_on_axis <= split) {
-
- // Same side of the split, so the
original interval is ok.
- nearNode = nearNode->left();
- continue;
- }
+ // Check to see if entry and exit are on the
+ // same side of the split.
+ if (exitPos_coord_on_axis <= split) {
+
+ // Same side of the split, so the original interval is ok.
+ nearNode = nearNode->left();
+ continue;
+ }
- // Otherwise update the near and far nodes,
and then update
- // the interval below.
- farNode = nearNode->right();
- nearNode = nearNode->left();
- }
- else {
- // Check to see if entry and exit are on the
same side.
- if (exitPos_coord_on_axis >= split) {
- nearNode = nearNode->right();
- continue;
- }
+ // Otherwise update the near and far nodes, and then update
+ // the interval below.
+ farNode = nearNode->right();
+ nearNode = nearNode->left();
+ }
+ else {
+ // Check to see if entry and exit are on the same side.
+ if (exitPos_coord_on_axis >= split) {
+ nearNode = nearNode->right();
+ continue;
+ }
- // Update otherwise.
- farNode = nearNode->left();
- nearNode = nearNode->right();
- }
+ // Update otherwise.
+ farNode = nearNode->left();
+ nearNode = nearNode->right();
+ }
- // Update location on the traversal stack.
- tmp = exitPos;
+ // Update location on the traversal stack.
+ tmp = exitPos;
- // ??? Increment to an unused node ???
- if (++exitPos == entryPos) ++exitPos;
+ // ??? Increment to an unused node ???
+ if (++exitPos == entryPos) ++exitPos;
- // Update the far node.
- // Specify a new exit node.
- travStack[exitPos].node = farNode;
- travStack[exitPos].t = (split - origin[axis])*
e.inverseDirection[axis];
- travStack[exitPos].prev = tmp;
- }
+ // Update the far node.
+ // Specify a new exit node.
+ travStack[exitPos].node = farNode;
+ travStack[exitPos].t = (split - origin[axis])*
e.inverseDirection[axis];
+ travStack[exitPos].prev = tmp;
+ }
- // Check to see if we found a non-empty leaf node.
- if (nearNode) {
+ // Check to see if we found a non-empty leaf node.
+ if (nearNode) {
- // Intersect the ray with a list of triangles.
- if (/*(nearNode->listSize() < 100) &&*/
+ // Intersect the ray with a list of triangles.
+ if (
intersectTriangles(ray, nearNode->listBegin(),
nearNode->listSize(),
/*travStack[exitPos].t,*/ e.hitInfo.minT(),
&isectData,
context, mailbox ) &&
- (isectData.rayHitTriIndex >= 0)) {
+ (isectData.rayHitTriIndex >= 0)) {
- if (isPickingEnabled()) {
- pickedTri =
isectData.rayHitTriIndex;
- cerr << "picked " <<
pickedTri << "\n";
- pickedBeginIndex =
pickedEndIndex = pickedTri;
- while (pickedBeginIndex > 0 &&
-
triToGroupMap->get(pickedBeginIndex-1)
- ==
triToGroupMap->get(pickedBeginIndex))
- pickedBeginIndex --;
- while (pickedEndIndex <
tris->getLen()-1 &&
-
triToGroupMap->get(pickedEndIndex+1)
- ==
triToGroupMap->get(pickedEndIndex))
- pickedEndIndex ++;
- cerr << "picked begin " <<
pickedBeginIndex << " end " << pickedEndIndex << "\n";
-
- cerr << "picked flag: " <<
(int)pickedFlag << std::endl;
- for (int i=pickedBeginIndex;
i<=pickedEndIndex; i++)
- triFlags->set(i,
pickedFlag);
- }
+ if (isPickingEnabled()) {
+ pickedTri = isectData.rayHitTriIndex;
+ // cerr << "picked " << pickedTri << "\n";
+ pickedBeginIndex = pickedEndIndex = pickedTri;
+ while (pickedBeginIndex > 0 &&
+ triToGroupMap->get(pickedBeginIndex-1)
+ == triToGroupMap->get(pickedBeginIndex))
+ pickedBeginIndex --;
+ while (pickedEndIndex < tris->getLen()-1 &&
+ triToGroupMap->get(pickedEndIndex+1)
+ == triToGroupMap->get(pickedEndIndex))
+ pickedEndIndex ++;
+ // cerr << "picked begin " << pickedBeginIndex << " end " <<
pickedEndIndex << "\n";
+
+ // cerr << "picked flag: " << (int)pickedFlag << std::endl;
+ for (int i=pickedBeginIndex; i<=pickedEndIndex; i++)
+ triFlags->set(i, pickedFlag);
+ }
- // Check against the hit record, Note that
tex coord mapper is null.
+ // Check against the hit record, Note that tex coord mapper is null.
if (e.hitInfo.hit(isectData.rayHit.t, material, this, 0 )) {
// if (isectData.rayHit.t > t_epsilon) {
@@ -377,30 +377,30 @@
else
e.hitInfo.scratchpad<ScratchPadInfo>().payload =
Color(RGB(0.0,0.0,1.0));
#else
- unsigned char flag;
- if ( pickedTri > 0 &&
- /*pickedBeginIndex <=
isectData.rayHitTriIndex &&
- isectData.rayHitTriIndex <= pickedEndIndex*/
-
(flag=triFlags->get(isectData.rayHitTriIndex))!=0)
- {
- switch(flag) {
- case PICK_HIGHLIGHT:
-
e.hitInfo.scratchpad<ScratchPadInfo>().payload = Color(RGB(1,1,1))-
-
tris->get(isectData.rayHitTriIndex).payload;
- break;
- case PICK_REMOVE:
-
e.hitInfo.scratchpad<ScratchPadInfo>().payload = Color(RGB(0,0,0));
- break;
- }
- } else
- e.hitInfo.scratchpad<ScratchPadInfo>().payload =
tris->get(isectData.rayHitTriIndex).payload;
+ unsigned char flag;
+ if ( pickedTri > 0 &&
+ /*pickedBeginIndex <= isectData.rayHitTriIndex &&
+ isectData.rayHitTriIndex <= pickedEndIndex*/
+ (flag=triFlags->get(isectData.rayHitTriIndex))!=0)
+ {
+ switch(flag) {
+ case PICK_HIGHLIGHT:
+ e.hitInfo.scratchpad<ScratchPadInfo>().payload =
Color(RGB(1,1,1))-
+ tris->get(isectData.rayHitTriIndex).payload;
+ break;
+ case PICK_REMOVE:
+ e.hitInfo.scratchpad<ScratchPadInfo>().payload =
Color(RGB(0,0,0));
+ break;
+ }
+ } else
+ e.hitInfo.scratchpad<ScratchPadInfo>().payload =
tris->get(isectData.rayHitTriIndex).payload;
#endif
// Check to make sure the found hit is inside the current cell.
// if ((isectData.rayHit.t <= travStack[exitPos].t)/* &&
(isectData.rayHit.t > travStack[entryPos].t)*/)
// break;
- }
- }
- }
+ }
+ }
+ }
// Check to see if the hit is inside the current cell.
if (e.hitInfo.minT() <= travStack[exitPos].t)
@@ -408,11 +408,11 @@
- // Move to the next
- entryPos = exitPos;
- exitPos = travStack[exitPos].prev;
- nearNode = travStack[entryPos].node;
- }
+ // Move to the next
+ entryPos = exitPos;
+ exitPos = travStack[exitPos].prev;
+ nearNode = travStack[entryPos].node;
+ }
}
///////////////////////////////////////////////////////////////////////////////
@@ -455,185 +455,185 @@
/* 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 */
inline 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)
+ const float vert0[3], const float vert1[3],
const float vert2[3],
+ float *t, float *u, float *v)
{
- float edge1[3], edge2[3];
- float tvec[3], pvec[3], qvec[3];
- float det,inv_det;
-
- /* find vectors for two edges sharing vert0 */
- SUB(edge1, vert1, vert0);
- SUB(edge2, vert2, vert0);
-
- /* begin calculating determinant - also used to calculate U parameter
*/
- CROSS(pvec, dir, edge2);
-
- /* if determinant is near zero, ray lies in plane of triangle */
- det = DOT(edge1, pvec);
-
- /* calculate distance from vert0 to ray origin */
- SUB(tvec, orig, vert0);
- inv_det = 1.0f/ det;
-
- CROSS(qvec, tvec, edge1);
-
- /* calculate U parameter */
- float uu = DOT(tvec, pvec);
- float vv;
-
- if (det > EPSILON)
- {
- if (uu < 0.0f || uu > det)
- return 0;
-
- /* calculate V parameter and test bounds */
- vv = DOT(dir, qvec);
- if (vv < 0.0f || uu + vv > det)
- return 0;
+ float edge1[3], edge2[3];
+ float tvec[3], pvec[3], qvec[3];
+ float det,inv_det;
+
+ /* find vectors for two edges sharing vert0 */
+ SUB(edge1, vert1, vert0);
+ SUB(edge2, vert2, vert0);
+
+ /* begin calculating determinant - also used to calculate U parameter */
+ CROSS(pvec, dir, edge2);
+
+ /* if determinant is near zero, ray lies in plane of triangle */
+ det = DOT(edge1, pvec);
+
+ /* calculate distance from vert0 to ray origin */
+ SUB(tvec, orig, vert0);
+ inv_det = 1.0f/ det;
+
+ CROSS(qvec, tvec, edge1);
+
+ /* calculate U parameter */
+ float uu = DOT(tvec, pvec);
+ float vv;
+
+ if (det > EPSILON)
+ {
+ if (uu < 0.0f || uu > det)
+ return 0;
+
+ /* calculate V parameter and test bounds */
+ vv = DOT(dir, qvec);
+ if (vv < 0.0f || uu + vv > det)
+ return 0;
- }
- else if(det < -EPSILON)
- {
- if (uu > 0.0f || uu < det)
- return 0;
-
- /* calculate V parameter and test bounds */
- vv = DOT(dir, qvec) ;
- if (vv > 0.0f || uu + vv < det)
- return 0;
- }
- else return 0; /* ray is parallell to the plane of the triangle */
+ }
+ else if(det < -EPSILON)
+ {
+ if (uu > 0.0f || uu < det)
+ return 0;
+
+ /* calculate V parameter and test bounds */
+ vv = DOT(dir, qvec) ;
+ if (vv > 0.0f || uu + vv < det)
+ return 0;
+ }
+ else return 0; /* ray is parallell to the plane of the triangle */
- *t = DOT(edge2, qvec) * inv_det;
- (*u) = uu*inv_det;
- (*v) = vv*inv_det;
+ *t = DOT(edge2, qvec) * inv_det;
+ (*u) = uu*inv_det;
+ (*v) = vv*inv_det;
- return 1;
+ return 1;
}
inline int intersect_triangle3_edge(const float orig[3], const float dir[3],
-
const float
vert0[3],
-
float *t,
float *u, float *v, const float *edge1, const float *edge2 )
+ const float vert0[3],
+ float *t, float *u, float *v, const float
*edge1, const float *edge2 )
{
- // float edge1[3], edge2[3];
- float tvec[3], pvec[3], qvec[3];
- float det,inv_det;
-
- /* find vectors for two edges sharing vert0 */
- // SUB(edge1, vert1, vert0);
- // SUB(edge2, vert2, vert0);
-
- /* begin calculating determinant - also used to calculate U parameter
*/
- CROSS(pvec, dir, edge2);
-
- /* if determinant is near zero, ray lies in plane of triangle */
- det = DOT(edge1, pvec);
-
- /* calculate distance from vert0 to ray origin */
- SUB(tvec, orig, vert0);
- inv_det = 1.0f/ det;
-
- CROSS(qvec, tvec, edge1);
-
- /* calculate U parameter */
- float uu = DOT(tvec, pvec);
- float vv;
-
- if (det > EPSILON)
- {
- if (uu < 0.0f || uu > det)
- return 0;
-
- /* calculate V parameter and test bounds */
- vv = DOT(dir, qvec);
- if (vv < 0.0f || uu + vv > det)
- return 0;
+ // float edge1[3], edge2[3];
+ float tvec[3], pvec[3], qvec[3];
+ float det,inv_det;
+
+ /* find vectors for two edges sharing vert0 */
+ // SUB(edge1, vert1, vert0);
+ // SUB(edge2, vert2, vert0);
+
+ /* begin calculating determinant - also used to calculate U parameter */
+ CROSS(pvec, dir, edge2);
+
+ /* if determinant is near zero, ray lies in plane of triangle */
+ det = DOT(edge1, pvec);
+
+ /* calculate distance from vert0 to ray origin */
+ SUB(tvec, orig, vert0);
+ inv_det = 1.0f/ det;
+
+ CROSS(qvec, tvec, edge1);
+
+ /* calculate U parameter */
+ float uu = DOT(tvec, pvec);
+ float vv;
+
+ if (det > EPSILON)
+ {
+ if (uu < 0.0f || uu > det)
+ return 0;
+
+ /* calculate V parameter and test bounds */
+ vv = DOT(dir, qvec);
+ if (vv < 0.0f || uu + vv > det)
+ return 0;
- }
- else if(det < -EPSILON)
- {
- if (uu > 0.0f || uu < det)
- return 0;
-
- /* calculate V parameter and test bounds */
- vv = DOT(dir, qvec) ;
- if (vv > 0.0f || uu + vv < det)
- return 0;
- }
- else return 0; /* ray is parallell to the plane of the triangle */
+ }
+ else if(det < -EPSILON)
+ {
+ if (uu > 0.0f || uu < det)
+ return 0;
+
+ /* calculate V parameter and test bounds */
+ vv = DOT(dir, qvec) ;
+ if (vv > 0.0f || uu + vv < det)
+ return 0;
+ }
+ else return 0; /* ray is parallell to the plane of the triangle */
- *t = DOT(edge2, qvec) * inv_det;
- (*u) = uu*inv_det;
- (*v) = vv*inv_det;
+ *t = DOT(edge2, qvec) * inv_det;
+ (*u) = uu*inv_det;
+ (*v) = vv*inv_det;
- return 1;
+ return 1;
}
inline int intersectTriangle3Edge(const Vectorf &direction, const Pointf
&origin,
- const Vectorf &edge1, Vectorf &edge2, Pointf &p0,
-
float &t, float &u, float &v )
+ const Vectorf &edge1, Vectorf &edge2,
Pointf &p0,
+ float &t, float &u, float &v )
{
- Vectorf tvec, pvec, qvec;
+ Vectorf tvec, pvec, qvec;
- // Vectorf edge1 = ( tri.edge1 );
- // Vectorf edge2 = ( tri.edge2 );
+ // Vectorf edge1 = ( tri.edge1 );
+ // Vectorf edge2 = ( tri.edge2 );
- /* begin calculating determinant - also used to calculate U parameter
*/
- pvec = Cross( direction, edge2 );
+ /* begin calculating determinant - also used to calculate U parameter */
+ pvec = Cross( direction, edge2 );
- // CROSS(pvec, dir, edge2);
+ // CROSS(pvec, dir, edge2);
- /* if determinant is near zero, ray lies in plane of triangle */
- // det = DOT(edge1, pvec);
- float det = Dot( edge1, pvec );
+ /* if determinant is near zero, ray lies in plane of triangle */
+ // det = DOT(edge1, pvec);
+ float det = Dot( edge1, pvec );
- /* calculate distance from vert0 to ray origin */
- // SUB(tvec, orig, vert0);
- tvec = origin - p0;
+ /* calculate distance from vert0 to ray origin */
+ // SUB(tvec, orig, vert0);
+ tvec = origin - p0;
- qvec = Cross( tvec, edge1 );
- // CROSS(qvec, tvec, edge1);
+ qvec = Cross( tvec, edge1 );
+ // CROSS(qvec, tvec, edge1);
- /* calculate U parameter */
- // float uu = DOT(tvec, pvec);
- // float vv;
- float uu = Dot( tvec, pvec );
- float vv;
+ /* calculate U parameter */
+ // float uu = DOT(tvec, pvec);
+ // float vv;
+ float uu = Dot( tvec, pvec );
+ float vv;
- if (det > 1e-5f) {
- if (uu < 0.0 || uu > det)
- return 0;
+ if (det > 1e-5f) {
+ if (uu < 0.0 || uu > det)
+ return 0;
- /* calculate V parameter and test bounds */
- vv = Dot( direction, qvec );
+ /* calculate V parameter and test bounds */
+ vv = Dot( direction, qvec );
- if (vv < 0.0 || uu + vv > det)
- return 0;
+ if (vv < 0.0 || uu + vv > det)
+ return 0;
- }
- else if(det < -1e-5f) {
- if (uu > 0.0 || uu < det)
- return 0;
-
- /* calculate V parameter and test bounds */
- vv = Dot(direction, qvec) ;
- if (vv > 0.0 || uu + vv < det)
- return 0;
- }
- else {
- return 0; /* ray is parallell to the plane of the triangle */
- }
+ }
+ else if(det < -1e-5f) {
+ if (uu > 0.0 || uu < det)
+ return 0;
+
+ /* calculate V parameter and test bounds */
+ vv = Dot(direction, qvec) ;
+ if (vv > 0.0 || uu + vv < det)
+ return 0;
+ }
+ else {
+ return 0; /* ray is parallell to the plane of the triangle */
+ }
- float inv_det = 1.0f / det;
+ float inv_det = 1.0f / det;
- t = (Dot( edge2, qvec ) * inv_det);
- u = (uu * inv_det);
- v = (vv * inv_det);
+ t = (Dot( edge2, qvec ) * inv_det);
+ u = (uu * inv_det);
+ v = (vv * inv_det);
- return 1;
+ return 1;
}
///////////////////////////////////////////////////////////////////////////////
@@ -644,10 +644,10 @@
void KDTreeTexture::mapValues(const RenderContext& /*context*/,
RayPacket& rays, Color results[]) const {
- for (int i=0;i<rays.getSize();++i) {
- RayPacket::Element &e = rays.get(i);
- results[i] =
e.hitInfo.scratchpad<Kdtree::KDTree::ScratchPadInfo>().payload;
- }
+ for (int i=0;i<rays.getSize();++i) {
+ RayPacket::Element &e = rays.get(i);
+ results[i] =
e.hitInfo.scratchpad<Kdtree::KDTree::ScratchPadInfo>().payload;
+ }
}
Modified: branches/itanium2/Model/Groups/TransparentKDTree.cc
==============================================================================
--- branches/itanium2/Model/Groups/TransparentKDTree.cc (original)
+++ branches/itanium2/Model/Groups/TransparentKDTree.cc Mon Nov 14 12:19:56
2005
@@ -403,7 +403,7 @@
// record hit if picking
if (isPickingEnabled()) {
pickedTri =
isectData.rayHitTriIndex;
- cerr << "picked " <<
pickedTri << "\n";
+ // cerr << "picked " <<
pickedTri << "\n";
pickedBeginIndex =
pickedEndIndex = pickedTri;
while (pickedBeginIndex > 0 &&
triToGroupMap->get(pickedBeginIndex-1)
@@ -413,8 +413,8 @@
triToGroupMap->get(pickedEndIndex+1)
==
triToGroupMap->get(pickedEndIndex))
pickedEndIndex ++;
- cerr << "picked begin " <<
pickedBeginIndex << "end " << pickedEndIndex << "\n";
- cerr << "picked flag: " <<
(int)pickedFlag << std::endl;
+ // cerr << "picked begin " <<
pickedBeginIndex << "end " << pickedEndIndex << "\n";
+ // cerr << "picked flag: " <<
(int)pickedFlag << std::endl;
for (int i=pickedBeginIndex;
i<=pickedEndIndex; i++)
triFlags->set(i,
pickedFlag);
}
Modified: branches/itanium2/Model/Groups/TransparentKDTree.h
==============================================================================
--- branches/itanium2/Model/Groups/TransparentKDTree.h (original)
+++ branches/itanium2/Model/Groups/TransparentKDTree.h Mon Nov 14 12:19:56
2005
@@ -1,30 +1,30 @@
/*
- For more information, please see:
http://software.sci.utah.edu
+ For more information, please see:
http://software.sci.utah.edu
- The MIT License
+ The MIT License
- Copyright (c) 2005
- Silicon Graphics Inc. Mountain View California.
+ Copyright (c) 2005
+ Silicon Graphics Inc. Mountain View California.
- 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:
+ 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 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.
- */
+ 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 __TRANSPARENT_KD_TREE_H__
#define __TRANSPARENT_KD_TREE_H__
@@ -50,102 +50,107 @@
namespace Manta {
- namespace Kdtree {
+ namespace Kdtree {
-
///////////////////////////////////////////////////////////////////////////
-
///////////////////////////////////////////////////////////////////////////
- // TRANSPARENT KDTREE CLASS
- // Note: Uses data structures defined in normal
TransparentKDTree.
-
///////////////////////////////////////////////////////////////////////////
-
///////////////////////////////////////////////////////////////////////////
- class TransparentKDTree : public PrimitiveCommon {
- private:
- BBox bbox;
-
- KDTreeNode *rootNode;
-
- VArray<int> *triIndices;
- VArray<Triangle> *tris;
- TriangleNormal *normals;
-
- VArray<int> *triToGroupMap;
- VArray<int> *groupToNameMap;
- VArray<unsigned char> *groupNames;
- bool __pickingEnabled;
- bool pickingEnabled;
- mutable long long pickedTri;
- mutable int pickedBeginIndex, pickedEndIndex;
- VArray<Color> pickedSavedColors;
- VArray<unsigned char> *triFlags;
- unsigned char pickedFlag;
-
- public:
- void enablePicking() {
- if (__pickingEnabled)
- pickingEnabled = true;
- }
- void disablePicking() { pickingEnabled = false; }
- bool isPickingEnabled() const { return
pickingEnabled&&__pickingEnabled; }
- void resetPicking() {
- pickedTri = -1;
- triFlags->clear();
- }
- void __setPicking(bool flag) { __pickingEnabled =
flag; }
-
- void setPickedFlag(unsigned char flag) { pickedFlag =
flag; }
- unsigned char getPickedFlag() { return pickedFlag; }
+
///////////////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////////////
+ // TRANSPARENT KDTREE CLASS
+ // Note: Uses data structures defined in normal TransparentKDTree.
+
///////////////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////////////
+ class TransparentKDTree : public PrimitiveCommon {
+ private:
+ BBox bbox;
+
+ KDTreeNode *rootNode;
+
+ VArray<int> *triIndices;
+ VArray<Triangle> *tris;
+ TriangleNormal *normals;
+
+ VArray<int> *triToGroupMap;
+ VArray<int> *groupToNameMap;
+ VArray<unsigned char> *groupNames;
+ bool __pickingEnabled;
+ bool pickingEnabled;
+ mutable long long pickedTri;
+ mutable int pickedBeginIndex, pickedEndIndex;
+ VArray<Color> pickedSavedColors;
+ VArray<unsigned char> *triFlags;
+ unsigned char pickedFlag;
+
+ public:
+ const unsigned char *getPickedName() {
+ if (pickedTri >= 0) return
&(groupNames->get(groupToNameMap->get(triToGroupMap->get( pickedTri ))));
+ return "No selection";
+ }
+ void enablePicking() {
+ if (__pickingEnabled)
+ pickingEnabled = true;
+ }
+ void disablePicking() { pickingEnabled = false; }
+ bool isPickingEnabled() const
+ { return pickingEnabled&&__pickingEnabled; }
+ void resetPicking() {
+ pickedTri = -1;
+ triFlags->clear();
+ }
+ void __setPicking(bool flag) { __pickingEnabled = flag; }
+
+ void setPickedFlag(unsigned char flag) { pickedFlag = flag; }
+ unsigned char getPickedFlag() { return pickedFlag; }
- private:
- Real sample_alpha;
+ private:
+ Real sample_alpha;
- // This method intersects a list of triangles with
the ray.
- int intersectTrianglesTransparent(const Ray* ray,
RayPacket::Element &e, unsigned int listBegin, int listSize, float maxDist,
void *userData, const RenderContext &context, bool isFirst=false) const;
+ // This method intersects a list of triangles with the ray.
+ int intersectTrianglesTransparent(const Ray* ray, RayPacket::Element
&e, unsigned int listBegin, int listSize, float maxDist, void *userData,
const RenderContext &context, bool isFirst=false) const;
- // This method is called by the above method with a
hansong ray.
- void _intersect(const Ray* ray, RayPacket::Element
&e, RayTriIntersectUserData &isectData, const RenderContext &context, float
_minDist=-1, float _maxDist=-1) const;
+ // This method is called by the above method with a hansong ray.
+ void _intersect(const Ray* ray, RayPacket::Element &e,
RayTriIntersectUserData &isectData, const RenderContext &context, float
_minDist=-1, float _maxDist=-1) const;
- // This structure is used to order the triangle hits
along the ray
- // before blending.
- struct Isect {
- Real t, u, v;
- int triIdx;
+ // This structure is used to order the triangle hits along the ray
+ // before blending.
+ struct Isect {
+ Real t, u, v;
+ int triIdx;
- inline bool operator < (const Isect &b) const
{ return t < b.t; }
- };
+ inline bool operator < (const Isect &b) const { return t < b.t; }
+ };
- // Per thread buffers used to order samples for
blending.
- // Note, numprocs+1 are used to allow space for
shootOneRay queries.
- static VArray<VArray<Isect> *> isectBuffers;
-
- public:
- // This structure is used to record info about the
hit.
- struct ScratchPadInfo : public KDTree::ScratchPadInfo
{
- Real alpha; // Alpha of the ray (fully
attenuated at alpha==1.0)
- Real sample_t; // t value along ray of last
sample blended.
+ // Per thread buffers used to order samples for blending.
+ // Note, numprocs+1 are used to allow space for shootOneRay queries.
+ static VArray<VArray<Isect> *> isectBuffers;
+
+ public:
+ // This structure is used to record info about the hit.
+ struct ScratchPadInfo : public KDTree::ScratchPadInfo {
+ Real alpha; // Alpha of the ray (fully attenuated at alpha==1.0)
+ Real sample_t; // t value along ray of last sample blended.
- inline void reset() {
- payload = Color(RGB(0.0,0.0,0.0));
- alpha = 0.0;
- sample_t = 0.0;
- }
- };
-
- // Constructor.
- // The transparent KDTree uses data owned by a normal
KDTree.
- TransparentKDTree( KDTree *kdtree_, Material
*material_, Real sample_alpha_ = 0.25 );
-
- void setAlpha( Real alpha_ ) { sample_alpha = alpha_;
};
- Real getAlpha() const { return sample_alpha; };
-
- // Primitive Interface.
- void intersect(const RenderContext& context, RayPacket&
rays) const;
- void preprocess(const PreprocessContext& context) {
};
- void setTexCoordMapper(const TexCoordMapper* new_tex)
{ };
- void computeNormal(const RenderContext& context,
RayPacket& rays) const;
- void computeBounds(const PreprocessContext &context,
BBox &box_ ) const { box_.extendByBox( bbox ); }
- void computeBounds( BBox &box_ ) const {
box_.extendByBox( bbox ); }
- };
+ inline void reset() {
+ payload = Color(RGB(0.0,0.0,0.0));
+ alpha = 0.0;
+ sample_t = 0.0;
}
+ };
+
+ // Constructor.
+ // The transparent KDTree uses data owned by a normal KDTree.
+ TransparentKDTree( KDTree *kdtree_, Material *material_, Real
sample_alpha_ = 0.9 );
+
+ void setAlpha( Real alpha_ ) { sample_alpha = alpha_; };
+ Real getAlpha() const { return sample_alpha; };
+
+ // Primitive Interface.
+ void intersect(const RenderContext& context, RayPacket& rays) const;
+ void preprocess(const PreprocessContext& context) { };
+ void setTexCoordMapper(const TexCoordMapper* new_tex) { };
+ void computeNormal(const RenderContext& context, RayPacket& rays)
const;
+ void computeBounds(const PreprocessContext &context, BBox &box_ )
const { box_.extendByBox( bbox ); }
+ void computeBounds( BBox &box_ ) const { box_.extendByBox( bbox ); }
+ };
+ }
}
Added: branches/itanium2/StandAlone/manta_scaling_plot.pl
==============================================================================
--- (empty file)
+++ branches/itanium2/StandAlone/manta_scaling_plot.pl Mon Nov 14 12:19:56
2005
@@ -0,0 +1,82 @@
+
+# Parse args
+for ($i=0;$i<@ARGV;++$i) {
+ if ($ARGV[$i] eq "-file") {
+ $input_file = $ARGV[++$i];
+ }
+}
+
+if ($input_file eq "") {
+ print "Usage: make_scaling_plot.pl -file <infile.html>\n";
+ exit(1);
+}
+
+$out_file = $input_file;
+
+# Open input file.
+if (!open(INPUT,"<",$input_file)) {
+ print "Cannot open $input_file.\n";
+ exit(1);
+}
+
+# Open a temp file.
+$tmp_file = "make_scaling_plot.temp.txt";
+if (!open(TEMP,">",$tmp_file)) {
+ print "Cannot open $tmp_file\n";
+ exit(1);
+}
+
+while (<INPUT>) {
+ $line = $_;
+
+ if ($line =~ /np([0-9]+)/) {
+ $np = $1;
+ }
+
+ if ($line =~ /^Min fps: ([0-9\.]*)/) {
+ $min = $1;
+ }
+ if ($line =~ /^Max fps: ([0-9\.]*)/) {
+ $max = $1;
+ }
+ if ($line =~ /^Mean fps: ([0-9\.]*)/) {
+ $mean = $1;
+ print TEMP "$np $min $max $mean\n";
+ }
+};
+
+close (TEMP);
+
+# Plot in gnuplot.
+if (!open(GNUPLOT, "|-", "gnuplot")) {
+ print "Could not open gnuplot\n";
+ exit(1);
+}
+
+$png_file = $out_file . ".png";
+$eps_file = $out_file . ".eps";
+
+print "Output to $png_file and $eps_file\n";
+
+$plot = "plot \"$tmp_file\" using 1:2 title \"Min\", " .
+ "\"$tmp_file\" using 1:3 title \"Max\", " .
+ "\"$tmp_file\" using 1:4 title \"Avg\"\n";
+
+print GNUPLOT "set data style linespoints\n";
+print GNUPLOT "set title \"Processor Scaling: $input_file\"\n";
+print GNUPLOT "set xlabel \"np\"\n";
+print GNUPLOT "set ylabel \"fps\"\n";
+
+ print GNUPLOT "set term png small color\n";
+ print GNUPLOT "set output \"$png_file\"\n";
+ print GNUPLOT $plot;
+
+print GNUPLOT "set term postscript eps enhanced color\n";
+print GNUPLOT "set output \"$eps_file\"\n";
+print GNUPLOT $plot;
+
+close (GNUPLOT);
+
+# Remove the tmp file.
+
+
Modified: branches/itanium2/fox/FMantaRecorder.cc
==============================================================================
--- branches/itanium2/fox/FMantaRecorder.cc (original)
+++ branches/itanium2/fox/FMantaRecorder.cc Mon Nov 14 12:19:56 2005
@@ -113,7 +113,7 @@
play_last_spinner->disable();
play_loop_check = new FXCheckButton( play_group, "Loop" );
- play_loop_check->setCheck( FALSE );
+ play_loop_check->setCheck( TRUE );
play_loop_check->disable();
//////////////////////////////////////////////////////////////////////////////
@@ -233,7 +233,7 @@
play_last_spinner->setRange( 1, total_points );
play_last_spinner->enable();
- play_loop_check->enable();
+ // play_loop_check->enable();
}
}
@@ -381,7 +381,7 @@
play_last_spinner->setRange( 1, total_points );
play_last_spinner->enable();
- play_loop_check->enable();
+ // play_loop_check->enable();
// Delete the data.
record_iter = 0;
@@ -458,5 +458,5 @@
play_time_spinner->enable();
play_start_spinner->enable();
play_last_spinner->enable();
- play_loop_check->enable();
+ // play_loop_check->enable();
};
Modified: branches/itanium2/fox/FMantaWindow.cc
==============================================================================
--- branches/itanium2/fox/FMantaWindow.cc (original)
+++ branches/itanium2/fox/FMantaWindow.cc Mon Nov 14 12:19:56 2005
@@ -152,10 +152,9 @@
hide_selected_check = new FXMenuCheck( options_menu, "Hide on Select",
this, ID_HIDE_SELECTED );
new FXMenuCommand( options_menu, "Unhide All", 0, this, ID_UNHIDE_ALL );
-
// Fly to bookmarks.
- // fly_bookmarks_check = new FXMenuCheck( options_menu, "Fly to Bookmarks"
);
- // fly_bookmarks_check->enable();
+ fly_bookmarks_check = new FXMenuCheck( options_menu, "Fly to Bookmarks" );
+ fly_bookmarks_check->enable();
new FXMenuSeparator( options_menu );
@@ -184,7 +183,6 @@
cutting_slider->setValue( 0.0 );
cutting_slider->disable();
-
/////////////////////////////////////////////////////////////////////////////
// Navigators.
frame = new FXHorizontalFrame( controls, LAYOUT_FILL_X );
@@ -282,7 +280,7 @@
int index = (FXint)(FXival)data;
// Get the text from the list box.
- string camera_text = camera_text_list[ index ];
+ string camera_text = camera_text_list[index];
// Send a transaction to our self to change the camera.
manta_interface->addTransaction("Camera Bookmark",
@@ -701,14 +699,14 @@
if (kdtree->isPickingEnabled()) {
int result = manta_frame->shootOneRay( x, y, point, normal );
if (!result) {
- std::cerr << "reset picking" << std::endl;
+ // std::cerr << "reset picking" << std::endl;
kdtree->resetPicking();
- // hide_selected_check->disable();
}
// Disable picking.
kdtree->disablePicking();
- // hide_selected_check->enable();
+
+ std::cerr << "Selected part: " << kdtree->getPickedName() << std::endl;
}
}
@@ -869,17 +867,78 @@
// Determine the channel number.
int channel = manta_frame->getMantaChannel();
- std::cout << "Camera text: " << camera_text << std::endl;
+ std::cerr << "Camera text: " << camera_text << std::endl;
- // Create the camera.
- Camera *camera = manta_interface->createCamera( camera_text );
+ // Create the new camera.
+ Camera *new_camera = manta_interface->createCamera( camera_text );
// Check to make sure the camera text was valid.
- if (camera != 0) {
- manta_interface->setCamera( channel, camera );
-
- // This is unsafe.
- manta_frame->getNavigator()->resetToCamera(
camera->getPosition(),camera->getLookAt(),camera->getUp());
+ if (new_camera != 0) {
+
+ // Check to see if we should animate to the bookmark or not.
+ if (fly_bookmarks_check->getCheck()) {
+
+ //////////////////////////////////////////////////////////////////////
+ // Create a camera path.
+
+ Point eye[4];
+ Point lookat[4];
+ Vector up[4];
+
+ // Determine destination.
+ Point point = new_camera->getPosition();
+ Vector normal = (new_camera->getPosition() - new_camera->getLookAt());
+ normal.normalize();
+
+ // Get the current manta camera.
+ Camera *camera = manta_interface->getCamera( channel );
+
+ eye[0] = eye[1] = camera->getPosition();
+ lookat[0] = lookat[1] = camera->getLookAt();
+ up[0] = up[1] = camera->getUp();
+
+ // Distance between POI and current location
+ Vector eyetopoi = point - camera->getPosition();
+ Real dist = sqrt(Dot(eyetopoi, eyetopoi));
+
+ eye[2] = eye[3] = point;
+ lookat[2] = lookat[3] = point - normal;
+ up[2] = up[3] = new_camera->getUp();
+
+ // Save the destination
+ dstPosition = new_camera->getPosition();
+ dstLookAt = new_camera->getLookAt();
+ dstUp = new_camera->getUp();
+
+ Real delta_t = 1.0/dist, delta_time = delta_t*5.0;
+
+ automator = new CameraPathAutomator(
+ manta_interface, 0, 0,
+ eye, lookat, up, 4,
+ delta_t,
+ delta_time);
+ automator->set_automator_mode( AutomatorUI::AUTOMATOR_EXIT );
+ automator->set_loop_behavior( CameraPathAutomator::PATH_STOP );
+
+ automator->set_terminate_callback( Callback::create( this,
&FMantaWindow::mantaPOIManeuverComplete ) );
+
+ automator->restart();
+
+
+
+
+
+ }
+ else {
+
/////////////////////////////////////////////////////////////////////////////////////
+ // Otherwise, move to the new camera without animating
+ manta_interface->setCamera( channel, new_camera );
+
+ // This is unsafe.
+ manta_frame->getNavigator()->resetToCamera( new_camera->getPosition(),
+ new_camera->getLookAt(),
+ new_camera->getUp());
+ }
}
}
- [MANTA] r708 - in branches/itanium2: Model/Groups StandAlone fox, abe, 11/14/2005
Archive powered by MHonArc 2.6.16.