[692] | 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-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | version.
|
---|
| 14 |
|
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
| 23 | -----------------------------------------------------------------------------
|
---|
| 24 | */
|
---|
| 25 | /***************************************************************************
|
---|
| 26 | octreenode.h - description
|
---|
| 27 | -------------------
|
---|
| 28 | begin : Fri Sep 27 2002
|
---|
| 29 | copyright : (C) 2002 by Jon Anderson
|
---|
| 30 | email : janders@users.sf.net
|
---|
| 31 |
|
---|
| 32 | Enhancements 2003 - 2004 (C) The OGRE Team
|
---|
| 33 | ***************************************************************************/
|
---|
| 34 |
|
---|
| 35 | #ifndef OCTREENODE_H
|
---|
| 36 | #define OCTREENODE_H
|
---|
| 37 |
|
---|
| 38 | #include <OgreSceneNode.h>
|
---|
| 39 |
|
---|
| 40 | #include <OgreOctreeSceneManager.h>
|
---|
| 41 |
|
---|
| 42 | namespace Ogre
|
---|
| 43 | {
|
---|
| 44 |
|
---|
| 45 | /** Specialized SceneNode that is customized for working within an Octree. Each node
|
---|
| 46 | * maintains it's own bounding box, rather than merging it with all the children.
|
---|
| 47 | *
|
---|
| 48 | */
|
---|
| 49 |
|
---|
| 50 | class OctreeNode : public SceneNode
|
---|
| 51 | {
|
---|
| 52 | public:
|
---|
| 53 | /** Standard constructor */
|
---|
| 54 | OctreeNode( SceneManager* creator );
|
---|
| 55 | /** Standard constructor */
|
---|
| 56 | OctreeNode( SceneManager* creator, const String& name );
|
---|
| 57 | /** Standard destructor */
|
---|
| 58 | ~OctreeNode();
|
---|
| 59 |
|
---|
| 60 | /** Overridden from Node to remove any reference to octants */
|
---|
| 61 | Node * removeChild( unsigned short index );
|
---|
| 62 |
|
---|
| 63 | /** Overridden from Node to remove any reference to octants */
|
---|
| 64 | Node * removeChild( const String & name );
|
---|
| 65 |
|
---|
| 66 | /** Overridden from Node to remove any reference to octants */
|
---|
| 67 | Node * removeChild( Node* child);
|
---|
| 68 |
|
---|
| 69 | /** Returns the Octree in which this OctreeNode resides
|
---|
| 70 | */
|
---|
| 71 | Octree * getOctant()
|
---|
| 72 | {
|
---|
| 73 | return mOctant;
|
---|
| 74 | };
|
---|
| 75 |
|
---|
| 76 | /** Sets the Octree in which this OctreeNode resides
|
---|
| 77 | */
|
---|
| 78 | void setOctant( Octree *o )
|
---|
| 79 | {
|
---|
| 80 | mOctant = o;
|
---|
| 81 | };
|
---|
| 82 |
|
---|
| 83 | /** Determines if the center of this node is within the given box
|
---|
| 84 | */
|
---|
| 85 | bool _isIn( AxisAlignedBox &box );
|
---|
| 86 |
|
---|
| 87 | /** Adds all the attached scenenodes to the render queue
|
---|
| 88 | */
|
---|
| 89 | virtual void _addToRenderQueue( Camera* cam, RenderQueue * q, bool onlyShadowCasters );
|
---|
| 90 |
|
---|
| 91 | /** Sets up the LegacyRenderOperation for rendering this scene node as geometry.
|
---|
| 92 | @remarks
|
---|
| 93 | This will render the scenenode as a bounding box.
|
---|
| 94 | */
|
---|
| 95 | virtual void getRenderOperation( RenderOperation& op );
|
---|
| 96 |
|
---|
| 97 | /** Returns the local bounding box of this OctreeNode.
|
---|
| 98 | @remarks
|
---|
| 99 | This is used to render the bounding box, rather then the global.
|
---|
| 100 | */
|
---|
| 101 | AxisAlignedBox & _getLocalAABB()
|
---|
| 102 | {
|
---|
| 103 | return mLocalAABB;
|
---|
| 104 | };
|
---|
| 105 |
|
---|
| 106 |
|
---|
| 107 |
|
---|
| 108 |
|
---|
| 109 | protected:
|
---|
| 110 |
|
---|
| 111 | /** Internal method for updating the bounds for this OctreeNode.
|
---|
| 112 | @remarks
|
---|
| 113 | This method determines the bounds solely from the attached objects, not
|
---|
| 114 | any children. If the node has changed it's bounds, it is removed from its
|
---|
| 115 | current octree, and reinserted into the tree.
|
---|
| 116 | */
|
---|
| 117 | void _updateBounds( void );
|
---|
| 118 |
|
---|
| 119 | void _removeNodeAndChildren( );
|
---|
| 120 |
|
---|
| 121 | ///local bounding box
|
---|
| 122 | AxisAlignedBox mLocalAABB;
|
---|
| 123 |
|
---|
| 124 | ///Octree this node is attached to.
|
---|
| 125 | Octree *mOctant;
|
---|
| 126 |
|
---|
| 127 | ///preallocated corners for rendering
|
---|
| 128 | Real mCorners[ 24 ];
|
---|
| 129 | ///shared colors for rendering
|
---|
| 130 | static unsigned long mColors[ 8 ];
|
---|
| 131 | ///shared indexes for rendering
|
---|
| 132 | static unsigned short mIndexes[ 24 ];
|
---|
| 133 |
|
---|
| 134 |
|
---|
| 135 | };
|
---|
| 136 |
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 |
|
---|
| 140 | #endif
|
---|