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

Revision 3102, 3.3 KB checked in by mattausch, 16 years ago (diff)

orthocam not working yet

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 transformed center point of this shape.
92        */
93        Vector3 GetWorldCenter() const;
94        /** If false, the highest (most detailed) LOD level is used for all entities.
95        */
96        static void SetUseLODs(bool useLODs) { sUseLODs = useLODs; }
97
98        static bool GetUseLODs() { return sUseLODs; }
99
100
101
102protected:
103
104        /** Internally updates current lod level.
105        */
106        void UpdateLODs(const Vector3 &viewPoint);
107        /** Returns updated index of current lod level.
108        */
109        int GetCurrentLODLevel();
110
111
112        /// the bounding box
113        AxisAlignedBox3 mBox;
114        /// describes a 3D transform
115        Transform3 *mTransform;
116        /// Stores information about the LOD levels
117        LODLevelArray mLODLevels;
118        /// the renderable shapes
119        ShapeContainer mShapes;
120        /// when this entity was last rendered
121        int mLastRendered;
122        /// the LOD level currently used for rendering
123        int mCurrentLODLevel;
124        /// frame number in which the LODs were last updated
125        int mLODLastUpdated;
126        /// the center of gravity of this entity
127        Vector3 mCenter;
128
129        static bool sUseLODs;
130};
131
132}
133
134#endif // __SCENEENTITY_H
Note: See TracBrowser for help on using the repository browser.