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

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