[12] | 1 | /**
|
---|
| 2 | \file
|
---|
| 3 | TestCullingApplication.h
|
---|
| 4 | */
|
---|
[18] | 5 | #include "CEGUIForwardRefs.h"
|
---|
[12] | 6 | #include "ExampleApplication.h"
|
---|
[26] | 7 | #include "OgreOcclusionCullingSceneManager.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 |
|
---|
[29] | 19 | String mCurrentAlgorithmCaptions[OcclusionCullingSceneManager::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 |
|
---|
| 30 | MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, CEGUI::Renderer *renderer,
|
---|
[29] | 31 | SceneNode* shipNode);
|
---|
[27] | 32 |
|
---|
[18] | 33 |
|
---|
| 34 | ~MouseQueryListener( )
|
---|
| 35 | {
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[29] | 38 | bool frameEnded(const FrameEvent& evt);
|
---|
[27] | 39 | /* MouseListener callbacks. */
|
---|
| 40 | virtual void mouseClicked(MouseEvent* e) { }
|
---|
| 41 | virtual void mouseEntered(MouseEvent* e) { }
|
---|
| 42 | virtual void mouseExited(MouseEvent* e) { }
|
---|
[18] | 43 |
|
---|
[27] | 44 | // This is when the mouse button goes DOWN.
|
---|
| 45 | virtual void mousePressed(MouseEvent* e);
|
---|
[18] | 46 |
|
---|
[27] | 47 | // This is when the mouse button is let UP.
|
---|
| 48 | virtual void mouseReleased(MouseEvent* e);
|
---|
[18] | 49 |
|
---|
[27] | 50 | /* MouseMotionListener callbacks */
|
---|
| 51 | virtual void mouseMoved (MouseEvent *e);
|
---|
[18] | 52 |
|
---|
[27] | 53 | // This is when the mouse is clicked, held and dragged.
|
---|
| 54 | virtual void mouseDragged (MouseEvent *e);
|
---|
[28] | 55 | /*
|
---|
[27] | 56 | void keyPressed(KeyEvent* e)
|
---|
| 57 | {
|
---|
[26] | 58 | if(e->getKey() == KC_ESCAPE)
|
---|
| 59 | {
|
---|
| 60 | mShutdownRequested = true;
|
---|
| 61 | e->consume();
|
---|
| 62 | return;
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | CEGUI::System::getSingleton().injectKeyDown(e->getKey());
|
---|
| 66 | CEGUI::System::getSingleton().injectChar(e->getKeyChar());
|
---|
| 67 | e->consume();
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | void keyReleased(KeyEvent* e)
|
---|
| 71 | {
|
---|
| 72 | CEGUI::System::getSingleton().injectKeyUp(e->getKey());
|
---|
| 73 | e->consume();
|
---|
| 74 | }
|
---|
| 75 | void keyClicked(KeyEvent* e)
|
---|
| 76 | {
|
---|
| 77 | // Do nothing
|
---|
| 78 | e->consume();
|
---|
| 79 | }
|
---|
| 80 |
|
---|
[28] | 81 | bool frameEnded(const FrameEvent& evt)
|
---|
[26] | 82 | {
|
---|
| 83 | if (mShutdownRequested)
|
---|
| 84 | return false;
|
---|
| 85 | else
|
---|
| 86 | return ExampleFrameListener::frameEnded(evt);
|
---|
| 87 | }
|
---|
[28] | 88 | */
|
---|
[29] | 89 | void changeAlgorithm();
|
---|
[26] | 90 |
|
---|
| 91 |
|
---|
[18] | 92 | protected:
|
---|
| 93 | bool mLMouseDown, mRMouseDown; // True if the mouse buttons are down
|
---|
| 94 | SceneManager *mSceneMgr; // A pointer to the scene manager
|
---|
| 95 | SceneNode *mCurrentObject; // The newly created object
|
---|
| 96 | CEGUI::Renderer *mGUIRenderer; // cegui renderer
|
---|
| 97 | SceneNode* mShipNode;
|
---|
[28] | 98 | // bool mShutdownRequested;
|
---|
[29] | 99 | int mCurrentAlgorithm;
|
---|
[28] | 100 | OverlayElement *mAlgorithmInfo;
|
---|
[18] | 101 | };
|
---|
| 102 |
|
---|
| 103 |
|
---|
[12] | 104 | class TestCullingApplication : public ExampleApplication
|
---|
| 105 | {
|
---|
| 106 | public:
|
---|
| 107 | /*TestCullingApplication()
|
---|
| 108 | {
|
---|
| 109 |
|
---|
| 110 | }*/
|
---|
| 111 |
|
---|
| 112 | protected:
|
---|
| 113 | void createScene(void);
|
---|
[29] | 114 | void createFrameListener(void);
|
---|
[12] | 115 |
|
---|
[18] | 116 | CEGUI::OgreCEGUIRenderer *mGUIRenderer;
|
---|
| 117 | CEGUI::System *mGUISystem;
|
---|
| 118 |
|
---|
[12] | 119 | private:
|
---|
[29] | 120 | void chooseSceneManager(void);
|
---|
| 121 |
|
---|
[12] | 122 | Entity* mShip;
|
---|
| 123 | SceneNode* mShipNode;
|
---|
| 124 |
|
---|
| 125 | /* String mQuakePk3;
|
---|
| 126 | String mQuakeLevel;
|
---|
| 127 |
|
---|
| 128 | // Override resource sources (include Quake3 archives)
|
---|
| 129 | void setupResources(void)
|
---|
| 130 | {
|
---|
| 131 |
|
---|
| 132 | // Load Quake3 locations from a file
|
---|
| 133 | ConfigFile cf;
|
---|
| 134 |
|
---|
| 135 | cf.load("quake3settings.cfg");
|
---|
| 136 |
|
---|
| 137 | mQuakePk3 = cf.getSetting("Pak0Location");
|
---|
| 138 | mQuakeLevel = cf.getSetting("Map");
|
---|
| 139 |
|
---|
| 140 | ExampleApplication::setupResources();
|
---|
| 141 | ResourceManager::addCommonArchiveEx(mQuakePk3, "Zip");
|
---|
| 142 |
|
---|
| 143 | }*/
|
---|
| 144 | // Override scene manager (use indoor instead of generic)
|
---|
[29] | 145 |
|
---|
| 146 |
|
---|
[26] | 147 |
|
---|
[12] | 148 | };
|
---|
| 149 |
|
---|