source: OGRE/trunk/ogrenew/PlugIns/OctreeSceneManager/include/OgreOctreeNode.h @ 657

Revision 657, 4.6 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

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#ifdef GTP_VISIBILITY_MODIFIED_OGRE
50class _OgreTerrainExport OctreeNode : public SceneNode
51#else
52class OctreeNode : public SceneNode
53#endif // GTP_VISIBILITY_MODIFIED_OGRE
54{
55public:
56    /** Standard constructor */
57    OctreeNode( SceneManager* creator );
58    /** Standard constructor */
59    OctreeNode( SceneManager* creator, const String& name );
60    /** Standard destructor */
61    ~OctreeNode();
62
63    /** Overridden from Node to remove any reference to octants */
64    Node * removeChild( unsigned short index );
65   
66    /** Overridden from Node to remove any reference to octants */
67    Node * removeChild( const String & name );
68
69    /** Overridden from Node to remove any reference to octants */
70    Node * removeChild( Node* child);
71
72    /** Returns the Octree in which this OctreeNode resides
73    */
74    Octree * getOctant()
75    {
76        return mOctant;
77    };
78
79    /** Sets the Octree in which this OctreeNode resides
80    */
81    void setOctant( Octree *o )
82    {
83        mOctant = o;
84    };
85
86    /** Determines if the center of this node is within the given box
87    */
88    bool _isIn( AxisAlignedBox &box );
89
90    /** Adds all the attached scenenodes to the render queue
91    */
92    virtual void _addToRenderQueue( Camera* cam, RenderQueue * q, bool onlyShadowCasters );
93
94    /** Sets up the LegacyRenderOperation for rendering this scene node as geometry.
95    @remarks
96    This will render the scenenode as a bounding box.
97    */
98    virtual void getRenderOperation( RenderOperation& op );
99
100    /** Returns the local bounding box of this OctreeNode.
101    @remarks
102    This is used to render the bounding box, rather then the global.
103    */
104    AxisAlignedBox & _getLocalAABB()
105    {
106        return mLocalAABB;
107    };
108
109
110
111#ifdef GTP_VISIBILITY_MODIFIED_OGRE
112        /// scale for node visualization
113        static void setVizScale(Real scale);
114#endif // GTP_VISIBILITY_MODIFIED_OGRE
115
116protected:
117
118    /** Internal method for updating the bounds for this OctreeNode.
119    @remarks
120    This method determines the bounds solely from the attached objects, not
121    any children. If the node has changed it's bounds, it is removed from its
122    current octree, and reinserted into the tree.
123    */
124    void _updateBounds( void );
125
126    void _removeNodeAndChildren( );
127
128    ///local bounding box
129    AxisAlignedBox mLocalAABB;
130
131    ///Octree this node is attached to.
132    Octree *mOctant;
133
134    ///preallocated corners for rendering
135    Real mCorners[ 24 ];
136    ///shared colors for rendering
137    static unsigned long mColors[ 8 ];
138    ///shared indexes for rendering
139    static unsigned short mIndexes[ 24 ];
140
141#ifdef GTP_VISIBILITY_MODIFIED_OGRE
142        // scale for node visualization
143        static Real msVizScale;
144#endif // GTP_VISIBILITY_MODIFIED_OGRE
145
146};
147
148}
149
150
151#endif
Note: See TracBrowser for help on using the repository browser.