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

Revision 2865, 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
30public:
31       
32        /** Creates a scene entity.
33        */
34        SceneEntity(Transform3 *trafo);
35
36        ~SceneEntity();
37        /** Renders this node.
38        */
39        void Render(RenderState *state);       
40        /** Set pointer to the shape
41        */
42        void AddShape(Shape *shape);
43        /** See set
44        */
45        inline Shape *GetShape(int i) const { return mShapes[i]; }
46        /** Returns number of shapes in vector.
47        */
48        inline int GetNumShapes() { return (int)mShapes.size(); }
49        /** Set pointer to the geometry
50        */
51        void SetTransform(Transform3 *trafo);
52        /** set frame where we last rendered this node
53        */
54        void SetLastRendered(int lastRendered);
55        /** returns frame where we last visited this node
56        */
57        int GetLastRendered() const;
58        /** Returns the trafo of this scene entity.
59        */
60        inline Transform3 *GetTransform() const  { return mTransform; }
61        /** Counts number of triangles in this entity using the specified lod level
62                with 0 being the highest or the current lod level (if the argument is -1).
63        */
64        int CountNumTriangles(int lodLevel = -1);
65        /** Returns the bounding box.
66        */
67        AxisAlignedBox3 GetBoundingBox() const;
68        /** Returns the transformed bounding box.
69        */
70        AxisAlignedBox3 GetTransformedBoundingBox() const;
71       
72
73
74        ////////////////
75
76       
77        /** Returns shapes of specified lod level
78        */
79        void GetLODLevel(int level, ShapeContainer::iterator &start, ShapeContainer::iterator &end);
80        /** Returns shapes of current lod level
81        */
82        void GetCurrentLODLevel(ShapeContainer::iterator &start, ShapeContainer::iterator &end);
83        /** Adds a new lod level.
84        */
85        void AddLODLevel(LODLevel *lod) { mLODLevels.push_back(lod); }
86        /** Returns numbers of lod levels.
87        */
88        int GetNumLODLevels() const { return (int)mLODLevels.size(); }
89        /** Returns transformed center point of this shape.
90        */
91        Vector3 GetCenter() const;
92        /** If false, the highest (most detailed) LOD level is used for all entities.
93        */
94        static void SetUseLODs(bool useLODs) { sUseLODs = useLODs; }
95
96
97protected:
98
99        /** Internally updates current lod level.
100        */
101        void UpdateLODs(const Vector3 &viewPoint);
102        /** Returns updated index of current lod level.
103        */
104        int GetCurrentLODLevel();
105
106
107        /// the bounding box
108        AxisAlignedBox3 mBox;
109        /// transform matrix
110        Transform3 *mTransform;
111        /// Stores information about the LOD levels
112        LODLevelContainer mLODLevels;
113        /// the renderable shapes
114        ShapeContainer mShapes;
115        /// when this entity was last rendered
116        int mLastRendered;
117
118        int mCurrentLODLevel;
119        /// which frame the lod info was last updated
120        int mLODLastUpdated;
121        /// the center of gravity of this scene entity
122        Vector3 mCenter;
123
124        static bool sUseLODs;
125};
126
127}
128
129#endif // __SCENEENTITY_H
Note: See TracBrowser for help on using the repository browser.