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