OGRE  2.0
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 
43 #include <list>
44 #include <algorithm>
45 
46 #include "OgreOctree.h"
47 
48 
49 namespace Ogre
50 {
51 
52 class OctreeNode;
54 
57 
62 {
64  friend class OctreeRaySceneQuery;
65  friend class OctreeSphereSceneQuery;
68 
69 public:
70  static int intersect_call;
72  OctreeSceneManager(const String& name);
74  OctreeSceneManager(const String& name, AxisAlignedBox &box, int max_depth );
77 
79  const String& getTypeName(void) const;
80 
83  void init( AxisAlignedBox &box, int d );
84 
86  virtual SceneNode * createSceneNodeImpl ( void );
88  virtual SceneNode * createSceneNodeImpl ( const String &name );
90  virtual Camera * createCamera( const String &name );
91 
93  virtual void destroySceneNode( const String &name );
94 
95 
96 
98  virtual void _updateSceneGraph( Camera * cam );
100  virtual void _findVisibleObjects ( Camera * cam,
101  VisibleObjectsBoundsInfo* visibleBounds, bool onlyShadowCasters );
102 
107  virtual void _alertVisibleObjects( void );
108 
114  void walkOctree( OctreeCamera *, RenderQueue *, Octree *,
115  VisibleObjectsBoundsInfo* visibleBounds, bool foundvisible,
116  bool onlyShadowCasters);
117 
121  void _updateOctreeNode( OctreeNode * );
123  void _removeOctreeNode( OctreeNode * );
126  void _addOctreeNode( OctreeNode *, Octree *octree, int depth = 0 );
127 
131  void findNodesIn( const AxisAlignedBox &box, list< SceneNode * >::type &list, SceneNode *exclude = 0 );
132 
136  void findNodesIn( const Sphere &sphere, list< SceneNode * >::type &list, SceneNode *exclude = 0 );
137 
141  void findNodesIn( const PlaneBoundedVolume &volume, list< SceneNode * >::type &list, SceneNode *exclude=0 );
142 
146  void findNodesIn( const Ray &ray, list< SceneNode * >::type &list, SceneNode *exclude=0 );
147 
149  void setShowBoxes( bool b )
150  {
151  mShowBoxes = b;
152  };
153 
155  void resize( const AxisAlignedBox &box );
156 
165  virtual bool setOption( const String &, const void * );
170  virtual bool getOption( const String &, void * );
171 
172  bool getOptionValues( const String & key, StringVector &refValueList );
173  bool getOptionKeys( StringVector &refKeys );
175  void clearScene(void);
176 
177  AxisAlignedBoxSceneQuery* createAABBQuery(const AxisAlignedBox& box, uint32 mask);
178  SphereSceneQuery* createSphereQuery(const Sphere& sphere, uint32 mask);
179  PlaneBoundedVolumeListSceneQuery* createPlaneBoundedVolumeQuery(const PlaneBoundedVolumeList& volumes, uint32 mask);
180  RaySceneQuery* createRayQuery(const Ray& ray, uint32 mask);
181  IntersectionSceneQuery* createIntersectionQuery(uint32 mask);
182 
183 protected:
184 
185 
187 
190 
193 
196 
201 
204 
205  Real mCorners[ 24 ];
206  static unsigned long mColors[ 8 ];
207  static unsigned short mIndexes[ 24 ];
208 
210 
211 };
212 
215 {
216 protected:
217  void initMetaData(void) const;
218 public:
222  static const String FACTORY_TYPE_NAME;
223  SceneManager* createInstance(const String& instanceName);
224  void destroyInstance(SceneManager* instance);
225 };
226 
227 
228 
229 }
230 
231 #endif
232 
Representation of a ray in space, i.e.
Definition: OgreRay.h:45
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:82
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
float Real
Software floating point type.
unsigned int uint32
Definition: OgrePlatform.h:420
Specialized viewpoint from which an Octree can be rendered.
SceneManager * createInstance(const String &instanceName)
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:53
Octree implementation of AxisAlignedBoxSceneQuery.
list< OctreeNode * >::type NodeList
Definition: OgreOctree.h:125
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:57
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
Definition: OgreCommon.h:53
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.
Specialises the SceneQuery class for querying along a ray.
Class which will create instances of a given SceneManager.