Changeset 919
- Timestamp:
- Mar 24, 2008, 1:12:31 PM (17 years ago)
- Location:
- code/branches/network
- Files:
-
- 2 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/audio/AudioManager.cc
r790 r919 84 84 } 85 85 86 void AudioManager:: update()86 void AudioManager::tick(float dt) 87 87 { 88 88 if (bgSounds.size() > 0) -
code/branches/network/src/audio/AudioManager.h
r790 r919 3 3 4 4 #include "AudioIncludes.h" 5 6 #include "core/Tickable.h" 5 7 6 8 #include "AudioPrereqs.h" … … 12 14 namespace audio 13 15 { 14 class _AudioExport AudioManager 16 class _AudioExport AudioManager : public orxonox::Tickable 15 17 { 16 18 public: … … 37 39 38 40 // Update 39 void update();41 void tick(float dt); 40 42 41 43 void ambientAdd(std::string file); -
code/branches/network/src/orxonox/CMakeLists.txt
r871 r919 1 1 SET( ORXONOX_SRC_FILES 2 2 GraphicsEngine.cc 3 InputHandler.cc 3 4 Main.cc 4 5 Orxonox.cc 5 objects/Tickable.cc 6 SpaceshipSteering.cc 6 # SpaceshipSteering.cc 7 7 hud/HUD.cc 8 8 particle/ParticleInterface.cc -
code/branches/network/src/orxonox/GraphicsEngine.cc
r790 r919 35 35 #include <OgreConfigFile.h> 36 36 #include <OgreTextureManager.h> 37 #include <OgreRenderWindow.h> 37 38 38 39 #include "core/Debug.h" … … 49 50 this->configPath_ = ""; 50 51 this->dataPath_ = ""; 51 scene_ = NULL; 52 this->root_ = 0; 53 this->scene_ = 0; 54 this->renderWindow_ = 0; 52 55 } 53 56 … … 98 101 { 99 102 root_->initialise(true, "OrxonoxV2"); 103 this->renderWindow_ = root_->getAutoCreatedWindow(); 100 104 TextureManager::getSingleton().setDefaultNumMipmaps(5); 101 105 ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); … … 131 135 } 132 136 137 /** 138 Returns the window handle of the render window. 139 At least the InputHandler uses this to create the OIS::InputManager 140 @return The window handle of the render window 141 */ 142 size_t GraphicsEngine::getWindowHandle() 143 { 144 if (this->renderWindow_) 145 { 146 Ogre::RenderWindow *renderWindow = this->root_->getAutoCreatedWindow(); 147 size_t windowHnd = 0; 148 renderWindow->getCustomAttribute("WINDOW", &windowHnd); 149 return windowHnd; 150 } 151 else 152 return 0; 153 } 154 155 /** 156 Get the width of the current render window 157 @return The width of the current render window 158 */ 159 int GraphicsEngine::getWindowWidth() const 160 { 161 if (this->renderWindow_) 162 { 163 return this->renderWindow_->getWidth(); 164 } 165 else 166 return 0; 167 } 168 169 /** 170 Get the height of the current render window 171 @return The height of the current render window 172 */ 173 int GraphicsEngine::getWindowHeight() const 174 { 175 if (this->renderWindow_) 176 { 177 return this->renderWindow_->getHeight(); 178 } 179 else 180 return 0; 181 } 133 182 134 183 } -
code/branches/network/src/orxonox/GraphicsEngine.h
r790 r919 33 33 void startRender(); 34 34 35 // several window properties 36 size_t getWindowHandle(); 37 int getWindowWidth() const; 38 int getWindowHeight() const; 39 35 40 virtual ~GraphicsEngine(); 36 41 private: … … 39 44 std::string dataPath_; //!< path to data file 40 45 Ogre::SceneManager* scene_; //!< scene manager of the game 46 Ogre::RenderWindow* renderWindow_;//!< the current render window 41 47 42 48 }; -
code/branches/network/src/orxonox/InputHandler.cc
r918 r919 22 22 * Reto Grieder 23 23 * Co-authors: 24 * ...24 * Some guy writing the example code from Ogre 25 25 * 26 26 */ … … 34 34 #include "OrxonoxStableHeaders.h" 35 35 36 #include <OgreRenderWindow.h> 37 36 #include "Orxonox.h" 38 37 #include "InputHandler.h" 39 38 … … 42 41 //using namespace OIS; 43 42 43 /** 44 @brief Constructor only resets the pointer values to 0. 45 */ 44 46 InputHandler::InputHandler() 45 47 { 46 RegisterObject(InputHandler); 47 } 48 49 void InputHandler::initialise(Ogre::RenderWindow *renderWindow) 48 /*if (orxonox::Identifier::isCreatingHierarchy() && !this->getParents()) 49 this->createParents(); 50 this->setIdentifier(orxonox::ClassManager<InputHandler>::getIdentifier()->registerClass(this->getParents(), "InputHandler", true)); 51 if (orxonox::Identifier::isCreatingHierarchy() && this->getParents()) 52 this->getParents()->insert(this->getParents()->end(), this->getIdentifier()); 53 orxonox::ClassManager<InputHandler>::getIdentifier()->addObject(this);*/ 54 55 //RegisterObject(InputHandler); 56 57 this->mouse_ = 0; 58 this->keyboard_ = 0; 59 this->inputSystem_ = 0; 60 61 //this->setConfigValues(); 62 } 63 64 void InputHandler::setConfigValues() 65 { 66 //SetConfigValue(codeFire_, 4).description("test value"); 67 68 ConfigValueContainer *containercodeFire_ = new ConfigValueContainer("asdfblah", "codeFire_", 4); 69 containercodeFire_->getValue(&codeFire_).description("test"); 70 //containercodeFire_-> 71 } 72 73 /** 74 @brief The one instance of the InputHandler is stored in this function. 75 @return The pointer to the only instance of the InputHandler 76 */ 77 InputHandler* InputHandler::getSingleton() 78 { 79 static InputHandler theOnlyInstance; 80 return &theOnlyInstance; 81 } 82 83 /** 84 @brief Creates the OIS::InputMananger, the keyboard and the mouse 85 @param windowHnd The window handle of the render window 86 @param windowWidth The width of the render window 87 @param windowHeight The height of the render window 88 */ 89 void InputHandler::initialise(size_t windowHnd, int windowWidth, int windowHeight) 50 90 { 51 91 if (!inputSystem_) … … 53 93 // Setup basic variables 54 94 OIS::ParamList paramList; 55 size_t windowHnd = 0;56 95 std::ostringstream windowHndStr; 57 58 // Get window handle59 renderWindow->getCustomAttribute("WINDOW", &windowHnd);60 96 61 97 // Fill parameter list … … 67 103 68 104 // If possible create a buffered keyboard 69 // (note: if below line doesn't compile, try: if (inputSystem_->getNumberOfDevices(OIS::OISKeyboard) > 0) {70 105 if (inputSystem_->numKeyboards() > 0) 71 106 { 72 //if (inputSystem_->getNumberOfDevices(OIS::OISKeyboard) > 0)73 //{74 107 keyboard_ = static_cast<OIS::Keyboard*>(inputSystem_->createInputObject(OIS::OISKeyboard, true)); 75 108 keyboard_->setEventCallback(this); … … 77 110 78 111 // If possible create a buffered mouse 79 // (note: if below line doesn't compile, try: if (inputSystem_->getNumberOfDevices(OIS::OISMouse) > 0) {80 112 if (inputSystem_->numMice() > 0 ) 81 113 { 82 //if (inputSystem_->getNumberOfDevices(OIS::OISMouse) > 0)83 //{84 114 mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true)); 85 115 mouse_->setEventCallback(this); 86 116 87 // Get window size88 unsigned int width, height, depth;89 int left, top;90 renderWindow->getMetrics(width, height, depth, left, top);91 92 117 // Set mouse region 93 this->setWindowExtents(wi dth, height);118 this->setWindowExtents(windowWidth, windowHeight); 94 119 } 95 120 } 96 121 } 97 122 123 /** 124 @brief Updates the InputHandler 125 @param dt Delta time 126 */ 98 127 void InputHandler::tick(float dt) 99 128 { … … 110 139 } 111 140 141 /** 142 @brief Adjusts the mouse window metrics. 143 This method has to be called every time the size of the window changes. 144 @param width The new width of the render window 145 @param height the new height of the render window 146 */ 112 147 void InputHandler::setWindowExtents(int width, int height) 113 148 { … … 118 153 } 119 154 155 /** 156 @brief Event handler for the keyPressed Event. 157 @param e Event information 158 */ 120 159 bool InputHandler::keyPressed(const OIS::KeyEvent &e) 121 160 { 122 return true; 123 } 124 161 if (e.key == OIS::KC_ESCAPE) 162 Orxonox::getSingleton()->abortRequest(); 163 return true; 164 } 165 166 /** 167 @brief Event handler for the keyReleased Event. 168 @param e Event information 169 */ 125 170 bool InputHandler::keyReleased(const OIS::KeyEvent &e) 126 171 { … … 128 173 } 129 174 175 /** 176 @brief Event handler for the mouseMoved Event. 177 @param e Event information 178 */ 130 179 bool InputHandler::mouseMoved(const OIS::MouseEvent &e) 131 180 { … … 133 182 } 134 183 184 /** 185 @brief Event handler for the mousePressed Event. 186 @param e Event information 187 @param id The ID of the mouse button 188 */ 135 189 bool InputHandler::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id) 136 190 { … … 138 192 } 139 193 194 /** 195 @brief Event handler for the mouseReleased Event. 196 @param e Event information 197 @param id The ID of the mouse button 198 */ 140 199 bool InputHandler::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id) 141 200 { -
code/branches/network/src/orxonox/InputHandler.h
r918 r919 39 39 #include <OIS/OISKeyboard.h> 40 40 41 #include <OgrePrerequisites.h>42 43 41 #include "OrxonoxPrereqs.h" 42 //#include "core/OrxonoxClass.h" 44 43 #include "core/Tickable.h" 45 44 46 45 namespace orxonox 47 46 { 48 class _OrxonoxExport InputHandler : public Tickable, public OIS::KeyListener, 49 public OIS::MouseListener 47 class _OrxonoxExport InputHandler 48 : public Tickable, 49 public OIS::KeyListener, public OIS::MouseListener 50 50 { 51 51 public: 52 InputHandler();53 52 54 void initialise( Ogre::RenderWindow *renderWindow);53 void initialise(size_t windowHnd, int windowWidth, int windowHeight); 55 54 void tick(float dt); 56 55 void setWindowExtents(int width, int height); 56 57 OIS::Mouse *getMouse() { return this->mouse_ ; } 58 OIS::Keyboard *getKeyboard() { return this->keyboard_; } 57 59 58 60 // input events … … 63 65 bool keyReleased (const OIS::KeyEvent &arg); 64 66 67 static InputHandler* getSingleton(); 68 69 void setConfigValues(); 70 65 71 private: 72 // don't mess with a Singleton 73 InputHandler (); 74 InputHandler (const InputHandler&) { } 75 ~InputHandler() { } 76 66 77 OIS::InputManager *inputSystem_; 67 78 OIS::Keyboard *keyboard_; 68 79 OIS::Mouse *mouse_; 80 81 // Key bindings 82 int codeFire_; 83 OIS::KeyCode codeMoveForward_; 69 84 70 85 }; -
code/branches/network/src/orxonox/Orxonox.cc
r918 r919 67 67 network::Server *server_g; 68 68 69 70 69 // objects 71 70 #include "tools/Timer.h" 72 #include "tools/OrxListener.h"73 71 #include "core/ArgReader.h" 74 72 #include "core/Debug.h" … … 79 77 #include "objects/weapon/BulletManager.h" 80 78 79 #include "InputHandler.h" 80 81 81 #include "Orxonox.h" 82 82 … … 95 95 this->auMan_ = 0; 96 96 this->singletonRef_ = 0; 97 this->keyboard_ = 0; 98 this->mouse_ = 0; 99 this->inputManager_ = 0; 97 //this->keyboard_ = 0; 98 //this->mouse_ = 0; 99 //this->inputManager_ = 0; 100 this->inputHandler_ = 0; 100 101 this->frameListener_ = 0; 101 102 this->root_ = 0; … … 187 188 //setupInputSystem(); 188 189 189 createFrameListener();190 191 190 startRenderLoop(); 192 191 } … … 201 200 setupInputSystem(); 202 201 203 createFrameListener();204 202 server_g->open(); 205 203 … … 215 213 setupScene(); 216 214 setupInputSystem(); 217 218 createFrameListener();219 215 220 216 startRenderLoop(); … … 380 376 void Orxonox::setupInputSystem() 381 377 { 382 size_t windowHnd = 0; 378 inputHandler_ = InputHandler::getSingleton(); 379 inputHandler_->initialise(ogre_->getWindowHandle(), 380 ogre_->getWindowWidth(), ogre_->getWindowHeight()); 381 382 /*size_t windowHnd = 0; 383 383 std::ostringstream windowHndStr; 384 384 OIS::ParamList pl; … … 403 403 { 404 404 throw new Ogre::Exception(42, e.eText, "OrxApplication::setupInputSystem"); 405 } 406 } 407 408 // FIXME we actually want to do this differently... 409 void Orxonox::createFrameListener() 410 { 411 frameListener_ = new OrxListener(keyboard_, auMan_, mode_); 412 } 413 414 void Orxonox::startRenderLoop() 415 { 416 // FIXME 417 // this is a hack!!! 418 // the call to reset the mouse clipping size should probably be somewhere 419 // else, however this works for the moment. 420 unsigned int width, height, depth; 421 int left, top; 422 ogre_->getRoot()->getAutoCreatedWindow()->getMetrics(width, height, depth, left, top); 423 424 if(mode_!=CLIENT){ 425 const OIS::MouseState &ms = mouse_->getMouseState(); 426 ms.width = width; 427 ms.height = height; 428 } 429 mainLoop(); 405 }*/ 430 406 } 431 407 … … 444 420 means of the recent most dt_n-1, dt_n-2, etc. 445 421 */ 446 void Orxonox:: mainLoop()422 void Orxonox::startRenderLoop() 447 423 { 448 424 // use the ogre timer class to measure time. -
code/branches/network/src/orxonox/Orxonox.h
r918 r919 42 42 inline GraphicsEngine* getOgrePointer() { return ogre_; }; 43 43 inline audio::AudioManager* getAudioManagerPointer() { return auMan_; }; 44 inline OIS::Keyboard* getKeyboard() { return this->keyboard_; }45 inline OIS::Mouse* getMouse() { return this->mouse_; }44 //inline OIS::Keyboard* getKeyboard() { return this->keyboard_; } 45 //inline OIS::Mouse* getMouse() { return this->mouse_; } 46 46 inline BulletManager* getBulletMgr() { return this->bulletMgr_; } 47 47 … … 64 64 void setupScene(); 65 65 void setupInputSystem(); 66 void createFrameListener();67 66 void startRenderLoop(); 68 void mainLoop();69 67 void updateTimers(float); 70 68 float calculateEventTime(unsigned long, std::deque<unsigned long>&); … … 77 75 BulletManager* bulletMgr_; //!< Keeps track of the thrown bullets 78 76 static Orxonox* singletonRef_; 79 OIS::Keyboard* keyboard_; 80 OIS::Mouse* mouse_; 81 OIS::InputManager* inputManager_; 77 InputHandler* inputHandler_; 78 //OIS::Keyboard* keyboard_; 79 //OIS::Mouse* mouse_; 80 //OIS::InputManager* inputManager_; 82 81 OrxListener* frameListener_; 83 82 Ogre::Root* root_; -
code/branches/network/src/orxonox/OrxonoxPrereqs.h
r790 r919 68 68 class Camera; 69 69 class GraphicsEngine; 70 class InputHandler; 70 71 class Mesh; 71 72 class Model; -
code/branches/network/src/orxonox/core/CMakeLists.txt
r871 r919 17 17 Executor.cc 18 18 XMLPort.cc 19 Tickable.cc 19 20 ) 20 21 -
code/branches/network/src/orxonox/objects/Fighter.cc
r790 r919 37 37 #include "util/tinyxml/tinyxml.h" 38 38 #include "util/String2Number.h" 39 #include "../core/CoreIncludes.h" 40 #include "../Orxonox.h" 41 #include "../particle/ParticleInterface.h" 39 #include "core/CoreIncludes.h" 40 #include "Orxonox.h" 41 #include "InputHandler.h" 42 #include "particle/ParticleInterface.h" 42 43 #include "weapon/AmmunitionDump.h" 43 44 #include "weapon/BarrelGun.h" … … 254 255 if (!this->setMouseEventCallback_) 255 256 { 256 if ( Orxonox::getSingleton()->getMouse())257 if (InputHandler::getSingleton()->getMouse()) 257 258 { 258 Orxonox::getSingleton()->getMouse()->setEventCallback(this);259 InputHandler::getSingleton()->getMouse()->setEventCallback(this); 259 260 this->setMouseEventCallback_ = true; 260 261 } … … 263 264 WorldEntity::tick(dt); 264 265 265 OIS::Keyboard* mKeyboard = Orxonox::getSingleton()->getKeyboard();266 OIS::Mouse* mMouse = Orxonox::getSingleton()->getMouse();266 OIS::Keyboard* mKeyboard = InputHandler::getSingleton()->getKeyboard(); 267 OIS::Mouse* mMouse = InputHandler::getSingleton()->getMouse(); 267 268 268 269 mKeyboard->capture(); -
code/branches/network/src/orxonox/objects/NPC.cc
r790 r919 85 85 void NPC::tick(float dt) 86 86 { 87 87 update(); 88 88 this->setVelocity(0.995*this->getVelocity() + this->getAcceleration()*dt); 89 89 this->translate(this->getVelocity()*dt); -
code/branches/network/src/orxonox/objects/SpaceShip.cc
r889 r919 39 39 #include "util/String2Number.h" 40 40 #include "util/Math.h" 41 #include "../core/CoreIncludes.h" 42 #include "../core/Debug.h" 43 #include "../Orxonox.h" 44 #include "../particle/ParticleInterface.h" 41 #include "core/CoreIncludes.h" 42 #include "core/Debug.h" 43 #include "Orxonox.h" 44 #include "InputHandler.h" 45 #include "particle/ParticleInterface.h" 45 46 #include "Projectile.h" 46 47 #include "core/XMLPort.h" … … 400 401 if (!this->setMouseEventCallback_) 401 402 { 402 if ( Orxonox::getSingleton()->getMouse())403 if (InputHandler::getSingleton()->getMouse()) 403 404 { 404 Orxonox::getSingleton()->getMouse()->setEventCallback(this);405 InputHandler::getSingleton()->getMouse()->setEventCallback(this); 405 406 this->setMouseEventCallback_ = true; 406 407 } … … 427 428 } 428 429 429 OIS::Keyboard* mKeyboard = Orxonox::getSingleton()->getKeyboard();430 OIS::Mouse* mMouse = Orxonox::getSingleton()->getMouse();430 OIS::Keyboard* mKeyboard = InputHandler::getSingleton()->getKeyboard(); 431 OIS::Mouse* mMouse = InputHandler::getSingleton()->getMouse(); 431 432 432 433 mKeyboard->capture(); -
code/branches/network/visual_studio/vc8/orxonox.vcproj
r918 r919 640 640 </File> 641 641 <File 642 RelativePath="..\..\src\orxonox\tools\OrxListener.cc"643 >644 </File>645 <File646 642 RelativePath="..\..\src\orxonox\tools\Timer.cc" 647 643 > … … 810 806 </File> 811 807 <File 812 RelativePath="..\..\src\orxonox\tools\OrxListener.h"813 >814 </File>815 <File816 808 RelativePath="..\..\src\orxonox\tools\Timer.h" 817 809 >
Note: See TracChangeset
for help on using the changeset viewer.