x
Yes
No
Do you want to visit DriveHQ English website?
Inicio
Características
Precios
Prueba gratuita
Software cliente
Acerca de nosotros
Servidor de archivos
|
Solución de copias de seguridad
|
Servidor FTP
|
Servidor de correo electrónico
|
Alojamiento web
|
Software cliente
Servidor de archivos
Solución de copia de seguridad
Servidor FTP
Servidor de correo electrónico
Alojamiento web
Software cliente
InputManager.cpp - Hosted on DriveHQ Cloud IT Platform
Arriba
Subir
Descargar
Compartir
Publicar
Nueva carpeta
Nuevo archivo
Copiar
Cortar
Eliminar
Pegar
Clasificación
Actualizar
Ruta de la carpeta: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\GameFactory\InputManager.cpp
Girar
Efecto
Propiedad
Historial
#include "InputManager.h" #include "GameScene.h" InputManager* InputManager::theSingleton = NULL; extern HWND hWndMainWin; InputManager::InputManager(){ myassert(theSingleton==NULL); theSingleton = this; OIS::ParamList pl; size_t windowHnd = 0; std::ostringstream windowHndStr; GameScene::GetSingleton()->GetRenderWindow()->getCustomAttribute("WINDOW", &windowHnd); //windowHndStr << windowHnd; windowHndStr << (size_t)hWndMainWin; pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" ))); pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE"))); mInputManager = OIS::InputManager::createInputSystem( pl ); //Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse) mKeyboard = new RKeyboard(static_cast
(mInputManager->createInputObject( OIS::OISKeyboard, false/*bufferedKeys*/ ))); mMouse = static_cast
(mInputManager->createInputObject( OIS::OISMouse, false/*bufferedMouse*/ )); unsigned int width, height, depth; int left, top; GameScene::GetSingleton()->GetRenderWindow()->getMetrics(width, height, depth, left, top); const OIS::MouseState &ms = mMouse->getMouseState(); ms.width = width; ms.height = height; } InputManager::~InputManager(){ while (mInputControllerPool.GetPool().size()>0){//cannot use for loop here because element's destructor remove itself from the container InputController* firstElement = (InputController*)*(mInputControllerPool.GetPool().begin()); SAFE_DELETE(firstElement); } theSingleton = NULL; mInputManager->destroyInputObject( mMouse ); mInputManager->destroyInputObject( mKeyboard->mKeyboard ); //mInputManager->destroyInputObject( mJoy ); OIS::InputManager::destroyInputSystem(mInputManager); mInputManager = NULL; } void InputManager::FrameMove(Ogre::Real elapsedTime){ mMouse->capture(); //const OIS::MouseState &ms = mMouse->getMouseState(); //if (ms.X.abs<=ms.width && ms.Y.abs <= ms.height){//got focus // mKeyboard->_Capture(); //} mKeyboard->_Capture(); RMouse* myMouse = &((RMouse)mMouse->getMouseState()); for (list
::iterator iter = mInputControllerPool.GetPool().begin(); iter!=mInputControllerPool.GetPool().end();iter++){ InputController* controller = static_cast
(*iter); controller->FrameMove(elapsedTime, myMouse, mKeyboard); } }
InputManager.cpp
Dirección de la página
Dirección del archivo
Anterior
25/55
Siguiente
Descargar
( 2 KB )
Comments
Total ratings:
0
Average rating:
No clasificado
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.