source: GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.h @ 1607

Revision 1607, 4.5 KB checked in by mattausch, 18 years ago (diff)
Line 
1#ifndef _TestCullingTerrainApplication_H__
2#define _TestCullingTerrainApplication_H__
3
4#include "CEGUIForwardRefs.h"
5#include <OgreRenderTargetListener.h>
6#include "ExampleApplication.h"
7
8#include "OgreTerrainContentGenerator.h"
9#include "TerrainFrameListener.h"
10
11#include <OgreEntity.h>
12#include <string>
13
14// z order index of visualizaion viewport
15#define VIZ_VIEWPORT_Z_ORDER 10
16
17class IVReader;
18
19//-- constants for animation
20const float walk_duration = 10.0f;
21const float wait_duration = 2.0f;
22const float rotate_factor = 0.7f;
23const float move_factor = 0.03;
24
25
26/** Rendertarget listener which shows a visualization.
27*/
28class VisualizationRenderTargetListener: public RenderTargetListener
29{
30public:
31       
32        VisualizationRenderTargetListener(SceneManager *sceneMgr);
33
34protected:
35        void preViewportUpdate (const RenderTargetViewportEvent &evt);
36        void postRenderTargetUpdate (const RenderTargetEvent &evt);
37
38        SceneManager *mSceneMgr;
39       
40        ShadowTechnique mSavedShadowTechnique;
41        ColourValue mSavedAmbientLight;
42};
43
44/** Class storing the current state of an entity.
45*/
46class EntityState
47{
48public:
49        enum State {STOP, WAITING, MOVING};
50
51        EntityState(Entity *ent, State entityState, Real speed);
52        ~EntityState();
53        /** Update the entity state.
54        */
55        void update(Real timeSinceLastFrame);
56
57        /** Returns entity.
58        */
59        Entity *GetEntity();
60
61        /** Returns entity state index.
62        */
63        EntityState::State GetState();
64
65        static bool OutOfBounds(SceneNode *node);
66
67        static Vector3 msMinPos;
68        static Vector3 msMaxPos;
69
70protected:
71
72        void SetAnimationState(String stateStr, bool loop);
73
74        AnimationState *mAnimationState;
75        Entity *mEntity;
76
77        State mState;
78        Real mAnimationSpeed;
79        Real mTimeElapsed;
80};
81
82typedef std::vector<EntityState *> EntityStates;
83
84class TestCullingTerrainApplication: public ExampleApplication
85{
86public:
87        TestCullingTerrainApplication();
88        ~TestCullingTerrainApplication();
89
90        /** Generates a scene using num entities of a type.
91                @param num the number of objects
92                @parma objectType the type of objects
93        */
94        void generateScene(int num, int objectType);
95
96        /** Returns the caption of the given id of a scene object type.
97        */
98        String getCurrentObjectCaption(int id);
99
100        /** Returns state vector of scene entities.
101        */
102        EntityStates &getEntityStates();
103
104        /** Updates all animations according to time elapsed since last frame.
105        */
106    void updateAnimations(Real timeSinceLastFrame);
107
108        /** Deletes vector of scene entity states.
109        */
110        void deleteEntityStates();
111
112        // object types
113        enum {ROBOT, TREE, NINJA};
114
115       
116        /** Clamps scene node to terrain.
117                @param sceneNode the node to be clamped
118                @param terrainOffs the offset of the node over the terrain
119                @returns if clamping was successful (i.e., the ray hit the terrain)
120        */
121        bool Clamp2Terrain(SceneNode *node, int terrainOffs);
122
123        /** Clamps camera to floor plane: used e.g., for vienna set.
124        */
125        bool Clamp2FloorPlane(const float dist);
126
127        /** Loads iv geometry.
128        */
129        bool LoadSceneIV(const String &filename, SceneNode *root, const int index);
130
131        bool LoadSceneCollada(const String &filename, SceneNode *root, const int index);
132
133        bool LoadScene(const String &filename);
134
135        bool LoadViewCells(const String &filename);
136
137        /** Loads configuration from disc.
138        */
139        void loadConfig(const String& filename);
140
141
142        /// if hilly terrain should be loaded
143        static bool msShowHillyTerrain;
144
145        String mFilename;
146        String mViewCellsFilename;
147        /// name of the visibility environment file
148        String mEnvironmentFilename;
149       
150        int mAlgorithm;
151
152
153protected:
154
155        //-- inherited from ExampleApplication
156        bool setup();
157        void createScene();
158        void createFrameListener();
159        void createCamera();
160        //void createViewports();
161       
162        virtual void createRenderTargetListener();
163
164        void BakeSceneIntoStaticGeometry(const String &staticGeomName,
165                                                                         const String &nodeName);
166
167        std::vector<EntityState *> mEntityStates;
168
169        /** cegui setup
170        */
171        void setupGui();
172
173        CEGUI::OgreCEGUIRenderer *mGUIRenderer;
174        CEGUI::System *mGUISystem;
175
176        Vector3 mMinTranslation;
177        Vector3 mMaxTranslation;
178
179        Vector3 mMinAngle;
180        Vector3 mMaxAngle;
181
182        TerrainContentGenerator *mTerrainContentGenerator;
183       
184        Camera *mVizCamera;
185        SceneNode *mCamNode;
186        Light *mSunLight;
187
188        TerrainFrameListener *mTerrainFrameListener;
189        ColourValue mAmbientLight;
190        RayQueryExecutor *mRayQueryExecutor;
191
192        Vector3 mTerrainMinPos;
193        Vector3 mTerrainMaxPos;
194
195        IVReader *mIVReader;
196       
197        StaticGeometry *mStaticGeometry;
198   
199
200private:
201        void chooseSceneManager(void);
202};
203
204#endif // TestCullingTerrainApplication
Note: See TracBrowser for help on using the repository browser.