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