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