|
From: <sik...@us...> - 2006-05-18 03:14:16
|
Revision: 24 Author: sik0fewl Date: 2006-05-17 20:13:59 -0700 (Wed, 17 May 2006) ViewCVS: http://svn.sourceforge.net/perceptioncrash/?rev=24&view=rev Log Message: ----------- More housekeeping Modified Paths: -------------- trunk/perceptioncrash/src/main.cpp Added Paths: ----------- trunk/perceptioncrash/src/Game.cpp trunk/perceptioncrash/src/Game.hpp trunk/perceptioncrash/src/Graphics.cpp trunk/perceptioncrash/src/Graphics.hpp trunk/perceptioncrash/src/Input.cpp trunk/perceptioncrash/src/Input.hpp trunk/perceptioncrash/src/Singleton.hpp Removed Paths: ------------- trunk/perceptioncrash/src/game.cpp trunk/perceptioncrash/src/game.hpp trunk/perceptioncrash/src/graphics.cpp trunk/perceptioncrash/src/graphics.hpp trunk/perceptioncrash/src/input.cpp trunk/perceptioncrash/src/input.hpp trunk/perceptioncrash/src/singleton.hpp Copied: trunk/perceptioncrash/src/Game.cpp (from rev 23, trunk/perceptioncrash/src/game.cpp) =================================================================== --- trunk/perceptioncrash/src/Game.cpp (rev 0) +++ trunk/perceptioncrash/src/Game.cpp 2006-05-18 03:13:59 UTC (rev 24) @@ -0,0 +1,86 @@ +#include <cmath> + +#include <boost/bind.hpp> + +#include "Game.hpp" + +Game::Game() + : mKeyQuit(Input::getSingleton().createKey("quit", Ogre::KC_ESCAPE)), + mKeyUp(Input::getSingleton().createKey("up", Ogre::KC_W)), + mKeyRight(Input::getSingleton().createKey("right", Ogre::KC_D)), + mKeyDown(Input::getSingleton().createKey("down", Ogre::KC_S)), + mKeyLeft(Input::getSingleton().createKey("left", Ogre::KC_A)) +{ + Input::getSingleton().registerMouseListener(boost::bind(&Game::mouseMotionListener, this, _1,_2)); +} + +void +Game::run() +{ + // This is all temporary stuff + Ogre::ResourceGroupManager rgm = Ogre::ResourceGroupManager::getSingleton(); + rgm.addResourceLocation("data/objects", "FileSystem", "General"); + rgm.addResourceLocation("data/maps/ogretestmap.zip", "Zip", + rgm.getWorldResourceGroupName()); + + rgm.linkWorldGeometryToResourceGroup(rgm.getWorldResourceGroupName(), + "ogretestmap.bsp", + Graphics::getSingleton().getSceneManagerPtr()); + + rgm.initialiseAllResourceGroups(); + rgm.loadResourceGroup(rgm.getWorldResourceGroupName(), false, true); + + Ogre::ViewPoint vp = Graphics::getSingleton().getSceneManagerPtr()->getSuggestedViewpoint(true); + Graphics::getSingleton().getCameraPtr()->setPosition(vp.position); + Graphics::getSingleton().getCameraPtr()->pitch(Ogre::Degree(90)); + Graphics::getSingleton().getCameraPtr()->rotate(vp.orientation); + Graphics::getSingleton().getCameraPtr()->setFixedYawAxis(true, Ogre::Vector3::UNIT_Z); + + Graphics::getSingleton().getSceneManagerPtr()->setAmbientLight(Ogre::ColourValue(1, 1, 1)); + + Ogre::Entity* myEntity = Graphics::getSingleton().getSceneManagerPtr()->createEntity("Robot1", "robot.mesh"); + Ogre::SceneNode* myNode = Graphics::getSingleton().getSceneManagerPtr()->getRootSceneNode()->createChildSceneNode("Robot1Node"); + myNode->attachObject(myEntity); + + // This is how the real game loop should go + while (!mKeyQuit->isDown()) + { + if (!Graphics::getSingleton().getRootPtr()->_fireFrameStarted()) + break; + + think(); + + Graphics::getSingleton().update(); + + if (!Graphics::getSingleton().getRootPtr()->_fireFrameEnded()) + break; + } +} + +void +Game::think() +{ + if (mKeyUp->isDown()) + { + Graphics::getSingleton().getCameraPtr()->moveRelative(Ogre::Vector3(0, 0, -2)); + } + if (mKeyRight->isDown()) + { + Graphics::getSingleton().getCameraPtr()->moveRelative(Ogre::Vector3(2, 0, 0)); + } + if (mKeyDown->isDown()) + { + Graphics::getSingleton().getCameraPtr()->moveRelative(Ogre::Vector3(0, 0, 2)); + } + if (mKeyLeft->isDown()) + { + Graphics::getSingleton().getCameraPtr()->moveRelative(Ogre::Vector3(-2, 0, 0)); + } +} + +void +Game::mouseMotionListener(Ogre::Real x, Ogre::Real y) +{ + Graphics::getSingleton().getCameraPtr()->yaw(Ogre::Radian(-x * 1.f)); + Graphics::getSingleton().getCameraPtr()->pitch(Ogre::Radian(-y * 1.f)); +} Copied: trunk/perceptioncrash/src/Game.hpp (from rev 23, trunk/perceptioncrash/src/game.hpp) =================================================================== --- trunk/perceptioncrash/src/Game.hpp (rev 0) +++ trunk/perceptioncrash/src/Game.hpp 2006-05-18 03:13:59 UTC (rev 24) @@ -0,0 +1,31 @@ +#ifndef PC_GAME_HPP +#define PC_GAME_HPP + +#include <memory> + +#include <Ogre.h> +#include <OgreEventListeners.h> +#include <OgreKeyEvent.h> + +#include "Graphics.hpp" +#include "Input.hpp" + + +class Game +{ + public: + Game(); + + void run(); + void think(); + void mouseMotionListener(Ogre::Real, Ogre::Real); + + private: + InputKey* mKeyQuit; + InputKey* mKeyUp; + InputKey* mKeyRight; + InputKey* mKeyDown; + InputKey* mKeyLeft; +}; + +#endif /*PC_GAME_HPP*/ Copied: trunk/perceptioncrash/src/Graphics.cpp (from rev 23, trunk/perceptioncrash/src/graphics.cpp) =================================================================== --- trunk/perceptioncrash/src/Graphics.cpp (rev 0) +++ trunk/perceptioncrash/src/Graphics.cpp 2006-05-18 03:13:59 UTC (rev 24) @@ -0,0 +1,37 @@ +#include "Graphics.hpp" + +graphics::graphics() + : mRoot(new Ogre::Root("plugins.cfg", "ogre.cfg", "ogre.log")), + mSmgr(mRoot->createSceneManager("BspSceneManager")) +{ + // HACK This is setting either OpenGL or first thing it comes to + Ogre::RenderSystemList* renderers = mRoot->getAvailableRenderers(); + Ogre::RenderSystem* r = *renderers->begin(); // default + + for (Ogre::RenderSystemList::iterator i = renderers->begin(); + i != renderers->end(); ++i) + { + if (Ogre::StringUtil::match((*i)->getName(), "*opengl*", false)) + r = *i; + } + + r->setConfigOption("FSAA", "0"); + r->setConfigOption("Full Screen", "no"); + r->setConfigOption("RTT Preferred Mode", "FBO"); + r->setConfigOption("Video Mode", "800 x 600"); + + mRoot->setRenderSystem(r); + mWindow = mRoot->initialise(true, "Application"); + + // Should probably change this stuff + mCamera = mSmgr->createCamera("camera"); + mCamera->setPosition(Ogre::Vector3(0.0f, 0.0f, 500.0f)); + mCamera->lookAt(Ogre::Vector3(0.0f, 0.0f, 0.0f)); + mCamera->setNearClipDistance(5.0f); + mCamera->setFarClipDistance(5000.0f); + + mViewport = mWindow->addViewport(mCamera); + mViewport->setBackgroundColour(Ogre::ColourValue(0.3f, 0.3f, 0.3f)); + + mCamera->setAspectRatio(Ogre::Real(mViewport->getActualWidth()) / Ogre::Real(mViewport->getActualHeight())); +} Copied: trunk/perceptioncrash/src/Graphics.hpp (from rev 23, trunk/perceptioncrash/src/graphics.hpp) =================================================================== --- trunk/perceptioncrash/src/Graphics.hpp (rev 0) +++ trunk/perceptioncrash/src/Graphics.hpp 2006-05-18 03:13:59 UTC (rev 24) @@ -0,0 +1,42 @@ +#ifndef PC_GRAPHICS_HPP +#define PC_GRAPHICS_HPP + +#include <memory> + +#include <Ogre.h> +#include <OgreEventListeners.h> +#include <OgreKeyEvent.h> + +#include "Singleton.hpp" + +class graphics +{ + public: + graphics(); + + void update() + { mRoot->_updateAllRenderTargets(); } + + Ogre::Root* getRootPtr() const + { return mRoot.get(); } + Ogre::RenderWindow* getWindowPtr() const + { return mWindow; } + Ogre::SceneManager* getSceneManagerPtr() const + { return mSmgr; } + Ogre::Camera* getCameraPtr() const + { return mCamera; } + Ogre::Viewport* getViewportPtr() const + { return mViewport; } + + private: + std::auto_ptr<Ogre::Root> mRoot; + + Ogre::RenderWindow* mWindow; + Ogre::SceneManager* mSmgr; + Ogre::Camera* mCamera; + Ogre::Viewport* mViewport; +}; + +typedef Singleton<graphics> Graphics; + +#endif /* PC_GRAPHICS_HPP*/ Copied: trunk/perceptioncrash/src/Input.cpp (from rev 23, trunk/perceptioncrash/src/input.cpp) =================================================================== --- trunk/perceptioncrash/src/Input.cpp (rev 0) +++ trunk/perceptioncrash/src/Input.cpp 2006-05-18 03:13:59 UTC (rev 24) @@ -0,0 +1,83 @@ +#include "Input.hpp" +#include "Graphics.hpp" + +input::input() + : mEventProcessor(new Ogre::EventProcessor) +{ + mEventProcessor->addKeyListener(this); + mEventProcessor->addMouseMotionListener(this); + mEventProcessor->initialise(Graphics::getSingleton().getWindowPtr()); + mEventProcessor->startProcessingEvents(); +} + +InputKey* +input::createKey(std::string str, int keycode) +{ + if (mKeys.find(str) == mKeys.end()) + return mKeys[str] = new InputKey(keycode); + + return 0; +} + +InputKey* +input::findKey(std::string str) +{ + if (mKeys.find(str) != mKeys.end()) + return mKeys[str]; + + return 0; +} + +void +input::keyClicked(Ogre::KeyEvent* e) +{ + // TODO make some clicked code, probably not needed +} + +void +input::keyPressed(Ogre::KeyEvent* e) +{ + std::map<std::string, InputKey*>::iterator i; + for (i = mKeys.begin(); i != mKeys.end(); ++i) + { + if (e->getKey() == i->second->getKey()) + { + i->second->setDown(); + } + } +} + +void +input::keyReleased(Ogre::KeyEvent* e) +{ + std::map<std::string, InputKey*>::iterator i; + for (i = mKeys.begin(); i != mKeys.end(); ++i) + { + if (e->getKey() == i->second->getKey()) + { + i->second->setDown(false); + } + } +} + +void +input::mouseMoved(Ogre::MouseEvent* e) +{ + std::list<boost::function<void(Ogre::Real, Ogre::Real)> >::iterator i; + for (i = mMouseListeners.begin(); i != mMouseListeners.end(); ++i) + { + (*i) (e->getRelX(), e->getRelY()); + } +} + +void +input::mouseDragged(Ogre::MouseEvent* e) +{ + +} + +void +input::mouseDragMoved(Ogre::MouseEvent* e) +{ + +} Copied: trunk/perceptioncrash/src/Input.hpp (from rev 23, trunk/perceptioncrash/src/input.hpp) =================================================================== --- trunk/perceptioncrash/src/Input.hpp (rev 0) +++ trunk/perceptioncrash/src/Input.hpp 2006-05-18 03:13:59 UTC (rev 24) @@ -0,0 +1,63 @@ +#ifndef PC_INPUT_HPP +#define PC_INPUT_HPP + +#include <map> +#include <list> + +#include <boost/function.hpp> + +#include <Ogre.h> +#include <OgreEventListeners.h> +#include <OgreKeyEvent.h> + +#include "Singleton.hpp" + +class InputKey +{ + public: + InputKey(int key): mKeycode(key), mDown(false) { } + + int getKey() const + { return mKeycode; } + bool isDown() const + { return mDown; } + + void setDown(bool yes = true) + { mDown = yes; } + + private: + int mKeycode; + bool mDown; +}; + +class input : public Ogre::KeyListener, + public Ogre::MouseMotionListener +{ + public: + input(); + + InputKey* createKey(std::string, int); + InputKey* findKey(std::string); + + void keyClicked(Ogre::KeyEvent*); + void keyPressed(Ogre::KeyEvent*); + void keyReleased(Ogre::KeyEvent*); + + void mouseMoved(Ogre::MouseEvent*); + void mouseDragged(Ogre::MouseEvent*); + void mouseDragMoved(Ogre::MouseEvent*); + + void registerMouseListener(boost::function<void(Ogre::Real, Ogre::Real)> m) + { mMouseListeners.push_back(m); } + + private: + std::map<std::string,InputKey*> mKeys; + std::list<boost::function<void(Ogre::Real, Ogre::Real)> > mMouseListeners; + + std::auto_ptr<Ogre::EventProcessor> mEventProcessor; +}; + +typedef + Singleton<input> Input; + +#endif /*PC_INPUT_HPP*/ Copied: trunk/perceptioncrash/src/Singleton.hpp (from rev 23, trunk/perceptioncrash/src/singleton.hpp) =================================================================== --- trunk/perceptioncrash/src/Singleton.hpp (rev 0) +++ trunk/perceptioncrash/src/Singleton.hpp 2006-05-18 03:13:59 UTC (rev 24) @@ -0,0 +1,23 @@ +#ifndef SINGLETON_HPP +#define SINGLETON_HPP + +template<class T> +class Singleton +{ + public: + static T& getSingleton() + { + static T instance; + + return instance; + } + + private: + Singleton(); + ~Singleton(); + + Singleton(Singleton const &); + Singleton& operator=(Singleton const &); +}; + +#endif // SINGLETON_HPP Deleted: trunk/perceptioncrash/src/game.cpp =================================================================== --- trunk/perceptioncrash/src/game.cpp 2006-05-18 03:09:48 UTC (rev 23) +++ trunk/perceptioncrash/src/game.cpp 2006-05-18 03:13:59 UTC (rev 24) @@ -1,86 +0,0 @@ -#include <cmath> - -#include <boost/bind.hpp> - -#include "game.hpp" - -Game::Game() - : mKeyQuit(Input::getSingleton().createKey("quit", Ogre::KC_ESCAPE)), - mKeyUp(Input::getSingleton().createKey("up", Ogre::KC_W)), - mKeyRight(Input::getSingleton().createKey("right", Ogre::KC_D)), - mKeyDown(Input::getSingleton().createKey("down", Ogre::KC_S)), - mKeyLeft(Input::getSingleton().createKey("left", Ogre::KC_A)) -{ - Input::getSingleton().registerMouseListener(boost::bind(&Game::mouseMotionListener, this, _1,_2)); -} - -void -Game::run() -{ - // This is all temporary stuff - Ogre::ResourceGroupManager rgm = Ogre::ResourceGroupManager::getSingleton(); - rgm.addResourceLocation("data/objects", "FileSystem", "General"); - rgm.addResourceLocation("data/maps/ogretestmap.zip", "Zip", - rgm.getWorldResourceGroupName()); - - rgm.linkWorldGeometryToResourceGroup(rgm.getWorldResourceGroupName(), - "ogretestmap.bsp", - Graphics::getSingleton().getSceneManagerPtr()); - - rgm.initialiseAllResourceGroups(); - rgm.loadResourceGroup(rgm.getWorldResourceGroupName(), false, true); - - Ogre::ViewPoint vp = Graphics::getSingleton().getSceneManagerPtr()->getSuggestedViewpoint(true); - Graphics::getSingleton().getCameraPtr()->setPosition(vp.position); - Graphics::getSingleton().getCameraPtr()->pitch(Ogre::Degree(90)); - Graphics::getSingleton().getCameraPtr()->rotate(vp.orientation); - Graphics::getSingleton().getCameraPtr()->setFixedYawAxis(true, Ogre::Vector3::UNIT_Z); - - Graphics::getSingleton().getSceneManagerPtr()->setAmbientLight(Ogre::ColourValue(1, 1, 1)); - - Ogre::Entity* myEntity = Graphics::getSingleton().getSceneManagerPtr()->createEntity("Robot1", "robot.mesh"); - Ogre::SceneNode* myNode = Graphics::getSingleton().getSceneManagerPtr()->getRootSceneNode()->createChildSceneNode("Robot1Node"); - myNode->attachObject(myEntity); - - // This is how the real game loop should go - while (!mKeyQuit->isDown()) - { - if (!Graphics::getSingleton().getRootPtr()->_fireFrameStarted()) - break; - - think(); - - Graphics::getSingleton().update(); - - if (!Graphics::getSingleton().getRootPtr()->_fireFrameEnded()) - break; - } -} - -void -Game::think() -{ - if (mKeyUp->isDown()) - { - Graphics::getSingleton().getCameraPtr()->moveRelative(Ogre::Vector3(0, 0, -2)); - } - if (mKeyRight->isDown()) - { - Graphics::getSingleton().getCameraPtr()->moveRelative(Ogre::Vector3(2, 0, 0)); - } - if (mKeyDown->isDown()) - { - Graphics::getSingleton().getCameraPtr()->moveRelative(Ogre::Vector3(0, 0, 2)); - } - if (mKeyLeft->isDown()) - { - Graphics::getSingleton().getCameraPtr()->moveRelative(Ogre::Vector3(-2, 0, 0)); - } -} - -void -Game::mouseMotionListener(Ogre::Real x, Ogre::Real y) -{ - Graphics::getSingleton().getCameraPtr()->yaw(Ogre::Radian(-x * 1.f)); - Graphics::getSingleton().getCameraPtr()->pitch(Ogre::Radian(-y * 1.f)); -} Deleted: trunk/perceptioncrash/src/game.hpp =================================================================== --- trunk/perceptioncrash/src/game.hpp 2006-05-18 03:09:48 UTC (rev 23) +++ trunk/perceptioncrash/src/game.hpp 2006-05-18 03:13:59 UTC (rev 24) @@ -1,31 +0,0 @@ -#ifndef PC_GAME_HPP -#define PC_GAME_HPP - -#include <memory> - -#include <Ogre.h> -#include <OgreEventListeners.h> -#include <OgreKeyEvent.h> - -#include "graphics.hpp" -#include "input.hpp" - - -class Game -{ - public: - Game(); - - void run(); - void think(); - void mouseMotionListener(Ogre::Real, Ogre::Real); - - private: - InputKey* mKeyQuit; - InputKey* mKeyUp; - InputKey* mKeyRight; - InputKey* mKeyDown; - InputKey* mKeyLeft; -}; - -#endif /*PC_GAME_HPP*/ Deleted: trunk/perceptioncrash/src/graphics.cpp =================================================================== --- trunk/perceptioncrash/src/graphics.cpp 2006-05-18 03:09:48 UTC (rev 23) +++ trunk/perceptioncrash/src/graphics.cpp 2006-05-18 03:13:59 UTC (rev 24) @@ -1,37 +0,0 @@ -#include "graphics.hpp" - -graphics::graphics() - : mRoot(new Ogre::Root("plugins.cfg", "ogre.cfg", "ogre.log")), - mSmgr(mRoot->createSceneManager("BspSceneManager")) -{ - // HACK This is setting either OpenGL or first thing it comes to - Ogre::RenderSystemList* renderers = mRoot->getAvailableRenderers(); - Ogre::RenderSystem* r = *renderers->begin(); // default - - for (Ogre::RenderSystemList::iterator i = renderers->begin(); - i != renderers->end(); ++i) - { - if (Ogre::StringUtil::match((*i)->getName(), "*opengl*", false)) - r = *i; - } - - r->setConfigOption("FSAA", "0"); - r->setConfigOption("Full Screen", "no"); - r->setConfigOption("RTT Preferred Mode", "FBO"); - r->setConfigOption("Video Mode", "800 x 600"); - - mRoot->setRenderSystem(r); - mWindow = mRoot->initialise(true, "Application"); - - // Should probably change this stuff - mCamera = mSmgr->createCamera("camera"); - mCamera->setPosition(Ogre::Vector3(0.0f, 0.0f, 500.0f)); - mCamera->lookAt(Ogre::Vector3(0.0f, 0.0f, 0.0f)); - mCamera->setNearClipDistance(5.0f); - mCamera->setFarClipDistance(5000.0f); - - mViewport = mWindow->addViewport(mCamera); - mViewport->setBackgroundColour(Ogre::ColourValue(0.3f, 0.3f, 0.3f)); - - mCamera->setAspectRatio(Ogre::Real(mViewport->getActualWidth()) / Ogre::Real(mViewport->getActualHeight())); -} Deleted: trunk/perceptioncrash/src/graphics.hpp =================================================================== --- trunk/perceptioncrash/src/graphics.hpp 2006-05-18 03:09:48 UTC (rev 23) +++ trunk/perceptioncrash/src/graphics.hpp 2006-05-18 03:13:59 UTC (rev 24) @@ -1,42 +0,0 @@ -#ifndef PC_GRAPHICS_HPP -#define PC_GRAPHICS_HPP - -#include <memory> - -#include <Ogre.h> -#include <OgreEventListeners.h> -#include <OgreKeyEvent.h> - -#include "singleton.hpp" - -class graphics -{ - public: - graphics(); - - void update() - { mRoot->_updateAllRenderTargets(); } - - Ogre::Root* getRootPtr() const - { return mRoot.get(); } - Ogre::RenderWindow* getWindowPtr() const - { return mWindow; } - Ogre::SceneManager* getSceneManagerPtr() const - { return mSmgr; } - Ogre::Camera* getCameraPtr() const - { return mCamera; } - Ogre::Viewport* getViewportPtr() const - { return mViewport; } - - private: - std::auto_ptr<Ogre::Root> mRoot; - - Ogre::RenderWindow* mWindow; - Ogre::SceneManager* mSmgr; - Ogre::Camera* mCamera; - Ogre::Viewport* mViewport; -}; - -typedef Singleton<graphics> Graphics; - -#endif /* PC_GRAPHICS_HPP*/ Deleted: trunk/perceptioncrash/src/input.cpp =================================================================== --- trunk/perceptioncrash/src/input.cpp 2006-05-18 03:09:48 UTC (rev 23) +++ trunk/perceptioncrash/src/input.cpp 2006-05-18 03:13:59 UTC (rev 24) @@ -1,83 +0,0 @@ -#include "input.hpp" -#include "graphics.hpp" - -input::input() - : mEventProcessor(new Ogre::EventProcessor) -{ - mEventProcessor->addKeyListener(this); - mEventProcessor->addMouseMotionListener(this); - mEventProcessor->initialise(Graphics::getSingleton().getWindowPtr()); - mEventProcessor->startProcessingEvents(); -} - -InputKey* -input::createKey(std::string str, int keycode) -{ - if (mKeys.find(str) == mKeys.end()) - return mKeys[str] = new InputKey(keycode); - - return 0; -} - -InputKey* -input::findKey(std::string str) -{ - if (mKeys.find(str) != mKeys.end()) - return mKeys[str]; - - return 0; -} - -void -input::keyClicked(Ogre::KeyEvent* e) -{ - // TODO make some clicked code, probably not needed -} - -void -input::keyPressed(Ogre::KeyEvent* e) -{ - std::map<std::string, InputKey*>::iterator i; - for (i = mKeys.begin(); i != mKeys.end(); ++i) - { - if (e->getKey() == i->second->getKey()) - { - i->second->setDown(); - } - } -} - -void -input::keyReleased(Ogre::KeyEvent* e) -{ - std::map<std::string, InputKey*>::iterator i; - for (i = mKeys.begin(); i != mKeys.end(); ++i) - { - if (e->getKey() == i->second->getKey()) - { - i->second->setDown(false); - } - } -} - -void -input::mouseMoved(Ogre::MouseEvent* e) -{ - std::list<boost::function<void(Ogre::Real, Ogre::Real)> >::iterator i; - for (i = mMouseListeners.begin(); i != mMouseListeners.end(); ++i) - { - (*i) (e->getRelX(), e->getRelY()); - } -} - -void -input::mouseDragged(Ogre::MouseEvent* e) -{ - -} - -void -input::mouseDragMoved(Ogre::MouseEvent* e) -{ - -} Deleted: trunk/perceptioncrash/src/input.hpp =================================================================== --- trunk/perceptioncrash/src/input.hpp 2006-05-18 03:09:48 UTC (rev 23) +++ trunk/perceptioncrash/src/input.hpp 2006-05-18 03:13:59 UTC (rev 24) @@ -1,63 +0,0 @@ -#ifndef PC_INPUT_HPP -#define PC_INPUT_HPP - -#include <map> -#include <list> - -#include <boost/function.hpp> - -#include <Ogre.h> -#include <OgreEventListeners.h> -#include <OgreKeyEvent.h> - -#include "singleton.hpp" - -class InputKey -{ - public: - InputKey(int key): mKeycode(key), mDown(false) { } - - int getKey() const - { return mKeycode; } - bool isDown() const - { return mDown; } - - void setDown(bool yes = true) - { mDown = yes; } - - private: - int mKeycode; - bool mDown; -}; - -class input : public Ogre::KeyListener, - public Ogre::MouseMotionListener -{ - public: - input(); - - InputKey* createKey(std::string, int); - InputKey* findKey(std::string); - - void keyClicked(Ogre::KeyEvent*); - void keyPressed(Ogre::KeyEvent*); - void keyReleased(Ogre::KeyEvent*); - - void mouseMoved(Ogre::MouseEvent*); - void mouseDragged(Ogre::MouseEvent*); - void mouseDragMoved(Ogre::MouseEvent*); - - void registerMouseListener(boost::function<void(Ogre::Real, Ogre::Real)> m) - { mMouseListeners.push_back(m); } - - private: - std::map<std::string,InputKey*> mKeys; - std::list<boost::function<void(Ogre::Real, Ogre::Real)> > mMouseListeners; - - std::auto_ptr<Ogre::EventProcessor> mEventProcessor; -}; - -typedef - Singleton<input> Input; - -#endif /*PC_INPUT_HPP*/ Modified: trunk/perceptioncrash/src/main.cpp =================================================================== --- trunk/perceptioncrash/src/main.cpp 2006-05-18 03:09:48 UTC (rev 23) +++ trunk/perceptioncrash/src/main.cpp 2006-05-18 03:13:59 UTC (rev 24) @@ -3,7 +3,7 @@ #include <Ogre.h> #include <OgreErrorDialog.h> -#include "game.hpp" +#include "Game.hpp" #if OGRE_PLATFORM==OGRE_PLATFORM_WIN32 #define WIN32_LEAN_AND_MEAN Deleted: trunk/perceptioncrash/src/singleton.hpp =================================================================== --- trunk/perceptioncrash/src/singleton.hpp 2006-05-18 03:09:48 UTC (rev 23) +++ trunk/perceptioncrash/src/singleton.hpp 2006-05-18 03:13:59 UTC (rev 24) @@ -1,23 +0,0 @@ -#ifndef SINGLETON_HPP -#define SINGLETON_HPP - -template<class T> -class Singleton -{ - public: - static T& getSingleton() - { - static T instance; - - return instance; - } - - private: - Singleton(); - ~Singleton(); - - Singleton(Singleton const &); - Singleton& operator=(Singleton const &); -}; - -#endif // SINGLETON_HPP This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |