[61] | 1 | /**
|
---|
| 2 | \file
|
---|
| 3 | TestCullingApplication.h
|
---|
| 4 | */
|
---|
| 5 | #include "CEGUIForwardRefs.h"
|
---|
| 6 | #include "ExampleApplication.h"
|
---|
[74] | 7 | #include "VisibilityEnvironment.h"
|
---|
[85] | 8 | #include "SceneContentGenerator.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 |
|
---|
| 27 | class MouseQueryListener : public ExampleFrameListener, public MouseListener, public MouseMotionListener
|
---|
| 28 | {
|
---|
| 29 | public:
|
---|
| 30 |
|
---|
| 31 | MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager,
|
---|
[85] | 32 | CEGUI::Renderer *renderer, SceneContentGenerator *sceneContentGenerator);
|
---|
[61] | 33 |
|
---|
| 34 |
|
---|
| 35 | ~MouseQueryListener( );
|
---|
| 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();
|
---|
[87] | 68 | void toggleUseCulling();
|
---|
[61] | 69 |
|
---|
| 70 | protected:
|
---|
| 71 | bool mLMouseDown, mRMouseDown; // True if the mouse buttons are down
|
---|
| 72 | SceneManager *mSceneMgr; // A pointer to the scene manager
|
---|
| 73 |
|
---|
| 74 | CEGUI::Renderer *mGUIRenderer; // cegui renderer
|
---|
| 75 |
|
---|
| 76 | bool mShutdownRequested;
|
---|
| 77 | int mCurrentAlgorithm;
|
---|
[85] | 78 | int mVisibilityThreshold;
|
---|
[61] | 79 |
|
---|
| 80 | OverlayElement *mAlgorithmInfo;
|
---|
| 81 | OverlayElement *mThresholdInfo;
|
---|
| 82 | OverlayElement *mFrustumCulledNodesInfo;
|
---|
| 83 | OverlayElement *mQueryCulledNodesInfo;
|
---|
| 84 | OverlayElement *mTraversedNodesInfo;
|
---|
| 85 | OverlayElement *mHierarchyNodesInfo;
|
---|
| 86 | OverlayElement *mRenderedNodesInfo;
|
---|
[87] | 87 | OverlayElement *mObjectsInfo;
|
---|
[86] | 88 | OverlayElement *mUseOptimizationInfo;
|
---|
[87] | 89 | OverlayElement *mQueriesIssuedInfo;
|
---|
[85] | 90 |
|
---|
| 91 | SceneContentGenerator *mSceneContentGenerator;
|
---|
[86] | 92 |
|
---|
| 93 | bool mUseOptimization;
|
---|
| 94 | bool mShowOctree;
|
---|
[87] | 95 | bool mUseCulling;
|
---|
[61] | 96 | };
|
---|
| 97 |
|
---|
| 98 |
|
---|
| 99 | class TestCullingApplication : public ExampleApplication
|
---|
| 100 | {
|
---|
[85] | 101 | public:
|
---|
| 102 | ~TestCullingApplication();
|
---|
[61] | 103 |
|
---|
[85] | 104 | protected:
|
---|
| 105 | void createScene();
|
---|
| 106 | void createFrameListener();
|
---|
| 107 | void setupGui();
|
---|
| 108 |
|
---|
[61] | 109 | //virtual void createCamera(void);
|
---|
| 110 |
|
---|
| 111 | CEGUI::OgreCEGUIRenderer *mGUIRenderer;
|
---|
| 112 | CEGUI::System *mGUISystem;
|
---|
| 113 |
|
---|
[79] | 114 | Vector3 mMinTranslation;
|
---|
| 115 | Vector3 mMaxTranslation;
|
---|
| 116 |
|
---|
| 117 | Vector3 mMinAngle;
|
---|
[61] | 118 | Vector3 mMaxAngle;
|
---|
| 119 |
|
---|
[85] | 120 | SceneContentGenerator *mSceneContentGenerator;
|
---|
| 121 |
|
---|
[61] | 122 | private:
|
---|
| 123 | void chooseSceneManager(void);
|
---|
| 124 | };
|
---|
| 125 |
|
---|