source: trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreOctreeNode.h @ 187

Revision 187, 4.5 KB checked in by mattausch, 19 years ago (diff)

added animationbug fix (deleting while animation)fixed visibilityQueriesadditive shadow volumes fixed for octree
hack to fully empty queue after traversal
added demo for vienna model

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 _OgreTerrainExport 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#ifdef GTP_VISIBILITY_MODIFIED_OGRE
107        /// scale for node visualization
108        static void setVizScale(Real scale);
109#endif // GTP_VISIBILITY_MODIFIED_OGRE
110
111protected:
112
113    /** Internal method for updating the bounds for this OctreeNode.
114    @remarks
115    This method determines the bounds solely from the attached objects, not
116    any children. If the node has changed it's bounds, it is removed from its
117    current octree, and reinserted into the tree.
118    */
119    void _updateBounds( void );
120
121    void _removeNodeAndChildren( );
122
123    ///local bounding box
124    AxisAlignedBox mLocalAABB;
125
126    ///Octree this node is attached to.
127    Octree *mOctant;
128
129    ///preallocated corners for rendering
130    Real mCorners[ 24 ];
131    ///shared colors for rendering
132    static unsigned long mColors[ 8 ];
133    ///shared indexes for rendering
134    static unsigned short mIndexes[ 24 ];
135
136#ifdef GTP_VISIBILITY_MODIFIED_OGRE
137        // scale for node visualization
138        static Real msVizScale;
139#endif // GTP_VISIBILITY_MODIFIED_OGRE
140
141};
142
143}
144
145
146#endif
Note: See TracBrowser for help on using the repository browser.