[187] | 1 | #ifndef _IVFrameListener_H__
|
---|
| 2 | #define _IVFrameListener_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 |
|
---|
| 13 |
|
---|
| 14 |
|
---|
| 15 | class TestCullingIVApplication;
|
---|
| 16 |
|
---|
| 17 |
|
---|
| 18 | using namespace Ogre;
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 | /** Frame listener specialised for terrains.
|
---|
| 22 | */
|
---|
| 23 | class IVFrameListener: public FrameListener, public MouseListener,
|
---|
| 24 | public MouseMotionListener, public KeyListener
|
---|
| 25 | {
|
---|
| 26 | public:
|
---|
| 27 |
|
---|
| 28 | IVFrameListener(RenderWindow* win,
|
---|
| 29 | Camera* cam,
|
---|
| 30 | SceneManager *sceneManager,
|
---|
| 31 | CEGUI::Renderer *renderer,
|
---|
| 32 | Camera *vizCamera,
|
---|
| 33 | SceneNode *camNode,
|
---|
| 34 | Light *sunLight,
|
---|
| 35 | TestCullingIVApplication *app);
|
---|
| 36 |
|
---|
| 37 | ~IVFrameListener();
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | bool frameStarted(const FrameEvent& evt);
|
---|
| 41 | bool frameEnded(const FrameEvent& evt);
|
---|
| 42 | //bool processUnbufferedKeyInput(const FrameEvent& evt);
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | /* MouseListener callbacks. */
|
---|
| 46 | virtual void mouseClicked(MouseEvent* e) { }
|
---|
| 47 | virtual void mouseEntered(MouseEvent* e) { }
|
---|
| 48 | virtual void mouseExited(MouseEvent* e) { }
|
---|
| 49 |
|
---|
| 50 | // This is when the mouse button goes DOWN.
|
---|
| 51 | void mousePressed(MouseEvent* e);
|
---|
| 52 |
|
---|
| 53 | // This is when the mouse button is let UP.
|
---|
| 54 | void mouseReleased(MouseEvent* e);
|
---|
| 55 |
|
---|
| 56 | /* MouseMotionListener callbacks */
|
---|
| 57 | void mouseMoved(MouseEvent *e);
|
---|
| 58 |
|
---|
| 59 | // This is when the mouse is clicked, held and dragged.
|
---|
| 60 | void mouseDragged(MouseEvent *e);
|
---|
| 61 |
|
---|
| 62 | void mouseDragDropped(MouseEvent *e);
|
---|
| 63 | void keyPressed(KeyEvent* e);
|
---|
| 64 |
|
---|
| 65 | void keyReleased(KeyEvent* e);
|
---|
| 66 | void keyClicked(KeyEvent* e);
|
---|
| 67 |
|
---|
| 68 | /** The information about camera position and orienation per frame.
|
---|
| 69 | */
|
---|
| 70 | typedef struct
|
---|
| 71 | {
|
---|
| 72 | Vector3 position;
|
---|
| 73 | Quaternion orientation;
|
---|
| 74 | Real timeElapsed;
|
---|
| 75 | } frame_info;
|
---|
| 76 |
|
---|
| 77 | enum {WALKTHROUGH, REPLAY, STATE_NUM};
|
---|
| 78 |
|
---|
| 79 | // visualization modes for scene nodes
|
---|
| 80 | enum {NODEVIZ_NONE, NODEVIZ_RENDER_NODES, NODEVIZ_RENDER_NODES_AND_CONTENT, NODEVIZ_MODES_NUM};
|
---|
| 81 | //enum {NODEVIZ_NONE, NODEVIZ_RENDER_GEOMETRY, NODEVIZ_MODES_NUM};
|
---|
| 82 |
|
---|
| 83 | void zoomVizCamera(int zoom);
|
---|
| 84 |
|
---|
| 85 | void addFrameInfo(SceneNode *camNode, Real timeElapsed);
|
---|
| 86 | void setCurrentFrameInfo(Real timeElapsed);
|
---|
| 87 |
|
---|
| 88 | void setAlgorithm(int algorithm);
|
---|
| 89 |
|
---|
| 90 | void moveCamera();
|
---|
| 91 |
|
---|
| 92 | void writeFrames();
|
---|
| 93 | void loadFrames();
|
---|
| 94 |
|
---|
| 95 | bool processUnbufferedKeyInput(const FrameEvent& evt);
|
---|
| 96 | bool processUnbufferedMouseInput(const FrameEvent& evt);
|
---|
| 97 |
|
---|
| 98 | void showStats(bool show);
|
---|
| 99 |
|
---|
| 100 | void updateStats();
|
---|
| 101 | void toggleShowHelp();
|
---|
| 102 | void toggleShowStats();
|
---|
| 103 |
|
---|
| 104 | void toggleShowShadows();
|
---|
| 105 | void toggleDisplayCameraDetails();
|
---|
| 106 | void takeScreenshot();
|
---|
| 107 | void nextSceneDetailLevel();
|
---|
| 108 | void nextFilter();
|
---|
| 109 | void nextAlgorithm();
|
---|
| 110 | void nextNodeVizMode();
|
---|
| 111 | void nextAppState();
|
---|
| 112 | void changeThreshold(int incr);
|
---|
| 113 | void changeAssumedVisibility(int incr);
|
---|
| 114 | void toggleTestGeometryForVisibleLeaves();
|
---|
| 115 | void toggleShowOctree();
|
---|
| 116 | void toggleUseDepthPass();
|
---|
[343] | 117 | void toggleUseArbQueries();
|
---|
[187] | 118 | void toggleShowViz();
|
---|
| 119 | void toggleRecord();
|
---|
| 120 |
|
---|
| 121 | bool Clamp2Floor();
|
---|
| 122 |
|
---|
| 123 | static String msAlgorithmCaptions[];
|
---|
| 124 |
|
---|
| 125 | protected:
|
---|
| 126 |
|
---|
| 127 | void initHelpOverlayElement(String name, int top);
|
---|
| 128 | void initOverlayElement(OverlayElement **elInfo, String ext, String name,
|
---|
| 129 | int top, String caption);
|
---|
| 130 |
|
---|
| 131 | //-- initialise overlays
|
---|
| 132 | void initHelpOverlay();
|
---|
| 133 | void initVisStatsOverlay();
|
---|
| 134 | void initQueryOverlay();
|
---|
| 135 |
|
---|
| 136 | void resetStats();
|
---|
| 137 |
|
---|
| 138 | SceneManager *mSceneMgr; // A pointer to the scene manager
|
---|
| 139 |
|
---|
| 140 | CEGUI::Renderer *mGUIRenderer; // cegui renderer
|
---|
| 141 |
|
---|
| 142 | int mCurrentAlgorithm;
|
---|
| 143 | int mVisibilityThreshold;
|
---|
| 144 | int mAssumedVisibility;
|
---|
| 145 | // the current frame number
|
---|
| 146 | int mCurrentFrame;
|
---|
| 147 | // the current application state
|
---|
| 148 | int mAppState;
|
---|
| 149 | // visualization mode
|
---|
| 150 | int mNodeVizMode;
|
---|
| 151 |
|
---|
| 152 |
|
---|
| 153 | OverlayElement *mAlgorithmInfo;
|
---|
| 154 | OverlayElement *mThresholdInfo;
|
---|
| 155 | OverlayElement *mAssumedVisibilityInfo;
|
---|
| 156 | OverlayElement *mFrustumCulledNodesInfo;
|
---|
| 157 | OverlayElement *mQueryCulledNodesInfo;
|
---|
| 158 | OverlayElement *mTraversedNodesInfo;
|
---|
| 159 | OverlayElement *mHierarchyNodesInfo;
|
---|
| 160 | OverlayElement *mTestGeometryForVisibleLeavesInfo;
|
---|
| 161 | OverlayElement *mUseDepthPassInfo;
|
---|
[343] | 162 | OverlayElement *mUseArbQueriesInfo;
|
---|
[187] | 163 | OverlayElement *mRenderedNodesInfo;
|
---|
| 164 | OverlayElement *mObjectsCountInfo;
|
---|
| 165 | OverlayElement *mQueriesIssuedInfo;
|
---|
| 166 | OverlayElement *mDelayedQueriesIssuedInfo;
|
---|
| 167 | OverlayElement *mDelayedTraversedNodesInfo;
|
---|
| 168 | OverlayElement *mCurrentObjectTypeInfo;
|
---|
| 169 |
|
---|
| 170 | OverlayElement *mQueryTypeInfo;
|
---|
| 171 | OverlayElement *mQueryVisibleNodesInfo;
|
---|
| 172 | OverlayElement *mQueryVisibleGeometryInfo;
|
---|
| 173 | OverlayElement *mQueryVisiblePatchInfo;
|
---|
| 174 |
|
---|
| 175 | OverlayElement *mQueryVisiblityInfo;
|
---|
| 176 | OverlayElement *mQueryNodeVisibilityInfo;
|
---|
| 177 | OverlayElement *mQueryGeometryVisibilityInfo;
|
---|
| 178 | OverlayElement *mQueryPatchVisibilityInfo;
|
---|
| 179 | //OverlayElement *mHelpInfo;
|
---|
| 180 |
|
---|
| 181 | bool mTestGeometryForVisibleLeaves;
|
---|
| 182 | bool mShowOctree;
|
---|
| 183 | bool mUseDepthPass;
|
---|
[343] | 184 | bool mUseArbQueries;
|
---|
[187] | 185 | bool mShowVisualization;
|
---|
| 186 | bool mCullCamera;
|
---|
[254] | 187 | bool mRecordFrames;
|
---|
[187] | 188 | bool mShowShadows;
|
---|
| 189 | bool mVisualizeCulledNodes;
|
---|
| 190 | bool mShowHelp;
|
---|
| 191 | bool mStatsOn;
|
---|
| 192 | bool mLMouseDown, mRMouseDown; // True if the mouse buttons are down
|
---|
| 193 | bool mShutdownRequested;
|
---|
| 194 | bool mDisplayCameraDetails;
|
---|
| 195 | bool mUseItemBuffer;
|
---|
| 196 | bool mUseAnimation;
|
---|
| 197 |
|
---|
| 198 | int mItemBufferMode;
|
---|
| 199 |
|
---|
| 200 | Real mVizCameraHeight;
|
---|
| 201 |
|
---|
| 202 | Camera *mVizCamera;
|
---|
| 203 | SceneNode *mCamNode;
|
---|
| 204 |
|
---|
| 205 | std::vector<frame_info> mFrameInfo;
|
---|
| 206 |
|
---|
| 207 | Real mReplayTimeElapsed;
|
---|
| 208 | //EventProcessor* mEventProcessor;
|
---|
| 209 | InputReader* mInputDevice;
|
---|
| 210 | Camera* mCamera;
|
---|
| 211 |
|
---|
| 212 | Vector3 mTranslateVector;
|
---|
| 213 | RenderWindow* mWindow;
|
---|
| 214 |
|
---|
| 215 | unsigned int mNumScreenShots;
|
---|
| 216 | int mSceneDetailIndex;
|
---|
| 217 | int mAniso;
|
---|
| 218 |
|
---|
| 219 | float mMoveScale;
|
---|
| 220 | Real mMoveSpeed;
|
---|
| 221 | Degree mRotScale;
|
---|
| 222 |
|
---|
| 223 | // just to stop toggles flipping too fast
|
---|
| 224 | Real mTimeDelay;
|
---|
| 225 | Radian mRotX, mRotY;
|
---|
| 226 | TextureFilterOptions mFiltering;
|
---|
| 227 |
|
---|
| 228 | Degree mRotateSpeed;
|
---|
| 229 |
|
---|
| 230 | Overlay* mDebugOverlay;
|
---|
| 231 | Overlay* mHelpOverlay;
|
---|
| 232 | Overlay* mCullStatsOverlay;
|
---|
| 233 | Overlay* mQueryOverlay;
|
---|
| 234 |
|
---|
| 235 | Light *mSunLight;
|
---|
| 236 | GtpVisibility::VisibilityManager *mVisibilityManager;
|
---|
| 237 | EventProcessor* mEventProcessor;
|
---|
| 238 |
|
---|
| 239 | bool mShiftPressed;
|
---|
| 240 | bool mShowQueryStats;
|
---|
| 241 |
|
---|
[259] | 242 | unsigned long mAccumulatedFps;
|
---|
| 243 | unsigned long mAccumulatedTris;
|
---|
[187] | 244 | unsigned long mFrameCount;
|
---|
| 245 |
|
---|
| 246 | //bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn;
|
---|
| 247 |
|
---|
| 248 | float mDelayedQueriesIssued;
|
---|
| 249 | float mDelayedTraversedNodes;
|
---|
| 250 |
|
---|
| 251 | TestCullingIVApplication *mApplication;
|
---|
| 252 | RaySceneQuery *mRaySceneQuery;
|
---|
| 253 | };
|
---|
| 254 |
|
---|
| 255 |
|
---|
| 256 | #endif //_IVFrameListener_H__ |
---|