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

Revision 2848, 2.9 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
93
94
95protected:
96
97        /** Internally updates current lod level.
98        */
99        void UpdateLODs(const Vector3 &viewPoint);
100        /** Returns updated index of current lod level.
101        */
102        int GetCurrentLODLevel();
103
104
105        /// the bounding box
106        AxisAlignedBox3 mBox;
107        /// transform matrix
108        Transform3 *mTransform;
109        /// Stores information about the LOD levels
110        LODLevelContainer mLODLevels;
111        /// the renderable shapes
112        ShapeContainer mShapes;
113        /// when this entity was last rendered
114        int mLastRendered;
115
116        int mCurrentLODLevel;
117        /// which frame the lod info was last updated
118        int mLODLastUpdated;
119        /// the center of gravity of this scene entity
120        Vector3 mCenter;
121};
122
123}
124
125#endif // __SCENEENTITY_H
Note: See TracBrowser for help on using the repository browser.