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

Revision 2844, 2.6 KB checked in by mattausch, 16 years ago (diff)

lod starting to work

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        /** Internally updates current lod level.
77        */
78        void UpdateLODs(Camera *cam);
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(LODLevel *lod) { mLODLevels.push_back(lod); }
88        /** Returns numbers of lod levels.
89        */
90        int GetNumLODLevels() const { return (int)mLODLevels.size(); }
91
92protected:
93
94        AxisAlignedBox3 mBox;
95        /// transform matrix
96        Transform3 *mTransform;
97        /// Stores information about the LOD levels
98        LODLevelContainer mLODLevels;
99        /// the renderable shapes
100        ShapeContainer mShapes;
101        /// when this entity was last rendered
102        int mLastRendered;
103
104        int mCurrentLODLevel;
105};
106
107}
108
109#endif // __SCENEENTITY_H
Note: See TracBrowser for help on using the repository browser.