Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

nvtraverser::RayIntersectTraverser Class Reference

RayIntersectTraverser. More...

#include <RayIntersectTraverser.h>

Inheritance diagram for nvtraverser::RayIntersectTraverser:

Inheritance graph
[legend]
Collaboration diagram for nvtraverser::RayIntersectTraverser:

Collaboration graph
[legend]
List of all members.

Public Member Functions

NVSG_API RayIntersectTraverser (void)
 Default constructor.
NVSG_API void release ()
 Release all resources.
NVSG_API void setRay (const nvmath::Vec3f &origin, const nvmath::Vec3f &dir)
 Set the ray for the intersection test.
NVSG_API void setCamClipping (bool b)
 Enable/disable camera plane clipping.
NVSG_API const IntersectiongetNearest (void) const
 Get the nearest intersection.
NVSG_API const IntersectiongetIntersections (void) const
 Get intersections.
NVSG_API size_t getNumberOfIntersections (void) const
 Get number of intersections.
NVSG_API void setBackFaceCulling (bool enable)
 Enable / disable back-face culling.
NVSG_API bool isBackFaceCullingEnabled ()
 Check if back-face culling is enabled.

Protected Types

enum  ISType {
  _NONE = 0, _BSTANGENT, _BSNEAR, _BSFAR,
  _BSNEARFAR
}
 Intersection type (bounding sphere). More...

Protected Member Functions

virtual NVSG_API ~RayIntersectTraverser (void)
 Default destructor.
virtual NVSG_API void doApply (const nvsg::ViewState *pViewState, const nvsg::Scene *pScene)
 Apply the traverser to the scene.
virtual NVSG_API void handleGeoNode (const nvsg::GeoNode *p)
 Routine to handle a GeoNode while traversing the scene graph.
virtual NVSG_API void handleGroup (const nvsg::Group *p)
 Routine to handle a Group node while traversing the scene graph.
virtual NVSG_API void handleLOD (const nvsg::LOD *p)
 Routine to handle a LOD (Level Of Detail) node while traversing the scene graph.
virtual NVSG_API void handleSwitch (const nvsg::Switch *p)
 Routine to handle a Switch node while traversing the scene graph.
virtual NVSG_API void handleTransform (const nvsg::Transform *p)
 Provide special treatment of a Transform node.
virtual NVSG_API void handleQuads (const nvsg::Quads *p)
 Routine to handle a Quads object while traversing the scene graph.
virtual NVSG_API void handleQuadStrips (const nvsg::QuadStrips *p)
 Routine to handle a QuadStrips object while traversing the scene graph.
virtual NVSG_API void handleTriangles (const nvsg::Triangles *p)
 Routine to handle a Triangles object while traversing the scene graph.
virtual NVSG_API void handleTriStrips (const nvsg::TriStrips *p)
 Routine to handle a TriStrips object while traversing the scene graph.
virtual NVSG_API bool preTraverseTransform (const nvsg::Transform *p)
 Handles actions to take between transform stack adjustment and traversal.
virtual NVSG_API void postTraverseTransform (const nvsg::Transform *p)
 Handles stuff to do between traversal and transform stack adjustment.
NVSG_API bool checkIntersection (const nvmath::Sphere3f &sphere)
 Check the current ray for intersection with a Sphere3f.
NVSG_API bool intersectTriangle (const nvmath::Vec3f &v0, const nvmath::Vec3f &v1, const nvmath::Vec3f &v2, nvmath::Vec3f &isp, float &dist)
 Intersect with triangle.
NVSG_API void storeIntersection (const nvsg::GeoSet *p, const nvmath::Vec3f &isp, float dist)
 store the intersection point isp.

Protected Attributes

bool m_backFaceCulling
 true: consider backface culling
bool m_ccw
 true: winding is supposed to be counterclockwise
bool m_camClipping
 true: use camera far/near clipping planes
nvmath::Vec3f m_rayOrigin
 Origin point of the ray - default (0,0,0).
nvmath::Vec3f m_rayDir
 Direction of the ray - default (0,0,-1).
const nvsg::Cameram_camera
 Camera of the scene that came in via apply (we ref/unref it).
std::stack< nvmath::Vec3fm_msRayOrigin
 stack of Origin point of the ray in model space
std::stack< nvmath::Vec3fm_msRayDir
 stack of Direction of the ray in model space
std::stack< nvmath::Vec3fm_msCamDir
 stack of camera direction in model space
std::vector< Intersectionm_intersectionList
 Intersection list containing all intersections.
size_t m_nearestIntIdx
 Index of the nearest z intersection.
nvsg::Pathm_curPath
 Current path.
size_t m_currentFrame
 This frame is to be used in an animation sequence.
float m_scaleFactor
 Adjusts distances by the scalings of the Transform nodes.

Static Protected Attributes

static const nvmath::Vec3f _RAY_ORIGIN_DEFAULT
 Default value: (0.f, 0.f, 0.f).
static const nvmath::Vec3f _RAY_DIRECTION_DEFAULT
 Default value: (0.f, 0.f, -1.f).

Detailed Description

RayIntersectTraverser.

A RayIntersectTraverser is a specialized traverser that calculates the intersections of a given ray that passes through the scene.

Note:
If you add new geometry objects classes to NVSG you must also derive from this class and add an operator for this object to handle the intersection calculation.

If you create a special kind of transformation node you also have to take care of the transformation stack in this class.


Member Enumeration Documentation

enum nvtraverser::RayIntersectTraverser::ISType [protected]
 

Intersection type (bounding sphere).

These are the possible types of intersections between the ray and the boundingsphere of an object in the scene. These types are used for the preintersection calculation with the objects bounding sphere. Regarding the intersection type we can skip objects.

Enumeration values:
_NONE  No intersection.
_BSTANGENT  Tangential intersection.
_BSNEAR  Intersection with the front part of the bounding sphere.
_BSFAR  Intersection with the back part of the bounding sphere.
_BSNEARFAR  Intersection with the front and back part of the bounding sphere.


Constructor & Destructor Documentation

NVSG_API nvtraverser::RayIntersectTraverser::RayIntersectTraverser void   ) 
 

Default constructor.

virtual NVSG_API nvtraverser::RayIntersectTraverser::~RayIntersectTraverser void   )  [protected, virtual]
 

Default destructor.


Member Function Documentation

NVSG_API void nvtraverser::RayIntersectTraverser::release  ) 
 

Release all resources.

By releasing all resources we can use this traverser for the next intersection calculation.

NVSG_API void nvtraverser::RayIntersectTraverser::setRay const nvmath::Vec3f origin,
const nvmath::Vec3f dir
 

Set the ray for the intersection test.

Sets a world-space ray along which to pick. The ray is defined as a world space origin point and direction vector. The direction vector must be normalized.

Parameters:
origin  World space origin
dir  Direction of the ray - must be normalized!

void nvtraverser::RayIntersectTraverser::setCamClipping bool  b  )  [inline]
 

Enable/disable camera plane clipping.

Enabling camera plane clipping forces the traverser to calculate only intersections that lie in between the camera's clip planes.

Parameters:
flag  true = enable clipping

const Intersection & nvtraverser::RayIntersectTraverser::getNearest void   )  const [inline]
 

Get the nearest intersection.

Returns:
The nearest intersection regarding the rays origin.

const Intersection * nvtraverser::RayIntersectTraverser::getIntersections void   )  const [inline]
 

Get intersections.

Returns:
All intersections along the ray.

size_t nvtraverser::RayIntersectTraverser::getNumberOfIntersections void   )  const [inline]
 

Get number of intersections.

Returns:
The number of intersections along the ray.

void nvtraverser::RayIntersectTraverser::setBackFaceCulling bool  enable  )  [inline]
 

Enable / disable back-face culling.

Take back-faces culling into account.

Parameters:
enable  true enables back-face culling

bool nvtraverser::RayIntersectTraverser::isBackFaceCullingEnabled  )  [inline]
 

Check if back-face culling is enabled.

Check if the ray intersection also test on back-faces.

Returns:
true, if back-face culling is enabled, meaning no back-face will be returned.

virtual NVSG_API void nvtraverser::RayIntersectTraverser::doApply const nvsg::ViewState pViewState,
const nvsg::Scene pScene
[protected, virtual]
 

Apply the traverser to the scene.

Start the intersection calculation of the given ray with the scene objects.

Parameters:
pViewState  Current view state
pScene  Scene to intersect the ray with

Reimplemented from nvtraverser::Traverser.

virtual NVSG_API void nvtraverser::RayIntersectTraverser::handleGeoNode const nvsg::GeoNode p  )  [protected, virtual]
 

Routine to handle a GeoNode while traversing the scene graph.

This routine gets called for each GeoNode object that will be visited while traversing the scene graph. The currently visited GeoNode object is pointed to by p. The base implementation ensures that all underlying components will be traversed in a correct way. For derived classes, it is recommended to always call the base implementation for traversing purposes.

Note:
: The behavior is undefined if p points to an invalid location.

Reimplemented from nvtraverser::Traverser.

virtual NVSG_API void nvtraverser::RayIntersectTraverser::handleGroup const nvsg::Group p  )  [protected, virtual]
 

Routine to handle a Group node while traversing the scene graph.

This routine gets called for each Group object that will be visited while traversing the scene graph. The currently visited Group object is pointed to by p. The base implementation ensures that all underlying components will be traversed in a correct way. For derived classes, it is recommended to always call the base implementation for traversing purposes.

Note:
: The behavior is undefined if p points to an invalid location.

Reimplemented from nvtraverser::Traverser.

virtual NVSG_API void nvtraverser::RayIntersectTraverser::handleLOD const nvsg::LOD p  )  [protected, virtual]
 

Routine to handle a LOD (Level Of Detail) node while traversing the scene graph.

This routine gets called for each LOD object that will be visited while traversing the scene graph. The currently visited LOD object is pointed to by p. The base implementation ensures that all underlying components will be traversed in a correct way. For derived classes, it is recommended to always call the base implementation for traversing purposes.

Note:
: The behavior is undefined if p points to an invalid location.

Reimplemented from nvtraverser::ModelViewTraverser.

virtual NVSG_API void nvtraverser::RayIntersectTraverser::handleSwitch const nvsg::Switch p  )  [protected, virtual]
 

Routine to handle a Switch node while traversing the scene graph.

This routine gets called for each Switch object that will be visited while traversing the scene graph. The currently visited Switch object is pointed to by p. The base implementation ensures that all underlying components will be traversed in a correct way. For derived classes, it is recommended to always call the base implementation for traversing purposes.

Note:
: The behavior is undefined if p points to an invalid location.

Reimplemented from nvtraverser::Traverser.

virtual NVSG_API void nvtraverser::RayIntersectTraverser::handleTransform const nvsg::Transform p  )  [protected, virtual]
 

Provide special treatment of a Transform node.

On a Transform the modelview matrix is modified, the children are traversed, and the modelview matrix is restored.

Reimplemented from nvtraverser::ModelViewTraverser.

virtual NVSG_API void nvtraverser::RayIntersectTraverser::handleQuads const nvsg::Quads p  )  [protected, virtual]
 

Routine to handle a Quads object while traversing the scene graph.

This routine gets called for each Quads object that will be visited while traversing the scene graph. The currently visited Quads object is pointed to by p. The base implementation ensures that all underlying components will be traversed in a correct way. For derived classes, it is recommended to always call the base implementation for traversing purposes.

Note:
: The behavior is undefined if p points to an invalid location.

Reimplemented from nvtraverser::Traverser.

virtual NVSG_API void nvtraverser::RayIntersectTraverser::handleQuadStrips const nvsg::QuadStrips p  )  [protected, virtual]
 

Routine to handle a QuadStrips object while traversing the scene graph.

This routine gets called for each QuadStrips object that will be visited while traversing the scene graph. The currently visited QuadStrips object is pointed to by p. The base implementation ensures that all underlying components will be traversed in a correct way. For derived classes, it is recommended to always call the base implementation for traversing purposes.

Note:
: The behavior is undefined if p points to an invalid location.

Reimplemented from nvtraverser::Traverser.

virtual NVSG_API void nvtraverser::RayIntersectTraverser::handleTriangles const nvsg::Triangles p  )  [protected, virtual]
 

Routine to handle a Triangles object while traversing the scene graph.

This routine gets called for each Triangles object that will be visited while traversing the scene graph. The currently visited Triangles object is pointed to by p. The base implementation ensures that all underlying components will be traversed in a correct way. For derived classes, it is recommended to always call the base implementation for traversing purposes.

Note:
: The behavior is undefined if p points to an invalid location.

Reimplemented from nvtraverser::Traverser.

virtual NVSG_API void nvtraverser::RayIntersectTraverser::handleTriStrips const nvsg::TriStrips p  )  [protected, virtual]
 

Routine to handle a TriStrips object while traversing the scene graph.

This routine gets called for each TriStrips object that will be visited while traversing the scene graph. The currently visited TriStrips object is pointed to by p. The base implementation ensures that all underlying components will be traversed in a correct way. For derived classes, it is recommended to always call the base implementation for traversing purposes.

Note:
: The behavior is undefined if p points to an invalid location.

Reimplemented from nvtraverser::Traverser.

virtual NVSG_API bool nvtraverser::RayIntersectTraverser::preTraverseTransform const nvsg::Transform p  )  [protected, virtual]
 

Handles actions to take between transform stack adjustment and traversal.

Adjusts the ray origin and direction and the camera direction in model space.

Returns:
result of the base class (ModelViewTraverser).
Parameters:
p  Transform node to traverse next

Reimplemented from nvtraverser::ModelViewTraverser.

virtual NVSG_API void nvtraverser::RayIntersectTraverser::postTraverseTransform const nvsg::Transform p  )  [protected, virtual]
 

Handles stuff to do between traversal and transform stack adjustment.

Readjusts the ray origin and direction and the camera direction in model space.

Parameters:
p  Transform node that was traversed immediately before this call.

Reimplemented from nvtraverser::ModelViewTraverser.

NVSG_API bool nvtraverser::RayIntersectTraverser::checkIntersection const nvmath::Sphere3f sphere  )  [protected]
 

Check the current ray for intersection with a Sphere3f.

Returns:
true, if the ray intersects sphere, otherwise false.

NVSG_API bool nvtraverser::RayIntersectTraverser::intersectTriangle const nvmath::Vec3f v0,
const nvmath::Vec3f v1,
const nvmath::Vec3f v2,
nvmath::Vec3f isp,
float &  dist
[protected]
 

Intersect with triangle.

This method tells if it intersects the triangle or not. It also calculates the intersection point between triangle and ray and the distance of the intersection from the origin of the ray.

Returns:
true: intersection in front of the ray origin, false: no such intersection
Parameters:
v0  First vertex of the triangle
v1  Second vertex of the triangle
v2  Third vertex of the triangle
isp  Result: intersection point (world space)
dist  Result: distance from camera to intersection

NVSG_API void nvtraverser::RayIntersectTraverser::storeIntersection const nvsg::GeoSet p,
const nvmath::Vec3f isp,
float  dist
[protected]
 

store the intersection point isp.

If the point isn't clipped, it is stored to the intersection list.

Parameters:
p  GeoSet that holds the intersection
isp  intersection point
dist  distance from camera to intersection


Member Data Documentation

const nvmath::Vec3f nvtraverser::RayIntersectTraverser::_RAY_ORIGIN_DEFAULT [static, protected]
 

Default value: (0.f, 0.f, 0.f).

const nvmath::Vec3f nvtraverser::RayIntersectTraverser::_RAY_DIRECTION_DEFAULT [static, protected]
 

Default value: (0.f, 0.f, -1.f).

bool nvtraverser::RayIntersectTraverser::m_backFaceCulling [protected]
 

true: consider backface culling

bool nvtraverser::RayIntersectTraverser::m_ccw [protected]
 

true: winding is supposed to be counterclockwise

bool nvtraverser::RayIntersectTraverser::m_camClipping [protected]
 

true: use camera far/near clipping planes

nvmath::Vec3f nvtraverser::RayIntersectTraverser::m_rayOrigin [protected]
 

Origin point of the ray - default (0,0,0).

nvmath::Vec3f nvtraverser::RayIntersectTraverser::m_rayDir [protected]
 

Direction of the ray - default (0,0,-1).

const nvsg::Camera* nvtraverser::RayIntersectTraverser::m_camera [protected]
 

Camera of the scene that came in via apply (we ref/unref it).

std::stack<nvmath::Vec3f> nvtraverser::RayIntersectTraverser::m_msRayOrigin [protected]
 

stack of Origin point of the ray in model space

std::stack<nvmath::Vec3f> nvtraverser::RayIntersectTraverser::m_msRayDir [protected]
 

stack of Direction of the ray in model space

std::stack<nvmath::Vec3f> nvtraverser::RayIntersectTraverser::m_msCamDir [protected]
 

stack of camera direction in model space

std::vector<Intersection> nvtraverser::RayIntersectTraverser::m_intersectionList [protected]
 

Intersection list containing all intersections.

size_t nvtraverser::RayIntersectTraverser::m_nearestIntIdx [protected]
 

Index of the nearest z intersection.

nvsg::Path* nvtraverser::RayIntersectTraverser::m_curPath [protected]
 

Current path.

size_t nvtraverser::RayIntersectTraverser::m_currentFrame [protected]
 

This frame is to be used in an animation sequence.

float nvtraverser::RayIntersectTraverser::m_scaleFactor [protected]
 

Adjusts distances by the scalings of the Transform nodes.


The documentation for this class was generated from the following file:
Generated on Tue Mar 1 13:21:06 2005 for NVSGSDK by NVIDIA