From: <spo...@us...> - 2007-04-05 13:01:38
|
Revision: 359 http://svn.sourceforge.net/opengate/?rev=359&view=rev Author: spom_spom Date: 2007-04-05 06:01:37 -0700 (Thu, 05 Apr 2007) Log Message: ----------- Ported to ogre-1.4. Freeimage from gentoo-ebuild dont work with ogre-1.4, Running ogsector with a manual installed Freeimage works fine. Modified Paths: -------------- branches/ogsector/configure.ac branches/ogsector/data/MediaFromOgre/ogrehead.mesh branches/ogsector/data/arrow.mesh branches/ogsector/data/povray/buildSkyBox.sh branches/ogsector/data/simpleHUD.overlay branches/ogsector/data/simpleSkybox.material branches/ogsector/data/simpleSkybox.zip branches/ogsector/ogre.cfg branches/ogsector/resources.cfg branches/ogsector/src/InputManager.cpp branches/ogsector/src/InputManager.h branches/ogsector/src/Sector.cpp branches/ogsector/src/Sector.h branches/ogsector/src/SectorClient.cpp branches/ogsector/src/SectorClient.h branches/ogsector/src/SectorClientFrameListener.cpp branches/ogsector/src/SectorClientFrameListener.h branches/ogsector/src/SectorObjects.cpp branches/ogsector/src/networkClient.cpp branches/ogsector/src/networkClient.h branches/ogsector/src/ogsectorclient.cpp Modified: branches/ogsector/configure.ac =================================================================== --- branches/ogsector/configure.ac 2007-04-05 12:33:54 UTC (rev 358) +++ branches/ogsector/configure.ac 2007-04-05 13:01:37 UTC (rev 359) @@ -21,7 +21,7 @@ AC_SUBST(AM_CXXFLAGS,"$AM_CXXFLAGS $OGRE_CFLAGS") AC_SUBST(AM_LDFLAGS,"$AM_LDFLAGS $OGRE_LIBS") -#OIS - http://www.sourceforge.net/projects/wgois/ +dnl OIS - http://www.sourceforge.net/projects/wgois/ PKG_CHECK_MODULES(OIS, [OIS >= 0.9.9]) AC_SUBST(AM_CXXFLAGS, "$AM_CXXFLAGS $OIS_CFLAGS") AC_SUBST(AM_LDFLAGS, "$AM_LDFLAGS $OIS_LIBS") @@ -36,6 +36,7 @@ AC_SUBST(AM_CXXFLAGS, "$AM_CXXFLAGS $freealut_CFLAGS") AC_SUBST(AM_LDFLAGS, "$AM_LDFLAGS $freealut_LIBS") +AC_SUBST([CXXFLAGS], ["${CXXFLAGS} -I$OGSECTOR_EXTERNALS_PATH/include"]) AC_SUBST([CXXFLAGS], ["${CXXFLAGS} -I$OGSECTOR_EXTERNALS_PATH/ogreopcode/include"]) AC_SUBST([CXXFLAGS], ["${CXXFLAGS} -I$OGSECTOR_EXTERNALS_PATH/ogreopcode/opcode132"]) AC_SUBST([LDFLAGS], ["${LDFLAGS} -L$OGSECTOR_EXTERNALS_PATH/lib/ -lOpcode -lOgreOpcode"]) Modified: branches/ogsector/data/MediaFromOgre/ogrehead.mesh =================================================================== (Binary files differ) Modified: branches/ogsector/data/arrow.mesh =================================================================== (Binary files differ) Modified: branches/ogsector/data/povray/buildSkyBox.sh =================================================================== --- branches/ogsector/data/povray/buildSkyBox.sh 2007-04-05 12:33:54 UTC (rev 358) +++ branches/ogsector/data/povray/buildSkyBox.sh 2007-04-05 13:01:37 UTC (rev 359) @@ -1,4 +1,4 @@ -RESOLUTION=1024 +RESOLUTION=512 POVFILE=skybox2.pov OUTNAME=${POVFILE%.pov} Modified: branches/ogsector/data/simpleHUD.overlay =================================================================== --- branches/ogsector/data/simpleHUD.overlay 2007-04-05 12:33:54 UTC (rev 358) +++ branches/ogsector/data/simpleHUD.overlay 2007-04-05 13:01:37 UTC (rev 359) @@ -64,7 +64,7 @@ colour_bottom 1 1 0.7 } - element TextArea(Core/DebugText) + element TextArea(OpenGate/DebugText) { metrics_mode pixels left 230 Modified: branches/ogsector/data/simpleSkybox.material =================================================================== --- branches/ogsector/data/simpleSkybox.material 2007-04-05 12:33:54 UTC (rev 358) +++ branches/ogsector/data/simpleSkybox.material 2007-04-05 13:01:37 UTC (rev 359) @@ -1,34 +1,34 @@ -material OpenGate/SimpleSkyBox1 -{ - technique - { - pass - { - lighting off - depth_write off - - texture_unit - { - cubic_texture skybox1.jpg separateUV - tex_address_mode clamp - } - } - } -} -material OpenGate/SimpleSkyBox2 -{ - technique - { - pass - { - lighting off - depth_write off - - texture_unit - { - cubic_texture skybox2.jpg separateUV - tex_address_mode clamp - } - } - } -} +material OpenGate/SimpleSkyBox1 +{ + technique + { + pass + { + lighting off + depth_write off + + texture_unit + { + cubic_texture skybox1.png separateUV + tex_address_mode clamp + } + } + } +} +material OpenGate/SimpleSkyBox2 +{ + technique + { + pass + { + lighting off + depth_write off + + texture_unit + { + cubic_texture skybox2.png separateUV + tex_address_mode clamp + } + } + } +} Modified: branches/ogsector/data/simpleSkybox.zip =================================================================== (Binary files differ) Modified: branches/ogsector/ogre.cfg =================================================================== --- branches/ogsector/ogre.cfg 2007-04-05 12:33:54 UTC (rev 358) +++ branches/ogsector/ogre.cfg 2007-04-05 13:01:37 UTC (rev 359) @@ -1,7 +1,7 @@ Render System=OpenGL Rendering Subsystem [OpenGL Rendering Subsystem] -FSAA=6 +FSAA=0 Full Screen=No RTT Preferred Mode=FBO Video Mode=1024 x 768 Modified: branches/ogsector/resources.cfg =================================================================== --- branches/ogsector/resources.cfg 2007-04-05 12:33:54 UTC (rev 358) +++ branches/ogsector/resources.cfg 2007-04-05 13:01:37 UTC (rev 359) @@ -6,9 +6,9 @@ [General] FileSystem=./data Zip=./data/simpleSkybox.zip - +# FileSystem=./data/MediaFromOgre Zip=./data/MediaFromOgre/fonts.zip - +# FileSystem=../../trunk/data/ FileSystem=../../trunk/data/materials Modified: branches/ogsector/src/InputManager.cpp =================================================================== --- branches/ogsector/src/InputManager.cpp 2007-04-05 12:33:54 UTC (rev 358) +++ branches/ogsector/src/InputManager.cpp 2007-04-05 13:01:37 UTC (rev 359) @@ -1,384 +1,388 @@ #include "InputManager.h" +#include "OgreStringConverter.h" -InputManager *InputManager::mInputManager; +InputManager::InputManager( unsigned long hWnd ){ + mMouse = NULL; + mKeyboard = NULL; + mJoyStick = NULL; + mInputSystem = NULL; -InputManager::InputManager( void ) : - mMouse( 0 ), - mKeyboard( 0 ), - mInputSystem( 0 ) { + OIS::ParamList pl; + pl.insert( OIS::ParamList::value_type( "WINDOW", Ogre::StringConverter::toString( hWnd ) ) ); + + m_hWnd = hWnd; + mInputSystem = OIS::InputManager::createInputSystem( pl ); + + if ( mInputSystem ){ + mMouse = static_cast<OIS::Mouse*>(mInputSystem->createInputObject( OIS::OISMouse, true )); + mMouse->setEventCallback( this ); + + mKeyboard = static_cast<OIS::Keyboard*>(mInputSystem->createInputObject( OIS::OISKeyboard, true)); + mKeyboard->setEventCallback( this ); + + if ( mInputSystem->numJoysticks() > 0 ) { + + // mJoysticks.resize( mInputSystem->numJoysticks() ); + + // itJoystick = mJoysticks.begin(); + // itJoystickEnd = mJoysticks.end(); + // for(; itJoystick != itJoystickEnd; ++itJoystick ) { + // (*itJoystick) = static_cast<OIS::JoyStick*>( mInputSystem->createInputObject( OIS::OISJoyStick, true ) ); + // (*itJoystick)->setEventCallback( this ); + // } + mJoyStick = static_cast<OIS::JoyStick*>(mInputSystem->createInputObject( OIS::OISJoyStick, true)); + mJoyStick->setEventCallback( this ); + } + } } InputManager::~InputManager( void ) { if( mInputSystem ) { if( mMouse ) { mInputSystem->destroyInputObject( mMouse ); - mMouse = 0; + mMouse = NULL; } - + if( mKeyboard ) { mInputSystem->destroyInputObject( mKeyboard ); - mKeyboard = 0; + mKeyboard = NULL; } - if( mJoysticks.size() > 0 ) { - itJoystick = mJoysticks.begin(); - itJoystickEnd = mJoysticks.end(); - for(; itJoystick != itJoystickEnd; ++itJoystick ) { - mInputSystem->destroyInputObject( *itJoystick ); - } - - mJoysticks.clear(); + if( mJoyStick ) { + mInputSystem->destroyInputObject( mJoyStick ); + mJoyStick = NULL; } - - //** did not compile against my OIS version - // mInputSystem->destroyInputSystem( ); - //** did not compile against my OIS version + } - - mInputSystem = 0; - - // Clear Listeners - mKeyListeners.clear(); - mMouseListeners.clear(); - mJoystickListeners.clear(); - } + OIS::InputManager::destroyInputSystem( mInputSystem ); + + mInputSystem = NULL; + + // Clear Listeners + mKeyListeners.clear(); + mMouseListeners.clear(); + mJoystickListeners.clear(); } -void InputManager::initialise( Ogre::RenderWindow *renderWindow ) { - if( !mInputSystem ) { - // Setup basic variables - OIS::ParamList paramList; - size_t windowHnd = 0; - std::ostringstream windowHndStr; +void InputManager::capture( ) { + if( mMouse ) mMouse->capture(); - // Get window handle -#if defined OIS_WIN32_PLATFORM - renderWindow->getCustomAttribute( "HWND", &windowHnd ); - // Uncomment these two lines to allow users to switch keyboards via the language bar - //paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND") )); - //paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE") )); + if( mKeyboard ) mKeyboard->capture(); -#elif defined OIS_LINUX_PLATFORM - renderWindow->getCustomAttribute( "GLXWINDOW", &windowHnd ); -#endif - - // Fill parameter list - windowHndStr << (unsigned int) windowHnd; - paramList.insert( std::make_pair( std::string( "WINDOW" ), windowHndStr.str() ) ); - - // Create inputsystem - mInputSystem = OIS::InputManager::createInputSystem( paramList ); - - // If possible create a buffered keyboard - if( mInputSystem->numKeyBoards() > 0 ) { - mKeyboard = static_cast<OIS::Keyboard*>( mInputSystem->createInputObject( OIS::OISKeyboard, true ) ); - mKeyboard->setEventCallback( this ); - } - - // If possible create a buffered mouse - if( mInputSystem->numMice() > 0 ) { - mMouse = static_cast<OIS::Mouse*>( mInputSystem->createInputObject( OIS::OISMouse, true ) ); - mMouse->setEventCallback( this ); - - // Get window size - unsigned int width, height, depth; - int left, top; - renderWindow->getMetrics( width, height, depth, left, top ); - - // Set mouse region - this->setWindowExtents( width, height ); - } - - // If possible create all joysticks in buffered mode - if( mInputSystem->numJoysticks() > 0 ) { - mJoysticks.resize( mInputSystem->numJoysticks() ); - - itJoystick = mJoysticks.begin(); - itJoystickEnd = mJoysticks.end(); - for(; itJoystick != itJoystickEnd; ++itJoystick ) { - (*itJoystick) = static_cast<OIS::JoyStick*>( mInputSystem->createInputObject( OIS::OISJoyStick, true ) ); - (*itJoystick)->setEventCallback( this ); - } - } - } + if( mJoyStick ) mJoyStick->capture(); } -void InputManager::capture( void ) { - // Need to capture / update each device every frame - if( mMouse ) { - mMouse->capture(); - } - - if( mKeyboard ) { - mKeyboard->capture(); - } - - if( mJoysticks.size() > 0 ) { - itJoystick = mJoysticks.begin(); - itJoystickEnd = mJoysticks.end(); - for(; itJoystick != itJoystickEnd; ++itJoystick ) { - (*itJoystick)->capture(); - } - } +void InputManager::setWindowExtents(int width, int height){ + //Set Mouse Region.. if window resizes, we should alter this to reflect as well + const OIS::MouseState &ms = mMouse->getMouseState(); + ms.width = width; + ms.height = height; } void InputManager::addKeyListener( OIS::KeyListener *keyListener, const std::string& instanceName ) { - if( mKeyboard ) { - // Check for duplicate items - itKeyListener = mKeyListeners.find( instanceName ); - if( itKeyListener == mKeyListeners.end() ) { - mKeyListeners[ instanceName ] = keyListener; - } - else { - // Duplicate Item - } - } -} - -void InputManager::addMouseListener( OIS::MouseListener *mouseListener, const std::string& instanceName ) { - if( mMouse ) { - // Check for duplicate items - itMouseListener = mMouseListeners.find( instanceName ); - if( itMouseListener == mMouseListeners.end() ) { - mMouseListeners[ instanceName ] = mouseListener; - } - else { - // Duplicate Item - } - } -} - -void InputManager::addJoystickListener( OIS::JoyStickListener *joystickListener, const std::string& instanceName ) { - if( mJoysticks.size() > 0 ) { - // Check for duplicate items - itJoystickListener = mJoystickListeners.find( instanceName ); - if( itJoystickListener == mJoystickListeners.end() ) { - mJoystickListeners[ instanceName ] = joystickListener; - } - else { - // Duplicate Item - } - } -} - -void InputManager::removeKeyListener( const std::string& instanceName ) { - // Check if item exists + if( mKeyboard ) { + // Check for duplicate items itKeyListener = mKeyListeners.find( instanceName ); - if( itKeyListener != mKeyListeners.end() ) { - mKeyListeners.erase( itKeyListener ); + if( itKeyListener == mKeyListeners.end() ) { + mKeyListeners[ instanceName ] = keyListener; } else { - // Doesn't Exist + // Duplicate Item } + } } -void InputManager::removeMouseListener( const std::string& instanceName ) { - // Check if item exists +void InputManager::addMouseListener( OIS::MouseListener *mouseListener, const std::string& instanceName ) { + if( mMouse ) { + // Check for duplicate items itMouseListener = mMouseListeners.find( instanceName ); - if( itMouseListener != mMouseListeners.end() ) { - mMouseListeners.erase( itMouseListener ); + if( itMouseListener == mMouseListeners.end() ) { + mMouseListeners[ instanceName ] = mouseListener; } else { - // Doesn't Exist + // Duplicate Item } + } } -void InputManager::removeJoystickListener( const std::string& instanceName ) { - // Check if item exists +void InputManager::addJoystickListener( OIS::JoyStickListener *joystickListener, const std::string& instanceName ) { + if( mJoyStick ) { + // Check for duplicate items itJoystickListener = mJoystickListeners.find( instanceName ); - if( itJoystickListener != mJoystickListeners.end() ) { - mJoystickListeners.erase( itJoystickListener ); + if( itJoystickListener == mJoystickListeners.end() ) { + mJoystickListeners[ instanceName ] = joystickListener; } else { - // Doesn't Exist + // Duplicate Item } + } } +void InputManager::removeKeyListener( const std::string & instanceName ) { + // Check if item exists + itKeyListener = mKeyListeners.find( instanceName ); + if( itKeyListener != mKeyListeners.end() ) { + mKeyListeners.erase( itKeyListener ); + } + else { + // Doesn't Exist + } +} + +void InputManager::removeMouseListener( const std::string & instanceName ) { + // Check if item exists + itMouseListener = mMouseListeners.find( instanceName ); + if( itMouseListener != mMouseListeners.end() ) { + mMouseListeners.erase( itMouseListener ); + } + else { + // Doesn't Exist + } +} + +void InputManager::removeJoystickListener( const std::string & instanceName ) { + // Check if item exists + itJoystickListener = mJoystickListeners.find( instanceName ); + if( itJoystickListener != mJoystickListeners.end() ) { + mJoystickListeners.erase( itJoystickListener ); + } + else { + // Doesn't Exist + } +} + void InputManager::removeKeyListener( OIS::KeyListener *keyListener ) { - itKeyListener = mKeyListeners.begin(); - itKeyListenerEnd = mKeyListeners.end(); - for(; itKeyListener != itKeyListenerEnd; ++itKeyListener ) { - if( itKeyListener->second == keyListener ) { - mKeyListeners.erase( itKeyListener ); - break; - } + itKeyListener = mKeyListeners.begin(); + itKeyListenerEnd = mKeyListeners.end(); + for(; itKeyListener != itKeyListenerEnd; ++itKeyListener ) { + if( itKeyListener->second == keyListener ) { + mKeyListeners.erase( itKeyListener ); + break; } + } } void InputManager::removeMouseListener( OIS::MouseListener *mouseListener ) { - itMouseListener = mMouseListeners.begin(); - itMouseListenerEnd = mMouseListeners.end(); - for(; itMouseListener != itMouseListenerEnd; ++itMouseListener ) { - if( itMouseListener->second == mouseListener ) { - mMouseListeners.erase( itMouseListener ); - break; - } + itMouseListener = mMouseListeners.begin(); + itMouseListenerEnd = mMouseListeners.end(); + for(; itMouseListener != itMouseListenerEnd; ++itMouseListener ) { + if( itMouseListener->second == mouseListener ) { + mMouseListeners.erase( itMouseListener ); + break; } + } } void InputManager::removeJoystickListener( OIS::JoyStickListener *joystickListener ) { - itJoystickListener = mJoystickListeners.begin(); - itJoystickListenerEnd = mJoystickListeners.end(); - for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) { - if( itJoystickListener->second == joystickListener ) { - mJoystickListeners.erase( itJoystickListener ); - break; - } + itJoystickListener = mJoystickListeners.begin(); + itJoystickListenerEnd = mJoystickListeners.end(); + for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) { + if( itJoystickListener->second == joystickListener ) { + mJoystickListeners.erase( itJoystickListener ); + break; } + } } void InputManager::removeAllListeners( void ) { - mKeyListeners.clear(); - mMouseListeners.clear(); - mJoystickListeners.clear(); + mKeyListeners.clear(); + mMouseListeners.clear(); + mJoystickListeners.clear(); } void InputManager::removeAllKeyListeners( void ) { - mKeyListeners.clear(); + mKeyListeners.clear(); } void InputManager::removeAllMouseListeners( void ) { - mMouseListeners.clear(); + mMouseListeners.clear(); } void InputManager::removeAllJoystickListeners( void ) { - mJoystickListeners.clear(); + mJoystickListeners.clear(); } -void InputManager::setWindowExtents( int width, int height ) { - // Set mouse region (if window resizes, we should alter this to reflect as well) - const OIS::MouseState &mouseState = mMouse->getMouseState(); - mouseState.width = width; - mouseState.height = height; -} - -OIS::Mouse* InputManager::getMouse( void ) { - return mMouse; -} - -OIS::Keyboard* InputManager::getKeyboard( void ) { - return mKeyboard; -} - -OIS::JoyStick* InputManager::getJoystick( unsigned int index ) { - // Make sure it's a valid index - if( index < mJoysticks.size() ) { - return mJoysticks[ index ]; - } - - return 0; -} - -int InputManager::getNumOfJoysticks( void ) { - // Cast to keep compiler happy ^^ - return (int) mJoysticks.size(); -} - bool InputManager::keyPressed( const OIS::KeyEvent &e ) { - itKeyListener = mKeyListeners.begin(); - itKeyListenerEnd = mKeyListeners.end(); - for(; itKeyListener != itKeyListenerEnd; ++itKeyListener ) { - itKeyListener->second->keyPressed( e ); - } - - return true; + itKeyListener = mKeyListeners.begin(); + itKeyListenerEnd = mKeyListeners.end(); + for(; itKeyListener != itKeyListenerEnd; ++itKeyListener ) { + itKeyListener->second->keyPressed( e ); + } + return true; } bool InputManager::keyReleased( const OIS::KeyEvent &e ) { - itKeyListener = mKeyListeners.begin(); - itKeyListenerEnd = mKeyListeners.end(); - for(; itKeyListener != itKeyListenerEnd; ++itKeyListener ) { - itKeyListener->second->keyReleased( e ); - } - - return true; + itKeyListener = mKeyListeners.begin(); + itKeyListenerEnd = mKeyListeners.end(); + for(; itKeyListener != itKeyListenerEnd; ++itKeyListener ) { + itKeyListener->second->keyReleased( e ); + } + return true; } bool InputManager::mouseMoved( const OIS::MouseEvent &e ) { - itMouseListener = mMouseListeners.begin(); - itMouseListenerEnd = mMouseListeners.end(); - for(; itMouseListener != itMouseListenerEnd; ++itMouseListener ) { + // for_each( mMouseListeners.begin(), mMouseListeners.end(), std::mem_fun( itMouseListener.second->mouseMoved( e ) ) ); + + itMouseListener = mMouseListeners.begin(); + itMouseListenerEnd = mMouseListeners.end(); + for(; itMouseListener != itMouseListenerEnd; ++itMouseListener ) { itMouseListener->second->mouseMoved( e ); - } - - return true; + } + return true; } bool InputManager::mousePressed( const OIS::MouseEvent &e, OIS::MouseButtonID id ) { - itMouseListener = mMouseListeners.begin(); - itMouseListenerEnd = mMouseListeners.end(); - for(; itMouseListener != itMouseListenerEnd; ++itMouseListener ) { - itMouseListener->second->mousePressed( e, id ); - } - - return true; + itMouseListener = mMouseListeners.begin(); + itMouseListenerEnd = mMouseListeners.end(); + for(; itMouseListener != itMouseListenerEnd; ++itMouseListener ) { + itMouseListener->second->mousePressed( e, id ); + } + return true; } bool InputManager::mouseReleased( const OIS::MouseEvent &e, OIS::MouseButtonID id ) { - itMouseListener = mMouseListeners.begin(); - itMouseListenerEnd = mMouseListeners.end(); - for(; itMouseListener != itMouseListenerEnd; ++itMouseListener ) { - itMouseListener->second->mouseReleased( e, id ); - } - - return true; + itMouseListener = mMouseListeners.begin(); + itMouseListenerEnd = mMouseListeners.end(); + for(; itMouseListener != itMouseListenerEnd; ++itMouseListener ) { + itMouseListener->second->mouseReleased( e, id ); + } + return true; } bool InputManager::povMoved( const OIS::JoyStickEvent &e, int pov ) { - itJoystickListener = mJoystickListeners.begin(); - itJoystickListenerEnd = mJoystickListeners.end(); - for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) { - itJoystickListener->second->povMoved( e, pov ); - } - - return true; + itJoystickListener = mJoystickListeners.begin(); + itJoystickListenerEnd = mJoystickListeners.end(); + for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) { + itJoystickListener->second->povMoved( e, pov ); + } + return true; } bool InputManager::axisMoved( const OIS::JoyStickEvent &e, int axis ) { itJoystickListener = mJoystickListeners.begin(); itJoystickListenerEnd = mJoystickListeners.end(); - + for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) { itJoystickListener->second->axisMoved( e, axis ); } - return true; } bool InputManager::sliderMoved( const OIS::JoyStickEvent &e, int sliderID ) { - itJoystickListener = mJoystickListeners.begin(); - itJoystickListenerEnd = mJoystickListeners.end(); - for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) { - itJoystickListener->second->sliderMoved( e, sliderID ); - } - - return true; + itJoystickListener = mJoystickListeners.begin(); + itJoystickListenerEnd = mJoystickListeners.end(); + for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) { + itJoystickListener->second->sliderMoved( e, sliderID ); + } + return true; } bool InputManager::buttonPressed( const OIS::JoyStickEvent &e, int button ) { - itJoystickListener = mJoystickListeners.begin(); - itJoystickListenerEnd = mJoystickListeners.end(); - for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) { - itJoystickListener->second->buttonPressed( e, button ); - } - - return true; + itJoystickListener = mJoystickListeners.begin(); + itJoystickListenerEnd = mJoystickListeners.end(); + for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) { + itJoystickListener->second->buttonPressed( e, button ); + } + return true; } bool InputManager::buttonReleased( const OIS::JoyStickEvent &e, int button ) { - itJoystickListener = mJoystickListeners.begin(); - itJoystickListenerEnd = mJoystickListeners.end(); - for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) { - itJoystickListener->second->buttonReleased( e, button ); - } - - return true; + itJoystickListener = mJoystickListeners.begin(); + itJoystickListenerEnd = mJoystickListeners.end(); + for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) { + itJoystickListener->second->buttonReleased( e, button ); + } + return true; } -InputManager* InputManager::getSingletonPtr( void ) { - if( !mInputManager ) { - mInputManager = new InputManager(); - } +// void InputManager::initialise( Ogre::RenderWindow *renderWindow ) { +// if( !mInputSystem ) { +// // Setup basic variables +// OIS::ParamList paramList; +// size_t windowHnd = 0; +// std::ostringstream windowHndStr; - return mInputManager; -} +// // Get window handle +// #if defined OIS_WIN32_PLATFORM +// renderWindow->getCustomAttribute( "HWND", &windowHnd ); +// // Uncomment these two lines to allow users to switch keyboards via the language bar +// //paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND") )); +// //paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE") )); + +// #elif defined OIS_LINUX_PLATFORM +// renderWindow->getCustomAttribute( "GLXWINDOW", &windowHnd ); +// #endif + +// // Fill parameter list +// windowHndStr << (unsigned int) windowHnd; +// paramList.insert( std::make_pair( std::string( "WINDOW" ), windowHndStr.str() ) ); + +// // Create inputsystem +// mInputSystem = OIS::InputManager::createInputSystem( paramList ); + +// // If possible create a buffered keyboard +// #ifndef WIN32 +// if( mInputSystem->numKeyBoards() > 0 ) { +// mKeyboard = static_cast<OIS::Keyboard*>( mInputSystem->createInputObject( OIS::OISKeyboard, true ) ); +// mKeyboard->setEventCallback( this ); +// } + +// // If possible create a buffered mouse +// if( mInputSystem->numMice() > 0 ) { +// mMouse = static_cast<OIS::Mouse*>( mInputSystem->createInputObject( OIS::OISMouse, true ) ); +// mMouse->setEventCallback( this ); + +// // Get window size +// unsigned int width, height, depth; +// int left, top; +// renderWindow->getMetrics( width, height, depth, left, top ); + +// // Set mouse region +// this->setWindowExtents( width, height ); +// } + +// // If possible create all joysticks in buffered mode +// if( mInputSystem->numJoysticks() > 0 ) { +// mJoysticks.resize( mInputSystem->numJoysticks() ); + +// itJoystick = mJoysticks.begin(); +// itJoystickEnd = mJoysticks.end(); +// for(; itJoystick != itJoystickEnd; ++itJoystick ) { +// (*itJoystick) = static_cast<OIS::JoyStick*>( mInputSystem->createInputObject( OIS::OISJoyStick, true ) ); +// (*itJoystick)->setEventCallback( this ); +// } +// } +// #endif +// } +// } + +// OIS::Mouse* InputManager::getMouse( void ) { +// return mMouse; +// } + +// OIS::Keyboard* InputManager::getKeyboard( void ) { +// return mKeyboard; +// } + +// OIS::JoyStick* InputManager::getJoystick( unsigned int index ) { +// // Make sure it's a valid index +// if( index < mJoysticks.size() ) { +// return mJoysticks[ index ]; +// } + +// return 0; +// } + +// int InputManager::getNumOfJoysticks( void ) { +// // Cast to keep compiler happy ^^ +// return (int) mJoysticks.size(); +// } + + +// InputManager* InputManager::getSingletonPtr( void ) { +// if( !mInputManager ) { +// mInputManager = new InputManager(); +// } + +// return mInputManager; +// } Modified: branches/ogsector/src/InputManager.h =================================================================== --- branches/ogsector/src/InputManager.h 2007-04-05 12:33:54 UTC (rev 358) +++ branches/ogsector/src/InputManager.h 2007-04-05 13:01:37 UTC (rev 359) @@ -1,97 +1,126 @@ #ifndef INPUTMANAGER_H // INPUTMANAGER_H #define INPUTMANAGER_H -#include <OISMouse.h> -#include <OISKeyboard.h> -#include <OISJoyStick.h> -#include <OISInputManager.h> +#ifdef WIN32 +#define OIS_WIN32_PLATFORM +#else +#define OIS_LINUX_PLATFORM +#endif -#include <OgreRenderWindow.h> +#include <OIS/OISEvents.h> +#include <OIS/OISInputManager.h> +#include <OIS/OISMouse.h> +#include <OIS/OISKeyboard.h> +#include <OIS/OISJoyStick.h> -#if defined OIS_WIN32_PLATFORM +#ifdef OIS_WIN32_PLATFORM #define WIN32_LEAN_AND_MEAN #include "windows.h" -#include "resource.h" -LRESULT DlgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); - +// #include "resource.h" +// LRESULT DlgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); #elif defined OIS_LINUX_PLATFORM -#include <X11/Xlib.h> -void checkX11Events(); #endif -class InputManager : public OIS::KeyListener, public OIS::MouseListener, public OIS::JoyStickListener { +class InputManager : public OIS::MouseListener, public OIS::KeyListener, public OIS::JoyStickListener { public: - virtual ~InputManager( void ); + InputManager( unsigned long hWnd ); + virtual ~InputManager(); + + void setWindowExtents( int width, int height ) ; - void initialise( Ogre::RenderWindow *renderWindow ); - void capture( void ); + /*! Need to capture / update each device every frame. */ + void capture(); void addKeyListener( OIS::KeyListener *keyListener, const std::string& instanceName ); void addMouseListener( OIS::MouseListener *mouseListener, const std::string& instanceName ); void addJoystickListener( OIS::JoyStickListener *joystickListener, const std::string& instanceName ); - + void removeKeyListener( const std::string & instanceName ); void removeMouseListener( const std::string & instanceName ); void removeJoystickListener( const std::string & instanceName ); - + void removeKeyListener( OIS::KeyListener * keyListener ); void removeMouseListener( OIS::MouseListener * mouseListener ); void removeJoystickListener( OIS::JoyStickListener * joystickListener ); - + void removeAllListeners( void ); void removeAllKeyListeners( void ); void removeAllMouseListeners( void ); void removeAllJoystickListeners( void ); + + // KeyListener + bool keyPressed(const OIS::KeyEvent &evt); + bool keyReleased(const OIS::KeyEvent &evt); + + // MouseListener + bool mouseMoved(const OIS::MouseEvent &evt); + bool mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID); + bool mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID); - void setWindowExtents( int width, int height ); - - OIS::Mouse* getMouse( void ); - OIS::Keyboard* getKeyboard( void ); - OIS::JoyStick* getJoystick( unsigned int index ); - - int getNumOfJoysticks( void ); - - static InputManager* getSingletonPtr( void ); - -private: - InputManager( void ); - InputManager( const InputManager & input ) { } - InputManager & operator = ( const InputManager & input ); - - bool keyPressed( const OIS::KeyEvent & e ); - bool keyReleased( const OIS::KeyEvent & e ); - - bool mouseMoved( const OIS::MouseEvent & e ); - bool mousePressed( const OIS::MouseEvent & e, OIS::MouseButtonID id ); - bool mouseReleased( const OIS::MouseEvent & e, OIS::MouseButtonID id ); - - bool povMoved( const OIS::JoyStickEvent & e, int pov ); - bool axisMoved( const OIS::JoyStickEvent & e, int axis ); + // JoyStickListener + bool axisMoved(const OIS::JoyStickEvent &evt, int index ); + bool buttonPressed(const OIS::JoyStickEvent &evt, int index ); + bool buttonReleased(const OIS::JoyStickEvent &evt, int index ); bool sliderMoved( const OIS::JoyStickEvent & e, int sliderID ); - bool buttonPressed( const OIS::JoyStickEvent & e, int button ); - bool buttonReleased( const OIS::JoyStickEvent & e, int button ); - - OIS::InputManager * mInputSystem; - OIS::Mouse * mMouse; - OIS::Keyboard * mKeyboard; - - std::vector< OIS::JoyStick * > mJoysticks; - std::vector< OIS::JoyStick * >::iterator itJoystick; - std::vector< OIS::JoyStick * >::iterator itJoystickEnd; - + bool povMoved(const OIS::JoyStickEvent &evt, int index ); + +protected: + + OIS::InputManager *mInputSystem; + OIS::Mouse *mMouse; + OIS::Keyboard *mKeyboard; + OIS::JoyStick *mJoyStick; + unsigned long m_hWnd; + std::map< std::string, OIS::KeyListener * > mKeyListeners; std::map< std::string, OIS::MouseListener * > mMouseListeners; std::map< std::string, OIS::JoyStickListener * > mJoystickListeners; - + std::map< std::string, OIS::KeyListener * >::iterator itKeyListener; std::map< std::string, OIS::MouseListener * >::iterator itMouseListener; std::map< std::string, OIS::JoyStickListener * >::iterator itJoystickListener; - + std::map< std::string, OIS::KeyListener * >::iterator itKeyListenerEnd; std::map< std::string, OIS::MouseListener * >::iterator itMouseListenerEnd; std::map< std::string, OIS::JoyStickListener * >::iterator itJoystickListenerEnd; - - static InputManager *mInputManager; + }; +// class InputManager : public OIS::KeyListener, public OIS::MouseListener, public OIS::JoyStickListener { +// public: +// virtual ~InputManager( void ); + +// void initialise( Ogre::RenderWindow *renderWindow ); +// void capture( void ); + +// void setWindowExtents( int width, int height ); + +// OIS::Mouse* getMouse( void ); +// OIS::Keyboard* getKeyboard( void ); +// OIS::JoyStick* getJoystick( unsigned int index ); + +// int getNumOfJoysticks( void ); + +// static InputManager* getSingletonPtr( void ); + +// private: +// InputManager( void ); +// InputManager( const InputManager & input ) { } +// InputManager & operator = ( const InputManager & input ); + +// OIS::InputManager * mInputSystem; +// OIS::Mouse * mMouse; +// OIS::Keyboard * mKeyboard; + +// std::vector< OIS::JoyStick * > mJoysticks; +// std::vector< OIS::JoyStick * >::iterator itJoystick; +// std::vector< OIS::JoyStick * >::iterator itJoystickEnd; + +// std::map< std::string, OIS::KeyListener * > mKeyListeners; +// std::map< std::string, OIS::MouseListener * > mMouseListeners; +// std::map< std::string, OIS::JoyStickListener * > mJoystickListeners; + +// static InputManager *mInputManager; +// }; + #endif // INPUTMANAGER_H Modified: branches/ogsector/src/Sector.cpp =================================================================== --- branches/ogsector/src/Sector.cpp 2007-04-05 12:33:54 UTC (rev 358) +++ branches/ogsector/src/Sector.cpp 2007-04-05 13:01:37 UTC (rev 359) @@ -5,20 +5,23 @@ Sector::Sector( Ogre::SceneManager * sceneMgr, Network * network ) : sceneMgr_( sceneMgr ), network_( network ){ sectorname_ = "Testsector"; + avatar_ = NULL; + avatarDeathSequenceTime_ = 0.0; sceneMgr_->setAmbientLight( Ogre::ColourValue(0.5, 0.5, 0.5) ); //** Create a skybox; sceneMgr_->setSkyBox( true, "OpenGate/SimpleSkyBox1", 100 ); - //** Create a light; - Ogre::Light * l = sceneMgr_->createLight("MainLight"); +// //** Create a light; + // Ogre::Light * l = sceneMgr_->createLight("MainLight"); - // Accept default settings: point light, white diffuse, just set position - // NB I could attach the light to a SceneNode if I wanted it to move automatically with - // other objects, but I don't - l->setPosition( 20, 80, 50 ); +// // Accept default settings: point light, white diffuse, just set position +// // NB I could attach the light to a SceneNode if I wanted it to move automatically with +// // other objects, but I don't +// l->setPosition( 0, 0, 200 ); + new OgreOpcode::CollisionManager( sceneMgr_ ); OgreOpcode::CollisionManager::getSingletonPtr()->addCollClass( "SectorObject" ); OgreOpcode::CollisionManager::getSingletonPtr()->addCollClass( "Bullet" ); @@ -39,28 +42,28 @@ createStaticObject( Ogre::String("ogrehead.mesh"), - "ogreheadStation", - Ogre::Vector3( 5000, 0, 0 ), - Ogre::Real( 500.0 ), - Ogre::Degree( 0.0 ) ); + "ogreheadStation", + Ogre::Vector3( 5000, 0, 0 ), + Ogre::Real( 500.0 ), + Ogre::Degree( 0.0 ) ); // createCircle(); createStaticObject( Ogre::String("ogrehead.mesh"), - "-100 0 0", - Ogre::Vector3( -100, 0, 0 ), - Ogre::Real( 10.0 ), - Ogre::Degree( 0.0 ) ); + "-100 0 0", + Ogre::Vector3( -100, 0, 0 ), + Ogre::Real( 10.0 ), + Ogre::Degree( 0.0 ) ); createStaticObject( Ogre::String("ogrehead.mesh"), - "100 0 0", - Ogre::Vector3( 100, 0, 0 ), - Ogre::Real( 10.0 ), - Ogre::Degree( 0.0 ) ); + "100 0 0", + Ogre::Vector3( 100, 0, 0 ), + Ogre::Real( 10.0 ), + Ogre::Degree( 0.0 ) ); itTarget_ = sectorObjects_.begin(); -} +} Sector::~Sector( ){ delete OgreOpcode::CollisionManager::getSingletonPtr(); @@ -73,7 +76,8 @@ void Sector::update( Ogre::Real elapsedTime ){ collideInSectorContext_->collide( 0.0 ); - // collideInSectorContext_->collide( elapsedTime ); + collideInSectorContext_->collide( elapsedTime ); + OgreOpcode::CollisionReporter report( collideInSectorContext_->getCollisionReport() ); int nCollids = report.getNumCollisions(); @@ -91,14 +95,12 @@ static_cast< BaseObject * >( col2->getClientData() )->collide( static_cast< BaseObject * >( col1->getClientData() ) ); } -// std::cout << "CollisionContext attached objects: " + Ogre::StringConverter::toString(collideInSectorContext_->getAttachedObjectCount()) << std::endl; -// std::cout << "CollisionContext owned objects: " + Ogre::StringConverter::toString(collideInSectorContext_->getOwnedObjectCount()) << std::endl; -// std::cout << "CollisionManager shapes: " + Ogre::StringConverter::toString(OgreOpcode::CollisionManager::getSingletonPtr()->getShapeCount())<< std::endl; + std::cout << "CollisionContext attached objects: " + Ogre::StringConverter::toString(collideInSectorContext_->getAttachedObjectCount()) << std::endl; + std::cout << "CollisionContext owned objects: " + Ogre::StringConverter::toString(collideInSectorContext_->getOwnedObjectCount()) << std::endl; + std::cout << "CollisionManager shapes: " + Ogre::StringConverter::toString(OgreOpcode::CollisionManager::getSingletonPtr()->getShapeCount())<< std::endl; - } + } - // avatar_->update( elapsedTime); - bool tmpsegfaultDebug = false; for ( std::map< long, SectorObjectMoveable * >::iterator it = movableObjects_.begin(); it != movableObjects_.end();){ if ( !it->second->update( elapsedTime ) ) { @@ -114,13 +116,13 @@ std::cout << "tmpsegfaultDebug done." << std::endl; tmpsegfaultDebug = false; } - - if ( avatarDeathSequenceTime_ > 0 ){ - avatarDeathSequenceTime_ -= elapsedTime; - } else if ( avatarDeathSequenceTime_ > -1 ) { - spawnAvatar(); - } - + + if ( avatarDeathSequenceTime_ > 0 ){ + avatarDeathSequenceTime_ -= elapsedTime; + } else if ( avatarDeathSequenceTime_ > -1 ) { + spawnAvatar(); + } + } SectorObjectMoveable * Sector::createMoveableObject( const Ogre::String & name, int userID, int childID ){ @@ -198,8 +200,6 @@ MessageShipRegister msg( 0, obj->childID(), obj->name(), obj->mainNode()->getPosition(), true ); network_->send( msg ); - - } void Sector::createAvatar( const Ogre::String & playername ){ @@ -211,7 +211,7 @@ void Sector::destructAvatar( ){ // sectorObjects_.erase( avatar_ ); movableObjects_.erase( avatar_->globalID() ); - delete avatar_; + if ( avatar_ != NULL ) delete avatar_; avatar_ = NULL; } @@ -224,24 +224,28 @@ } void Sector::spawnAvatar( ){ - avatarDeathSequenceTime_ = -1.0; - - avatar_->mainNode()->setPosition( 0.0, 0.0, 0.0 ); - avatar_->mainNode()->setOrientation( Ogre::Quaternion( 1.0, 0.0, 0.0, 0.0 ) ); - avatar_->setVelocity( Ogre::Vector3( 0.0, 0.0, -20.0 ) ); - avatar_->reset(); - - MessageShipRegister msg( 0, 0, avatar_->name(), avatar_->mainNode()->getPosition(), true ); - network_->send( msg ); - - avatar_->setVisible( false ); - listener_->avatarDeathSequence( false ); + if ( avatar_ != NULL ){ + avatarDeathSequenceTime_ = -1.0; + + avatar_->mainNode()->setPosition( 0.0, 0.0, 500.0 ); + avatar_->mainNode()->setOrientation( Ogre::Quaternion( 1.0, 0.0, 0.0, 0.0 ) ); + avatar_->setVelocity( Ogre::Vector3( 0.0, 0.0, -20.0 ) ); + avatar_->reset(); + + MessageShipRegister msg( 0, 0, avatar_->name(), avatar_->mainNode()->getPosition(), true ); + network_->send( msg ); + + avatar_->setVisible( false ); + listener_->avatarDeathSequence( false ); + } } SectorObject * Sector::nextTarget( ){ if ( sectorObjects_.size() != 0 ){ itTarget_ ++; - if ( (*itTarget_) == avatar_ ) return nextTarget(); + if ( avatar_ != NULL ){ + if ( (*itTarget_) == avatar_ ) return nextTarget(); + } if ( itTarget_ == sectorObjects_.end() ) itTarget_ = sectorObjects_.begin(); return (*itTarget_); @@ -254,7 +258,9 @@ if ( itTarget_ == sectorObjects_.begin() ) itTarget_ = sectorObjects_.end(); itTarget_ --; - if ( (*itTarget_) == avatar_ ) return prevTarget(); + if ( avatar_ != NULL ){ + if ( (*itTarget_) == avatar_ ) return prevTarget(); + } return (*itTarget_); } return NULL; @@ -323,17 +329,19 @@ } void Sector::sendAllVesselMovements( ){ - MessageShipMovement msg( 0, - avatar_->mainNode()->getPosition(), - avatar_->velDirection(), - avatar_->mainNode()->getOrientation(), - avatar_->thrustPercent(), - avatar_->scaledYaw(), - avatar_->scaledPitch(), - avatar_->scaledRoll(), - avatar_->incNetSequence() ); + if ( avatar_ != NULL ){ + MessageShipMovement msg( 0, + avatar_->mainNode()->getPosition(), + avatar_->velDirection(), + avatar_->mainNode()->getOrientation(), + avatar_->thrustPercent(), + avatar_->scaledYaw(), + avatar_->scaledPitch(), + avatar_->scaledRoll(), + avatar_->incNetSequence() ); - network_->send( msg, false ); + network_->send( msg, false ); + } for ( std::map< int, SectorObjectMoveableAi * >::iterator it = localAiObjects_.begin(); it != localAiObjects_.end(); it ++ ){ MessageShipMovement msgObj( it->second->childID(), @@ -375,7 +383,9 @@ } void Sector::sendAllVesselStatus( ){ - sendVesselStatus( *avatar_ ); + if ( avatar_ != NULL ){ + sendVesselStatus( *avatar_ ); + } // for ( std::map< int, SectorObjectMoveableAi * >::iterator it = localAiObjects_.begin(); it != localAiObjects_.end(); it ++ ){ // sendVesselStatus( *(it->second) ); // } Modified: branches/ogsector/src/Sector.h =================================================================== --- branches/ogsector/src/Sector.h 2007-04-05 12:33:54 UTC (rev 358) +++ branches/ogsector/src/Sector.h 2007-04-05 13:01:37 UTC (rev 359) @@ -25,7 +25,6 @@ void setNetwork( Network * network ){ network_ = network; } - void update( Ogre::Real elapsedTime ); void createStaticObject( const Ogre::String & meshname, const Ogre::String & objectname, @@ -57,7 +56,6 @@ SectorObject * prevTarget( ); - void receiveVesselRegister( const MessageShipRegister & msg ); void sendAllVesselStatus( ); @@ -74,7 +72,6 @@ void receiveVesselAmmoHit( const MessageShipAmmoHit & msg ); - protected: SectorClientFrameListener * listener_; Ogre::SceneManager * sceneMgr_; Modified: branches/ogsector/src/SectorClient.cpp =================================================================== --- branches/ogsector/src/SectorClient.cpp 2007-04-05 12:33:54 UTC (rev 358) +++ branches/ogsector/src/SectorClient.cpp 2007-04-05 13:01:37 UTC (rev 359) @@ -11,28 +11,30 @@ if ( sector_ != NULL ) delete sector_; } -bool SectorClient::setup( ){ - root_ = new Ogre::Root(); +bool SectorClient::setup( bool dialog ){ + root_ = new Ogre::Root; setupResources(); - if ( !configure() ) return false; + if ( !configure( dialog ) ) return false; - sceneMgr_ = root_->createSceneManager( Ogre::ST_GENERIC, "BaseSMInstance"); + //** load ressources + Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); + //** load scene Manager + sceneMgr_ = root_->createSceneManager( Ogre::ST_GENERIC, "BaseSMInstance" ); + createCameras(); createViewports(); + //** spom dont what for // Set default mipmap level (NB some APIs ignore this) - Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); - - // Create any resource listeners (for loading screens) + // Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); + // Create any resource listeners (for loading screens) // createResourceListener(); - - // Load resources - loadResources(); - + //** spom dont what for + // Create the scene createScene(); @@ -64,58 +66,61 @@ } } -bool SectorClient::configure( void ){ - root_->restoreConfig(); - window_ = root_->initialise( true ); - return true; - - // Show the configuration dialog and initialise the system - // You can skip this and use root.restoreConfig() to load configuration - // settings if you were sure there are valid ones saved in ogre.cfg - if ( root_->showConfigDialog() ) { - // If returned true, user clicked OK so initialise - // Here we choose to let the system create a default rendering window by passing 'true' - window_ = root_->initialise( true ); +bool SectorClient::configure( bool dialog ){ + if ( !dialog ){ + root_->restoreConfig(); + window_ = root_->initialise( true, "OGSectorClient"); return true; } else { - return false; + // Show the configuration dialog and initialise the system + // You can skip this and use root.restoreConfig() to load configuration + // settings if you were sure there are valid ones saved in ogre.cfg + if ( root_->showConfigDialog() ) { + // If returned true, user clicked OK so initialise + // Here we choose to let the system create a default rendering window by passing 'true' + window_ = root_->initialise( true ); + return true; + } else { + return false; + } } + return false; } void SectorClient::createCameras( ) { camera_ = sceneMgr_->createCamera("CameraMain"); - camera_->setPosition( Ogre::Vector3( 0, 0, 200 ) ); - camera_->lookAt( Ogre::Vector3( 0, 0, -300 ) ); + camera_->setPosition( Ogre::Vector3( 0, 0, 500 ) ); + camera_->lookAt( Ogre::Vector3( 0, 0, 0 ) ); camera_->setNearClipDistance( 1 ); // camera_->setAspectRatio( Real(vp->getActualWidth()) / Real(vp->getActualHeight())); Ogre::Camera * camera1 = sceneMgr_->createCamera("Camera1"); - camera1->setPosition( Ogre::Vector3( 0, 0, 200 ) ); - camera1->lookAt( Ogre::Vector3( 0, 0, -300 ) ); + camera1->setPosition( Ogre::Vector3( 0, 0, 500 ) ); + camera1->lookAt( Ogre::Vector3( 0, 0, 0 ) ); camera1->setNearClipDistance( 1 ); - Ogre::Camera * camera2 = sceneMgr_->createCamera("Camera2"); - camera2->setPosition( Ogre::Vector3( 0, 0, 200 ) ); - camera2->lookAt( Ogre::Vector3( 0, 0, -300 ) ); - camera2->setNearClipDistance( 1 ); +// Ogre::Camera * camera2 = sceneMgr_->createCamera("Camera2"); +// camera2->setPosition( Ogre::Vector3( 0, 0, 200 ) ); +// camera2->lookAt( Ogre::Vector3( 0, 0, -300 ) ); +// camera2->setNearClipDistance( 1 ); } void SectorClient::createViewports( ) { Ogre::Viewport* vp = window_->addViewport( camera_, 0, 0.0, 0.0, 1.0f, 1.0f ); vp->setBackgroundColour( Ogre::ColourValue( 0, 0, 0) ); - Ogre::Viewport* vp1 = window_->addViewport( sceneMgr_->getCamera( "Camera1" ), 1, 0.84, 0.84, 0.15, 0.15 ); + Ogre::Viewport* vp1 = window_->addViewport( sceneMgr_->getCamera( "Camera1" ), 1, 0.01, 0.84, 0.15, 0.15 ); vp1->setBackgroundColour( Ogre::ColourValue( 0.1, 0.1, 0.1 ) ); vp1->setSkiesEnabled( true ); vp1->setShadowsEnabled( false ); vp1->setOverlaysEnabled( false ); - Ogre::Viewport* vp2 = window_->addViewport( sceneMgr_->getCamera( "Camera2" ), 2, 0.84, 0.01, 0.15, 0.15 ); - vp2->setBackgroundColour( Ogre::ColourValue( 0.1, 0.1, 0.1 ) ); - vp2->setSkiesEnabled( false ); - vp2->setOverlaysEnabled( false ); - vp2->setShadowsEnabled( false ); - window_->removeViewport( 2 ); +// Ogre::Viewport* vp2 = window_->addViewport( sceneMgr_->getCamera( "Camera2" ), 2, 0.84, 0.01, 0.15, 0.15 ); +// vp2->setBackgroundColour( Ogre::ColourValue( 0.1, 0.1, 0.1 ) ); +// vp2->setSkiesEnabled( false ); +// vp2->setOverlaysEnabled( false ); +// vp2->setShadowsEnabled( false ); +// window_->removeViewport( 2 ); } void SectorClient::createFrameListener( ) { Modified: branches/ogsector/src/SectorClient.h =================================================================== --- branches/ogsector/src/SectorClient.h 2007-04-05 12:33:54 UTC (rev 358) +++ branches/ogsector/src/SectorClient.h 2007-04-05 13:01:37 UTC (rev 359) @@ -26,8 +26,8 @@ if ( root_ != NULL ) delete root_; } - virtual void go( void ){ - if ( !setup() ) return; + virtual void go( bool dialog ){ + if ( !setup( dialog ) ) return; root_->startRendering(); @@ -36,12 +36,12 @@ protected: - virtual bool setup( ); + virtual bool setup( bool dialog ); //! Method which will define the source of resources (other than current folder) virtual void setupResources( ); - virtual bool configure( ); + virtual bool configure( bool dialog ); // virtual void chooseSceneManager( ){ } @@ -55,10 +55,6 @@ virtual void destroyScene( ); - virtual void loadResources( ) { - Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); - } - Ogre::Root * root_; Ogre::Camera * camera_; Modified: branches/ogsector/src/SectorClientFrameListener.cpp =================================================================== --- branches/ogsector/src/SectorClientFrameListener.cpp 2007-04-05 12:33:54 UTC (rev 358) +++ branches/ogsector/src/SectorClientFrameListener.cpp 2007-04-05 13:01:37 UTC (rev 359) @@ -14,30 +14,33 @@ bool useBufferedInputMouse ) : camera_( cam ), window_( win ), sector_( sector ), network_( nw ){ + shutDownRequest_ = false; + deathSequence_ = false; + sceneDetailIndex_ = 0; + target_ = NULL; + cameraMode_ = 1; + sector_->setListener( this ); - inputManager_ = InputManager::getSingletonPtr(); - inputManager_->initialise( window_ ); + windowsWidth_ = window_->getWidth( ); + windowsHeight_ = window_->getHeight( ); + windowsHalfWidth_ = (int)(windowsWidth_ * 0.5); + windowsHalfHeight_ = (int)(windowsHeight_ * 0.5); + + unsigned long hWnd; + window_->getCustomAttribute( "WINDOW", &hWnd ); + + inputManager_ = new InputManager( hWnd ); + inputManager_->setWindowExtents( windowsWidth_, windowsHeight_ ); + inputManager_->addKeyListener( this, "SectorClientKeyListener" ); inputManager_->addMouseListener( this, "SectorClientMouseListener" ); inputManager_->addJoystickListener( this, "SectorClientJoystickListener" ); - cameraMode_ = 1; - cameraRotateSpeed_ = 36; - cameraRotateScale_ = 0.0f; - cameraMoveSpeed_ = 100; - cameraMoveScale_ = 0.0f; - cameraTranslate_ = Ogre::Vector3::ZERO; - timeSinceLastSectorUpdate_ = 0.0; timeSinceLastNetworkUpdate_ = 0.0; - deathSequence_ = false; inputInitialState_ = true; lastInputWheelState_ = 0; - windowsWidth_ = window_->getWidth( ); - windowsHeight_ = window_->getHeight( ); - windowsHalfWidth_ = (int)(windowsWidth_ * 0.5); - windowsHalfHeight_ = (int)(windowsHeight_ * 0.5); hudOverlay_ = Ogre::OverlayManager::getSingleton().getByName("OpenGate/SimpleHUD"); @@ -58,32 +61,35 @@ mouseOverlay_->show(); chatMode_ = false; - setTarget( sector_->nextTarget() ); - // targetPointer_ = camera_->getSceneManager()->getRootSceneNode()->createChildSceneNode( "TargetPointer" ); +// cameraRotateSpeed_ = 36; +// cameraRotateScale_ = 0.0f; +// cameraMoveSpeed_ = 100; +// cameraMoveScale_ = 0.0f; +// cameraTranslate_ = Ogre::Vector3::ZERO; + +// targetPointer_ = camera_->getSceneManager()->getRootSceneNode()->createChildSceneNode( "TargetPointer" ); // BillboardSet* mySet = camera_->getSceneManager()->createBillboardSet("mySet"); // targetPointerBB_ = mySet->createBillboard( Vector3(0, 0, 0) ); // mySet->setMaterialName( "TargetPointer" ); // targetPointerBB_->setDimensions( 32.0, 32.0 ); // targetPointer_->attachObject( mySet ); - //targetPointer_->scale( 0.05, 0.05, 0.05 ); +// targetPointer_->scale( 0.05, 0.05, 0.05 ); // BillboardSet *targetPointerBillboard = camera_->getSceneManager()->createBillboardSet( "hudTargetPointer" ); // targetPointerBillboard->setMaterialName( "TargetPointer" ); // Billboard * hudTargetPointer = targetPointerBillboard->createBillboard( Ogre::Vector3( 0.0, 0.0, -100 ) ); -// // hudTargetPointer-> +// hudTargetPointer-> - - spaceDustParticleSystem_ = camera_->getSceneManager()->createParticleSystem( "SpaceDust", "Space/Dust" ); - Ogre::SceneNode * spaceDustNode = sector_->avatar()->mainNode()->createChildSceneNode( "DustParticles", camera_->getRealPosition() ); +// spaceDustParticleSystem_ = camera_->getSceneManager()->createParticleSystem( "SpaceDust", "Space/Dust" ); +// Ogre::SceneNode * spaceDustNode = sector_->avatar()->mainNode()->createChildSceneNode( "DustParticles", camera_->getRealPosition() ); - // spaceDustNode_->attachObject( spaceDustParticleSystem_ ); - //camera_->getParentSceneNode() +// spaceDustNode_->attachObject( spaceDustParticleSystem_ ); +// camera_->getParentSceneNode() - - // listener for the space dust +// listener for the space dust // SpaceDust* psd = new SpaceDust(mCamera, ps); // mRoot->addFrameListener(psd); @@ -93,7 +99,6 @@ // statsOn_ = true; // numScreenShots_ = 0; - sceneDetailIndex_ = 0; // aniso_ = 1; // filtering_ = TFO_BILINEAR; } @@ -102,21 +107,18 @@ inputManager_->removeKeyListener( "SectorClientKeyListener" ); inputManager_->removeMouseListener( "SectorClientMouseListener" ); inputManager_->removeJoystickListener( "SectorClientJoystickListener" ); - - //** neccesary because of new operator in inputmanager + + //** neccesary because of new operator in inputmanager; if ( inputManager_ != NULL ) delete inputManager_; } bool SectorClientFrameListener::frameStarted( const Ogre::FrameEvent & evt ) { if ( window_->isClosed() ) return false; - - timeSinceLastSectorUpdate_ += evt.timeSinceLastFrame; timeSinceLastNetworkUpdate_ += evt.timeSinceLastFrame; if ( deathSequence_ ){ - } else { //** capture my input inputManager_->capture(); @@ -164,7 +166,7 @@ timeSinceLastSectorUpdate_ = 0.0; updateHUD_(); } - + //** send movement data, max 10 net-updates/second if ( timeSinceLastNetworkUpdate_ > 0.1 ){ sector_->sendAllVesselMovements( ); @@ -174,7 +176,7 @@ //** update my camera; updateCamera_(); - renderSpaceDust(); +// renderSpaceDust(); return true; } @@ -185,67 +187,67 @@ bool SectorClientFrameListener::keyPressed( const OIS::KeyEvent & e ){ + //** ESCAPE leads to shutdown; + if ( e.key == OIS::KC_ESCAPE) { shutDownRequest_ = true; } + if ( !chatMode_ ){ if ( e.key == OIS::KC_RETURN) { chatMode_ = true; } - - //** ESCAPE leads to shutdown; - if ( e.key == OIS::KC_ESCAPE) { shutDownRequest_ = true; } - //** Avatar yaw LEFT; - if ( e.key == OIS::KC_A || e.key == OIS::KC_NUMPAD4 ) { sector_->avatar()->setScaledYaw( 1.0 ); } - - //** Avatar yaw RIGHT; - if ( e.key == OIS::KC_D || e.key == OIS::KC_NUMPAD6 ) { sector_->avatar()->setScaledYaw( -1.0 ); } + if ( sector_->avatar() != NULL ){ + //** Avatar yaw LEFT; + if ( e.key == OIS::KC_A || e.key == OIS::KC_NUMPAD4 ) { sector_->avatar()->setScaledYaw( 1.0 ); } + + //** Avatar yaw RIGHT; + if ( e.key == OIS::KC_D || e.key == OIS::KC_NUMPAD6 ) { sector_->avatar()->setScaledYaw( -1.0 ); } + + //** Avatar pitch DOWN; + if ( e.key == OIS::KC_W || e.key == OIS::KC_NUMPAD8 ) { sector_->avatar()->setScaledPitch( -1.0 ); } + + //** Avatar pitch UP; + if ( e.key == OIS::KC_S || e.key == OIS::KC_NUMPAD2 ) { sector_->avatar()->setScaledPitch( 1.0 ); } + + //** Avatar roll (181 == NUM/); + if ( e.key == OIS::KC_NUMPAD0 || e.key == 181 ) { sector_->avatar()->setScaledRoll( 1.0 ); } + + //** Avatar roll (55 == NUM*); + if ( e.key == OIS::KC_NUMPADCOMMA || e.key == 55 ) { sector_->avatar()->setScaledRoll( -1.0 ); } + + //** Avatar increase thrust by 10%; + if ( e.key == OIS::KC_NUMPAD7 ) { sector_->avatar()->incrementThrust(); } + + //** Avatar increase thrust by 10%; + if ( e.key == OIS::KC_NUMPAD1 ) { sector_->avatar()->decrementThrust(); } + + //** Avatar press break; + if ( e.key == OIS::KC_NUMPAD3 ) { sector_->avatar()->setBreakPressed( true ); } + + //** Avatar press afterburner; + if ( e.key == OIS::KC_NUMPAD9 ) { sector_->avatar()->setAfterburnerPressed( true ); } + + //** Avatar centering; + if ( e.key == OIS::KC_NUMPAD5 ) { + sector_->avatar()->setScaledYaw( 0.0 ); + sector_->avatar()->setScaledPitch( 0.0 ); + sector_->avatar()->setScaledRoll( 0.0 ); + } + //** selfdestruct and eject; + if ( e.key == OIS::KC_F11 ) { sector_->avatarDied(); } + } // if avatar; - //** Avatar pitch DOWN; - if ( e.key == OIS::KC_W || e.key == OIS::KC_NUMPAD8 ) { sector_->avatar()->setScaledPitch( -1.0 ); } - - //** Avatar pitch UP; - if ( e.key == OIS::KC_S || e.key == OIS::KC_NUMPAD2 ) { sector_->avatar()->setScaledPitch( 1.0 ); } - - //** Avatar roll (181 == NUM/); - if ( e.key == OIS::KC_NUMPAD0 || e.key == 181 ) { sector_->avatar()->setScaledRoll( 1.0 ); } - - //** Avatar roll (55 == NUM*); - if ( e.key == OIS::KC_NUMPADCOMMA || e.key == 55 ) { sector_->avatar()->setScaledRoll( -1.0 ); } - - //** Avatar increase thrust by 10%; - if ( e.key == OIS::KC_NUMPAD7 ) { sector_->avatar()->incrementThrust(); } - - //** Avatar increase thrust by 10%; - if ( e.key == OIS::KC_NUMPAD1 ) { sector_->avatar()->decrementThrust(); } - - //** Avatar press break; - if ( e.key == OIS::KC_NUMPAD3 ) { sector_->avatar()->setBreakPressed( true ); } - - //** Avatar press afterburner; - if ( e.key == OIS::KC_NUMPAD9 ) { sector_->avatar()->setAfterburnerPressed( true ); } - - //** Avatar centering; - if ( e.key == OIS::KC_NUMPAD5 ) { - sector_->avatar()->setScaledYaw( 0.0 ); - sector_->avatar()->setScaledPitch( 0.0 ); - sector_->avatar()->setScaledRoll( 0.0 ); - } - //** next Target; if ( e.key == OIS::KC_N ) { setTarget( sector_->nextTarget() ); } - + //** prev Target; if ( e.key == OIS::KC_P ) { setTarget( sector_->prevTarget() ); } - - //** selfdestruct and eject; - if ( e.key == OIS::KC_F11 ) { sector_->avatarDied(); } - + //** spawn; if ( e.key == OIS::KC_F12 ) { sector_->spawnAiObject(); } - //** Toggle through camera modes; if ( e.key == OIS::KC_6 ) { toggleNextCamera_(); } - + //** Create one screenshot; if ( e.key == OIS::KC_SYSRQ ) { char tmp[ 20 ]; @@ -304,159 +306,169 @@ // MaterialManager::getSingleton().setDefaultTextureFiltering( filtering_ ); // MaterialManager::getSingleton().setDefaultAnisotropy( aniso_ );... [truncated message content] |