[12] | 1 | /**
|
---|
| 2 | \file
|
---|
| 3 | TestCullingApplication.h
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | #include "ExampleApplication.h"
|
---|
| 7 |
|
---|
| 8 | class TestCullingFrameListener : public ExampleFrameListener
|
---|
| 9 | {
|
---|
| 10 | protected:
|
---|
| 11 | SceneNode* mShipNode;
|
---|
| 12 |
|
---|
| 13 | public:
|
---|
| 14 | TestCullingFrameListener(RenderWindow* win, Camera* cam, SceneNode* shipNode) : ExampleFrameListener(win, cam)
|
---|
| 15 | {
|
---|
| 16 | mShipNode = shipNode;
|
---|
| 17 | };
|
---|
| 18 |
|
---|
| 19 | bool frameStarted(const FrameEvent& evt)
|
---|
| 20 | {
|
---|
| 21 | Real MoveFactor = 80.0 * evt.timeSinceLastFrame;
|
---|
| 22 |
|
---|
| 23 | mInputDevice->capture();
|
---|
| 24 |
|
---|
| 25 | if(mInputDevice->isKeyDown(Ogre::KC_UP))
|
---|
| 26 | mShipNode->translate(0.0, MoveFactor, 0.0);
|
---|
| 27 |
|
---|
| 28 | if(mInputDevice->isKeyDown(Ogre::KC_DOWN))
|
---|
| 29 | mShipNode->translate(0.0, -MoveFactor, 0.0);
|
---|
| 30 |
|
---|
| 31 | if(mInputDevice->isKeyDown(Ogre::KC_LEFT))
|
---|
| 32 | mShipNode->translate(-MoveFactor, 0.0, 0.0);
|
---|
| 33 |
|
---|
| 34 | if(mInputDevice->isKeyDown(Ogre::KC_RIGHT))
|
---|
| 35 | mShipNode->translate(MoveFactor, 0.0, 0.0);
|
---|
| 36 |
|
---|
| 37 | if(mInputDevice->isKeyDown(Ogre::KC_ESCAPE))
|
---|
| 38 | return false;
|
---|
| 39 |
|
---|
| 40 | return true;
|
---|
| 41 | }
|
---|
| 42 | };
|
---|
| 43 |
|
---|
| 44 | class TestCullingApplication : public ExampleApplication
|
---|
| 45 | {
|
---|
| 46 | public:
|
---|
| 47 | /*TestCullingApplication()
|
---|
| 48 | {
|
---|
| 49 |
|
---|
| 50 |
|
---|
| 51 | }*/
|
---|
| 52 |
|
---|
| 53 | protected:
|
---|
| 54 | void createScene(void);
|
---|
| 55 |
|
---|
| 56 | void createFrameListener(void)
|
---|
| 57 | {
|
---|
| 58 | mFrameListener= new TestCullingFrameListener(mWindow, mCamera, mShipNode);
|
---|
| 59 | mRoot->addFrameListener(mFrameListener);
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | private:
|
---|
| 63 | Entity* mShip;
|
---|
| 64 | SceneNode* mShipNode;
|
---|
| 65 |
|
---|
| 66 | /* String mQuakePk3;
|
---|
| 67 | String mQuakeLevel;
|
---|
| 68 |
|
---|
| 69 | // Override resource sources (include Quake3 archives)
|
---|
| 70 | void setupResources(void)
|
---|
| 71 | {
|
---|
| 72 |
|
---|
| 73 | // Load Quake3 locations from a file
|
---|
| 74 | ConfigFile cf;
|
---|
| 75 |
|
---|
| 76 | cf.load("quake3settings.cfg");
|
---|
| 77 |
|
---|
| 78 | mQuakePk3 = cf.getSetting("Pak0Location");
|
---|
| 79 | mQuakeLevel = cf.getSetting("Map");
|
---|
| 80 |
|
---|
| 81 | ExampleApplication::setupResources();
|
---|
| 82 | ResourceManager::addCommonArchiveEx(mQuakePk3, "Zip");
|
---|
| 83 |
|
---|
| 84 | }*/
|
---|
| 85 | // Override scene manager (use indoor instead of generic)
|
---|
| 86 | void chooseSceneManager(void)
|
---|
| 87 | {
|
---|
[16] | 88 | // mSceneMgr = mRoot->getSceneManager(ST_GENERIC);
|
---|
| 89 | mSceneMgr = mRoot->getSceneManager(ST_INTERIOR);
|
---|
[12] | 90 | }
|
---|
| 91 | /*
|
---|
| 92 | // Scene creation
|
---|
| 93 | void createScene(void)
|
---|
| 94 | {
|
---|
| 95 |
|
---|
| 96 | // Load world geometry
|
---|
| 97 | mSceneMgr->setWorldGeometry(mQuakeLevel);
|
---|
| 98 |
|
---|
| 99 | // modify camera for close work
|
---|
| 100 | mCamera->setNearClipDistance(4);
|
---|
| 101 | mCamera->setFarClipDistance(4000);
|
---|
| 102 |
|
---|
| 103 | // Also change position, and set Quake-type orientation
|
---|
| 104 | // Get random player start point
|
---|
| 105 | ViewPoint vp = mSceneMgr->getSuggestedViewpoint(true);
|
---|
| 106 | mCamera->setPosition(vp.position);
|
---|
| 107 | mCamera->pitch(Degree(90)); // Quake uses X/Y horizon, Z up
|
---|
| 108 | mCamera->rotate(vp.orientation);
|
---|
| 109 | // Don't yaw along variable axis, causes leaning
|
---|
| 110 | mCamera->setFixedYawAxis(true, Vector3::UNIT_Z);
|
---|
| 111 | }*/
|
---|
| 112 |
|
---|
| 113 | };
|
---|
| 114 |
|
---|