1 | #ifndef _TerrainFrameListener_H__
|
---|
2 | #define _TerrainFrameListener_H__
|
---|
3 |
|
---|
4 | #include "CEGUIForwardRefs.h"
|
---|
5 | #include <Ogre.h>
|
---|
6 | #include <OgreKeyEvent.h>
|
---|
7 | #include <OgreEventListeners.h>
|
---|
8 | #include <OgreStringConverter.h>
|
---|
9 | #include <OgreException.h>
|
---|
10 | #include "VisibilityEnvironment.h"
|
---|
11 | #include "VisibilityManager.h"
|
---|
12 | #include "OgreTerrainContentGenerator.h"
|
---|
13 |
|
---|
14 | using namespace Ogre;
|
---|
15 |
|
---|
16 | // z order index of visualizaion viewport
|
---|
17 | #define VIZ_VIEWPORT_Z_ORDER 10
|
---|
18 |
|
---|
19 |
|
---|
20 | /** Mouse query listener for terrain
|
---|
21 | */
|
---|
22 | class TerrainFrameListener: public FrameListener, public MouseListener, public MouseMotionListener, public KeyListener
|
---|
23 | {
|
---|
24 | public:
|
---|
25 |
|
---|
26 | TerrainFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager,
|
---|
27 | CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator, Camera *vizCamera,
|
---|
28 | SceneNode *camNode, Light *sunLight);
|
---|
29 |
|
---|
30 | ~TerrainFrameListener();
|
---|
31 |
|
---|
32 |
|
---|
33 | bool frameStarted(const FrameEvent& evt);
|
---|
34 | bool frameEnded(const FrameEvent& evt);
|
---|
35 | //bool processUnbufferedKeyInput(const FrameEvent& evt);
|
---|
36 |
|
---|
37 |
|
---|
38 | /* MouseListener callbacks. */
|
---|
39 | virtual void mouseClicked(MouseEvent* e) { }
|
---|
40 | virtual void mouseEntered(MouseEvent* e) { }
|
---|
41 | virtual void mouseExited(MouseEvent* e) { }
|
---|
42 |
|
---|
43 | // This is when the mouse button goes DOWN.
|
---|
44 | virtual void mousePressed(MouseEvent* e);
|
---|
45 |
|
---|
46 | // This is when the mouse button is let UP.
|
---|
47 | virtual void mouseReleased(MouseEvent* e);
|
---|
48 |
|
---|
49 | /* MouseMotionListener callbacks */
|
---|
50 | virtual void mouseMoved (MouseEvent *e);
|
---|
51 |
|
---|
52 | // This is when the mouse is clicked, held and dragged.
|
---|
53 | virtual void mouseDragged (MouseEvent *e);
|
---|
54 |
|
---|
55 | void keyPressed(KeyEvent* e);
|
---|
56 |
|
---|
57 | void keyReleased(KeyEvent* e);
|
---|
58 | void keyClicked(KeyEvent* e);
|
---|
59 |
|
---|
60 | /** The information about camera position and orienation per frame */
|
---|
61 | typedef struct
|
---|
62 | {
|
---|
63 | Vector3 position;
|
---|
64 | Quaternion orientation;
|
---|
65 | Real timeElapsed;
|
---|
66 | } frame_info;
|
---|
67 |
|
---|
68 | enum {WALKTHROUGH, REPLAY, STATE_NUM};
|
---|
69 |
|
---|
70 | // visualization modes for scene nodes
|
---|
71 | enum {NODEVIZ_NONE, NODEVIZ_RENDER_NODES, NODEVIZ_RENDER_NODES_AND_CONTENT, NODEVIZ_MODES_NUM};
|
---|
72 | //enum {NODEVIZ_NONE, NODEVIZ_RENDER_GEOMETRY, NODEVIZ_MODES_NUM};
|
---|
73 |
|
---|
74 | void zoomVizCamera(int zoom);
|
---|
75 |
|
---|
76 | void addFrameInfo(SceneNode *camNode, Real timeElapsed);
|
---|
77 | void setCurrentFrameInfo(Real timeElapsed);
|
---|
78 |
|
---|
79 | void setAlgorithm(int algorithm);
|
---|
80 |
|
---|
81 | void moveCamera();
|
---|
82 |
|
---|
83 | void writeFrames();
|
---|
84 | void loadFrames();
|
---|
85 |
|
---|
86 |
|
---|
87 | // Constructor takes a RenderWindow because it uses that to determine input context
|
---|
88 | //ExampleFrameListener(RenderWindow* win, Camera* cam, bool useBufferedInputKeys = false, bool useBufferedInputMouse = false)
|
---|
89 |
|
---|
90 | bool processUnbufferedKeyInput(const FrameEvent& evt);
|
---|
91 | bool processUnbufferedMouseInput(const FrameEvent& evt);
|
---|
92 |
|
---|
93 | void showStats(bool show);
|
---|
94 |
|
---|
95 | void updateStats();
|
---|
96 |
|
---|
97 | void toggleShowHelp();
|
---|
98 | void toggleShowStats();
|
---|
99 |
|
---|
100 | void toggleShowShadows();
|
---|
101 | void toggleDisplayCameraDetails();
|
---|
102 | void takeScreenShot();
|
---|
103 | void nextSceneDetailLevel();
|
---|
104 | void nextFilter();
|
---|
105 | void nextAlgorithm();
|
---|
106 | void nextNodeVizMode();
|
---|
107 | void nextAppState();
|
---|
108 | void changeThreshold(int incr);
|
---|
109 |
|
---|
110 | void toggleUseOptimization();
|
---|
111 | void toggleShowOctree();
|
---|
112 | void toggleUseDepthPass();
|
---|
113 | void toggleShowViz();
|
---|
114 | void toggleRecord();
|
---|
115 |
|
---|
116 | /** Applies visibility query. Collects the visible objects
|
---|
117 | and their visibility information.
|
---|
118 | @param fromnPoint if query should be from point or from camera
|
---|
119 | @param relativeVisibility if query should return number of visible pixels or the ratio
|
---|
120 | visible pixels / projected pixels.
|
---|
121 | */
|
---|
122 | void ApplyVisibilityQuery(bool fromPoint, bool relativeVisibility);
|
---|
123 |
|
---|
124 | void toggleShowQueryStats();
|
---|
125 |
|
---|
126 | protected:
|
---|
127 |
|
---|
128 | /** Clamp camera to terrain.
|
---|
129 | */
|
---|
130 | void Clamp2Terrain();
|
---|
131 |
|
---|
132 | SceneManager *mSceneMgr; // A pointer to the scene manager
|
---|
133 |
|
---|
134 | CEGUI::Renderer *mGUIRenderer; // cegui renderer
|
---|
135 |
|
---|
136 | int mCurrentAlgorithm;
|
---|
137 | int mVisibilityThreshold;
|
---|
138 | // the current frame number
|
---|
139 | int mCurrentFrame;
|
---|
140 | // the current application state
|
---|
141 | int mAppState;
|
---|
142 | // The number of objects on the screen
|
---|
143 | int mObjectCount;
|
---|
144 | // visualization mode
|
---|
145 | int mNodeVizMode;
|
---|
146 |
|
---|
147 | SceneNode *mCurrentObject; // the newly created object
|
---|
148 |
|
---|
149 | OverlayElement *mAlgorithmInfo;
|
---|
150 | OverlayElement *mThresholdInfo;
|
---|
151 | OverlayElement *mFrustumCulledNodesInfo;
|
---|
152 | OverlayElement *mQueryCulledNodesInfo;
|
---|
153 | OverlayElement *mTraversedNodesInfo;
|
---|
154 | OverlayElement *mHierarchyNodesInfo;
|
---|
155 | OverlayElement *mUseOptimizationInfo;
|
---|
156 | OverlayElement *mUseDepthPassInfo;
|
---|
157 | OverlayElement *mRenderedNodesInfo;
|
---|
158 | OverlayElement *mObjectsInfo;
|
---|
159 | OverlayElement *mQueriesIssuedInfo;
|
---|
160 |
|
---|
161 | OverlayElement *mQueryTypeInfo;
|
---|
162 | OverlayElement *mQueryVisibleNodesInfo;
|
---|
163 | OverlayElement *mQueryVisibleGeometryInfo;
|
---|
164 | OverlayElement *mQueryVisiblityInfo;
|
---|
165 | OverlayElement *mQueryNodeVisibilityInfo;
|
---|
166 | OverlayElement *mQueryGeometryVisibilityInfo;
|
---|
167 |
|
---|
168 | RayQueryExecutor *mRayQueryExecutor;
|
---|
169 | TerrainContentGenerator *mTerrainContentGenerator;
|
---|
170 |
|
---|
171 | bool mUseOptimization;
|
---|
172 | bool mShowOctree;
|
---|
173 | bool mUseDepthPass;
|
---|
174 | bool mShowVisualization;
|
---|
175 | bool mCullCamera;
|
---|
176 | bool mRecord;
|
---|
177 | bool mShowShadows;
|
---|
178 | bool mVisualizeCulledNodes;
|
---|
179 | bool mShowHelp;
|
---|
180 | bool mStatsOn;
|
---|
181 | bool mLMouseDown, mRMouseDown; // True if the mouse buttons are down
|
---|
182 | bool mShutdownRequested;
|
---|
183 | bool mDisplayCameraDetails;
|
---|
184 |
|
---|
185 | Real mVizCameraHeight;
|
---|
186 |
|
---|
187 | Camera *mVizCamera;
|
---|
188 | SceneNode *mCamNode;
|
---|
189 |
|
---|
190 | //std::deque<Vector3> mWalkList; // The list of points we are walking to
|
---|
191 | std::vector<frame_info> mFrameInfo;
|
---|
192 |
|
---|
193 | Real mTimeElapsed;
|
---|
194 | //EventProcessor* mEventProcessor;
|
---|
195 | InputReader* mInputDevice;
|
---|
196 | Camera* mCamera;
|
---|
197 |
|
---|
198 | Vector3 mTranslateVector;
|
---|
199 | RenderWindow* mWindow;
|
---|
200 |
|
---|
201 | //bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn;
|
---|
202 | unsigned int mNumScreenShots;
|
---|
203 | int mSceneDetailIndex;
|
---|
204 | int mAniso;
|
---|
205 |
|
---|
206 | float mMoveScale;
|
---|
207 | Degree mRotScale;
|
---|
208 | // just to stop toggles flipping too fast
|
---|
209 | Real mTimeDelay;
|
---|
210 | Radian mRotX, mRotY;
|
---|
211 | TextureFilterOptions mFiltering;
|
---|
212 |
|
---|
213 | Real mMoveSpeed;
|
---|
214 | Degree mRotateSpeed;
|
---|
215 |
|
---|
216 | Overlay* mDebugOverlay;
|
---|
217 | Overlay* mHelpOverlay;
|
---|
218 | Overlay* mCullStatsOverlay;
|
---|
219 | Overlay* mQueryOverlay;
|
---|
220 |
|
---|
221 | Light *mSunLight;
|
---|
222 | GtpVisibility::VisibilityManager *mVisibilityManager;
|
---|
223 | EventProcessor* mEventProcessor;
|
---|
224 |
|
---|
225 | bool mShiftPressed;
|
---|
226 | bool mShowQueryStats;
|
---|
227 |
|
---|
228 | //bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn;
|
---|
229 | };
|
---|
230 |
|
---|
231 |
|
---|
232 | #endif //_TerrainFrameListener_H__ |
---|