Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r550 - in branches/itanium2: Model/Groups Model/Intersections Model/MiscObjects StandAlone
- Date: Wed, 14 Sep 2005 15:41:48 -0600 (MDT)
Author: bigler
Date: Wed Sep 14 15:41:46 2005
New Revision: 550
Modified:
branches/itanium2/Model/Groups/FrustumKDTree.h
branches/itanium2/Model/Groups/KDTree.h
branches/itanium2/Model/Groups/KDTreeLoader.h
branches/itanium2/Model/Intersections/Plane.h
branches/itanium2/Model/MiscObjects/CuttingPlane.h
branches/itanium2/StandAlone/CMakeLists.txt
branches/itanium2/StandAlone/frust-test.cc
Log:
Model/Groups/FrustumKDTree.h
Comment out intersect function until we get an implementation.
Added virtual desctructor to FrustumKDTree class.
Model/Groups/KDTree.h
Added virtual destructor for KDTree.
Model/Groups/KDTreeLoader.h
Model/Intersections/Plane.h
Model/MiscObjects/CuttingPlane.h
Code formatting. No tabs, trailing whitespace, line width.
StandAlone/CMakeLists.txt
Fixed typo for frust-test linked in libraries. Added thread
libraries for frust-test.
StandAlone/frust-test.cc
Hey, it now does one test. I don't think the result is right,
though.
Modified: branches/itanium2/Model/Groups/FrustumKDTree.h
==============================================================================
--- branches/itanium2/Model/Groups/FrustumKDTree.h (original)
+++ branches/itanium2/Model/Groups/FrustumKDTree.h Wed Sep 14 15:41:46
2005
@@ -124,9 +124,11 @@
KDTree( kdtree_, material_ )
{ }
+ virtual ~FrustumKDTree() {}
+
// Intersection method -- Intersect frustum with kdtree then call
// KDTree::intersect.
- virtual void intersect(const RenderContext& context, RayPacket& rays)
const;
+ //virtual void intersect(const RenderContext& context, RayPacket&
rays) const;
};
}; // end namespace Kdtree
Modified: branches/itanium2/Model/Groups/KDTree.h
==============================================================================
--- branches/itanium2/Model/Groups/KDTree.h (original)
+++ branches/itanium2/Model/Groups/KDTree.h Wed Sep 14 15:41:46 2005
@@ -318,6 +318,8 @@
Color payload; // Payload of the intersected face.
};
+ virtual ~KDTree() {}
+
// Primitive Interface.
virtual void intersect(const RenderContext& context, RayPacket& rays)
const;
void computeNormal (const RenderContext& context, RayPacket& rays)
const;
Modified: branches/itanium2/Model/Groups/KDTreeLoader.h
==============================================================================
--- branches/itanium2/Model/Groups/KDTreeLoader.h (original)
+++ branches/itanium2/Model/Groups/KDTreeLoader.h Wed Sep 14 15:41:46
2005
@@ -1,30 +1,30 @@
/*
- For more information, please see:
http://software.sci.utah.edu
-
- The MIT License
-
- 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:
-
- 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.
- */
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ 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:
+
+ 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 __KDTREELOADER_H__
#define __KDTREELOADER_H__
@@ -32,16 +32,16 @@
#include <Model/Groups/KDTree.h>
namespace Manta {
- namespace Kdtree {
+ namespace Kdtree {
+
+ class KDTree;
- class KDTree;
+ // Load the specified file (and associated kdtree files) using the given
+ // number of processors. For example if using model.v3c1, the files
+ // model.v3c1.kd and model.v3c1.idx must be located in the same
directory.
+ int load( KDTree *kdtree, const char *filename, int np );
- // Load the specified file (and associated kdtree files)
using the given
- // number of processors. For example if using model.v3c1, the
files
- // model.v3c1.kd and model.v3c1.idx must be located in the
same directory.
- int load( KDTree *kdtree, const char *filename, int np );
-
- };
+ };
};
-#endif
\ No newline at end of file
+#endif
Modified: branches/itanium2/Model/Intersections/Plane.h
==============================================================================
--- branches/itanium2/Model/Intersections/Plane.h (original)
+++ branches/itanium2/Model/Intersections/Plane.h Wed Sep 14 15:41:46
2005
@@ -4,25 +4,25 @@
#define Manta_Model_Intersections_Plane__H
namespace Manta {
- namespace Intersection {
-
- template< typename Scalar >
- inline bool intersectPlane( const Point &point,
- const Vector &normal,
-
Scalar &t,
-
const Ray &ray ) {
-
- Scalar dn = Dot( ray.direction(), normal );
- if (dn != 0.0) {
- Scalar ao = Dot( (point-ray.origin()), normal
);
- t = ao/dn;
- return true;
- }
- return true;
- }
-
-
- }
-};
+ namespace Intersection {
-#endif
\ No newline at end of file
+ template< typename Scalar >
+ inline bool intersectPlane( const Point &point,
+ const Vector &normal,
+ Scalar &t,
+ const Ray &ray ) {
+
+ Scalar dn = Dot( ray.direction(), normal );
+ if (dn != 0.0) {
+ Scalar ao = Dot( (point-ray.origin()), normal );
+ t = ao/dn;
+ return true;
+ }
+ return true;
+ }
+
+
+ } // end namespace Intersection
+}; // end namespace Manta
+
+#endif
Modified: branches/itanium2/Model/MiscObjects/CuttingPlane.h
==============================================================================
--- branches/itanium2/Model/MiscObjects/CuttingPlane.h (original)
+++ branches/itanium2/Model/MiscObjects/CuttingPlane.h Wed Sep 14 15:41:46
2005
@@ -8,51 +8,60 @@
#include <Interface/RayPacket.h>
-// Cutting plane for intersections.
+// Cutting plane for intersections.
// Abe Stephens abe@sgi.com
namespace Manta {
-
+
class CuttingPlane : public Object {
- private:
- BBox bounds; // Bounds of the internal object.
- Object *internal_object; // Object to be cut.
-
- Real movement_scale;
- Point initial_point;
-
- Point plane_point;
- Vector plane_normal;
-
- public:
+ private:
+ BBox bounds; // Bounds of the internal object.
+ Object *internal_object; // Object to be cut.
+
+ Real movement_scale;
+ Point initial_point;
+
+ Point plane_point;
+ Vector plane_normal;
+
+ public:
CuttingPlane( const Point &point_, const Vector &normal_, Object
*internal_object_ ) :
- initial_point( point_ ), plane_point( point_ ),
- plane_normal( normal_ ), internal_object(
internal_object_ ),
- movement_scale( 1.0 ) { }
-
- // Preprocess the internal object and compute its bounds.
+ initial_point( point_ ), plane_point( point_ ),
+ plane_normal( normal_ ), internal_object( internal_object_ ),
+ movement_scale( 1.0 ) { }
+
+ // Preprocess the internal object and compute its bounds.
void preprocess( const PreprocessContext &context );
-
- // Return the bounds of the object.
- void computeBounds(const PreprocessContext& context, BBox& bbox) const {
bbox.extendByBox( bounds ); };
-
- // Intersection method.
- void intersect(const RenderContext& context, RayPacket& rays)
const;
-
- // Accessors.
- const BBox &getBounds() { return bounds; };
- Object *getObject() { return internal_object; };
- void setObject( Object *object_ ) { internal_object =
object_; };
-
- void getPlanePoint ( Point &result ) { result = plane_point;
};
- void getPlaneNormal( Vector &result ) { result =
plane_normal; };
-
- void setPlanePoint ( const Point &plane_point_ ) {
plane_point = plane_point_; };
- void setPlaneNormal( const Vector &plane_normal_ ) {
plane_normal = plane_normal_; };
-
- // Move the plane point a signed distance along the plane
normal.
- void movePlaneAlongNormal( Real distance );
- };
+
+ // Return the bounds of the object.
+ void computeBounds(const PreprocessContext& context, BBox& bbox) const
+ {
+ bbox.extendByBox( bounds );
+ }
+
+ // Intersection method.
+ void intersect(const RenderContext& context, RayPacket& rays) const;
+
+ // Accessors.
+ const BBox &getBounds() { return bounds; };
+ Object *getObject() { return internal_object; };
+ void setObject( Object *object_ ) { internal_object = object_; };
+
+ void getPlanePoint ( Point &result ) { result = plane_point; };
+ void getPlaneNormal( Vector &result ) { result = plane_normal; };
+
+ void setPlanePoint ( const Point &plane_point_ )
+ {
+ plane_point = plane_point_;
+ }
+ void setPlaneNormal( const Vector &plane_normal_ )
+ {
+ plane_normal = plane_normal_;
+ }
+
+ // Move the plane point a signed distance along the plane normal.
+ void movePlaneAlongNormal( Real distance );
+ };
}
-#endif
\ No newline at end of file
+#endif
Modified: branches/itanium2/StandAlone/CMakeLists.txt
==============================================================================
--- branches/itanium2/StandAlone/CMakeLists.txt (original)
+++ branches/itanium2/StandAlone/CMakeLists.txt Wed Sep 14 15:41:46 2005
@@ -19,11 +19,13 @@
${CMAKE_THREAD_LIBS_INIT})
ADD_EXECUTABLE(frust-test frust-test.cc)
-TARGET_LINK_LIBRARIES(manta Manta_Engine
- Manta_UserInterface
- Manta_Model
- Manta_Image
- Manta_Interface
- Manta_Core
- SCIRun_Core)
+TARGET_LINK_LIBRARIES(frust-test Manta_Engine
+ Manta_UserInterface
+ Manta_Model
+ Manta_Image
+ Manta_Interface
+ Manta_Core
+ SCIRun_Core
+ ${CMAKE_THREAD_LIBS_INIT}
+ )
Modified: branches/itanium2/StandAlone/frust-test.cc
==============================================================================
--- branches/itanium2/StandAlone/frust-test.cc (original)
+++ branches/itanium2/StandAlone/frust-test.cc Wed Sep 14 15:41:46 2005
@@ -8,6 +8,7 @@
#include <Model/Groups/FrustumKDTree.h>
+#include <Interface/Context.h>
#include <sgi_stl_warnings_off.h>
#include <iostream>
@@ -39,9 +40,55 @@
return 1;
}
+ // Here's the bounding box for the node
+ Point bbox_min(-10,-5,-4), bbox_max(-2,7,12);
+ BBox bbox(bbox_min, bbox_max);
// OK, create my first KDTreeNode
-
-
+ KDTreeNode node;
+ node.internal.split = 2; // split position
+ node.internal.flags = 2; // z axis
+ node.internal.flags |= KDNODE_INTERNAL_MASK; // This is an internal node
+ // Now to create a RenderContext, but we don't actually use it for
+ // the frustum intersect functions, so fill it as much as you need to.
+ RenderContext render_context(NULL,
+ 0, 0, 1,
+ NULL,
+ NULL, NULL,
+ NULL, NULL,
+ NULL,NULL );
+ // Ah, the ray packet
+ RayPacketData rp_data;
+ int rp_flags = RayPacket::ConstantOrigin | RayPacket::ConstantDirections;
+ RayPacket rays(rp_data, 2, 1, rp_flags);
+ Point ray_origin(20, 1, 20);
+ Point Pn(20,1,2), Pf(2,1,2);
+ rays.get(0).ray = Ray(ray_origin, Pn-ray_origin);
+ rays.get(1).ray = Ray(ray_origin, Pf-ray_origin);
+
+ // Now for the PacketFrustum
+ PacketFrustum pfrustum(rays);
+
+ // Now to try a test
+ FrustumKDTree kdtree(NULL);
+
+ FrustumKDTree::IntersectCase result =
+ kdtree.frustum_node_intersect(render_context, &node, pfrustum, bbox);
+ switch(result) {
+ case FrustumKDTree::INTERSECT_NONE:
+ cout << "INTERSECT_NONE\n";
+ break;
+ case FrustumKDTree::INTERSECT_MIN:
+ cout << "INTERSECT_MIN\n";
+ break;
+ case FrustumKDTree::INTERSECT_MAX:
+ cout << "INTERSECT_MAX\n";
+ break;
+ case FrustumKDTree::INTERSECT_BOTH:
+ cout << "INTERSECT_BOTH\n";
+ break;
+ }
+
+
return 0;
}
- [MANTA] r550 - in branches/itanium2: Model/Groups Model/Intersections Model/MiscObjects StandAlone, bigler, 09/14/2005
Archive powered by MHonArc 2.6.16.