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

Revision 723, 3.6 KB checked in by mattausch, 18 years ago (diff)

found slowdown

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