[12] | 1 | /**
|
---|
| 2 | \file
|
---|
| 3 | TestCullingApplication.h
|
---|
| 4 | */
|
---|
[18] | 5 | #include "CEGUIForwardRefs.h"
|
---|
[12] | 6 | #include "ExampleApplication.h"
|
---|
[32] | 7 | #include "OgreOcclusionCullingSceneTraverser.h"
|
---|
[12] | 8 |
|
---|
[55] | 9 |
|
---|
[28] | 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 |
|
---|
[32] | 20 | String mCurrentAlgorithmCaptions[OcclusionCullingSceneTraverser::NUM_RENDERMODES] =
|
---|
[28] | 21 | {
|
---|
| 22 | "Cull Frustum",
|
---|
| 23 | "Stop and Wait",
|
---|
| 24 | "Coherent Occlusion Culling"
|
---|
| 25 | };
|
---|
| 26 |
|
---|
[18] | 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);
|
---|
[27] | 33 |
|
---|
[18] | 34 |
|
---|
[44] | 35 | ~MouseQueryListener( );
|
---|
[18] | 36 |
|
---|
[34] | 37 | bool frameStarted(const FrameEvent& evt);
|
---|
[29] | 38 | bool frameEnded(const FrameEvent& evt);
|
---|
[34] | 39 |
|
---|
[27] | 40 | /* MouseListener callbacks. */
|
---|
| 41 | virtual void mouseClicked(MouseEvent* e) { }
|
---|
| 42 | virtual void mouseEntered(MouseEvent* e) { }
|
---|
| 43 | virtual void mouseExited(MouseEvent* e) { }
|
---|
[18] | 44 |
|
---|
[27] | 45 | // This is when the mouse button goes DOWN.
|
---|
| 46 | virtual void mousePressed(MouseEvent* e);
|
---|
[18] | 47 |
|
---|
[27] | 48 | // This is when the mouse button is let UP.
|
---|
| 49 | virtual void mouseReleased(MouseEvent* e);
|
---|
[18] | 50 |
|
---|
[27] | 51 | /* MouseMotionListener callbacks */
|
---|
| 52 | virtual void mouseMoved (MouseEvent *e);
|
---|
[18] | 53 |
|
---|
[27] | 54 | // This is when the mouse is clicked, held and dragged.
|
---|
| 55 | virtual void mouseDragged (MouseEvent *e);
|
---|
[26] | 56 |
|
---|
[32] | 57 | void keyPressed(KeyEvent* e);
|
---|
[26] | 58 |
|
---|
[32] | 59 | void keyReleased(KeyEvent* e);
|
---|
| 60 | void keyClicked(KeyEvent* e);
|
---|
[26] | 61 |
|
---|
[29] | 62 | void changeAlgorithm();
|
---|
[32] | 63 | void changeThreshold(int incr);
|
---|
[30] | 64 | void changeStats();
|
---|
[26] | 65 |
|
---|
[18] | 66 | protected:
|
---|
| 67 | bool mLMouseDown, mRMouseDown; // True if the mouse buttons are down
|
---|
| 68 | SceneManager *mSceneMgr; // A pointer to the scene manager
|
---|
[34] | 69 |
|
---|
| 70 | CEGUI::Renderer *mGUIRenderer; // cegui renderer
|
---|
| 71 |
|
---|
[32] | 72 | bool mShutdownRequested;
|
---|
[29] | 73 | int mCurrentAlgorithm;
|
---|
[32] | 74 | int mThreshold;
|
---|
| 75 |
|
---|
[28] | 76 | OverlayElement *mAlgorithmInfo;
|
---|
[30] | 77 | OverlayElement *mThresholdInfo;
|
---|
| 78 | OverlayElement *mFrustumCulledNodesInfo;
|
---|
| 79 | OverlayElement *mQueryCulledNodesInfo;
|
---|
| 80 | OverlayElement *mTraversedNodesInfo;
|
---|
[42] | 81 | OverlayElement *mHierarchyNodesInfo;
|
---|
| 82 | OverlayElement *mSceneNodesInfo;
|
---|
[52] | 83 | OverlayElement *mRenderedNodesInfo;
|
---|
[18] | 84 | };
|
---|
| 85 |
|
---|
| 86 |
|
---|
[12] | 87 | class TestCullingApplication : public ExampleApplication
|
---|
| 88 | {
|
---|
| 89 | public:
|
---|
[44] | 90 | //~TestCullingApplication();
|
---|
[12] | 91 |
|
---|
| 92 | protected:
|
---|
| 93 | void createScene(void);
|
---|
[29] | 94 | void createFrameListener(void);
|
---|
[34] | 95 | void setupGui(void);
|
---|
[51] | 96 | /** generates a the scene hierarchy with random values
|
---|
| 97 | @param number of objects to generate
|
---|
| 98 | */
|
---|
| 99 | void generateScene(int numObjects);
|
---|
[12] | 100 |
|
---|
[51] | 101 | /** generates a new scene object |
---|
| 102 | @param tranlationRatio ratio between minimal and maximal possible translation |
---|
| 103 | @param rotationRatio ratio between minimal and maximal possible rotation |
---|
| 104 | @idx the index of the new object |
---|
| 105 | @entName the name of the object entity |
---|
| 106 | */ |
---|
| 107 | void generateSceneObject(const Vector3 &translationRatio, const Vector3 &rotationRatio,
|
---|
| 108 | const int idx, const String &entName);
|
---|
| 109 |
|
---|
| 110 | //virtual void createCamera(void);
|
---|
| 111 |
|
---|
[18] | 112 | CEGUI::OgreCEGUIRenderer *mGUIRenderer;
|
---|
| 113 | CEGUI::System *mGUISystem;
|
---|
| 114 |
|
---|
[51] | 115 | Vector3 mMinTranslation; |
---|
| 116 | Vector3 mMaxTranslation; |
---|
| 117 | |
---|
| 118 | Vector3 mMinAngle; |
---|
| 119 | Vector3 mMaxAngle;
|
---|
| 120 |
|
---|
[12] | 121 | private:
|
---|
[29] | 122 | void chooseSceneManager(void);
|
---|
[12] | 123 | };
|
---|
| 124 |
|
---|