OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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-2014 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 "OgreSphere.h"
33 #include "OgreRay.h"
34 #include "OgreHeaderPrefix.h"
35 
36 namespace Ogre {
69  {
70  public:
87  WFT_RENDER_OPERATION
88  };
89 
103  struct WorldFragment {
111  void* geometry;
114 
115  };
116  protected:
121 
122  public:
125 
127  SceneQuery(SceneManager* mgr);
128  virtual ~SceneQuery();
129 
146  virtual void setQueryMask(uint32 mask);
148  virtual uint32 getQueryMask(void) const;
149 
160  virtual void setWorldFragmentType(enum WorldFragmentType wft);
161 
163  virtual WorldFragmentType getWorldFragmentType(void) const;
164 
167  {return &mSupportedWorldFragments;}
168 
169 
170  };
171 
179  {
180  public:
181  virtual ~SceneQueryListener() { }
187  virtual bool queryResult(MovableObject* object) = 0;
193  virtual bool queryResult(SceneQuery::WorldFragment* fragment) = 0;
194 
195  };
196 
201  {
206  };
207 
215  : public SceneQuery, public SceneQueryListener
216  {
217  protected:
219  public:
222  virtual ~RegionSceneQuery();
231  virtual SceneQueryResult& execute(void);
232 
240  virtual void execute(SceneQueryListener* listener) = 0;
241 
245  virtual SceneQueryResult& getLastResults(void) const;
252  virtual void clearResults(void);
253 
255  bool queryResult(MovableObject* first);
257  bool queryResult(SceneQuery::WorldFragment* fragment);
258  };
259 
262  {
263  protected:
265  public:
267  virtual ~AxisAlignedBoxSceneQuery();
268 
270  void setBox(const AxisAlignedBox& box);
271 
273  const AxisAlignedBox& getBox(void) const;
274 
275  };
276 
279  {
280  protected:
282  public:
284  virtual ~SphereSceneQuery();
286  void setSphere(const Sphere& sphere);
287 
289  const Sphere& getSphere() const;
290 
291  };
292 
296  {
297  protected:
299  public:
303  void setVolumes(const PlaneBoundedVolumeList& volumes);
304 
306  const PlaneBoundedVolumeList& getVolumes() const;
307 
308  };
309 
310 
311  /*
313  class _OgreExport PyramidSceneQuery : public RegionSceneQuery
314  {
315  public:
316  PyramidSceneQuery(SceneManager* mgr);
317  virtual ~PyramidSceneQuery();
318  };
319  */
320 
327  {
328  public:
336  virtual bool queryResult(MovableObject* obj, Real distance) = 0;
337 
344  virtual bool queryResult(SceneQuery::WorldFragment* fragment, Real distance) = 0;
345 
346  };
347 
350  {
358  bool operator < (const RaySceneQueryResultEntry& rhs) const
359  {
360  return this->distance < rhs.distance;
361  }
362 
363  };
365 
368  {
369  protected:
374 
375  public:
377  virtual ~RaySceneQuery();
379  virtual void setRay(const Ray& ray);
381  virtual const Ray& getRay(void) const;
400  virtual void setSortByDistance(bool sort, ushort maxresults = 0);
402  virtual bool getSortByDistance(void) const;
405  virtual ushort getMaxResults(void) const;
414  virtual RaySceneQueryResult& execute(void);
415 
423  virtual void execute(RaySceneQueryListener* listener) = 0;
424 
428  virtual RaySceneQueryResult& getLastResults(void);
435  virtual void clearResults(void);
436 
438  bool queryResult(MovableObject* obj, Real distance);
440  bool queryResult(SceneQuery::WorldFragment* fragment, Real distance);
441 
442 
443 
444 
445  };
446 
453  {
454  public:
462  virtual bool queryResult(MovableObject* first, MovableObject* second) = 0;
463 
470  virtual bool queryResult(MovableObject* movable, SceneQuery::WorldFragment* fragment) = 0;
471 
472  /* NB there are no results for world fragments intersecting other world fragments;
473  it is assumed that world geometry is either static or at least that self-intersections
474  are irrelevant or dealt with elsewhere (such as the custom scene manager) */
475 
476 
477  };
478 
479  typedef std::pair<MovableObject*, MovableObject*> SceneQueryMovableObjectPair;
480  typedef std::pair<MovableObject*, SceneQuery::WorldFragment*> SceneQueryMovableObjectWorldFragmentPair;
485  {
490 
491 
492 
493  };
494 
505  {
506  protected:
508  public:
510  virtual ~IntersectionSceneQuery();
511 
520  virtual IntersectionSceneQueryResult& execute(void);
521 
529  virtual void execute(IntersectionSceneQueryListener* listener) = 0;
530 
534  virtual IntersectionSceneQueryResult& getLastResults(void) const;
541  virtual void clearResults(void);
542 
544  bool queryResult(MovableObject* first, MovableObject* second);
546  bool queryResult(MovableObject* movable, SceneQuery::WorldFragment* fragment);
547  };
548 
552 }
553 
554 #include "OgreHeaderSuffix.h"
555 
556 #endif
Representation of a ray in space, i.e.
Definition: OgreRay.h:45
IntersectionSceneQueryResult * mLastResult
unsigned char uint8
Definition: OgrePlatform.h:422
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:420
SceneQuery::WorldFragment * worldFragment
The world fragment, or NULL if this is not a fragment result.
#define _OgreExport
Definition: OgrePlatform.h:255
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:50
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