[61] | 1 | /**
|
---|
| 2 | \file
|
---|
| 3 | TestCullingTerrainApplication.h
|
---|
| 4 | */
|
---|
| 5 | #include "CEGUIForwardRefs.h"
|
---|
| 6 | #include "ExampleApplication.h"
|
---|
| 7 | #include "TerrainContentGenerator.h"
|
---|
[74] | 8 | #include "VisibilityEnvironment.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,
|
---|
[94] | 32 | CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator, Camera *vizCamera);
|
---|
[61] | 33 |
|
---|
[80] | 34 | ~MouseQueryListener();
|
---|
[61] | 35 |
|
---|
| 36 | bool frameStarted(const FrameEvent& evt);
|
---|
| 37 | bool frameEnded(const FrameEvent& evt);
|
---|
| 38 |
|
---|
| 39 | /* MouseListener callbacks. */
|
---|
| 40 | virtual void mouseClicked(MouseEvent* e) { }
|
---|
| 41 | virtual void mouseEntered(MouseEvent* e) { }
|
---|
| 42 | virtual void mouseExited(MouseEvent* e) { }
|
---|
| 43 |
|
---|
| 44 | // This is when the mouse button goes DOWN.
|
---|
| 45 | virtual void mousePressed(MouseEvent* e);
|
---|
| 46 |
|
---|
| 47 | // This is when the mouse button is let UP.
|
---|
| 48 | virtual void mouseReleased(MouseEvent* e);
|
---|
| 49 |
|
---|
| 50 | /* MouseMotionListener callbacks */
|
---|
| 51 | virtual void mouseMoved (MouseEvent *e);
|
---|
| 52 |
|
---|
| 53 | // This is when the mouse is clicked, held and dragged.
|
---|
| 54 | virtual void mouseDragged (MouseEvent *e);
|
---|
| 55 |
|
---|
| 56 | void keyPressed(KeyEvent* e);
|
---|
| 57 |
|
---|
| 58 | void keyReleased(KeyEvent* e);
|
---|
| 59 | void keyClicked(KeyEvent* e);
|
---|
| 60 |
|
---|
[85] | 61 | void nextAlgorithm();
|
---|
| 62 | void setAlgorithm(int algorithm);
|
---|
[61] | 63 | void changeThreshold(int incr);
|
---|
[87] | 64 | void updateStats();
|
---|
[86] | 65 | void toggleUseOptimization();
|
---|
| 66 | void toggleShowOctree();
|
---|
[87] | 67 | void toggleUseCulling();
|
---|
[93] | 68 | void toggleCullCamera();
|
---|
[94] | 69 | void FixVizCamera();
|
---|
[61] | 70 |
|
---|
| 71 | protected:
|
---|
[94] | 72 | void clamp2Terrain(Camera *cam);
|
---|
| 73 |
|
---|
[61] | 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;
|
---|
[86] | 89 | OverlayElement *mUseOptimizationInfo;
|
---|
[61] | 90 | OverlayElement *mRenderedNodesInfo;
|
---|
[87] | 91 | OverlayElement *mObjectsInfo;
|
---|
| 92 | OverlayElement *mQueriesIssuedInfo;
|
---|
[61] | 93 |
|
---|
| 94 | SceneNode *mCurrentObject; // The newly created object
|
---|
| 95 | int mCount; // The number of robots on the screen
|
---|
| 96 |
|
---|
| 97 | RayQueryExecutor *mRayQueryExecutor;
|
---|
[82] | 98 | TerrainContentGenerator *mTerrainContentGenerator;
|
---|
[86] | 99 |
|
---|
| 100 | bool mUseOptimization;
|
---|
| 101 | bool mShowOctree;
|
---|
[87] | 102 | bool mUseCulling;
|
---|
[93] | 103 | bool mUseCullCamera;
|
---|
| 104 |
|
---|
[94] | 105 | Camera *mVisualizationCamera;
|
---|
[61] | 106 | };
|
---|
| 107 |
|
---|
| 108 |
|
---|
| 109 | class TestCullingTerrainApplication : public ExampleApplication
|
---|
| 110 | {
|
---|
| 111 | public:
|
---|
| 112 | ~TestCullingTerrainApplication();
|
---|
| 113 |
|
---|
| 114 | protected:
|
---|
[85] | 115 | void createScene();
|
---|
| 116 | void createFrameListener();
|
---|
| 117 | void setupGui();
|
---|
| 118 | virtual void createCamera();
|
---|
[61] | 119 |
|
---|
| 120 | CEGUI::OgreCEGUIRenderer *mGUIRenderer;
|
---|
| 121 | CEGUI::System *mGUISystem;
|
---|
| 122 |
|
---|
[87] | 123 | Vector3 mMinTranslation;
|
---|
| 124 | Vector3 mMaxTranslation;
|
---|
| 125 |
|
---|
| 126 | Vector3 mMinAngle;
|
---|
[61] | 127 | Vector3 mMaxAngle;
|
---|
| 128 |
|
---|
[82] | 129 | TerrainContentGenerator *mTerrainContentGenerator;
|
---|
[75] | 130 |
|
---|
[94] | 131 | Camera *mVisualizationCamera;
|
---|
[93] | 132 |
|
---|
[61] | 133 | private:
|
---|
| 134 | void chooseSceneManager(void);
|
---|
| 135 | };
|
---|
| 136 |
|
---|