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