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