dtCore::Isector Class Reference

This class is used to check for intersections of a line segment with geometry. More...

#include <isector.h>

Inheritance diagram for dtCore::Isector:

dtCore::Transformable dtCore::DeltaDrawable dtCore::Base

List of all members.

Public Member Functions

 Isector (Scene *scene=NULL)
 Constructs a new intersection query.
 Isector (const osg::Vec3 &start, const osg::Vec3 &dir, Scene *scene=NULL)
 Constructs a new intersection query using a ray constructed with the specified parameters.
 Isector (Scene *scene, const osg::Vec3 &start, const osg::Vec3 &end)
 Constructs a new intersection query using a line segment with the specified parameters.
void SetGeometry (DeltaDrawable *drawable)
 Sets a drawable as the root of the intersection tests.
void ClearQueryRoot ()
 Clears the currently assigned root drawable of the intersection tests.
DeltaDrawableGetQueryRoot ()
 
Returns:
the root of the scene to query.

const DeltaDrawableGetQueryRoot () const
 
Returns:
the root of the scene to query.

void SetScene (Scene *newScene)
 Sets the scene to use as the base for the scene query.
SceneGetScene ()
 
Returns:
the scene being queried.

const SceneGetScene () const
 
Returns:
the scene being queried.

void SetEyePoint (const osg::Vec3 &newEyePoint)
 Sets the eyepoint.
const osg::Vec3 GetEyePoint () const
 Gets the starting position of the intersection ray.
void SetUseEyePoint (bool newValue)
 Sets if this Isector should consider the eye point for LOD calculations when doing the intersection or if it should ignore it and always use the highest LOD when intersecting.S.
bool GetUseEyePoint () const
 
Returns:
true if the eye point is being considered for LOD calculation when doing an intersection.

void SetStartPosition (const osg::Vec3 &start)
 Sets the starting position of the intersection ray.
const osg::Vec3 & GetStartPosition () const
 Gets the starting position of the intersection ray.
void SetEndPosition (const osg::Vec3 &endXYZ)
void SetDirection (const osg::Vec3 &dir)
 Sets the direction of the intersection ray.
const osg::Vec3 & GetDirection () const
 Gets the direction of the intersection ray.
void SetLength (float distance)
 Set the length of the isector.
float GetLength () const
 Get the length of the isector.
void GetHitPoint (osg::Vec3 &xyz, int pointNum=0) const
 
Returns:
the intersected point

void GetHitPointNormal (osg::Vec3 &normal, int pointNum=0) const
 
Returns:
the normal at the intersected point

int GetNumberOfHits () const
 Get the number of intersected items.
bool Update ()
 Ray traces the scene.
void Reset ()
 Resets the intersection query.
DeltaDrawableGetClosestDeltaDrawable ()
 Gets the DeltaDrawable that is closest to the query's starting point along the intersection ray.
const DeltaDrawableGetClosestDeltaDrawable () const
 Gets the DeltaDrawable that is closest to the query's starting point along the intersection ray.
const osg::LineSegment * GetLineSegment () const
 Gets the line segment used for this intersection query.
osgUtil::IntersectVisitor & GetIntersectVisitor ()
 Gives access to the underlying intersect visitor.
DeltaDrawableMapNodePathToDrawable (osg::NodePath &geode)
 Finds the DeltaDrawable that contains the given geometry node.
const
osgUtil::IntersectVisitor::HitList & 
GetHitList () const
 Get the Hitlist member.
osgUtil::IntersectVisitor::HitList & GetHitList ()
 Get the Hitlist member.

Protected Member Functions

virtual ~Isector ()


Detailed Description

This class is used to check for intersections of a line segment with geometry.

Supply the starting position, the direction vector, the length of the Isector, and the geometry to intersect with.

If no geometry is specified with SetGeometry(), the whole Scene is searched.

After calling Update(), the results of the intersection may be queried with GetHitPoint().

Note:
Although derived from Transformable, this class does not use any inherited functionality from Transformable at this point.
To search the whole Scene for the height of terrain at a given xyz:
      Isector *isect = new Isector( mScene );
      osg::Vec3 queryPoint( 500.0f, 500.0f, 1000.0f );
      isect->SetStartPosition( queryPoint );
      osg::Vec3 direction( 0.0f, 0.0f, -1.0f );
      isect->SetDirection( direction );

      isect->Update();

      osg::Vec3 hitPt;
      isect->GetHitPoint( hitPt );

Constructor & Destructor Documentation

dtCore::Isector::Isector ( dtCore::Scene scene = NULL  ) 

Constructs a new intersection query.

Parameters:
scene A Delta3D scene to intersect. If this is 0, a root drawable must be set.
Note:
The default ray has a starting position of (0,0,0) and a direction of (0,1,0).

dtCore::Isector::Isector ( const osg::Vec3 &  start,
const osg::Vec3 &  dir,
dtCore::Scene scene = NULL 
)

Constructs a new intersection query using a ray constructed with the specified parameters.

Parameters:
start The start of the ray.
dir The direction the ray is traveling.
scene The Delta3D scene to intersect.

dtCore::Isector::Isector ( dtCore::Scene scene,
const osg::Vec3 &  start,
const osg::Vec3 &  end 
)

Constructs a new intersection query using a line segment with the specified parameters.

Parameters:
scene The Delta3D scene to intersect.
start The start of the line segment.
end The end point of the line segment.

dtCore::Isector::~Isector (  )  [protected, virtual]


Member Function Documentation

void dtCore::Isector::SetGeometry ( DeltaDrawable drawable  )  [inline]

Sets a drawable as the root of the intersection tests.

If this is specified, it will take precedence over the currently assigned Delta3D scene.

Parameters:
drawable The drawable to intersect.

void dtCore::Isector::ClearQueryRoot (  )  [inline]

Clears the currently assigned root drawable of the intersection tests.

DeltaDrawable* dtCore::Isector::GetQueryRoot (  )  [inline]

Returns:
the root of the scene to query.

It will return if this is using the entire scene.

const DeltaDrawable* dtCore::Isector::GetQueryRoot (  )  const [inline]

Returns:
the root of the scene to query.

It will return if this is using the entire scene.

void dtCore::Isector::SetScene ( dtCore::Scene newScene  ) 

Sets the scene to use as the base for the scene query.

Scene* dtCore::Isector::GetScene (  )  [inline]

Returns:
the scene being queried.

const Scene* dtCore::Isector::GetScene (  )  const [inline]

Returns:
the scene being queried.

void dtCore::Isector::SetEyePoint ( const osg::Vec3 &  newEyePoint  )  [inline]

Sets the eyepoint.

This is used for LOD calculations when doing intersections.

Parameters:
the eye point

const osg::Vec3 dtCore::Isector::GetEyePoint (  )  const [inline]

Gets the starting position of the intersection ray.

Returns:
A vector containing the start position of the intersection ray.

void dtCore::Isector::SetUseEyePoint ( bool  newValue  ) 

Sets if this Isector should consider the eye point for LOD calculations when doing the intersection or if it should ignore it and always use the highest LOD when intersecting.S.

bool dtCore::Isector::GetUseEyePoint (  )  const

Returns:
true if the eye point is being considered for LOD calculation when doing an intersection.

void dtCore::Isector::SetStartPosition ( const osg::Vec3 &  start  )  [inline]

Sets the starting position of the intersection ray.

Parameters:
start The start position.

const osg::Vec3& dtCore::Isector::GetStartPosition (  )  const [inline]

Gets the starting position of the intersection ray.

Returns:
A vector containing the start position of the intersection ray.

void dtCore::Isector::SetEndPosition ( const osg::Vec3 &  endXYZ  )  [inline]

void dtCore::Isector::SetDirection ( const osg::Vec3 &  dir  )  [inline]

Sets the direction of the intersection ray.

Parameters:
dir The direction vector. This is normalized before being assigned.

const osg::Vec3& dtCore::Isector::GetDirection (  )  const [inline]

Gets the direction of the intersection ray.

Returns:
The direction unit vector.

void dtCore::Isector::SetLength ( float  distance  )  [inline]

Set the length of the isector.

float dtCore::Isector::GetLength (  )  const [inline]

Get the length of the isector.

void dtCore::Isector::GetHitPoint ( osg::Vec3 &  xyz,
int  pointNum = 0 
) const

Returns:
the intersected point

Get the intersected point since the last call to Update().

Parameters:
xyz : The xyz position to be filled out [in/out]
pointNum,: Which intersection point to return [0..GetNumberOfHits()]

void dtCore::Isector::GetHitPointNormal ( osg::Vec3 &  normal,
int  pointNum = 0 
) const

Returns:
the normal at the intersected point

Get the normal at the intersected point.

int dtCore::Isector::GetNumberOfHits (  )  const

Get the number of intersected items.

Get the number of items that were intersected by this Isector.

Note: Isector::Update() must be called prior to calling this method.

Returns:
The number of intersected items

bool dtCore::Isector::Update (  ) 

Ray traces the scene.

Returns:
True if any intersections were detected.
Note:
If the query root has been set, only the query root drawable and its children are candidates for intersection. If not, all drawables in the scene are possibilities.

void dtCore::Isector::Reset (  ) 

Resets the intersection query.

Call this in between disjoint intersection executions.

DeltaDrawable* dtCore::Isector::GetClosestDeltaDrawable (  )  [inline]

Gets the DeltaDrawable that is closest to the query's starting point along the intersection ray.

Returns:
A valid DeltaDrawable.

const DeltaDrawable* dtCore::Isector::GetClosestDeltaDrawable (  )  const [inline]

Gets the DeltaDrawable that is closest to the query's starting point along the intersection ray.

Returns:
A valid DeltaDrawable.

const osg::LineSegment* dtCore::Isector::GetLineSegment (  )  const [inline]

Gets the line segment used for this intersection query.

Returns:

osgUtil::IntersectVisitor& dtCore::Isector::GetIntersectVisitor (  )  [inline]

Gives access to the underlying intersect visitor.

This is useful when a more detailed description of the intersection tests are required.

Returns:

dtCore::DeltaDrawable * dtCore::Isector::MapNodePathToDrawable ( osg::NodePath &  geode  ) 

Finds the DeltaDrawable that contains the given geometry node.

Parameters:
geode The node to search for.
Returns:
A valid DeltaDrawable if one was found or 0 otherwise.

const osgUtil::IntersectVisitor::HitList& dtCore::Isector::GetHitList (  )  const [inline]

Get the Hitlist member.

Do not assume this list is sorted based on distance from the starting point.

Returns:
a const reference to the entire hit list

osgUtil::IntersectVisitor::HitList& dtCore::Isector::GetHitList (  )  [inline]

Get the Hitlist member.

Do not assume this list is sorted based on distance from the starting point.

Returns:
a non-const reference to the entire hit list


http://www.delta3d.org
2.0.0 generated 14 Feb 2008