source: GTP/trunk/Lib/Geom/OgreStuff/include/opt/OgreOctreeNode.h @ 1809

Revision 1809, 4.2 KB checked in by gumbau, 18 years ago (diff)
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25/***************************************************************************
26octreenode.h  -  description
27-------------------
28begin                : Fri Sep 27 2002
29copyright            : (C) 2002 by Jon Anderson
30email                : janders@users.sf.net
31
32Enhancements 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
42namespace 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
50class OctreeNode : public SceneNode
51{
52public:
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
109protected:
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
Note: See TracBrowser for help on using the repository browser.