source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h @ 3120

Revision 3120, 3.8 KB checked in by mattausch, 16 years ago (diff)

worked on filtering now trying to reduce flickering (have to reorder ssao function quite much

Line 
1#ifndef __SCENEENTITY_H
2#define __SCENEENTITY_H
3
4#include "common.h"
5#include "AxisAlignedBox3.h"
6#include "Triangle3.h"
7#include "LODInfo.h"
8
9
10namespace CHCDemoEngine
11{
12
13class Material;
14class Geometry;
15class RenderState;
16class Transform3;
17class Camera;
18
19
20/** Class representing a scene entity.
21    A scene entity basically consists of geometry, transformation, and a material
22*/
23class SceneEntity
24{
25        friend class RenderQueue;
26        friend class EntityMerger;
27
28public:
29       
30        /** Creates a scene entity.
31        */
32        SceneEntity(Transform3 *trafo);
33        /** Copy constructur.
34        */
35        //SceneEntity(const SceneEntity &e);
36        /** Destructor.
37        */
38        virtual ~SceneEntity();
39        /** Renders this node.
40        */
41        virtual void Render(RenderState *state);       
42        /** Set pointer to the shape
43        */
44        void AddShape(Shape *shape);
45        /** See set
46        */
47        inline Shape *GetShape(int i) const { return mShapes[i]; }
48        /** Returns number of shapes in vector.
49        */
50        inline int GetNumShapes() { return (int)mShapes.size(); }
51        /** Set pointer to the geometry
52        */
53        void SetTransform(Transform3 *trafo);
54        /** set frame where we last rendered this node
55        */
56        void SetLastRendered(int lastRendered);
57        /** returns frame where we last visited this node
58        */
59        int GetLastRendered() const;
60        /** Returns the trafo of this scene entity.
61        */
62        inline Transform3 *GetTransform() const  { return mTransform; }
63        /** Counts number of triangles in this entity using the specified lod level
64                with 0 being the highest or the current lod level (if the argument is -1).
65        */
66        int CountNumTriangles(int lodLevel = -1);
67        /** Returns the local bounding box.
68        */
69        AxisAlignedBox3 GetBoundingBox() const;
70        /** Returns the transformed bounding box.
71        */
72        AxisAlignedBox3 GetWorldBoundingBox() const;
73       
74
75
76        ////////////////
77
78       
79        /** Returns shapes of specified lod level
80        */
81        void GetLODLevel(int level, ShapeContainer::iterator &start, ShapeContainer::iterator &end);
82        /** Returns shapes of current lod level
83        */
84        void GetCurrentLODLevel(ShapeContainer::iterator &start, ShapeContainer::iterator &end);
85        /** Adds a new lod level.
86        */
87        void AddLODLevel(const LODLevel &lod) { mLODLevels.push_back(lod); }
88        /** Returns numbers of lod levels.
89        */
90        int GetNumLODLevels() const { return (int)mLODLevels.size(); }
91        /** Returns center point of this shape.
92        */
93        Vector3 GetCenter() const {return mCenter; }
94        /** Returns transformed center point of this shape.
95        */
96        Vector3 GetWorldCenter() const;
97        /** Prepare this scene entity for rendering, i.e., sets the state and the transform.
98                This is used with the render queue. When a shape belonging to this scene entity
99                is rendered, this function is called in beforehand.
100        */
101        void Prepare(RenderState *state);
102
103
104        /////////////
105        //-- static functions
106
107        /** If false, the highest (most detailed) LOD level is used for all entities.
108        */
109        static void SetUseLODs(bool useLODs) { sUseLODs = useLODs; }
110        /** See set
111        */
112        static bool GetUseLODs() { return sUseLODs; }
113
114
115        int mId;
116
117protected:
118
119        /** Internally updates current lod level.
120        */
121        void UpdateLODs(const Vector3 &viewPoint);
122        /** Returns updated index of current lod level.
123        */
124        int GetCurrentLODLevel();
125
126
127        /////////////////////
128
129        /// the bounding box
130        AxisAlignedBox3 mBox;
131        /// describes a 3D transform
132        Transform3 *mTransform;
133        /// Stores information about the LOD levels
134        LODLevelArray mLODLevels;
135        /// the renderable shapes
136        ShapeContainer mShapes;
137        /// when this entity was last rendered
138        int mLastRendered;
139        /// the LOD level currently used for rendering
140        int mCurrentLODLevel;
141        /// frame number in which the LODs were last updated
142        int mLODLastUpdated;
143        /// the center of gravity of this entity
144        Vector3 mCenter;
145
146        static bool sUseLODs;
147        static int sCurrentId;
148};
149
150
151}
152
153#endif // __SCENEENTITY_H
Note: See TracBrowser for help on using the repository browser.