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

Revision 1604, 4.5 KB checked in by mattausch, 18 years ago (diff)
RevLine 
[115]1#ifndef _TestCullingTerrainApplication_H__
2#define _TestCullingTerrainApplication_H__
3
[61]4#include "CEGUIForwardRefs.h"
[139]5#include <OgreRenderTargetListener.h>
[61]6#include "ExampleApplication.h"
[139]7
[107]8#include "OgreTerrainContentGenerator.h"
[133]9#include "TerrainFrameListener.h"
[61]10
[161]11#include <OgreEntity.h>
[723]12#include <string>
[161]13
[173]14// z order index of visualizaion viewport
15#define VIZ_VIEWPORT_Z_ORDER 10
16
[866]17class IVReader;
[173]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*/
[99]28class VisualizationRenderTargetListener: public RenderTargetListener
29{
30public:
[1604]31       
[99]32        VisualizationRenderTargetListener(SceneManager *sceneMgr);
33
34protected:
35        void preViewportUpdate (const RenderTargetViewportEvent &evt);
36        void postRenderTargetUpdate (const RenderTargetEvent &evt);
37
38        SceneManager *mSceneMgr;
[139]39       
40        ShadowTechnique mSavedShadowTechnique;
41        ColourValue mSavedAmbientLight;
[99]42};
43
[161]44/** Class storing the current state of an entity.
45*/
46class EntityState
47{
48public:
49        enum State {STOP, WAITING, MOVING};
[61]50
[161]51        EntityState(Entity *ent, State entityState, Real speed);
[164]52        ~EntityState();
[161]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
[164]65        static bool OutOfBounds(SceneNode *node);
66
67        static Vector3 msMinPos;
68        static Vector3 msMaxPos;
69
[161]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
[160]84class TestCullingTerrainApplication: public ExampleApplication
[61]85{
86public:
[145]87        TestCullingTerrainApplication();
[61]88        ~TestCullingTerrainApplication();
89
[161]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        */
[160]94        void generateScene(int num, int objectType);
95
[161]96        /** Returns the caption of the given id of a scene object type.
97        */
[160]98        String getCurrentObjectCaption(int id);
99
[161]100        /** Returns state vector of scene entities.
101        */
102        EntityStates &getEntityStates();
[160]103
[161]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
[915]113        enum {ROBOT, TREE, NINJA};
[161]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
[866]123        /** Clamps camera to floor plane: used for vienna set.
124        */
125        bool Clamp2FloorPlane();
126
[924]127        /** Loads iv geometry.
[866]128        */
[924]129        bool LoadSceneIV(const String &filename, SceneNode *root, const int index);
[866]130
[1003]131        bool LoadSceneCollada(const String &filename, SceneNode *root, const int index);
132
[937]133        bool LoadScene(const String &filename);
[924]134
[937]135        bool LoadViewCells(const String &filename);
[924]136
137        /** Loads configuration from disc.
138        */
139        void loadConfig(const String& filename);
[1271]140
141
[932]142        /// if hilly terrain should be loaded
[866]143        static bool msShowHillyTerrain;
144
[937]145        String mFilename;
146        String mViewCellsFilename;
[973]147        /// name of the visibility environment file
[937]148        String mEnvironmentFilename;
[1271]149       
150        int mAlgorithm;
[937]151
[1271]152
[61]153protected:
[160]154
[99]155        //-- inherited from ExampleApplication
156        bool setup();
[85]157        void createScene();
158        void createFrameListener();
[99]159        void createCamera();
160        //void createViewports();
161       
162        virtual void createRenderTargetListener();
163
[901]164        void BakeSceneIntoStaticGeometry(const String &staticGeomName,
165                                                                         const String &nodeName);
166
[161]167        std::vector<EntityState *> mEntityStates;
[160]168
[161]169        /** cegui setup
170        */
[85]171        void setupGui();
[61]172
173        CEGUI::OgreCEGUIRenderer *mGUIRenderer;
174        CEGUI::System *mGUISystem;
175
[87]176        Vector3 mMinTranslation;
177        Vector3 mMaxTranslation;
178
179        Vector3 mMinAngle;
[61]180        Vector3 mMaxAngle;
181
[82]182        TerrainContentGenerator *mTerrainContentGenerator;
[99]183       
[100]184        Camera *mVizCamera;
185        SceneNode *mCamNode;
[109]186        Light *mSunLight;
[75]187
[133]188        TerrainFrameListener *mTerrainFrameListener;
[139]189        ColourValue mAmbientLight;
[161]190        RayQueryExecutor *mRayQueryExecutor;
191
[164]192        Vector3 mTerrainMinPos;
193        Vector3 mTerrainMaxPos;
[183]194
[866]195        IVReader *mIVReader;
[901]196       
197        StaticGeometry *mStaticGeometry;
[1271]198   
[924]199
[61]200private:
201        void chooseSceneManager(void);
[115]202};
203
204#endif // TestCullingTerrainApplication
Note: See TracBrowser for help on using the repository browser.