[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"
|
---|
[99] | 9 | #include <OgreRenderTargetListener.h>
|
---|
[61] | 10 |
|
---|
[100] | 11 |
|
---|
[61] | 12 | Real timeDelay = 0;
|
---|
| 13 | #define KEY_PRESSED(_key,_timeDelay, _macro) \
|
---|
| 14 | { \
|
---|
| 15 | if (mInputDevice->isKeyDown(_key) && timeDelay <= 0) \
|
---|
| 16 | { \
|
---|
| 17 | timeDelay = _timeDelay; \
|
---|
| 18 | _macro ; \
|
---|
| 19 | } \
|
---|
| 20 | }
|
---|
| 21 |
|
---|
[74] | 22 | String mCurrentAlgorithmCaptions[GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS] =
|
---|
[61] | 23 | {
|
---|
[74] | 24 | "View Frustum Culling",
|
---|
| 25 | "Stop and Wait Culling",
|
---|
| 26 | "Coherent Hierarchical Culling"
|
---|
[61] | 27 | };
|
---|
| 28 |
|
---|
[99] | 29 | class VisualizationRenderTargetListener: public RenderTargetListener
|
---|
| 30 | {
|
---|
| 31 | public:
|
---|
| 32 | VisualizationRenderTargetListener(SceneManager *sceneMgr);
|
---|
| 33 |
|
---|
| 34 | protected:
|
---|
| 35 | void preViewportUpdate (const RenderTargetViewportEvent &evt);
|
---|
| 36 | void postRenderTargetUpdate (const RenderTargetEvent &evt);
|
---|
| 37 |
|
---|
| 38 | SceneManager *mSceneMgr;
|
---|
| 39 | };
|
---|
| 40 |
|
---|
[61] | 41 | class MouseQueryListener : public ExampleFrameListener, public MouseListener, public MouseMotionListener
|
---|
| 42 | {
|
---|
| 43 | public:
|
---|
| 44 |
|
---|
| 45 | MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager,
|
---|
[100] | 46 | CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator, Camera *vizCamera,
|
---|
| 47 | SceneNode *camNode);
|
---|
[61] | 48 |
|
---|
[80] | 49 | ~MouseQueryListener();
|
---|
[61] | 50 |
|
---|
| 51 | bool frameStarted(const FrameEvent& evt);
|
---|
| 52 | bool frameEnded(const FrameEvent& evt);
|
---|
[100] | 53 | bool processUnbufferedKeyInput(const FrameEvent& evt);
|
---|
| 54 |
|
---|
[61] | 55 |
|
---|
| 56 | /* MouseListener callbacks. */
|
---|
| 57 | virtual void mouseClicked(MouseEvent* e) { }
|
---|
| 58 | virtual void mouseEntered(MouseEvent* e) { }
|
---|
| 59 | virtual void mouseExited(MouseEvent* e) { }
|
---|
| 60 |
|
---|
| 61 | // This is when the mouse button goes DOWN.
|
---|
| 62 | virtual void mousePressed(MouseEvent* e);
|
---|
| 63 |
|
---|
| 64 | // This is when the mouse button is let UP.
|
---|
| 65 | virtual void mouseReleased(MouseEvent* e);
|
---|
| 66 |
|
---|
| 67 | /* MouseMotionListener callbacks */
|
---|
| 68 | virtual void mouseMoved (MouseEvent *e);
|
---|
| 69 |
|
---|
| 70 | // This is when the mouse is clicked, held and dragged.
|
---|
| 71 | virtual void mouseDragged (MouseEvent *e);
|
---|
| 72 |
|
---|
| 73 | void keyPressed(KeyEvent* e);
|
---|
| 74 |
|
---|
| 75 | void keyReleased(KeyEvent* e);
|
---|
| 76 | void keyClicked(KeyEvent* e);
|
---|
| 77 |
|
---|
[85] | 78 | void nextAlgorithm();
|
---|
| 79 | void setAlgorithm(int algorithm);
|
---|
[61] | 80 | void changeThreshold(int incr);
|
---|
[87] | 81 | void updateStats();
|
---|
[86] | 82 | void toggleUseOptimization();
|
---|
| 83 | void toggleShowOctree();
|
---|
[99] | 84 | void toggleUseVisibilityCulling();
|
---|
| 85 | void toggleShowViz();
|
---|
[103] | 86 | void toggleRenderNodesForViz();
|
---|
[100] | 87 | void zoomVizCamera(int zoom);
|
---|
| 88 | void moveCamera();
|
---|
[61] | 89 |
|
---|
[104] | 90 |
|
---|
[61] | 91 | protected:
|
---|
[104] | 92 | void Clamp2Terrain();
|
---|
[94] | 93 |
|
---|
[104] | 94 | bool NextLocation();
|
---|
| 95 |
|
---|
[61] | 96 | bool mLMouseDown, mRMouseDown; // True if the mouse buttons are down
|
---|
| 97 | SceneManager *mSceneMgr; // A pointer to the scene manager
|
---|
| 98 |
|
---|
| 99 | CEGUI::Renderer *mGUIRenderer; // cegui renderer
|
---|
| 100 |
|
---|
| 101 | bool mShutdownRequested;
|
---|
| 102 | int mCurrentAlgorithm;
|
---|
[85] | 103 | int mVisibilityThreshold;
|
---|
[61] | 104 |
|
---|
| 105 | OverlayElement *mAlgorithmInfo;
|
---|
| 106 | OverlayElement *mThresholdInfo;
|
---|
| 107 | OverlayElement *mFrustumCulledNodesInfo;
|
---|
| 108 | OverlayElement *mQueryCulledNodesInfo;
|
---|
| 109 | OverlayElement *mTraversedNodesInfo;
|
---|
| 110 | OverlayElement *mHierarchyNodesInfo;
|
---|
[86] | 111 | OverlayElement *mUseOptimizationInfo;
|
---|
[61] | 112 | OverlayElement *mRenderedNodesInfo;
|
---|
[87] | 113 | OverlayElement *mObjectsInfo;
|
---|
| 114 | OverlayElement *mQueriesIssuedInfo;
|
---|
[61] | 115 |
|
---|
| 116 | SceneNode *mCurrentObject; // The newly created object
|
---|
| 117 | int mCount; // The number of robots on the screen
|
---|
| 118 |
|
---|
| 119 | RayQueryExecutor *mRayQueryExecutor;
|
---|
[82] | 120 | TerrainContentGenerator *mTerrainContentGenerator;
|
---|
[86] | 121 |
|
---|
| 122 | bool mUseOptimization;
|
---|
| 123 | bool mShowOctree;
|
---|
[99] | 124 | bool mUseVisibilityCulling;
|
---|
| 125 | bool mShowVisualization;
|
---|
[103] | 126 | bool mRenderNodesForViz;
|
---|
[100] | 127 | bool mCullCamera;
|
---|
[93] | 128 |
|
---|
[100] | 129 | Real mVizCameraHeight;
|
---|
| 130 |
|
---|
| 131 | Camera *mVizCamera;
|
---|
| 132 | SceneNode *mCamNode;
|
---|
[104] | 133 | Real mWalkSpeed;
|
---|
| 134 | Real mDistance;
|
---|
| 135 | Vector3 mDestination;
|
---|
| 136 | Vector3 mDirection;
|
---|
[100] | 137 |
|
---|
[104] | 138 | std::deque<Vector3> mWalkList; // The list of points we are walking to
|
---|
[61] | 139 | };
|
---|
| 140 |
|
---|
| 141 |
|
---|
| 142 | class TestCullingTerrainApplication : public ExampleApplication
|
---|
| 143 | {
|
---|
| 144 | public:
|
---|
| 145 | ~TestCullingTerrainApplication();
|
---|
| 146 |
|
---|
| 147 | protected:
|
---|
[99] | 148 | //-- inherited from ExampleApplication
|
---|
| 149 | bool setup();
|
---|
[85] | 150 | void createScene();
|
---|
| 151 | void createFrameListener();
|
---|
[99] | 152 | void createCamera();
|
---|
| 153 | //void createViewports();
|
---|
| 154 |
|
---|
| 155 | virtual void createRenderTargetListener();
|
---|
| 156 |
|
---|
| 157 | /** cegui setup */
|
---|
[85] | 158 | void setupGui();
|
---|
[61] | 159 |
|
---|
| 160 | CEGUI::OgreCEGUIRenderer *mGUIRenderer;
|
---|
| 161 | CEGUI::System *mGUISystem;
|
---|
| 162 |
|
---|
[87] | 163 | Vector3 mMinTranslation;
|
---|
| 164 | Vector3 mMaxTranslation;
|
---|
| 165 |
|
---|
| 166 | Vector3 mMinAngle;
|
---|
[61] | 167 | Vector3 mMaxAngle;
|
---|
| 168 |
|
---|
[82] | 169 | TerrainContentGenerator *mTerrainContentGenerator;
|
---|
[99] | 170 |
|
---|
[100] | 171 | Camera *mVizCamera;
|
---|
| 172 | SceneNode *mCamNode;
|
---|
[99] | 173 | VisualizationRenderTargetListener *mRenderTargetListener;
|
---|
[75] | 174 |
|
---|
[61] | 175 | private:
|
---|
| 176 | void chooseSceneManager(void);
|
---|
[99] | 177 | }; |
---|