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

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