[47] | 1 | /**
|
---|
| 2 | \file
|
---|
[48] | 3 | TestCullingTerrainApplication.h
|
---|
[47] | 4 | */
|
---|
| 5 | #include "CEGUIForwardRefs.h"
|
---|
| 6 | #include "ExampleApplication.h"
|
---|
| 7 | #include "OgreOcclusionCullingSceneTraverser.h"
|
---|
[55] | 8 | #include "TerrainContentGenerator.h"
|
---|
[47] | 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 |
|
---|
| 20 | String mCurrentAlgorithmCaptions[OcclusionCullingSceneTraverser::NUM_RENDERMODES] =
|
---|
| 21 | {
|
---|
| 22 | "Cull Frustum",
|
---|
| 23 | "Stop and Wait",
|
---|
| 24 | "Coherent Occlusion Culling"
|
---|
| 25 | };
|
---|
| 26 |
|
---|
| 27 | class MouseQueryListener : public ExampleFrameListener, public MouseListener, public MouseMotionListener
|
---|
| 28 | {
|
---|
| 29 | public:
|
---|
| 30 |
|
---|
[55] | 31 | MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager,
|
---|
| 32 | CEGUI::Renderer *renderer, RayQueryExecutor *rqe);
|
---|
[47] | 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 |
|
---|
| 62 | void changeAlgorithm();
|
---|
| 63 | void changeThreshold(int incr);
|
---|
| 64 | void changeStats();
|
---|
| 65 |
|
---|
| 66 | protected:
|
---|
| 67 | bool mLMouseDown, mRMouseDown; // True if the mouse buttons are down
|
---|
| 68 | SceneManager *mSceneMgr; // A pointer to the scene manager
|
---|
| 69 |
|
---|
| 70 | CEGUI::Renderer *mGUIRenderer; // cegui renderer
|
---|
| 71 |
|
---|
| 72 | bool mShutdownRequested;
|
---|
| 73 | int mCurrentAlgorithm;
|
---|
| 74 | int mThreshold;
|
---|
| 75 |
|
---|
| 76 | OverlayElement *mAlgorithmInfo;
|
---|
| 77 | OverlayElement *mThresholdInfo;
|
---|
| 78 | OverlayElement *mFrustumCulledNodesInfo;
|
---|
| 79 | OverlayElement *mQueryCulledNodesInfo;
|
---|
| 80 | OverlayElement *mTraversedNodesInfo;
|
---|
| 81 | OverlayElement *mHierarchyNodesInfo;
|
---|
| 82 | OverlayElement *mSceneNodesInfo;
|
---|
[52] | 83 | OverlayElement *mRenderedNodesInfo;
|
---|
[47] | 84 |
|
---|
| 85 | SceneNode *mCurrentObject; // The newly created object
|
---|
[55] | 86 | RaySceneQuery *mRaySceneQuery; // The ray scene query pointer
|
---|
[47] | 87 | int mCount; // The number of robots on the screen
|
---|
[55] | 88 |
|
---|
| 89 | RayQueryExecutor *mRayQueryExecutor;
|
---|
[47] | 90 | };
|
---|
| 91 |
|
---|
| 92 |
|
---|
[48] | 93 | class TestCullingTerrainApplication : public ExampleApplication
|
---|
[47] | 94 | {
|
---|
| 95 | public:
|
---|
[55] | 96 | ~TestCullingTerrainApplication();
|
---|
[47] | 97 |
|
---|
| 98 | protected:
|
---|
| 99 | void createScene(void);
|
---|
| 100 | void createFrameListener(void);
|
---|
| 101 | void setupGui(void);
|
---|
| 102 | virtual void createCamera(void);
|
---|
| 103 |
|
---|
[55] | 104 | /** |
---|
| 105 | generates a new scene object |
---|
| 106 | @param tranlationRatio ratio between minimal and maximal possible translation |
---|
| 107 | @param rotationRatio ratio between minimal and maximal possible rotation |
---|
| 108 | @idx the index of the new object |
---|
| 109 | @entName the name of the object entity |
---|
| 110 | */ |
---|
| 111 | void generateSceneObject(const Vector3 &translationRatio, const Vector3 &rotationRatio,
|
---|
| 112 | const int idx, const String &entName);
|
---|
| 113 |
|
---|
[47] | 114 | CEGUI::OgreCEGUIRenderer *mGUIRenderer;
|
---|
| 115 | CEGUI::System *mGUISystem;
|
---|
[55] | 116 | RayQueryExecutor *mRayQueryExecutor;
|
---|
| 117 | TerrainContentGenerator *mTerrainContentGenerator;
|
---|
[47] | 118 |
|
---|
[55] | 119 | Vector3 mMinTranslation; |
---|
| 120 | Vector3 mMaxTranslation; |
---|
| 121 | |
---|
| 122 | Vector3 mMinAngle; |
---|
| 123 | Vector3 mMaxAngle;
|
---|
| 124 |
|
---|
[47] | 125 | private:
|
---|
| 126 | void chooseSceneManager(void);
|
---|
| 127 | };
|
---|
| 128 |
|
---|