OgreSceneQuery.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
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 __SceneQuery_H__
#define __SceneQuery_H__
#include "OgrePrerequisites.h"
#include "OgreAxisAlignedBox.h"
#include "OgreSphere.h"
#include "OgreRay.h"
#include "OgreRenderOperation.h"
#include "OgrePlaneBoundedVolume.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
// forward declaration
class SceneQueryListener;
class _OgreExport SceneQuery : public SceneMgtAlloc
{
public:
enum WorldFragmentType {
WFT_NONE,
WFT_PLANE_BOUNDED_REGION,
WFT_SINGLE_INTERSECTION,
WFT_CUSTOM_GEOMETRY,
WFT_RENDER_OPERATION
};
struct WorldFragment {
WorldFragmentType fragmentType;
Vector3 singleIntersection;
list<Plane>::type* planes;
void* geometry;
RenderOperation* renderOp;
};
protected:
SceneManager* mParentSceneMgr;
uint32 mQueryMask;
uint32 mQueryTypeMask;
set<WorldFragmentType>::type mSupportedWorldFragments;
WorldFragmentType mWorldFragmentType;
public:
SceneQuery(SceneManager* mgr);
virtual ~SceneQuery();
virtual void setQueryMask(uint32 mask);
virtual uint32 getQueryMask(void) const;
virtual void setQueryTypeMask(uint32 mask);
virtual uint32 getQueryTypeMask(void) const;
virtual void setWorldFragmentType(enum WorldFragmentType wft);
virtual WorldFragmentType getWorldFragmentType(void) const;
virtual const set<WorldFragmentType>::type* getSupportedWorldFragmentTypes(void) const
{return &mSupportedWorldFragments;}
};
class _OgreExport SceneQueryListener
{
public:
virtual ~SceneQueryListener() { }
virtual bool queryResult(MovableObject* object) = 0;
virtual bool queryResult(SceneQuery::WorldFragment* fragment) = 0;
};
typedef list<MovableObject*>::type SceneQueryResultMovableList;
typedef list<SceneQuery::WorldFragment*>::type SceneQueryResultWorldFragmentList;
struct _OgreExport SceneQueryResult : public SceneMgtAlloc
{
SceneQueryResultMovableList movables;
SceneQueryResultWorldFragmentList worldFragments;
};
class _OgreExport RegionSceneQuery
: public SceneQuery, public SceneQueryListener
{
protected:
SceneQueryResult* mLastResult;
public:
RegionSceneQuery(SceneManager* mgr);
virtual ~RegionSceneQuery();
virtual SceneQueryResult& execute(void);
virtual void execute(SceneQueryListener* listener) = 0;
virtual SceneQueryResult& getLastResults(void) const;
virtual void clearResults(void);
bool queryResult(MovableObject* first);
bool queryResult(SceneQuery::WorldFragment* fragment);
};
class _OgreExport AxisAlignedBoxSceneQuery : public RegionSceneQuery
{
protected:
AxisAlignedBox mAABB;
public:
AxisAlignedBoxSceneQuery(SceneManager* mgr);
virtual ~AxisAlignedBoxSceneQuery();
void setBox(const AxisAlignedBox& box);
const AxisAlignedBox& getBox(void) const;
};
class _OgreExport SphereSceneQuery : public RegionSceneQuery
{
protected:
Sphere mSphere;
public:
SphereSceneQuery(SceneManager* mgr);
virtual ~SphereSceneQuery();
void setSphere(const Sphere& sphere);
const Sphere& getSphere() const;
};
class _OgreExport PlaneBoundedVolumeListSceneQuery : public RegionSceneQuery
{
protected:
PlaneBoundedVolumeList mVolumes;
public:
PlaneBoundedVolumeListSceneQuery(SceneManager* mgr);
virtual ~PlaneBoundedVolumeListSceneQuery();
void setVolumes(const PlaneBoundedVolumeList& volumes);
const PlaneBoundedVolumeList& getVolumes() const;
};
/*
class _OgreExport PyramidSceneQuery : public RegionSceneQuery
{
public:
PyramidSceneQuery(SceneManager* mgr);
virtual ~PyramidSceneQuery();
};
*/
class _OgreExport RaySceneQueryListener
{
public:
virtual ~RaySceneQueryListener() { }
virtual bool queryResult(MovableObject* obj, Real distance) = 0;
virtual bool queryResult(SceneQuery::WorldFragment* fragment, Real distance) = 0;
};
struct _OgreExport RaySceneQueryResultEntry
{
Real distance;
MovableObject* movable;
SceneQuery::WorldFragment* worldFragment;
bool operator < (const RaySceneQueryResultEntry& rhs) const
{
return this->distance < rhs.distance;
}
};
typedef vector<RaySceneQueryResultEntry>::type RaySceneQueryResult;
class _OgreExport RaySceneQuery : public SceneQuery, public RaySceneQueryListener
{
protected:
Ray mRay;
bool mSortByDistance;
ushort mMaxResults;
RaySceneQueryResult mResult;
public:
RaySceneQuery(SceneManager* mgr);
virtual ~RaySceneQuery();
virtual void setRay(const Ray& ray);
virtual const Ray& getRay(void) const;
virtual void setSortByDistance(bool sort, ushort maxresults = 0);
virtual bool getSortByDistance(void) const;
virtual ushort getMaxResults(void) const;
virtual RaySceneQueryResult& execute(void);
virtual void execute(RaySceneQueryListener* listener) = 0;
virtual RaySceneQueryResult& getLastResults(void);
virtual void clearResults(void);
bool queryResult(MovableObject* obj, Real distance);
bool queryResult(SceneQuery::WorldFragment* fragment, Real distance);
};
class _OgreExport IntersectionSceneQueryListener
{
public:
virtual ~IntersectionSceneQueryListener() { }
virtual bool queryResult(MovableObject* first, MovableObject* second) = 0;
virtual bool queryResult(MovableObject* movable, SceneQuery::WorldFragment* fragment) = 0;
/* NB there are no results for world fragments intersecting other world fragments;
it is assumed that world geometry is either static or at least that self-intersections
are irrelevant or dealt with elsewhere (such as the custom scene manager) */
};
typedef std::pair<MovableObject*, MovableObject*> SceneQueryMovableObjectPair;
typedef std::pair<MovableObject*, SceneQuery::WorldFragment*> SceneQueryMovableObjectWorldFragmentPair;
typedef list<SceneQueryMovableObjectPair>::type SceneQueryMovableIntersectionList;
typedef list<SceneQueryMovableObjectWorldFragmentPair>::type SceneQueryMovableWorldFragmentIntersectionList;
struct _OgreExport IntersectionSceneQueryResult : public SceneMgtAlloc
{
SceneQueryMovableIntersectionList movables2movables;
SceneQueryMovableWorldFragmentIntersectionList movables2world;
};
class _OgreExport IntersectionSceneQuery
: public SceneQuery, public IntersectionSceneQueryListener
{
protected:
IntersectionSceneQueryResult* mLastResult;
public:
IntersectionSceneQuery(SceneManager* mgr);
virtual ~IntersectionSceneQuery();
virtual IntersectionSceneQueryResult& execute(void);
virtual void execute(IntersectionSceneQueryListener* listener) = 0;
virtual IntersectionSceneQueryResult& getLastResults(void) const;
virtual void clearResults(void);
bool queryResult(MovableObject* first, MovableObject* second);
bool queryResult(MovableObject* movable, SceneQuery::WorldFragment* fragment);
};
}
#include "OgreHeaderSuffix.h"
#endif
Ogre::IntersectionSceneQuery
Separate SceneQuery class to query for pairs of objects which are possibly intersecting one another...
Definition: OgreSceneQuery.h:512
Ogre::RaySceneQueryResultEntry::worldFragment
SceneQuery::WorldFragment * worldFragment
The world fragment, or NULL if this is not a fragment result.
Definition: OgreSceneQuery.h:365
Ogre::RaySceneQueryListener::~RaySceneQueryListener
virtual ~RaySceneQueryListener()
Definition: OgreSceneQuery.h:338
Ogre::SceneQueryMovableObjectWorldFragmentPair
std::pair< MovableObject *, SceneQuery::WorldFragment * > SceneQueryMovableObjectWorldFragmentPair
Definition: OgreSceneQuery.h:489
Ogre::SceneQuery::WFT_PLANE_BOUNDED_REGION
Return pointers to convex plane-bounded regions.
Definition: OgreSceneQuery.h:87
Ogre::SceneQueryListener::~SceneQueryListener
virtual ~SceneQueryListener()
Definition: OgreSceneQuery.h:190
OgreAxisAlignedBox.h
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::list
Definition: OgrePrerequisites.h:505
Ogre::RaySceneQuery::mSortByDistance
bool mSortByDistance
Definition: OgreSceneQuery.h:380
Ogre::MovableObject
Abstract class defining a movable object in a scene.
Definition: OgreMovableObject.h:60
Ogre::SceneQueryMovableWorldFragmentIntersectionList
list< SceneQueryMovableObjectWorldFragmentPair >::type SceneQueryMovableWorldFragmentIntersectionList
Definition: OgreSceneQuery.h:491
Ogre::SphereSceneQuery::mSphere
Sphere mSphere
Definition: OgreSceneQuery.h:290
Ogre::AxisAlignedBoxSceneQuery
Specialises the SceneQuery class for querying within an axis aligned box.
Definition: OgreSceneQuery.h:270
Ogre::Sphere
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:51
Ogre::IntersectionSceneQueryResult::movables2movables
SceneQueryMovableIntersectionList movables2movables
List of movable / movable intersections (entities, particle systems etc)
Definition: OgreSceneQuery.h:496
Ogre::IntersectionSceneQuery::mLastResult
IntersectionSceneQueryResult * mLastResult
Definition: OgreSceneQuery.h:516
Ogre::SceneQuery::mParentSceneMgr
SceneManager * mParentSceneMgr
Definition: OgreSceneQuery.h:123
Ogre::SceneQuery::WorldFragment::fragmentType
WorldFragmentType fragmentType
The type of this world fragment.
Definition: OgreSceneQuery.h:111
Ogre::SceneQuery::getSupportedWorldFragmentTypes
virtual const set< WorldFragmentType >::type * getSupportedWorldFragmentTypes(void) const
Returns the types of world fragments this query supports.
Definition: OgreSceneQuery.h:175
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::IntersectionSceneQueryListener
Alternative listener class for dealing with IntersectionSceneQuery.
Definition: OgreSceneQuery.h:461
Ogre::SceneQuery::mQueryTypeMask
uint32 mQueryTypeMask
Definition: OgreSceneQuery.h:125
Ogre::SceneQuery::WorldFragment::geometry
void * geometry
Custom geometry block, only applicable for WFT_CUSTOM_GEOMETRY.
Definition: OgreSceneQuery.h:117
Ogre::SceneQueryMovableObjectPair
std::pair< MovableObject *, MovableObject * > SceneQueryMovableObjectPair
Definition: OgreSceneQuery.h:488
Ogre::SphereSceneQuery
Specialises the SceneQuery class for querying within a sphere.
Definition: OgreSceneQuery.h:287
Ogre::SceneQueryResult::worldFragments
SceneQueryResultWorldFragmentList worldFragments
List of world fragments.
Definition: OgreSceneQuery.h:214
Ogre::RaySceneQueryResult
vector< RaySceneQueryResultEntry >::type RaySceneQueryResult
Definition: OgreSceneQuery.h:373
Ogre::SceneQuery::mSupportedWorldFragments
set< WorldFragmentType >::type mSupportedWorldFragments
Definition: OgreSceneQuery.h:126
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
OgrePlaneBoundedVolume.h
Ogre::PlaneBoundedVolumeListSceneQuery::mVolumes
PlaneBoundedVolumeList mVolumes
Definition: OgreSceneQuery.h:307
OgrePrerequisites.h
Ogre::SceneQueryResultWorldFragmentList
list< SceneQuery::WorldFragment * >::type SceneQueryResultWorldFragmentList
Definition: OgreSceneQuery.h:207
Ogre::SceneQuery::WorldFragmentType
WorldFragmentType
This type can be used by collaborating applications & SceneManagers to agree on the type of world geo...
Definition: OgreSceneQuery.h:83
Ogre::IntersectionSceneQueryResult::movables2world
SceneQueryMovableWorldFragmentIntersectionList movables2world
List of movable / world intersections.
Definition: OgreSceneQuery.h:498
Ogre::PlaneBoundedVolumeList
vector< PlaneBoundedVolume >::type PlaneBoundedVolumeList
Definition: OgrePlaneBoundedVolume.h:128
Ogre::RaySceneQuery
Specialises the SceneQuery class for querying along a ray.
Definition: OgreSceneQuery.h:376
Ogre::SceneQuery::WFT_CUSTOM_GEOMETRY
Custom geometry as defined by the SceneManager.
Definition: OgreSceneQuery.h:91
OgreRenderOperation.h
Ogre::PlaneBoundedVolumeListSceneQuery
Specialises the SceneQuery class for querying within a plane-bounded volume.
Definition: OgreSceneQuery.h:304
Ogre::set
Definition: OgrePrerequisites.h:519
Ogre::SceneQuery::WFT_SINGLE_INTERSECTION
Return a single intersection point (typically RaySceneQuery only)
Definition: OgreSceneQuery.h:89
Ogre::SceneQuery::mWorldFragmentType
WorldFragmentType mWorldFragmentType
Definition: OgreSceneQuery.h:127
Ogre::SceneQuery::WFT_NONE
Return no world geometry hits at all.
Definition: OgreSceneQuery.h:85
Ogre::RaySceneQueryResultEntry
This struct allows a single comparison of result data no matter what the type.
Definition: OgreSceneQuery.h:358
Ogre::SceneQuery::mQueryMask
uint32 mQueryMask
Definition: OgreSceneQuery.h:124
Ogre::SceneQuery
A class for performing queries on a scene.
Definition: OgreSceneQuery.h:74
OgreHeaderSuffix.h
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre::SceneQueryListener
This optional class allows you to receive per-result callbacks from SceneQuery executions instead of ...
Definition: OgreSceneQuery.h:187
OgreRay.h
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::RaySceneQueryResultEntry::distance
Real distance
Distance along the ray.
Definition: OgreSceneQuery.h:361
Ogre::SceneQueryResult
Holds the results of a scene query.
Definition: OgreSceneQuery.h:209
Ogre::IntersectionSceneQueryListener::~IntersectionSceneQueryListener
virtual ~IntersectionSceneQueryListener()
Definition: OgreSceneQuery.h:464
Ogre::SceneQuery::WorldFragment::renderOp
RenderOperation * renderOp
General render operation structure, fallback if nothing else is available.
Definition: OgreSceneQuery.h:119
Ogre::IntersectionSceneQueryResult
Holds the results of an intersection scene query (pair values).
Definition: OgreSceneQuery.h:493
Ogre::vector
Definition: OgrePrerequisites.h:491
Ogre::RegionSceneQuery::mLastResult
SceneQueryResult * mLastResult
Definition: OgreSceneQuery.h:227
OgreHeaderPrefix.h
Ogre::RaySceneQuery::mRay
Ray mRay
Definition: OgreSceneQuery.h:379
Ogre::RenderOperation
&#39;New&#39; rendering operation using vertex buffers.
Definition: OgreRenderOperation.h:45
Ogre::SceneQueryMovableIntersectionList
list< SceneQueryMovableObjectPair >::type SceneQueryMovableIntersectionList
Definition: OgreSceneQuery.h:490
Ogre::SceneQuery::WorldFragment::singleIntersection
Vector3 singleIntersection
Single intersection point, only applicable for WFT_SINGLE_INTERSECTION.
Definition: OgreSceneQuery.h:113
Ogre::RaySceneQueryListener
Alternative listener class for dealing with RaySceneQuery.
Definition: OgreSceneQuery.h:335
Ogre::ushort
unsigned short ushort
Definition: OgrePrerequisites.h:113
Ogre::list::type
std::list< T, A > type
Definition: OgrePrerequisites.h:508
Ogre::AxisAlignedBox
A 3D box aligned with the x/y/z axes.
Definition: OgreAxisAlignedBox.h:54
Ogre::SceneManager
Manages the organisation and rendering of a &#39;scene&#39; i.e.
Definition: OgreSceneManager.h:143
Ogre::SceneQueryResult::movables
SceneQueryResultMovableList movables
List of movable objects in the query (entities, particle systems etc)
Definition: OgreSceneQuery.h:212
Ogre::SceneQuery::WorldFragment
Represents part of the world geometry that is a result of a SceneQuery.
Definition: OgreSceneQuery.h:109
OgreSphere.h
Ogre::AxisAlignedBoxSceneQuery::mAABB
AxisAlignedBox mAABB
Definition: OgreSceneQuery.h:273
Ogre::RegionSceneQuery
Abstract class defining a query which returns single results from a region.
Definition: OgreSceneQuery.h:223
Ogre::RaySceneQuery::mResult
RaySceneQueryResult mResult
Definition: OgreSceneQuery.h:382
Ogre::RaySceneQuery::mMaxResults
ushort mMaxResults
Definition: OgreSceneQuery.h:381
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre::SceneQuery::WorldFragment::planes
list< Plane >::type * planes
Planes bounding a convex region, only applicable for WFT_PLANE_BOUNDED_REGION.
Definition: OgreSceneQuery.h:115
Ogre::RaySceneQueryResultEntry::movable
MovableObject * movable
The movable, or NULL if this is not a movable result.
Definition: OgreSceneQuery.h:363
Ogre::Ray
Representation of a ray in space, i.e.
Definition: OgreRay.h:46
Ogre::operator<
bool operator<(SharedPtr< T > const &a, SharedPtr< U > const &b)
Definition: OgreSharedPtr.h:326
Ogre::SceneQueryResultMovableList
list< MovableObject * >::type SceneQueryResultMovableList
Definition: OgreSceneQuery.h:206

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.