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