OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OgreSceneQuery.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2011 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __SceneQuery_H__
29 #define __SceneQuery_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreAxisAlignedBox.h"
33 #include "OgreSphere.h"
34 #include "OgreRay.h"
35 #include "OgreRenderOperation.h"
36 #include "OgrePlaneBoundedVolume.h"
37 
38 namespace Ogre {
39 
40  // forward declaration
41  class SceneQueryListener;
74  {
75  public:
92  WFT_RENDER_OPERATION
93  };
94 
108  struct WorldFragment {
116  void* geometry;
119 
120  };
121  protected:
127 
128  public:
130  SceneQuery(SceneManager* mgr);
131  virtual ~SceneQuery();
132 
142  virtual void setQueryMask(uint32 mask);
144  virtual uint32 getQueryMask(void) const;
145 
154  virtual void setQueryTypeMask(uint32 mask);
156  virtual uint32 getQueryTypeMask(void) const;
157 
168  virtual void setWorldFragmentType(enum WorldFragmentType wft);
169 
171  virtual WorldFragmentType getWorldFragmentType(void) const;
172 
175  {return &mSupportedWorldFragments;}
176 
177 
178  };
179 
187  {
188  public:
189  virtual ~SceneQueryListener() { }
195  virtual bool queryResult(MovableObject* object) = 0;
201  virtual bool queryResult(SceneQuery::WorldFragment* fragment) = 0;
202 
203  };
204 
209  {
214  };
215 
223  : public SceneQuery, public SceneQueryListener
224  {
225  protected:
227  public:
230  virtual ~RegionSceneQuery();
239  virtual SceneQueryResult& execute(void);
240 
248  virtual void execute(SceneQueryListener* listener) = 0;
249 
253  virtual SceneQueryResult& getLastResults(void) const;
260  virtual void clearResults(void);
261 
263  bool queryResult(MovableObject* first);
265  bool queryResult(SceneQuery::WorldFragment* fragment);
266  };
267 
270  {
271  protected:
273  public:
275  virtual ~AxisAlignedBoxSceneQuery();
276 
278  void setBox(const AxisAlignedBox& box);
279 
281  const AxisAlignedBox& getBox(void) const;
282 
283  };
284 
287  {
288  protected:
290  public:
292  virtual ~SphereSceneQuery();
294  void setSphere(const Sphere& sphere);
295 
297  const Sphere& getSphere() const;
298 
299  };
300 
304  {
305  protected:
307  public:
311  void setVolumes(const PlaneBoundedVolumeList& volumes);
312 
314  const PlaneBoundedVolumeList& getVolumes() const;
315 
316  };
317 
318 
319  /*
321  class _OgreExport PyramidSceneQuery : public RegionSceneQuery
322  {
323  public:
324  PyramidSceneQuery(SceneManager* mgr);
325  virtual ~PyramidSceneQuery();
326  };
327  */
328 
335  {
336  public:
344  virtual bool queryResult(MovableObject* obj, Real distance) = 0;
345 
352  virtual bool queryResult(SceneQuery::WorldFragment* fragment, Real distance) = 0;
353 
354  };
355 
358  {
366  bool operator < (const RaySceneQueryResultEntry& rhs) const
367  {
368  return this->distance < rhs.distance;
369  }
370 
371  };
373 
376  {
377  protected:
382 
383  public:
385  virtual ~RaySceneQuery();
387  virtual void setRay(const Ray& ray);
389  virtual const Ray& getRay(void) const;
408  virtual void setSortByDistance(bool sort, ushort maxresults = 0);
410  virtual bool getSortByDistance(void) const;
413  virtual ushort getMaxResults(void) const;
422  virtual RaySceneQueryResult& execute(void);
423 
431  virtual void execute(RaySceneQueryListener* listener) = 0;
432 
436  virtual RaySceneQueryResult& getLastResults(void);
443  virtual void clearResults(void);
444 
446  bool queryResult(MovableObject* obj, Real distance);
448  bool queryResult(SceneQuery::WorldFragment* fragment, Real distance);
449 
450 
451 
452 
453  };
454 
461  {
462  public:
470  virtual bool queryResult(MovableObject* first, MovableObject* second) = 0;
471 
478  virtual bool queryResult(MovableObject* movable, SceneQuery::WorldFragment* fragment) = 0;
479 
480  /* NB there are no results for world fragments intersecting other world fragments;
481  it is assumed that world geometry is either static or at least that self-intersections
482  are irrelevant or dealt with elsewhere (such as the custom scene manager) */
483 
484 
485  };
486 
487  typedef std::pair<MovableObject*, MovableObject*> SceneQueryMovableObjectPair;
488  typedef std::pair<MovableObject*, SceneQuery::WorldFragment*> SceneQueryMovableObjectWorldFragmentPair;
493  {
498 
499 
500 
501  };
502 
513  {
514  protected:
516  public:
518  virtual ~IntersectionSceneQuery();
519 
528  virtual IntersectionSceneQueryResult& execute(void);
529 
537  virtual void execute(IntersectionSceneQueryListener* listener) = 0;
538 
542  virtual IntersectionSceneQueryResult& getLastResults(void) const;
549  virtual void clearResults(void);
550 
552  bool queryResult(MovableObject* first, MovableObject* second);
554  bool queryResult(MovableObject* movable, SceneQuery::WorldFragment* fragment);
555  };
556 
560 }
561 
562 
563 
564 #endif
Representation of a ray in space, i.e.
Definition: OgreRay.h:46
IntersectionSceneQueryResult * mLastResult
Represents part of the world geometry that is a result of a SceneQuery.
float Real
Software floating point type.
std::pair< MovableObject *, MovableObject * > SceneQueryMovableObjectPair
unsigned int uint32
Definition: OgrePlatform.h:246
SceneQuery::WorldFragment * worldFragment
The world fragment, or NULL if this is not a fragment result.
#define _OgreExport
Definition: OgrePlatform.h:203
Holds the results of an intersection scene query (pair values).
RenderOperation * renderOp
General render operation structure, fallback if nothing else is available.
bool operator<(SharedPtr< T > const &a, SharedPtr< U > const &b)
A class for performing queries on a scene.
Manages the organisation and rendering of a 'scene' i.e.
Holds the results of a scene query.
This struct allows a single comparison of result data no matter what the type.
list< Plane >::type * planes
Planes bounding a convex region, only applicable for WFT_PLANE_BOUNDED_REGION.
Specialises the SceneQuery class for querying within a sphere.
A 3D box aligned with the x/y/z axes.
std::list< T, A > type
SceneQueryMovableIntersectionList movables2movables
List of movable / movable intersections (entities, particle systems etc)
Abstract class defining a movable object in a scene.
MovableObject * movable
The movable, or NULL if this is not a movable result.
Custom geometry as defined by the SceneManager.
vector< PlaneBoundedVolume >::type PlaneBoundedVolumeList
list< SceneQueryMovableObjectWorldFragmentPair >::type SceneQueryMovableWorldFragmentIntersectionList
SceneQueryResultMovableList movables
List of movable objects in the query (entities, particle systems etc)
Return a single intersection point (typically RaySceneQuery only)
SceneQueryResultWorldFragmentList worldFragments
List of world fragments.
Alternative listener class for dealing with RaySceneQuery.
Return no world geometry hits at all.
Alternative listener class for dealing with IntersectionSceneQuery.
WorldFragmentType fragmentType
The type of this world fragment.
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:51
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Real distance
Distance along the ray.
list< SceneQueryMovableObjectPair >::type SceneQueryMovableIntersectionList
SceneQueryResult * mLastResult
WorldFragmentType
This type can be used by collaborating applications & SceneManagers to agree on the type of world geo...
list< SceneQuery::WorldFragment * >::type SceneQueryResultWorldFragmentList
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
Vector3 singleIntersection
Single intersection point, only applicable for WFT_SINGLE_INTERSECTION.
unsigned short ushort
set< WorldFragmentType >::type mSupportedWorldFragments
'New' rendering operation using vertex buffers.
Abstract class defining a query which returns single results from a region.
Specialises the SceneQuery class for querying within an axis aligned box.
RaySceneQueryResult mResult
SceneManager * mParentSceneMgr
virtual const set< WorldFragmentType >::type * getSupportedWorldFragmentTypes(void) const
Returns the types of world fragments this query supports.
Specialises the SceneQuery class for querying within a plane-bounded volume.
vector< RaySceneQueryResultEntry >::type RaySceneQueryResult
Separate SceneQuery class to query for pairs of objects which are possibly intersecting one another...
This optional class allows you to receive per-result callbacks from SceneQuery executions instead of ...
void * geometry
Custom geometry block, only applicable for WFT_CUSTOM_GEOMETRY.
std::pair< MovableObject *, SceneQuery::WorldFragment * > SceneQueryMovableObjectWorldFragmentPair
SceneQueryMovableWorldFragmentIntersectionList movables2world
List of movable / world intersections.
Specialises the SceneQuery class for querying along a ray.
WorldFragmentType mWorldFragmentType
Return pointers to convex plane-bounded regions.
list< MovableObject * >::type SceneQueryResultMovableList