source: OGRE/trunk/ogre_changes/Ogre1.2/PlugIns/OctreeSceneManager/include/OgreOctreeNode.h @ 921

Revision 921, 4.6 KB checked in by mattausch, 18 years ago (diff)

added updates for visibility

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
50#ifdef GTP_VISIBILITY_MODIFIED_OGRE
51class _OgreTerrainExport OctreeNode : public SceneNode
52#else
53class OctreeNode : public SceneNode
54#endif // GTP_VISIBILITY_MODIFIED_OGRE
55{
56public:
57    /** Standard constructor */
58    OctreeNode( SceneManager* creator );
59    /** Standard constructor */
60    OctreeNode( SceneManager* creator, const String& name );
61    /** Standard destructor */
62    ~OctreeNode();
63
64    /** Overridden from Node to remove any reference to octants */
65    Node * removeChild( unsigned short index );
66   
67    /** Overridden from Node to remove any reference to octants */
68    Node * removeChild( const String & name );
69
70    /** Overridden from Node to remove any reference to octants */
71    Node * removeChild( Node* child);
72
73    /** Returns the Octree in which this OctreeNode resides
74    */
75    Octree * getOctant()
76    {
77        return mOctant;
78    };
79
80    /** Sets the Octree in which this OctreeNode resides
81    */
82    void setOctant( Octree *o )
83    {
84        mOctant = o;
85    };
86
87    /** Determines if the center of this node is within the given box
88    */
89    bool _isIn( AxisAlignedBox &box );
90
91    /** Adds all the attached scenenodes to the render queue
92    */
93    virtual void _addToRenderQueue( Camera* cam, RenderQueue * q, bool onlyShadowCasters );
94
95    /** Sets up the LegacyRenderOperation for rendering this scene node as geometry.
96    @remarks
97    This will render the scenenode as a bounding box.
98    */
99    virtual void getRenderOperation( RenderOperation& op );
100
101    /** Returns the local bounding box of this OctreeNode.
102    @remarks
103    This is used to render the bounding box, rather then the global.
104    */
105    AxisAlignedBox & _getLocalAABB()
106    {
107        return mLocalAABB;
108    };
109
110#ifdef GTP_VISIBILITY_MODIFIED_OGRE
111        /// scale for node visualization
112        static void setVizScale(Real scale);
113#endif // GTP_VISIBILITY_MODIFIED_OGRE
114
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.