OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreOctreeSceneManager.h
Go to the documentation of this file.
1 /***************************************************************************
2 octreescenemanager.h - description
3 -------------------
4 begin : Fri Sep 27 2002
5 copyright : (C) 2002 by Jon Anderson
6 email : janders@users.sf.net
7 ***************************************************************************/
8 
9 /*
10 -----------------------------------------------------------------------------
11 This source file is part of OGRE
12 (Object-oriented Graphics Rendering Engine)
13 For the latest info, see http://www.ogre3d.org/
14 
15 Copyright (c) 2000-2014 Torus Knot Software Ltd
16 
17 Permission is hereby granted, free of charge, to any person obtaining a copy
18 of this software and associated documentation files (the "Software"), to deal
19 in the Software without restriction, including without limitation the rights
20 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21 copies of the Software, and to permit persons to whom the Software is
22 furnished to do so, subject to the following conditions:
23 
24 The above copyright notice and this permission notice shall be included in
25 all copies or substantial portions of the Software.
26 
27 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
33 THE SOFTWARE.
34 -----------------------------------------------------------------------------
35 */
36 
37 #ifndef OCTREESCENEMANAGER_H
38 #define OCTREESCENEMANAGER_H
39 
41 #include "OgreSceneManager.h"
42 #include "OgreRenderOperation.h"
43 #include "OgreSphere.h"
44 
45 #include <list>
46 #include <algorithm>
47 
48 #include "OgreOctree.h"
49 
50 
51 namespace Ogre
52 {
53 
54 class OctreeNode;
55 
56 class OctreeCamera;
57 class OctreeIntersectionSceneQuery;
58 class OctreeRaySceneQuery;
59 class OctreeSphereSceneQuery;
60 class OctreeAxisAlignedBoxSceneQuery;
62 
65 
70 {
72  friend class OctreeRaySceneQuery;
73  friend class OctreeSphereSceneQuery;
76 
77 public:
78  static int intersect_call;
80  OctreeSceneManager(const String& name);
82  OctreeSceneManager(const String& name, AxisAlignedBox &box, int max_depth );
85 
87  const String& getTypeName(void) const;
88 
91  void init( AxisAlignedBox &box, int d );
92 
94  virtual SceneNode * createSceneNodeImpl ( void );
96  virtual SceneNode * createSceneNodeImpl ( const String &name );
98  virtual Camera * createCamera( const String &name );
99 
101  virtual void destroySceneNode( const String &name );
102 
103 
104 
106  virtual void _updateSceneGraph( Camera * cam );
108  virtual void _findVisibleObjects ( Camera * cam,
109  VisibleObjectsBoundsInfo* visibleBounds, bool onlyShadowCasters );
110 
115  virtual void _alertVisibleObjects( void );
116 
122  void walkOctree( OctreeCamera *, RenderQueue *, Octree *,
123  VisibleObjectsBoundsInfo* visibleBounds, bool foundvisible,
124  bool onlyShadowCasters);
125 
129  void _updateOctreeNode( OctreeNode * );
131  void _removeOctreeNode( OctreeNode * );
134  void _addOctreeNode( OctreeNode *, Octree *octree, int depth = 0 );
135 
139  void findNodesIn( const AxisAlignedBox &box, list< SceneNode * >::type &list, SceneNode *exclude = 0 );
140 
144  void findNodesIn( const Sphere &sphere, list< SceneNode * >::type &list, SceneNode *exclude = 0 );
145 
149  void findNodesIn( const PlaneBoundedVolume &volume, list< SceneNode * >::type &list, SceneNode *exclude=0 );
150 
154  void findNodesIn( const Ray &ray, list< SceneNode * >::type &list, SceneNode *exclude=0 );
155 
157  void setShowBoxes( bool b )
158  {
159  mShowBoxes = b;
160  };
161 
162  void setLooseOctree( bool b )
163  {
164  mLoose = b;
165  };
166 
167 
169  void resize( const AxisAlignedBox &box );
170 
179  virtual bool setOption( const String &, const void * );
184  virtual bool getOption( const String &, void * );
185 
186  bool getOptionValues( const String & key, StringVector &refValueList );
187  bool getOptionKeys( StringVector &refKeys );
189  void clearScene(void);
190 
191  AxisAlignedBoxSceneQuery* createAABBQuery(const AxisAlignedBox& box, uint32 mask);
192  SphereSceneQuery* createSphereQuery(const Sphere& sphere, uint32 mask);
193  PlaneBoundedVolumeListSceneQuery* createPlaneBoundedVolumeQuery(const PlaneBoundedVolumeList& volumes, uint32 mask);
194  RaySceneQuery* createRayQuery(const Ray& ray, uint32 mask);
195  IntersectionSceneQuery* createIntersectionQuery(uint32 mask);
196 
197 protected:
198 
199 
201 
204 
207 
210 
215 
218 
219 
220  bool mLoose;
221 
222  Real mCorners[ 24 ];
223  static unsigned long mColors[ 8 ];
224  static unsigned short mIndexes[ 24 ];
225 
227 
228 };
229 
232 {
233 protected:
234  void initMetaData(void) const;
235 public:
239  static const String FACTORY_TYPE_NAME;
240  SceneManager* createInstance(const String& instanceName);
241  void destroyInstance(SceneManager* instance);
242 };
243 
244 
245 
246 }
247 
248 #endif
249 
Representation of a ray in space, i.e.
Definition: OgreRay.h:46
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
float Real
Software floating point type.
unsigned int uint32
Definition: OgrePlatform.h:344
Specialized viewpoint from which an Octree can be rendered.
SceneManager * createInstance(const String &instanceName)
Create a new instance of a SceneManager.
Manages the organisation and rendering of a 'scene' i.e.
Specialises the SceneQuery class for querying within a sphere.
Octree implementation of RaySceneQuery.
A 3D box aligned with the x/y/z axes.
AxisAlignedBox mBox
Size of the octree.
std::list< T, A > type
void initMetaData(void) const
Internal method to initialise the metadata, must be implemented.
Class representing a node in the scene graph.
Definition: OgreSceneNode.h:58
Octree implementation of AxisAlignedBoxSceneQuery.
list< OctreeNode * >::type NodeList
Definition: OgreOctree.h:126
vector< PlaneBoundedVolume >::type PlaneBoundedVolumeList
Specialized SceneManager that divides the geometry into an octree in order to facilitate spatial quer...
Octree implementation of PlaneBoundedVolumeListSceneQuery.
void setShowBoxes(bool b)
Sets the box visibility flag.
#define _OgreOctreePluginExport
int mNumObjects
Number of rendered objs.
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:51
bool mShowBoxes
Boxes visibility flag.
Octree datastructure for managing scene nodes.
Definition: OgreOctree.h:58
list< unsigned long >::type ColorList
Factory for OctreeSceneManager.
list< WireBoundingBox * >::type BoxList
vector< String >::type StringVector
Octree implementation of IntersectionSceneQuery.
Represents a convex volume bounded by planes.
void destroyInstance(SceneManager *instance)
Destroy an instance of a SceneManager.
Class to manage the scene object rendering queue.
Specialises the SceneQuery class for querying within an axis aligned box.
int mMaxDepth
Max depth for the tree.
Octree implementation of SphereSceneQuery.
Specialises the SceneQuery class for querying within a plane-bounded volume.
_StringBase String
BoxList mBoxes
List of boxes to be rendered.
Separate SceneQuery class to query for pairs of objects which are possibly intersecting one another...
static const String FACTORY_TYPE_NAME
Factory type name.
Octree * mOctree
The root octree.
Specialized SceneNode that is customized for working within an Octree.
Structure collecting together information about the visible objects that have been discovered in a sc...
Specialises the SceneQuery class for querying along a ray.
Class which will create instances of a given SceneManager.