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

Revision 2865, 3.1 KB checked in by mattausch, 16 years ago (diff)
RevLine 
[2764]1#ifndef __SCENEENTITY_H
2#define __SCENEENTITY_H
3
[2818]4#include "glInterface.h"
[2819]5#include <Cg/cg.h>
6#include <Cg/cgGL.h>
[2764]7#include "common.h"
8#include "AxisAlignedBox3.h"
9#include "Triangle3.h"
[2839]10#include "LODInfo.h"
[2764]11
[2819]12
[2776]13namespace CHCDemoEngine
[2764]14{
15
16class Material;
17class Geometry;
18class RenderState;
[2840]19class Transform3;
[2844]20class Camera;
[2764]21
[2840]22
[2764]23/** Class representing a scene entity.
[2793]24    A scene entity basically consists of geometry, transformation, and a material
[2764]25*/
26class SceneEntity
27{
[2802]28        friend class RenderQueue;
29
[2764]30public:
[2839]31       
[2764]32        /** Creates a scene entity.
33        */
[2840]34        SceneEntity(Transform3 *trafo);
[2792]35
36        ~SceneEntity();
[2764]37        /** Renders this node.
38        */
39        void Render(RenderState *state);       
[2839]40        /** Set pointer to the shape
[2764]41        */
[2839]42        void AddShape(Shape *shape);
[2764]43        /** See set
44        */
[2839]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(); }
[2764]49        /** Set pointer to the geometry
50        */
[2840]51        void SetTransform(Transform3 *trafo);
[2764]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;
[2839]58        /** Returns the trafo of this scene entity.
59        */
[2840]60        inline Transform3 *GetTransform() const  { return mTransform; }
[2844]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        */
[2848]64        int CountNumTriangles(int lodLevel = -1);
[2844]65        /** Returns the bounding box.
66        */
67        AxisAlignedBox3 GetBoundingBox() const;
68        /** Returns the transformed bounding box.
69        */
70        AxisAlignedBox3 GetTransformedBoundingBox() const;
71       
[2764]72
[2841]73
[2844]74        ////////////////
[2842]75
[2847]76       
[2844]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(); }
[2847]89        /** Returns transformed center point of this shape.
90        */
91        Vector3 GetCenter() const;
[2865]92        /** If false, the highest (most detailed) LOD level is used for all entities.
93        */
94        static void SetUseLODs(bool useLODs) { sUseLODs = useLODs; }
[2847]95
[2848]96
[2764]97protected:
98
[2847]99        /** Internally updates current lod level.
100        */
101        void UpdateLODs(const Vector3 &viewPoint);
[2848]102        /** Returns updated index of current lod level.
103        */
104        int GetCurrentLODLevel();
[2847]105
106
107        /// the bounding box
[2844]108        AxisAlignedBox3 mBox;
[2764]109        /// transform matrix
[2840]110        Transform3 *mTransform;
111        /// Stores information about the LOD levels
[2844]112        LODLevelContainer mLODLevels;
[2840]113        /// the renderable shapes
[2839]114        ShapeContainer mShapes;
[2840]115        /// when this entity was last rendered
[2764]116        int mLastRendered;
[2844]117
118        int mCurrentLODLevel;
[2847]119        /// which frame the lod info was last updated
120        int mLODLastUpdated;
[2848]121        /// the center of gravity of this scene entity
[2847]122        Vector3 mCenter;
[2865]123
124        static bool sUseLODs;
[2764]125};
126
127}
128
129#endif // __SCENEENTITY_H
Note: See TracBrowser for help on using the repository browser.