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

Revision 639, 3.6 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>
12
[173]13// z order index of visualizaion viewport
14#define VIZ_VIEWPORT_Z_ORDER 10
15
16
17//-- constants for animation
18const float walk_duration = 10.0f;
19const float wait_duration = 2.0f;
20const float rotate_factor = 0.7f;
21const float move_factor = 0.03;
22
23
24/** Rendertarget listener which shows a visualization.
25*/
[99]26class VisualizationRenderTargetListener: public RenderTargetListener
27{
28public:
29        VisualizationRenderTargetListener(SceneManager *sceneMgr);
30
31protected:
32        void preViewportUpdate (const RenderTargetViewportEvent &evt);
33        void postRenderTargetUpdate (const RenderTargetEvent &evt);
34
35        SceneManager *mSceneMgr;
[139]36       
37        ShadowTechnique mSavedShadowTechnique;
38        ColourValue mSavedAmbientLight;
[99]39};
40
[161]41/** Class storing the current state of an entity.
42*/
43class EntityState
44{
45public:
46        enum State {STOP, WAITING, MOVING};
[61]47
[161]48        EntityState(Entity *ent, State entityState, Real speed);
[164]49        ~EntityState();
[161]50        /** Update the entity state.
51        */
52        void update(Real timeSinceLastFrame);
53
54        /** Returns entity.
55        */
56        Entity *GetEntity();
57
58        /** Returns entity state index.
59        */
60        EntityState::State GetState();
61
[164]62        static bool OutOfBounds(SceneNode *node);
63
64        static Vector3 msMinPos;
65        static Vector3 msMaxPos;
66
[161]67protected:
68
69        void SetAnimationState(String stateStr, bool loop);
70
71        AnimationState *mAnimationState;
72        Entity *mEntity;
73
74        State mState;
75        Real mAnimationSpeed;
76        Real mTimeElapsed;
77};
78
79typedef std::vector<EntityState *> EntityStates;
80
[160]81class TestCullingTerrainApplication: public ExampleApplication
[61]82{
83public:
[145]84        TestCullingTerrainApplication();
[61]85        ~TestCullingTerrainApplication();
86
[161]87        /** Generates a scene using num entities of a type.
88                @param num the number of objects
89                @parma objectType the type of objects
90        */
[160]91        void generateScene(int num, int objectType);
92
[161]93        /** Returns the caption of the given id of a scene object type.
94        */
[160]95        String getCurrentObjectCaption(int id);
96
[161]97        /** Returns state vector of scene entities.
98        */
99        EntityStates &getEntityStates();
[160]100
[161]101        /** Updates all animations according to time elapsed since last frame.
102        */
103    void updateAnimations(Real timeSinceLastFrame);
104
105        /** Deletes vector of scene entity states.
106        */
107        void deleteEntityStates();
108
109        // object types
110        enum {ROBOT, ATHENA, NINJA};
111
112       
113        /** Clamps scene node to terrain.
114                @param sceneNode the node to be clamped
115                @param terrainOffs the offset of the node over the terrain
116                @returns if clamping was successful (i.e., the ray hit the terrain)
117        */
118        bool Clamp2Terrain(SceneNode *node, int terrainOffs);
119
[61]120protected:
[160]121
[99]122        //-- inherited from ExampleApplication
123        bool setup();
[85]124        void createScene();
125        void createFrameListener();
[99]126        void createCamera();
127        //void createViewports();
128       
129        virtual void createRenderTargetListener();
130
[161]131        std::vector<EntityState *> mEntityStates;
[160]132
[161]133        /** cegui setup
134        */
[85]135        void setupGui();
[61]136
137        CEGUI::OgreCEGUIRenderer *mGUIRenderer;
138        CEGUI::System *mGUISystem;
139
[87]140        Vector3 mMinTranslation;
141        Vector3 mMaxTranslation;
142
143        Vector3 mMinAngle;
[61]144        Vector3 mMaxAngle;
145
[82]146        TerrainContentGenerator *mTerrainContentGenerator;
[99]147       
[100]148        Camera *mVizCamera;
149        SceneNode *mCamNode;
[109]150        Light *mSunLight;
[75]151
[133]152        TerrainFrameListener *mTerrainFrameListener;
[139]153        ColourValue mAmbientLight;
[161]154        RayQueryExecutor *mRayQueryExecutor;
155
[164]156        Vector3 mTerrainMinPos;
157        Vector3 mTerrainMaxPos;
[183]158
[61]159private:
160        void chooseSceneManager(void);
[115]161};
162
163#endif // TestCullingTerrainApplication
Note: See TracBrowser for help on using the repository browser.