OGRE  1.9
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 "OgreAxisAlignedBox.h"
33 #include "OgreSphere.h"
34 #include "OgreRay.h"
35 #include "OgreRenderOperation.h"
36 #include "OgrePlaneBoundedVolume.h"
37 #include "OgreHeaderPrefix.h"
38 
39 namespace Ogre {
40 
41  // forward declaration
42  class SceneQueryListener;
75  {
76  public:
93  WFT_RENDER_OPERATION
94  };
95 
109  struct WorldFragment {
117  void* geometry;
120 
121  };
122  protected:
128 
129  public:
131  SceneQuery(SceneManager* mgr);
132  virtual ~SceneQuery();
133 
143  virtual void setQueryMask(uint32 mask);
145  virtual uint32 getQueryMask(void) const;
146 
155  virtual void setQueryTypeMask(uint32 mask);
157  virtual uint32 getQueryTypeMask(void) const;
158 
169  virtual void setWorldFragmentType(enum WorldFragmentType wft);
170 
172  virtual WorldFragmentType getWorldFragmentType(void) const;
173 
176  {return &mSupportedWorldFragments;}
177 
178 
179  };
180 
188  {
189  public:
190  virtual ~SceneQueryListener() { }
196  virtual bool queryResult(MovableObject* object) = 0;
202  virtual bool queryResult(SceneQuery::WorldFragment* fragment) = 0;
203 
204  };
205 
210  {
215  };
216 
224  : public SceneQuery, public SceneQueryListener
225  {
226  protected:
228  public:
231  virtual ~RegionSceneQuery();
240  virtual SceneQueryResult& execute(void);
241 
249  virtual void execute(SceneQueryListener* listener) = 0;
250 
254  virtual SceneQueryResult& getLastResults(void) const;
261  virtual void clearResults(void);
262 
264  bool queryResult(MovableObject* first);
266  bool queryResult(SceneQuery::WorldFragment* fragment);
267  };
268 
271  {
272  protected:
274  public:
276  virtual ~AxisAlignedBoxSceneQuery();
277 
279  void setBox(const AxisAlignedBox& box);
280 
282  const AxisAlignedBox& getBox(void) const;
283 
284  };
285 
288  {
289  protected:
291  public:
293  virtual ~SphereSceneQuery();
295  void setSphere(const Sphere& sphere);
296 
298  const Sphere& getSphere() const;
299 
300  };
301 
305  {
306  protected:
308  public:
312  void setVolumes(const PlaneBoundedVolumeList& volumes);
313 
315  const PlaneBoundedVolumeList& getVolumes() const;
316 
317  };
318 
319 
320  /*
322  class _OgreExport PyramidSceneQuery : public RegionSceneQuery
323  {
324  public:
325  PyramidSceneQuery(SceneManager* mgr);
326  virtual ~PyramidSceneQuery();
327  };
328  */
329 
336  {
337  public:
345  virtual bool queryResult(MovableObject* obj, Real distance) = 0;
346 
353  virtual bool queryResult(SceneQuery::WorldFragment* fragment, Real distance) = 0;
354 
355  };
356 
359  {
367  bool operator < (const RaySceneQueryResultEntry& rhs) const
368  {
369  return this->distance < rhs.distance;
370  }
371 
372  };
374 
377  {
378  protected:
383 
384  public:
386  virtual ~RaySceneQuery();
388  virtual void setRay(const Ray& ray);
390  virtual const Ray& getRay(void) const;
409  virtual void setSortByDistance(bool sort, ushort maxresults = 0);
411  virtual bool getSortByDistance(void) const;
414  virtual ushort getMaxResults(void) const;
423  virtual RaySceneQueryResult& execute(void);
424 
432  virtual void execute(RaySceneQueryListener* listener) = 0;
433 
437  virtual RaySceneQueryResult& getLastResults(void);
444  virtual void clearResults(void);
445 
447  bool queryResult(MovableObject* obj, Real distance);
449  bool queryResult(SceneQuery::WorldFragment* fragment, Real distance);
450 
451 
452 
453 
454  };
455 
462  {
463  public:
471  virtual bool queryResult(MovableObject* first, MovableObject* second) = 0;
472 
479  virtual bool queryResult(MovableObject* movable, SceneQuery::WorldFragment* fragment) = 0;
480 
481  /* NB there are no results for world fragments intersecting other world fragments;
482  it is assumed that world geometry is either static or at least that self-intersections
483  are irrelevant or dealt with elsewhere (such as the custom scene manager) */
484 
485 
486  };
487 
488  typedef std::pair<MovableObject*, MovableObject*> SceneQueryMovableObjectPair;
489  typedef std::pair<MovableObject*, SceneQuery::WorldFragment*> SceneQueryMovableObjectWorldFragmentPair;
494  {
499 
500 
501 
502  };
503 
514  {
515  protected:
517  public:
519  virtual ~IntersectionSceneQuery();
520 
529  virtual IntersectionSceneQueryResult& execute(void);
530 
538  virtual void execute(IntersectionSceneQueryListener* listener) = 0;
539 
543  virtual IntersectionSceneQueryResult& getLastResults(void) const;
550  virtual void clearResults(void);
551 
553  bool queryResult(MovableObject* first, MovableObject* second);
555  bool queryResult(MovableObject* movable, SceneQuery::WorldFragment* fragment);
556  };
557 
561 }
562 
563 #include "OgreHeaderSuffix.h"
564 
565 #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:344
SceneQuery::WorldFragment * worldFragment
The world fragment, or NULL if this is not a fragment result.
#define _OgreExport
Definition: OgrePlatform.h:260
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