Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Ogre::RaySceneQuery Class Reference

Specialises the SceneQuery class for querying along a ray. More...

#include <OgreSceneQuery.h>

Inheritance diagram for Ogre::RaySceneQuery:

Inheritance graph
[legend]
Collaboration diagram for Ogre::RaySceneQuery:

Collaboration graph
[legend]
List of all members.

Public Types

enum  WorldFragmentType {
  WFT_NONE, WFT_PLANE_BOUNDED_REGION, WFT_SINGLE_INTERSECTION, WFT_CUSTOM_GEOMETRY,
  WFT_RENDER_OPERATION
}
 This type can be used by collaborating applications & SceneManagers to agree on the type of world geometry to be returned from queries. More...


Public Methods

 RaySceneQuery (SceneManager *mgr)
virtual ~RaySceneQuery ()
void setRay (const Ray &ray)
 Sets the ray which is to be used for this query.

const RaygetRay (void) const
 Gets the ray which is to be used for this query.

void setSortByDistance (bool sort, ushort maxresults=0)
 Sets whether the results of this query will be sorted by distance along the ray.

bool getSortByDistance (void) const
 Gets whether the results are sorted by distance.

ushort getMaxResults (void) const
 Gets the maximum number of results returned from the query (only relevant if results are being sorted).

virtual RaySceneQueryResultexecute (void)
 Executes the query, returning the results back in one list.

virtual void execute (RaySceneQueryListener *listener)=0
 Executes the query and returns each match through a listener interface.

virtual RaySceneQueryResultgetLastResults (void) const
 Gets the results of the last query that was run using this object, provided the query was executed using the collection-returning version of execute.

virtual void clearResults (void)
 Clears the results of the last query execution.

bool queryResult (MovableObject *obj, Real distance)
 Self-callback in order to deal with execute which returns collection.

bool queryResult (SceneQuery::WorldFragment *fragment, Real distance)
 Self-callback in order to deal with execute which returns collection.

virtual void setQueryMask (unsigned long mask)
 Sets the mask for results of this query.

virtual unsigned long getQueryMask (void) const
 Returns the current mask for this query.

virtual void setWorldFragmentType (enum WorldFragmentType wft)
 Tells the query what kind of world geometry to return from queries; often the full renderable geometry is not what is needed.

virtual WorldFragmentType getWorldFragmentType (void) const
 Gets the current world fragment types to be returned from the query.

virtual const std::set< WorldFragmentType > * getSupportedWorldFragmentTypes (void) const
 Returns the types of world fragments this query supports.


Protected Attributes

Ray mRay
bool mSortByDistance
ushort mMaxResults
RaySceneQueryResultmLastResult
SceneManagermParentSceneMgr
unsigned long mQueryMask
std::set< WorldFragmentTypemSupportedWorldFragments
WorldFragmentType mWorldFragmentType

Detailed Description

Specialises the SceneQuery class for querying along a ray.

Definition at line 332 of file OgreSceneQuery.h.


Member Enumeration Documentation

enum Ogre::SceneQuery::WorldFragmentType [inherited]
 

This type can be used by collaborating applications & SceneManagers to agree on the type of world geometry to be returned from queries.

Not all these types will be supported by all SceneManagers; once the application has decided which SceneManager specialisation to use, it is expected that it will know which type of world geometry abstraction is available to it.

Enumeration values:
WFT_NONE  Return no world geometry hits at all.
WFT_PLANE_BOUNDED_REGION  Return pointers to convex plane-bounded regions.
WFT_SINGLE_INTERSECTION  Return a single intersection point (typically RaySceneQuery only).
WFT_CUSTOM_GEOMETRY  Custom geometry as defined by the SceneManager.
WFT_RENDER_OPERATION  General RenderOperation structure.

Definition at line 72 of file OgreSceneQuery.h.


Constructor & Destructor Documentation

Ogre::RaySceneQuery::RaySceneQuery SceneManager   mgr
 

Definition at line 158 of file OgreSceneQuery.cpp.

References mLastResult, mMaxResults, and mSortByDistance.

Ogre::RaySceneQuery::~RaySceneQuery   [virtual]
 

Definition at line 165 of file OgreSceneQuery.cpp.

References clearResults().


Member Function Documentation

void Ogre::RaySceneQuery::clearResults void    [virtual]
 

Clears the results of the last query execution.

Remarks:
You only need to call this if you specifically want to free up the memory used by this object to hold the last query results. This object clears the results itself when executing and when destroying itself.

Definition at line 233 of file OgreSceneQuery.cpp.

References mLastResult.

Referenced by execute(), and ~RaySceneQuery().

virtual void Ogre::RaySceneQuery::execute RaySceneQueryListener   listener [pure virtual]
 

Executes the query and returns each match through a listener interface.

Remarks:
Note that this method does not store the results of the query internally so does not update the 'last result' value. This means that this version of execute is more lightweight and therefore more efficient than the version which returns the results as a collection.

Implemented in Ogre::DefaultRaySceneQuery.

RaySceneQueryResult & Ogre::RaySceneQuery::execute void    [virtual]
 

Executes the query, returning the results back in one list.

Remarks:
This method executes the scene query as configured, gathers the results into one structure and returns a reference to that structure. These results will also persist in this query object until the next query is executed, or clearResults() is called. An more lightweight version of this method that returns results through a listener is also available.

Definition at line 196 of file OgreSceneQuery.cpp.

References clearResults(), mLastResult, mMaxResults, and Ogre::RaySceneQueryResult.

RaySceneQueryResult & Ogre::RaySceneQuery::getLastResults void    const [virtual]
 

Gets the results of the last query that was run using this object, provided the query was executed using the collection-returning version of execute.

Definition at line 227 of file OgreSceneQuery.cpp.

References mLastResult, and Ogre::RaySceneQueryResult.

ushort Ogre::RaySceneQuery::getMaxResults void    const
 

Gets the maximum number of results returned from the query (only relevant if results are being sorted).

Definition at line 191 of file OgreSceneQuery.cpp.

References mMaxResults, and Ogre::ushort.

unsigned long Ogre::SceneQuery::getQueryMask void    const [virtual, inherited]
 

Returns the current mask for this query.

Definition at line 46 of file OgreSceneQuery.cpp.

References Ogre::SceneQuery::mQueryMask.

const Ray & Ogre::RaySceneQuery::getRay void    const
 

Gets the ray which is to be used for this query.

Definition at line 175 of file OgreSceneQuery.cpp.

References mRay.

bool Ogre::RaySceneQuery::getSortByDistance void    const
 

Gets whether the results are sorted by distance.

Definition at line 186 of file OgreSceneQuery.cpp.

References mSortByDistance.

virtual const std::set<WorldFragmentType>* Ogre::SceneQuery::getSupportedWorldFragmentTypes void    const [virtual, inherited]
 

Returns the types of world fragments this query supports.

Definition at line 151 of file OgreSceneQuery.h.

SceneQuery::WorldFragmentType Ogre::SceneQuery::getWorldFragmentType void    const [virtual, inherited]
 

Gets the current world fragment types to be returned from the query.

Definition at line 63 of file OgreSceneQuery.cpp.

References Ogre::SceneQuery::mWorldFragmentType.

bool Ogre::RaySceneQuery::queryResult SceneQuery::WorldFragment   fragment,
Real    distance
[virtual]
 

Self-callback in order to deal with execute which returns collection.

Implements Ogre::RaySceneQueryListener.

Definition at line 254 of file OgreSceneQuery.cpp.

References Ogre::RaySceneQueryResultEntry::distance, mLastResult, Ogre::RaySceneQueryResultEntry::movable, Ogre::Real, and Ogre::RaySceneQueryResultEntry::worldFragment.

bool Ogre::RaySceneQuery::queryResult MovableObject   obj,
Real    distance
[virtual]
 

Self-callback in order to deal with execute which returns collection.

Implements Ogre::RaySceneQueryListener.

Definition at line 242 of file OgreSceneQuery.cpp.

References Ogre::RaySceneQueryResultEntry::distance, mLastResult, Ogre::RaySceneQueryResultEntry::movable, Ogre::Real, and Ogre::RaySceneQueryResultEntry::worldFragment.

void Ogre::SceneQuery::setQueryMask unsigned long    mask [virtual, inherited]
 

Sets the mask for results of this query.

Remarks:
This method allows you to set a 'mask' to limit the results of this query to certain types of result. The actual meaning of this value is up to the application; basically MovableObject instances will only be returned from this query if a bitwise AND operation between this mask value and the MovableObject::getQueryFlags value is non-zero. The application will have to decide what each of the bits means.

Definition at line 41 of file OgreSceneQuery.cpp.

References Ogre::SceneQuery::mQueryMask.

Referenced by Ogre::SceneManager::createAABBQuery(), Ogre::SceneManager::createIntersectionQuery(), Ogre::BspSceneManager::createIntersectionQuery(), Ogre::SceneManager::createRayQuery(), and Ogre::SceneManager::createSphereQuery().

void Ogre::RaySceneQuery::setRay const Ray   ray
 

Sets the ray which is to be used for this query.

Definition at line 170 of file OgreSceneQuery.cpp.

References mRay.

void Ogre::RaySceneQuery::setSortByDistance bool    sort,
ushort    maxresults = 0
 

Sets whether the results of this query will be sorted by distance along the ray.

Remarks:
Often you want to know what was the first object a ray intersected with, and this method allows you to ask the query to sort the results so that the nearest results are listed first.

Note that because the query returns results based on bounding volumes, the ray may not actually intersect the detail of the objects returned from the query, just their bounding volumes. For this reason the caller is advised to use more detailed intersection tests on the results if a more accurate result is required; OGRE uses bounds checking in order to give the most speedy results since not all applications need extreme accuracy.

Parameters:
sort  If true, results will be sorted.
maxresults  If sorting is enabled, this value can be used to constrain the maximum number of results that are returned. Please note (as above) that the use of bounding volumes mean that accuracy is not guaranteed; if in doubt, allow more results and filter them in more detail. 0 means unlimited results.

Definition at line 180 of file OgreSceneQuery.cpp.

References mMaxResults, mSortByDistance, and Ogre::ushort.

void Ogre::SceneQuery::setWorldFragmentType enum WorldFragmentType    wft [virtual, inherited]
 

Tells the query what kind of world geometry to return from queries; often the full renderable geometry is not what is needed.

Remarks:
The application receiving the world geometry is expected to know what to do with it; inevitably this means that the application must have knowledge of at least some of the structures used by the custom SceneManager.

The default setting is WFT_NONE.

Definition at line 51 of file OgreSceneQuery.cpp.

References Except, Ogre::SceneQuery::mSupportedWorldFragments, and Ogre::SceneQuery::mWorldFragmentType.


Member Data Documentation

RaySceneQueryResult* Ogre::RaySceneQuery::mLastResult [protected]
 

Definition at line 338 of file OgreSceneQuery.h.

Referenced by clearResults(), execute(), getLastResults(), queryResult(), and RaySceneQuery().

ushort Ogre::RaySceneQuery::mMaxResults [protected]
 

Definition at line 337 of file OgreSceneQuery.h.

Referenced by execute(), getMaxResults(), RaySceneQuery(), and setSortByDistance().

SceneManager* Ogre::SceneQuery::mParentSceneMgr [protected, inherited]
 

Definition at line 112 of file OgreSceneQuery.h.

Referenced by Ogre::DefaultSphereSceneQuery::execute(), Ogre::DefaultRaySceneQuery::execute(), Ogre::DefaultAxisAlignedBoxSceneQuery::execute(), Ogre::DefaultIntersectionSceneQuery::execute(), and Ogre::BspIntersectionSceneQuery::execute().

unsigned long Ogre::SceneQuery::mQueryMask [protected, inherited]
 

Definition at line 113 of file OgreSceneQuery.h.

Referenced by Ogre::DefaultIntersectionSceneQuery::execute(), Ogre::BspIntersectionSceneQuery::execute(), Ogre::SceneQuery::getQueryMask(), and Ogre::SceneQuery::setQueryMask().

Ray Ogre::RaySceneQuery::mRay [protected]
 

Definition at line 335 of file OgreSceneQuery.h.

Referenced by Ogre::DefaultRaySceneQuery::execute(), getRay(), and setRay().

bool Ogre::RaySceneQuery::mSortByDistance [protected]
 

Definition at line 336 of file OgreSceneQuery.h.

Referenced by getSortByDistance(), RaySceneQuery(), and setSortByDistance().

std::set<WorldFragmentType> Ogre::SceneQuery::mSupportedWorldFragments [protected, inherited]
 

Definition at line 114 of file OgreSceneQuery.h.

Referenced by Ogre::BspIntersectionSceneQuery::BspIntersectionSceneQuery(), Ogre::DefaultAxisAlignedBoxSceneQuery::DefaultAxisAlignedBoxSceneQuery(), Ogre::DefaultIntersectionSceneQuery::DefaultIntersectionSceneQuery(), Ogre::DefaultRaySceneQuery::DefaultRaySceneQuery(), Ogre::DefaultSphereSceneQuery::DefaultSphereSceneQuery(), and Ogre::SceneQuery::setWorldFragmentType().

WorldFragmentType Ogre::SceneQuery::mWorldFragmentType [protected, inherited]
 

Definition at line 115 of file OgreSceneQuery.h.

Referenced by Ogre::SceneQuery::getWorldFragmentType(), and Ogre::SceneQuery::setWorldFragmentType().


The documentation for this class was generated from the following files:

Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:16:26 2004