[21] | 1 | /* |
---|
| 2 | SimpleScenesApplication.h |
---|
| 3 | ------------------------ |
---|
| 4 | Defintion of the class responsible for running the OgreOde |
---|
| 5 | demo scenes. Wrangles input and the various different test |
---|
| 6 | scenes into a single application. Extends the ExampleApplication |
---|
| 7 | and ExampleFrameListener classes. |
---|
| 8 | */ |
---|
| 9 | #ifndef _SIMPLESCENESAPPLICATION_H_ |
---|
| 10 | #define _SIMPLESCENESAPPLICATION_H_ |
---|
| 11 | |
---|
| 12 | // Include the OgreOde interface which includes Ogre itself |
---|
| 13 | #include "OgreOde_Core.h" |
---|
| 14 | #include "ExampleApplication.h" |
---|
| 15 | |
---|
| 16 | #if !(OGRE_VERSION_MINOR < 4) |
---|
| 17 | using namespace OIS; |
---|
| 18 | #endif //OGRE_VERSION not heihort |
---|
| 19 | |
---|
| 20 | // Our framework class for the different tests |
---|
| 21 | #include "SimpleScenes.h" |
---|
| 22 | |
---|
| 23 | class SimpleScenesApplication; |
---|
| 24 | |
---|
| 25 | /* |
---|
| 26 | A frame listener that does default processing before deferring to the main application |
---|
| 27 | */ |
---|
| 28 | class SimpleScenesFrameListener:public ExampleFrameListener |
---|
| 29 | { |
---|
| 30 | public: |
---|
| 31 | // Standard example constructor with one additional parameter |
---|
| 32 | SimpleScenesFrameListener(SimpleScenesApplication* demo,RenderWindow* win,Camera* cam) : |
---|
| 33 | ExampleFrameListener(win,cam), |
---|
| 34 | _demo(demo) |
---|
| 35 | { |
---|
| 36 | mMoveSpeed = 15.0; |
---|
| 37 | } |
---|
| 38 | ~SimpleScenesFrameListener(){} |
---|
| 39 | |
---|
| 40 | bool frameStarted(const FrameEvent& evt); |
---|
| 41 | bool frameEnded(const FrameEvent& evt); |
---|
| 42 | |
---|
| 43 | protected: |
---|
| 44 | // Keep track of the application that created us |
---|
| 45 | SimpleScenesApplication* _demo; |
---|
| 46 | }; |
---|
| 47 | |
---|
| 48 | /* |
---|
| 49 | The test application, based on the Ogre example application for consistency |
---|
| 50 | */ |
---|
| 51 | class SimpleScenesApplication: public ExampleApplication |
---|
| 52 | { |
---|
| 53 | // The frame listener gets access to some special things |
---|
| 54 | friend class SimpleScenesFrameListener; |
---|
| 55 | |
---|
| 56 | public: |
---|
| 57 | // Standard constructor/destructor |
---|
| 58 | SimpleScenesApplication() : |
---|
| 59 | ExampleApplication() |
---|
| 60 | { |
---|
| 61 | _test = 0; |
---|
| 62 | _plane = 0; |
---|
| 63 | _stepper = 0; |
---|
| 64 | _world = 0; |
---|
| 65 | |
---|
| 66 | _time_elapsed = 0.0; |
---|
| 67 | _time_step = SimpleScenes::STEP_RATE; |
---|
| 68 | _looking = _chasing = false; |
---|
| 69 | _paused = false; |
---|
| 70 | } |
---|
| 71 | ~SimpleScenesApplication(); |
---|
| 72 | |
---|
| 73 | protected: |
---|
| 74 | // Override stuff from the base class |
---|
| 75 | void createScene(void); |
---|
| 76 | void createFrameListener(void) |
---|
| 77 | { |
---|
| 78 | mFrameListener= new SimpleScenesFrameListener(this,mWindow,mCamera); |
---|
| 79 | mRoot->addFrameListener(mFrameListener); |
---|
| 80 | } |
---|
| 81 | void chooseSceneManager(void) |
---|
| 82 | { |
---|
| 83 | mSceneMgr = mRoot->createSceneManager( ST_GENERIC, "basicsm" ); |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | // Add the standard resources, plus our own pack |
---|
| 87 | void setupResources(void) |
---|
| 88 | { |
---|
| 89 | ExampleApplication::setupResources(); |
---|
| 90 | ResourceGroupManager *rsm = ResourceGroupManager::getSingletonPtr(); |
---|
| 91 | StringVector groups = rsm->getResourceGroups(); |
---|
| 92 | if (std::find(groups.begin(), groups.end(), String("OgreOde")) == groups.end()) |
---|
| 93 | { |
---|
| 94 | FileInfoListPtr finfo = ResourceGroupManager::getSingleton().findResourceFileInfo ( |
---|
| 95 | "Bootstrap", "axes.mesh"); |
---|
| 96 | |
---|
| 97 | const bool isSDK = (!finfo->empty()) && |
---|
| 98 | StringUtil::startsWith (finfo->begin()->archive->getName(), "../../media/packs/ogrecore.zip", true); |
---|
| 99 | |
---|
| 100 | rsm->createResourceGroup("OgreOde"); |
---|
| 101 | if (isSDK) |
---|
| 102 | { |
---|
| 103 | rsm->addResourceLocation("../../../ogreode/demos/Media","FileSystem", "OgreOde"); |
---|
| 104 | } |
---|
| 105 | else |
---|
| 106 | { |
---|
| 107 | rsm->addResourceLocation("../../../../../ogreaddons/ogreode/demos/Media","FileSystem", "OgreOde"); |
---|
| 108 | } |
---|
| 109 | } |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | // The frame listener will call these |
---|
| 113 | |
---|
| 114 | #if (OGRE_VERSION_MINOR < 4) |
---|
| 115 | void frameStarted(const FrameEvent& evt,InputReader* mInputDevice); |
---|
| 116 | void frameEnded(const FrameEvent& evt,InputReader* mInputDevice); |
---|
| 117 | #else |
---|
| 118 | void frameStarted(const FrameEvent& evt, OIS::Keyboard* input, OIS::Mouse* mouse); |
---|
| 119 | void frameEnded(const FrameEvent& evt, OIS::Keyboard* input, OIS::Mouse* mouse); |
---|
| 120 | #endif //OGRE_VERSION not heihort |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | protected: |
---|
| 125 | OgreOde::World* _world; |
---|
| 126 | OgreOde::StepHandler* _stepper; |
---|
| 127 | OgreOde::InfinitePlaneGeometry* _plane; |
---|
| 128 | SimpleScenes* _test; |
---|
| 129 | |
---|
| 130 | Real _delay,_time_elapsed,_time_step; |
---|
| 131 | Light* _spot; |
---|
| 132 | bool _looking,_chasing,_paused; |
---|
| 133 | }; |
---|
| 134 | |
---|
| 135 | #endif |
---|