OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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-2011 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 
63 
66 //typedef list< SceneNode * >::type SceneNodeList;
67 
68 
74 {
76  friend class OctreeRaySceneQuery;
77  friend class OctreeSphereSceneQuery;
80 
81 public:
82  static int intersect_call;
84  OctreeSceneManager(const String& name);
86  OctreeSceneManager(const String& name, AxisAlignedBox &box, int max_depth );
89 
91  const String& getTypeName(void) const;
92 
95  void init( AxisAlignedBox &box, int d );
96 
98  virtual SceneNode * createSceneNodeImpl ( void );
100  virtual SceneNode * createSceneNodeImpl ( const String &name );
102  virtual Camera * createCamera( const String &name );
103 
105  virtual void destroySceneNode( const String &name );
106 
107 
108 
110  virtual void _updateSceneGraph( Camera * cam );
112  virtual void _findVisibleObjects ( Camera * cam,
113  VisibleObjectsBoundsInfo* visibleBounds, bool onlyShadowCasters );
114 
119  virtual void _alertVisibleObjects( void );
120 
126  void walkOctree( OctreeCamera *, RenderQueue *, Octree *,
127  VisibleObjectsBoundsInfo* visibleBounds, bool foundvisible,
128  bool onlyShadowCasters);
129 
133  void _updateOctreeNode( OctreeNode * );
135  void _removeOctreeNode( OctreeNode * );
138  void _addOctreeNode( OctreeNode *, Octree *octree, int depth = 0 );
139 
143  void findNodesIn( const AxisAlignedBox &box, list< SceneNode * >::type &list, SceneNode *exclude = 0 );
144 
148  void findNodesIn( const Sphere &sphere, list< SceneNode * >::type &list, SceneNode *exclude = 0 );
149 
153  void findNodesIn( const PlaneBoundedVolume &volume, list< SceneNode * >::type &list, SceneNode *exclude=0 );
154 
158  void findNodesIn( const Ray &ray, list< SceneNode * >::type &list, SceneNode *exclude=0 );
159 
161  void setShowBoxes( bool b )
162  {
163  mShowBoxes = b;
164  };
165 
166  void setLooseOctree( bool b )
167  {
168  mLoose = b;
169  };
170 
171 
173  void resize( const AxisAlignedBox &box );
174 
183  virtual bool setOption( const String &, const void * );
188  virtual bool getOption( const String &, void * );
189 
190  bool getOptionValues( const String & key, StringVector &refValueList );
191  bool getOptionKeys( StringVector &refKeys );
193  void clearScene(void);
194 
195  AxisAlignedBoxSceneQuery* createAABBQuery(const AxisAlignedBox& box, unsigned long mask);
196  SphereSceneQuery* createSphereQuery(const Sphere& sphere, unsigned long mask);
197  PlaneBoundedVolumeListSceneQuery* createPlaneBoundedVolumeQuery(const PlaneBoundedVolumeList& volumes, unsigned long mask);
198  RaySceneQuery* createRayQuery(const Ray& ray, unsigned long mask);
199  IntersectionSceneQuery* createIntersectionQuery(unsigned long mask);
200 
201 protected:
202 
203 
205 
208 
211 
214 
219 
222 
223 
224  bool mLoose;
225 
226  Real mCorners[ 24 ];
227  static unsigned long mColors[ 8 ];
228  static unsigned short mIndexes[ 24 ];
229 
231 
232 };
233 
236 {
237 protected:
238  void initMetaData(void) const;
239 public:
243  static const String FACTORY_TYPE_NAME;
244  SceneManager* createInstance(const String& instanceName);
245  void destroyInstance(SceneManager* instance);
246 };
247 
248 
249 
250 }
251 
252 #endif
253 
Representation of a ray in space, i.e.
Definition: OgreRay.h:46
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:85
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
float Real
Software floating point type.
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:57
Octree implementation of AxisAlignedBoxSceneQuery.
list< OctreeNode * >::type NodeList
Definition: OgreOctree.h:127
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.
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:59
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.