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

Revision 2980, 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;
[2980]29        friend class EntityMerger;
[2802]30
[2764]31public:
[2839]32       
[2764]33        /** Creates a scene entity.
34        */
[2840]35        SceneEntity(Transform3 *trafo);
[2792]36
37        ~SceneEntity();
[2764]38        /** Renders this node.
39        */
40        void Render(RenderState *state);       
[2839]41        /** Set pointer to the shape
[2764]42        */
[2839]43        void AddShape(Shape *shape);
[2764]44        /** See set
45        */
[2839]46        inline Shape *GetShape(int i) const { return mShapes[i]; }
47        /** Returns number of shapes in vector.
48        */
49        inline int GetNumShapes() { return (int)mShapes.size(); }
[2764]50        /** Set pointer to the geometry
51        */
[2840]52        void SetTransform(Transform3 *trafo);
[2764]53        /** set frame where we last rendered this node
54        */
55        void SetLastRendered(int lastRendered);
56        /** returns frame where we last visited this node
57        */
58        int GetLastRendered() const;
[2839]59        /** Returns the trafo of this scene entity.
60        */
[2840]61        inline Transform3 *GetTransform() const  { return mTransform; }
[2844]62        /** Counts number of triangles in this entity using the specified lod level
63                with 0 being the highest or the current lod level (if the argument is -1).
64        */
[2848]65        int CountNumTriangles(int lodLevel = -1);
[2844]66        /** Returns the bounding box.
67        */
68        AxisAlignedBox3 GetBoundingBox() const;
69        /** Returns the transformed bounding box.
70        */
71        AxisAlignedBox3 GetTransformedBoundingBox() const;
72       
[2764]73
[2841]74
[2844]75        ////////////////
[2842]76
[2847]77       
[2844]78        /** Returns shapes of specified lod level
79        */
80        void GetLODLevel(int level, ShapeContainer::iterator &start, ShapeContainer::iterator &end);
81        /** Returns shapes of current lod level
82        */
83        void GetCurrentLODLevel(ShapeContainer::iterator &start, ShapeContainer::iterator &end);
84        /** Adds a new lod level.
85        */
86        void AddLODLevel(LODLevel *lod) { mLODLevels.push_back(lod); }
87        /** Returns numbers of lod levels.
88        */
89        int GetNumLODLevels() const { return (int)mLODLevels.size(); }
[2847]90        /** Returns transformed center point of this shape.
91        */
92        Vector3 GetCenter() const;
[2865]93        /** If false, the highest (most detailed) LOD level is used for all entities.
94        */
95        static void SetUseLODs(bool useLODs) { sUseLODs = useLODs; }
[2847]96
[2848]97
[2764]98protected:
99
[2847]100        /** Internally updates current lod level.
101        */
102        void UpdateLODs(const Vector3 &viewPoint);
[2848]103        /** Returns updated index of current lod level.
104        */
105        int GetCurrentLODLevel();
[2847]106
107
108        /// the bounding box
[2844]109        AxisAlignedBox3 mBox;
[2764]110        /// transform matrix
[2840]111        Transform3 *mTransform;
112        /// Stores information about the LOD levels
[2844]113        LODLevelContainer mLODLevels;
[2840]114        /// the renderable shapes
[2839]115        ShapeContainer mShapes;
[2840]116        /// when this entity was last rendered
[2764]117        int mLastRendered;
[2844]118
119        int mCurrentLODLevel;
[2847]120        /// which frame the lod info was last updated
121        int mLODLastUpdated;
[2848]122        /// the center of gravity of this scene entity
[2847]123        Vector3 mCenter;
[2865]124
125        static bool sUseLODs;
[2764]126};
127
128}
129
130#endif // __SCENEENTITY_H
Note: See TracBrowser for help on using the repository browser.