[160] | 1 | #ifndef _TerrainFrameListener_H__
|
---|
| 2 | #define _TerrainFrameListener_H__
|
---|
| 3 |
|
---|
[61] | 4 | #include "CEGUIForwardRefs.h"
|
---|
| 5 | #include "ExampleApplication.h"
|
---|
[74] | 6 | #include "VisibilityEnvironment.h"
|
---|
[107] | 7 | #include "OgreSceneContentGenerator.h"
|
---|
[61] | 8 |
|
---|
| 9 | Real timeDelay = 0;
|
---|
| 10 | #define KEY_PRESSED(_key,_timeDelay, _macro) \
|
---|
| 11 | { \
|
---|
| 12 | if (mInputDevice->isKeyDown(_key) && timeDelay <= 0) \
|
---|
| 13 | { \
|
---|
| 14 | timeDelay = _timeDelay; \
|
---|
| 15 | _macro ; \
|
---|
| 16 | } \
|
---|
| 17 | }
|
---|
| 18 |
|
---|
[254] | 19 | String mCurrentAlgorithmCaptions[] =
|
---|
[61] | 20 | {
|
---|
[74] | 21 | "View Frustum Culling",
|
---|
| 22 | "Stop and Wait Culling",
|
---|
| 23 | "Coherent Hierarchical Culling"
|
---|
[61] | 24 | };
|
---|
| 25 |
|
---|
[133] | 26 | class TerrainFrameListener : public ExampleFrameListener, public MouseListener, public MouseMotionListener
|
---|
[61] | 27 | {
|
---|
| 28 | public:
|
---|
| 29 |
|
---|
[160] | 30 | TerrainFrameListener(RenderWindow* win,
|
---|
| 31 | Camera* cam,
|
---|
| 32 | SceneManager *sceneManager,
|
---|
| 33 | CEGUI::Renderer *renderer,
|
---|
| 34 | SceneContentGenerator *sceneContentGenerator);
|
---|
[61] | 35 |
|
---|
| 36 |
|
---|
[160] | 37 | ~TerrainFrameListener();
|
---|
[61] | 38 |
|
---|
| 39 | bool frameStarted(const FrameEvent& evt);
|
---|
| 40 | bool frameEnded(const FrameEvent& evt);
|
---|
| 41 |
|
---|
| 42 | /* MouseListener callbacks. */
|
---|
| 43 | virtual void mouseClicked(MouseEvent* e) { }
|
---|
| 44 | virtual void mouseEntered(MouseEvent* e) { }
|
---|
| 45 | virtual void mouseExited(MouseEvent* e) { }
|
---|
| 46 |
|
---|
| 47 | // This is when the mouse button goes DOWN.
|
---|
| 48 | virtual void mousePressed(MouseEvent* e);
|
---|
| 49 |
|
---|
| 50 | // This is when the mouse button is let UP.
|
---|
| 51 | virtual void mouseReleased(MouseEvent* e);
|
---|
| 52 |
|
---|
| 53 | /* MouseMotionListener callbacks */
|
---|
| 54 | virtual void mouseMoved (MouseEvent *e);
|
---|
| 55 |
|
---|
| 56 | // This is when the mouse is clicked, held and dragged.
|
---|
| 57 | virtual void mouseDragged (MouseEvent *e);
|
---|
| 58 |
|
---|
| 59 | void keyPressed(KeyEvent* e);
|
---|
| 60 |
|
---|
| 61 | void keyReleased(KeyEvent* e);
|
---|
| 62 | void keyClicked(KeyEvent* e);
|
---|
| 63 |
|
---|
[85] | 64 | void nextAlgorithm();
|
---|
| 65 | void setAlgorithm(int algorithm);
|
---|
[61] | 66 | void changeThreshold(int incr);
|
---|
[87] | 67 | void updateStats();
|
---|
[155] | 68 | void toggleTestGeometryForVisibleLeaves();
|
---|
[86] | 69 | void toggleShowOctree();
|
---|
[115] | 70 | void toggleUseDepthPass();
|
---|
[99] | 71 | void toggleShowViz();
|
---|
[61] | 72 |
|
---|
| 73 | protected:
|
---|
| 74 | bool mLMouseDown, mRMouseDown; // True if the mouse buttons are down
|
---|
| 75 | SceneManager *mSceneMgr; // A pointer to the scene manager
|
---|
| 76 |
|
---|
| 77 | CEGUI::Renderer *mGUIRenderer; // cegui renderer
|
---|
| 78 |
|
---|
| 79 | bool mShutdownRequested;
|
---|
| 80 | int mCurrentAlgorithm;
|
---|
[85] | 81 | int mVisibilityThreshold;
|
---|
[61] | 82 |
|
---|
| 83 | OverlayElement *mAlgorithmInfo;
|
---|
| 84 | OverlayElement *mThresholdInfo;
|
---|
| 85 | OverlayElement *mFrustumCulledNodesInfo;
|
---|
| 86 | OverlayElement *mQueryCulledNodesInfo;
|
---|
| 87 | OverlayElement *mTraversedNodesInfo;
|
---|
| 88 | OverlayElement *mHierarchyNodesInfo;
|
---|
| 89 | OverlayElement *mRenderedNodesInfo;
|
---|
[160] | 90 | OverlayElement *mObjectsCountInfo;
|
---|
[155] | 91 | OverlayElement *mTestGeometryForVisibleLeavesInfo;
|
---|
[87] | 92 | OverlayElement *mQueriesIssuedInfo;
|
---|
[85] | 93 |
|
---|
| 94 | SceneContentGenerator *mSceneContentGenerator;
|
---|
[86] | 95 |
|
---|
[155] | 96 | bool mTestGeometryForVisibleLeaves;
|
---|
[86] | 97 | bool mShowOctree;
|
---|
[115] | 98 | bool mUseDepthPass;
|
---|
[99] | 99 | bool mShowVisualization;
|
---|
[93] | 100 |
|
---|
[112] | 101 | bool mVisualizeCulledNodes;
|
---|
| 102 |
|
---|
[100] | 103 | Camera *mVizCamera;
|
---|
[61] | 104 | };
|
---|
| 105 |
|
---|
| 106 |
|
---|
| 107 | class TestCullingApplication : public ExampleApplication
|
---|
| 108 | {
|
---|
[85] | 109 | public:
|
---|
| 110 | ~TestCullingApplication();
|
---|
[61] | 111 |
|
---|
[85] | 112 | protected:
|
---|
| 113 | void createScene();
|
---|
| 114 | void createFrameListener();
|
---|
| 115 | void setupGui();
|
---|
| 116 |
|
---|
[61] | 117 | //virtual void createCamera(void);
|
---|
| 118 |
|
---|
| 119 | CEGUI::OgreCEGUIRenderer *mGUIRenderer;
|
---|
| 120 | CEGUI::System *mGUISystem;
|
---|
| 121 |
|
---|
[79] | 122 | Vector3 mMinTranslation;
|
---|
| 123 | Vector3 mMaxTranslation;
|
---|
| 124 |
|
---|
| 125 | Vector3 mMinAngle;
|
---|
[61] | 126 | Vector3 mMaxAngle;
|
---|
| 127 |
|
---|
[85] | 128 | SceneContentGenerator *mSceneContentGenerator;
|
---|
| 129 |
|
---|
[61] | 130 | private:
|
---|
| 131 | void chooseSceneManager(void);
|
---|
| 132 | };
|
---|
| 133 |
|
---|
[160] | 134 | #endif // _TerrainFrameListener_H__ |
---|