[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;
|
---|
[52] | 81 | OverlayElement *mRenderedNodesInfo;
|
---|
[18] | 82 | };
|
---|
| 83 |
|
---|
| 84 |
|
---|
[12] | 85 | class TestCullingApplication : public ExampleApplication
|
---|
| 86 | {
|
---|
| 87 | public:
|
---|
[44] | 88 | //~TestCullingApplication();
|
---|
[12] | 89 |
|
---|
| 90 | protected:
|
---|
| 91 | void createScene(void);
|
---|
[29] | 92 | void createFrameListener(void);
|
---|
[34] | 93 | void setupGui(void);
|
---|
[51] | 94 | /** generates a the scene hierarchy with random values
|
---|
| 95 | @param number of objects to generate
|
---|
| 96 | */
|
---|
| 97 | void generateScene(int numObjects);
|
---|
[12] | 98 |
|
---|
[51] | 99 | /** generates a new scene object |
---|
| 100 | @param tranlationRatio ratio between minimal and maximal possible translation |
---|
| 101 | @param rotationRatio ratio between minimal and maximal possible rotation |
---|
| 102 | @idx the index of the new object |
---|
| 103 | @entName the name of the object entity |
---|
| 104 | */ |
---|
| 105 | void generateSceneObject(const Vector3 &translationRatio, const Vector3 &rotationRatio,
|
---|
| 106 | const int idx, const String &entName);
|
---|
| 107 |
|
---|
| 108 | //virtual void createCamera(void);
|
---|
| 109 |
|
---|
[18] | 110 | CEGUI::OgreCEGUIRenderer *mGUIRenderer;
|
---|
| 111 | CEGUI::System *mGUISystem;
|
---|
| 112 |
|
---|
[51] | 113 | Vector3 mMinTranslation; |
---|
| 114 | Vector3 mMaxTranslation; |
---|
| 115 | |
---|
| 116 | Vector3 mMinAngle; |
---|
| 117 | Vector3 mMaxAngle;
|
---|
| 118 |
|
---|
[12] | 119 | private:
|
---|
[29] | 120 | void chooseSceneManager(void);
|
---|
[12] | 121 | };
|
---|
| 122 |
|
---|