From: <spo...@us...> - 2007-09-24 22:15:51
|
Revision: 793 http://opengate.svn.sourceforge.net/opengate/?rev=793&view=rev Author: spom_spom Date: 2007-09-24 15:15:55 -0700 (Mon, 24 Sep 2007) Log Message: ----------- remove ogre dependencies from servercode. Modified Paths: -------------- trunk/src/LogManager.cpp trunk/src/LogManager.h trunk/src/Makefile.am trunk/src/Sector.cpp trunk/src/SectorObjects.cpp trunk/src/VesselManager.cpp trunk/src/common.cpp trunk/src/common.h trunk/src/metaserver.cpp trunk/src/metaserver.h trunk/src/networkProtocol.cpp trunk/src/networkProtocol.h trunk/src/networkServer.cpp trunk/src/networkServer.h trunk/src/networkServerUser.cpp trunk/src/networkServerUser.h trunk/src/opengateclient.cpp trunk/src/opengateserver.cpp Added Paths: ----------- trunk/src/LogManagerBase.cpp trunk/src/LogManagerBase.h trunk/src/commonWithOgre.cpp trunk/src/commonWithOgre.h Modified: trunk/src/LogManager.cpp =================================================================== --- trunk/src/LogManager.cpp 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/LogManager.cpp 2007-09-24 22:15:55 UTC (rev 793) @@ -25,29 +25,12 @@ template<> LogManager * Ogre::Singleton< LogManager >::ms_Singleton = 0; -LogManager::LogManager( ) { +LogManager::LogManager( ) : LogManagerBase() { console_ = NULL; - haveLogFile_ = false; - haveChatLogFile_ = false; - haveConsole_ = false; } -LogManager::~LogManager( ) { - if ( haveLogFile_ ) logFile_.close(); - if ( haveChatLogFile_ ) chatLogFile_.close(); -} +LogManager::~LogManager( ) { } -void LogManager::setLogFile( const std::string & logFileName ){ - logFile_.open( logFileName.c_str(), std::fstream::trunc ); - haveLogFile_ = true; -} - -void LogManager::setChatLogFile( const std::string & chatLogFileName ){ - chatLogFile_.open( chatLogFileName.c_str(), std::fstream::app ); - chatLogFile_ << "\n" << timeStamp() << "Starting new session" << std::endl; - haveChatLogFile_ = true; -} - void LogManager::setConsole( Console * console ){ if ( console ){ console_ = console; @@ -57,68 +40,10 @@ } } -std::string LogManager::timeStamp() { - std::time_t now = std::time( 0 ); - struct tm * time = localtime( &now ); - - return std::string("[" - + toStr( time->tm_year + 1900 ) + "." - + toStr( time->tm_mon + 1 ) + "." - + toStr( time->tm_mday ) + "-" - + toStr( time->tm_hour ) + ":" - + toStr( time->tm_min ) + ":" - + toStr( time->tm_sec ) + "]" ); -} - -void LogManager::chat( const std::string & name, const std::string & msg ){ - std::string logMsg( name + ": " + msg ); - - if ( haveChatLogFile_ ) chatLogFile_ << timeStamp() << " " << logMsg << std::endl; - writeToConsole_( logMsg ); - cout( logMsg ); -} - -void LogManager::info( const std::string & msg ){ - std::string logMsg( "INFO: " + msg ); - writeToConsole_( logMsg ); - write_( logMsg ); -} - -void LogManager::debug( const std::string & msg ){ - std::string logMsg( "DEBUG: " + msg ); - writeToConsole_( logMsg ); - write_( logMsg ); -} - -void LogManager::warn( const std::string & msg ){ - std::string logMsg( "WARN: " + msg ); - writeToConsole_( logMsg ); - write_( logMsg ); -} - -void LogManager::fatal( const std::string & msg ){ - std::string logMsg( "FATAL: " + msg ); - writeToConsole_( logMsg ); - write_( logMsg ); -} - -void LogManager::cout( const std::string & msg ){ - std::cout << msg << std::endl; -} - -void LogManager::fout( const std::string & msg ){ - write_( msg ); -} - void LogManager::writeToConsole_( const std::string & msg ){ if ( haveConsole_ ) console_->print( msg ); } -void LogManager::write_( const std::string & msg ){ - std::cout << msg << std::endl; - if ( haveLogFile_ ) logFile_ << timeStamp() << ": " << msg << std::endl; -} - LogManager & LogManager::getSingleton( ){ assert( ms_Singleton ); return ( *ms_Singleton ); @@ -131,31 +56,4 @@ return ms_Singleton; } -// LogManager & LogManager::operator - ( LogType logType ) { -// logType_ = logType; -// return *this; -// } - -// class Flush{ -// public: -// Flush( LogManager & log ){ -// } -// }; - -// LogManager & LogManager::operator << ( const Flush & flush ) { -// switch( logType_ ){ -// case Chat: -// chatLogFile_ << std::endl; -// case Info: -// case Fatal: -// // if ( console_ ) (*console_) << x; -// case Debug: -// std::cout << std::endl; -// logFile_ << std::endl; -// break; -// } -// return *this; -// } - - } //namespace OpenGate Modified: trunk/src/LogManager.h =================================================================== --- trunk/src/LogManager.h 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/LogManager.h 2007-09-24 22:15:55 UTC (rev 793) @@ -21,141 +21,38 @@ #ifndef _OPENGATE_LOGMANAGER__H #define _OPENGATE_LOGMANAGER__H -#include <iostream> -#include <fstream> -#include <string> - #include <OgreSingleton.h> +#include "LogManagerBase.h" -#include "common.h" - namespace OpenGate{ class Console; -enum LogType{ None, Info, Chat, Debug, Fatal}; - -/*! - * \brief This class handles all the logging in Opengate - * - * Opengate has several possibilities of logging. The three main logging methods - * are persistent logging, session logging and console logging. Persistent - * logging is done in a file. All messages are logged into a file. These file - * will always get the messages appended. This way no message is overwritten and - * therefore is persistent. It can be used for chatlogs for example. - * The session logging is done similar to the persistent logging. It is also - * written to a file but this file will be empty each time Opengate starts. The - * console logging is not put into any file. - * The logmanager knows if he has a storage for the persistent logging (see - * setChatLogFile() ) and also if he has a file for session logging (see - * setLogFile() ). You can also add an Console for the so called console - * logging (see setConsole()). - * - * Opengate also supports different levels of importance for the logging. These - * levels are handled like this: - * <table> - * <tr><td>Level</td><td>Persistent log</td><td>Session log (and stdout)</td><td>Console log</td><td>Description</td></tr> - * <tr><td>info</td><td> </td><td>X</td><td>X</td><td>General interesting information (i.e. "player connected")</td></tr> - * <tr><td>chat</td><td>X</td><td>X</td><td>X</td><td>Chat from and to other users</td></tr> - * <tr><td>debug</td><td> </td><td>X</td><td> </td><td>Messages that indicate internal things that might be interesting for developers</td></tr> - * <tr><td>warning</td><td> </td><td>X</td><td> </td><td>Messages interesting for developers</td></tr> - * <tr><td>fatal</td><td> </td><td>X</td><td>X</td><td>Messages when really bad things happen</td></tr> - * </table> - * \author Carsten <spo...@us... > - */ -class LogManager : public Ogre::Singleton< LogManager >, public std::ostream { +class LogManager : public Ogre::Singleton< LogManager >, public LogManagerBase{ public: - LogManager( ); + LogManager(); - virtual ~LogManager( ); + virtual ~LogManager(); - /*! Open a session log file with the given filename \param logFileName The name of the file */ - void setLogFile( const std::string & logFileName ); + /*! This method returns the single instance of the LogManager */ + static LogManager & getSingleton( void ); - /*! Open the persistent log file for the chatlog with the given filename \param logFileName The name of the file */ - void setChatLogFile( const std::string & chatLogFileName ); - /*! Use the given Console console to write the logs to it \param console The given Console */ void setConsole( Console * console ); - /*! Create a timestamp \return A timestamp in the format [YYYY.MM.DD-HH.MM.SS] */ - std::string timeStamp(); - - /*! Protocol a message with info-level importance */ - void info( const std::string & msg ); - - /*! Protocol a chat-message */ - void chat( const std::string & name, const std::string & msg ); - - /*! Protocol a message with debug-level importance */ - void debug( const std::string & msg ); - - /*! Protocol a message with warn-level importance */ - void warn( const std::string & msg ); - - /*! Protocol a message with fatal-level importance */ - void fatal( const std::string & msg ); - - /*! Write to std::out only. For debug purposes only.*/ - void cout( const std::string & msg ); - - /*! Write to logfile only. */ - void fout( const std::string & msg ); - - /*! This method returns the single instance of the LogManager */ - static LogManager & getSingleton( void ); - /*! This method return a pointer to the single instance of the LogManager */ static LogManager * getSingletonPtr( void ); -// LogManager & operator - ( LogType type ); -// template < class T > LogManager & operator << ( const T & x ); -// // LogManager & operator << ( const std::endl & endl ){} -// LogManager & operator << ( const Flush & flush ); + /*! This method writes the given message to the console */ -// template < class T > LogManager & operator << ( LogManager & log, const T & val ); - -// template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& endl(basic_ostream<_CharT, _Traits>& __os) -// { return -// flush( __os.put(__os.widen('\n') ) ) ; } - protected: - /*! This method writes the given message to stdout and (if available) to a logfile */ - void write_( const std::string & msg ); + virtual void writeToConsole_( const std::string & msg ); - /*! This method writes the given message to the console */ - void writeToConsole_( const std::string & msg ); - - /*! Handle to the session log file */ - std::ofstream logFile_; - /*! Handle to the persistent log file */ - std::ofstream chatLogFile_; - /*! Handle to the console log */ Console * console_; - - /*! True, if we have a session log file */ - bool haveLogFile_; - /*! True, if we have a persistent log file */ - bool haveChatLogFile_; - /*! True, if we have a console log */ - bool haveConsole_; }; -inline LogManager & endl( LogManager & log ){ - std::cout << "LogManager & operator:: endl" << std::endl; - return log; -} - -template < class T > LogManager & operator << ( LogManager & log, const T & val ){ - std::cout << "LogManager & operator const val" << std::endl; - std::cout << val << std::endl; -// if ( haveLogFile_ ) logFile_ << timeStamp() << ": " << val; - return log; -} - - } //namespace OpenGate #endif // _OPENGATE_LOGMANAGER__H Added: trunk/src/LogManagerBase.cpp =================================================================== --- trunk/src/LogManagerBase.cpp (rev 0) +++ trunk/src/LogManagerBase.cpp 2007-09-24 22:15:55 UTC (rev 793) @@ -0,0 +1,105 @@ +/*************************************************************************** + * Copyright (C) 2006-2007 by OpenGate development team * + * spo...@us... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "LogManagerBase.h" + +namespace OpenGate{ + +LogManagerBase::LogManagerBase( ) { + haveLogFile_ = false; + haveChatLogFile_ = false; + haveConsole_ = false; +} + +LogManagerBase::~LogManagerBase( ) { + if ( haveLogFile_ ) logFile_.close(); + if ( haveChatLogFile_ ) chatLogFile_.close(); +} + +void LogManagerBase::setLogFile( const std::string & logFileName ){ + logFile_.open( logFileName.c_str(), std::fstream::trunc ); + haveLogFile_ = true; +} + +void LogManagerBase::setChatLogFile( const std::string & chatLogFileName ){ + chatLogFile_.open( chatLogFileName.c_str(), std::fstream::app ); + chatLogFile_ << "\n" << timeStamp() << "Starting new session" << std::endl; + haveChatLogFile_ = true; +} + +std::string LogManagerBase::timeStamp() { + std::time_t now = std::time( 0 ); + struct tm * time = localtime( &now ); + + return std::string("[" + + toStr( time->tm_year + 1900 ) + "." + + toStr( time->tm_mon + 1 ) + "." + + toStr( time->tm_mday ) + "-" + + toStr( time->tm_hour ) + ":" + + toStr( time->tm_min ) + ":" + + toStr( time->tm_sec ) + "]" ); +} + +void LogManagerBase::chat( const std::string & name, const std::string & msg ){ + std::string logMsg( name + ": " + msg ); + + if ( haveChatLogFile_ ) chatLogFile_ << timeStamp() << " " << logMsg << std::endl; + writeToConsole_( logMsg ); + cout( logMsg ); +} + +void LogManagerBase::info( const std::string & msg ){ + std::string logMsg( "INFO: " + msg ); + writeToConsole_( logMsg ); + write_( logMsg ); +} + +void LogManagerBase::debug( const std::string & msg ){ + std::string logMsg( "DEBUG: " + msg ); + writeToConsole_( logMsg ); + write_( logMsg ); +} + +void LogManagerBase::warn( const std::string & msg ){ + std::string logMsg( "WARN: " + msg ); + writeToConsole_( logMsg ); + write_( logMsg ); +} + +void LogManagerBase::fatal( const std::string & msg ){ + std::string logMsg( "FATAL: " + msg ); + writeToConsole_( logMsg ); + write_( logMsg ); +} + +void LogManagerBase::cout( const std::string & msg ){ + std::cout << msg << std::endl; +} + +void LogManagerBase::fout( const std::string & msg ){ + write_( msg ); +} + +void LogManagerBase::write_( const std::string & msg ){ + std::cout << msg << std::endl; + if ( haveLogFile_ ) logFile_ << timeStamp() << ": " << msg << std::endl; +} + +} //namespace OpenGate Added: trunk/src/LogManagerBase.h =================================================================== --- trunk/src/LogManagerBase.h (rev 0) +++ trunk/src/LogManagerBase.h 2007-09-24 22:15:55 UTC (rev 793) @@ -0,0 +1,143 @@ +/*************************************************************************** + * Copyright (C) 2006-2007 by OpenGate development team * + * spo...@us... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _OPENGATE_LOGMANAGERBASE__H +#define _OPENGATE_LOGMANAGERBASE__H + +#include <iostream> +#include <fstream> +#include <string> + +#include "common.h" + +namespace OpenGate{ + +enum LogType{ None, Info, Chat, Debug, Fatal}; + +/*! + * \brief This class handles all the logging in Opengate + * + * Opengate has several possibilities of logging. The three main logging methods + * are persistent logging, session logging and console logging. Persistent + * logging is done in a file. All messages are logged into a file. These file + * will always get the messages appended. This way no message is overwritten and + * therefore is persistent. It can be used for chatlogs for example. + * The session logging is done similar to the persistent logging. It is also + * written to a file but this file will be empty each time Opengate starts. The + * console logging is not put into any file. + * The logmanager knows if he has a storage for the persistent logging (see + * setChatLogFile() ) and also if he has a file for session logging (see + * setLogFile() ). You can also add an Console for the so called console + * logging (see setConsole()). + * + * Opengate also supports different levels of importance for the logging. These + * levels are handled like this: + * <table> + * <tr><td>Level</td><td>Persistent log</td><td>Session log (and stdout)</td><td>Console log</td><td>Description</td></tr> + * <tr><td>info</td><td> </td><td>X</td><td>X</td><td>General interesting information (i.e. "player connected")</td></tr> + * <tr><td>chat</td><td>X</td><td>X</td><td>X</td><td>Chat from and to other users</td></tr> + * <tr><td>debug</td><td> </td><td>X</td><td> </td><td>Messages that indicate internal things that might be interesting for developers</td></tr> + * <tr><td>warning</td><td> </td><td>X</td><td> </td><td>Messages interesting for developers</td></tr> + * <tr><td>fatal</td><td> </td><td>X</td><td>X</td><td>Messages when really bad things happen</td></tr> + * </table> + * \author Carsten <spo...@us... > + */ +class LogManagerBase : public std::ostream { +public: + LogManagerBase( ); + + virtual ~LogManagerBase( ); + + /*! Open a session log file with the given filename \param logFileName The name of the file */ + void setLogFile( const std::string & logFileName ); + + /*! Open the persistent log file for the chatlog with the given filename \param logFileName The name of the file */ + void setChatLogFile( const std::string & chatLogFileName ); + + /*! Create a timestamp \return A timestamp in the format [YYYY.MM.DD-HH.MM.SS] */ + std::string timeStamp(); + + /*! Protocol a message with info-level importance */ + void info( const std::string & msg ); + + /*! Protocol a chat-message */ + void chat( const std::string & name, const std::string & msg ); + + /*! Protocol a message with debug-level importance */ + void debug( const std::string & msg ); + + /*! Protocol a message with warn-level importance */ + void warn( const std::string & msg ); + + /*! Protocol a message with fatal-level importance */ + void fatal( const std::string & msg ); + + /*! Write to std::out only. For debug purposes only.*/ + void cout( const std::string & msg ); + + /*! Write to logfile only. */ + void fout( const std::string & msg ); + +// LogManagerBase & operator - ( LogType type ); +// template < class T > LogManagerBase & operator << ( const T & x ); +// // LogManagerBase & operator << ( const std::endl & endl ){} +// LogManagerBase & operator << ( const Flush & flush ); + +// template < class T > LogManagerBase & operator << ( LogManagerBase & log, const T & val ); + +// template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& endl(basic_ostream<_CharT, _Traits>& __os) +// { return +// flush( __os.put(__os.widen('\n') ) ) ; } + +protected: + + /*! This method writes the given message to stdout and (if available) to a logfile */ + virtual void write_( const std::string & msg ); + + virtual void writeToConsole_( const std::string & msg ){ } + + /*! Handle to the session log file */ + std::ofstream logFile_; + /*! Handle to the persistent log file */ + std::ofstream chatLogFile_; + + /*! True, if we have a session log file */ + bool haveLogFile_; + /*! True, if we have a persistent log file */ + bool haveChatLogFile_; + /*! True, if we have a console log */ + bool haveConsole_; +}; + +inline LogManagerBase & endl( LogManagerBase & log ){ + std::cout << "LogManager & operator:: endl" << std::endl; + return log; +} + +template < class T > LogManagerBase & operator << ( LogManagerBase & log, const T & val ){ + std::cout << "LogManager & operator const val" << std::endl; + std::cout << val << std::endl; +// if ( haveLogFile_ ) logFile_ << timeStamp() << ": " << val; + return log; +} + +} //namespace OpenGate + +#endif // _OPENGATE_LOGMANAGERBASE__H Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/Makefile.am 2007-09-24 22:15:55 UTC (rev 793) @@ -7,6 +7,8 @@ opengateclient.cpp \ common.h \ common.cpp \ + commonWithOgre.h \ + commonWithOgre.cpp \ networkProtocol.h \ networkProtocol.cpp \ networkClient.h \ @@ -39,6 +41,8 @@ InitState.cpp \ LogManager.h \ LogManager.cpp \ + LogManagerBase.h \ + LogManagerBase.cpp \ MarketDialog.h \ MarketDialog.cpp \ OpcodeWrapper.h \ @@ -73,21 +77,20 @@ $(freealut_LIBS) \ $(vorbisfile_LIBS) \ $(OIS_LIBS) \ - -L$(OGSECTOR_EXTERNALS_PATH)/lib/ + $(OgreOpcode_LIBS) +# -L$(OGSECTOR_EXTERNALS_PATH)/lib/ opengateclient_CXXFLAGS = \ $(OGRE_CFLAGS) \ - $(CEGUI_CFLAGS) + $(CEGUI_CFLAGS) \ + $(OgreOpcode_CFLAGS) opengateserver_SOURCES = \ opengateserver.cpp \ common.h \ common.cpp \ - LogManager.h \ - LogManager.cpp \ - Console.h \ - InputManager.h \ - InputManager.cpp \ + LogManagerBase.h \ + LogManagerBase.cpp \ networkProtocol.h \ networkProtocol.cpp \ networkServer.h \ @@ -97,12 +100,12 @@ metaserver.h \ metaserver.cpp -opengateserver_LDFLAGS = \ - $(OGRE_LIBS) \ - $(OIS_LIBS) +opengateserver_LDFLAGS = +# $(OGRE_LIBS) \ +# $(OIS_LIBS) -opengateserver_CXXFLAGS = \ - $(OGRE_CFLAGS) +opengateserver_CXXFLAGS = +# $(OGRE_CFLAGS) testopenalmanager_SOURCES = \ testopenalmanager.cpp \ @@ -122,6 +125,8 @@ Entity.cpp \ LogManager.h \ LogManager.cpp \ + LogManagerBase.h \ + LogManagerBase.cpp \ InputManager.h \ InputManager.cpp \ OpenALSoundManager.h \ Modified: trunk/src/Sector.cpp =================================================================== --- trunk/src/Sector.cpp 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/Sector.cpp 2007-09-24 22:15:55 UTC (rev 793) @@ -36,6 +36,8 @@ #include <OgreRenderSystem.h> #include <OgreMeshManager.h> +#include "commonWithOgre.h" + namespace OpenGate{ // class StarField : public Ogre::SimpleRenderable { @@ -258,7 +260,7 @@ Ogre::Vector3 pos( 0.0, 0.0, 0.0); pSubElem = pElem->FirstChildElement( "position" ); if ( pSubElem ){ - pos = toVector3( pSubElem->FirstChild()->Value(), ',' ); + pos = Ogre::Vector3( &toVector3( pSubElem->FirstChild()->Value(), ',' )[ 0 ] ); } else { log_->warn( "missing pos for station " + name ); continue; @@ -268,7 +270,7 @@ Ogre::Vector3 targetDirection( 0.0, 0.0, 0.0); pSubElem = pElem->FirstChildElement( "direction" ); if ( pSubElem ){ - targetDirection = toVector3( pSubElem->FirstChild()->Value(), ',' ); + targetDirection = Ogre::Vector3( &toVector3( pSubElem->FirstChild()->Value(), ',' )[0]); Ogre::Quaternion rot = ( obj->mainNode()->getOrientation().zAxis()* -1.0).getRotationTo( targetDirection ); obj->mainNode()->rotate( rot ); } @@ -310,7 +312,7 @@ Ogre::Vector3 pos( 0.0, 0.0, 0.0); pSubElem = pElem->FirstChildElement( "position" ); if ( pSubElem ){ - pos = toVector3( pSubElem->FirstChild()->Value(), ',' ); + pos = Ogre::Vector3( &toVector3( pSubElem->FirstChild()->Value(), ',' )[ 0 ] ); } else { log_->warn( "missing pos for sectorobject " + name ); continue; @@ -319,19 +321,19 @@ Ogre::Vector3 scale( 1.0, 1.0, 1.0) ; pSubElem = pElem->FirstChildElement( "scale" ); if ( pSubElem ){ - scale = toVector3( pSubElem->FirstChild()->Value(), ',' ); + scale = Ogre::Vector3( &toVector3( pSubElem->FirstChild()->Value(), ',' )[ 0 ] ); } Ogre::Vector3 direction( 0.0, 0.0, 0.0 ); pSubElem = pElem->FirstChildElement( "direction" ); if ( pSubElem ){ - direction = toVector3( pSubElem->FirstChild()->Value(), ',' ); + direction = Ogre::Vector3( &toVector3( pSubElem->FirstChild()->Value(), ',' )[ 0 ] ); } Ogre::Vector3 size( 0.0, 0.0, 0.0) ; pSubElem = pElem->FirstChildElement( "size" ); if ( pSubElem ){ - size = toVector3( pSubElem->FirstChild()->Value(), ',' ); + size = Ogre::Vector3( &toVector3( pSubElem->FirstChild()->Value(), ',' )[ 0 ] ); } std::string material; @@ -787,9 +789,9 @@ void Sector::sendVesselMovement( SectorObjectMoveableLocal * obj ){ if ( obj ){ MessageBodyShipMovement msg( obj->childID(), - obj->mainNode()->getPosition(), - obj->velocity(), - obj->mainNode()->getOrientation(), + obj->mainNode()->getPosition().ptr(), + obj->velocity().ptr(), + obj->mainNode()->getOrientation().ptr(), obj->thrust(), obj->scaledYaw(), obj->scaledPitch(), @@ -803,7 +805,7 @@ void Sector::sendVesselRegister( SectorObjectMoveableLocal * obj ){ if ( obj ) { log_->info( std::string( "Send register " ) + obj->name() + " id:" + toStr( obj->vessel()->id() ) ); - MessageBodyShipRegister msg( obj->userID(), obj->childID(), obj->name(), obj->mainNode()->getPosition(), + MessageBodyShipRegister msg( obj->userID(), obj->childID(), obj->name(), obj->mainNode()->getPosition().ptr(), obj->vessel()->id(), obj->mass(), obj->maxShield(), obj->maxThrust() ); network_->send( msg ); } @@ -817,7 +819,7 @@ log_->info( "Create player object " + msg.name()+ " " + toStr( msg.senderID() ) + " VesselID: " + toStr( msg.vesselID() ) ); SectorObjectMoveable * obj = createMoveableObject( msg.name(), msg.senderID(), msg.childID(), *VesselManager::getSingleton().vessel( msg.vesselID() ) ); - obj->mainNode()->setPosition( msg.position() ); + obj->mainNode()->setPosition( toOgreVec( msg.position() ) ); obj->setMass( msg.mass() ); obj->setMaxShield( msg.maxShield() ); obj->setMaxThrust( msg.maxThrust() ); @@ -828,7 +830,7 @@ SectorObjectMoveableAi * obj = createAiMoveableObject( msg.name(), msg.senderID(), msg.childID(), *VesselManager::getSingleton().vessel( msg.vesselID() ) ); - obj->mainNode()->setPosition( msg.position() ); + obj->mainNode()->setPosition( toOgreVec( msg.position() ) ); if ( movableObjects_.count( createGlobalID( msg.senderID(), 0 ) ) ){ log_->info( "ai object target: " + movableObjects_[ createGlobalID( msg.senderID(), 0 ) ]->name() ); @@ -981,7 +983,7 @@ void Sector::sendProjectile( const Projectile & projectile ){ if ( network_->online() ){ MessageBodyShipProjectileFired msg( projectile.parent().childID(), projectile.shotCount(), - projectile.position(), projectile.velocity(), + projectile.position().ptr(), projectile.velocity().ptr(), projectile.damage(), projectile.lifeTime() ); network_->send( msg ); } Modified: trunk/src/SectorObjects.cpp =================================================================== --- trunk/src/SectorObjects.cpp 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/SectorObjects.cpp 2007-09-24 22:15:55 UTC (rev 793) @@ -18,7 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "common.h" +#include "commonWithOgre.h" #include "Sector.h" #include "SectorObjects.h" #include "Projectile.h" @@ -336,9 +336,9 @@ void SectorObjectMoveable::setFlightProperties( const MessageBodyShipMovement & msg ){ if ( forceMovement_ ){ - mainNode_->setPosition( msg.position() ); - mainNode_->setOrientation( msg.orientation() ); - vel_ = msg.velocity(); + mainNode_->setPosition( toOgreVec( msg.position() ) ); + mainNode_->setOrientation( toOgreQuat( msg.orientation() ) ); + vel_ = toOgreVec( msg.velocity() ); setThrust( msg.thrust() ); setScaledYaw( msg.yaw() ); setScaledPitch( msg.pitch() ); @@ -366,14 +366,14 @@ setScaledRoll( msg.roll() ); setScaledPitch( msg.pitch() ); - vel_ = msg.velocity(); + vel_ = toOgreVec( msg.velocity() ); setThrust( msg.thrust() ); - Ogre::Vector3 srcP = mainNode_->getPosition( ); - Ogre::Quaternion srcQ = mainNode_->getOrientation( ); - Ogre::Vector3 destP = msg.position( ); + Ogre::Vector3 srcP( mainNode_->getPosition( ) ); + Ogre::Quaternion srcQ( mainNode_->getOrientation( ) ); + Ogre::Vector3 destP( toOgreVec( msg.position( ) ) ); - Ogre::Quaternion diff = Ogre::Quaternion::nlerp( 1, srcQ, msg.orientation() ); + Ogre::Quaternion diff = Ogre::Quaternion::nlerp( 1, srcQ, toOgreQuat( msg.orientation() ) ); interpolateRot_ = diff * srcQ.Inverse(); // if ( msg.childID() > 0 ){ Modified: trunk/src/VesselManager.cpp =================================================================== --- trunk/src/VesselManager.cpp 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/VesselManager.cpp 2007-09-24 22:15:55 UTC (rev 793) @@ -30,7 +30,7 @@ TiXmlElement * pElem; for ( pElem = hRoot->FirstChild( key ).Element(); pElem != 0; pElem = pElem->NextSiblingElement( key ) ) { if ( pElem ) { - mountPoints.push_back( toVector3( pElem->GetText(), ' ' ) ); + mountPoints.push_back( Ogre::Vector3( &toVector3( pElem->GetText(), ' ' )[ 0 ]) ); } } return mountPoints; Modified: trunk/src/common.cpp =================================================================== --- trunk/src/common.cpp 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/common.cpp 2007-09-24 22:15:55 UTC (rev 793) @@ -19,9 +19,6 @@ ***************************************************************************/ #include "common.h" -#include <OgreSceneNode.h> -#include <OgreVector3.h> -#include <OgreMovableObject.h> long createGlobalID( int userId, int childId ) { return childId * MAXUSERID + userId; } @@ -51,8 +48,8 @@ return subStrings; } -Ogre::Vector3 toVector3( const std::string & vecStr, const char delimiter ){ - Ogre::Vector3 vect( 0.0, 0.0, 0.0 ); +std::vector < float > toVector3( const std::string & vecStr, const char delimiter ){ + std::vector < float > vect( 3, 0.0 ); int pos = 0, nextPos = 0, count = 0; std::string str; while ( ( nextPos = vecStr.find( delimiter, pos ) ) != (int)std::string::npos ){ @@ -70,36 +67,6 @@ return vect; } - -void dumpSceneNodes( std::stringstream & ss, Ogre::Node * n, int level ) { - for ( int i = 0; i < level; i++ ) { - ss << " "; - } - ss << "SceneNode: " << n->getName() << std::endl; - - Ogre::SceneNode::ObjectIterator object_it = ((Ogre::SceneNode *)n)->getAttachedObjectIterator(); - Ogre::Node::ChildNodeIterator node_it = n->getChildIterator(); - - Ogre::MovableObject *m; - while ( object_it.hasMoreElements() ){ - for ( int i = 0; i < level + 2; i++ ) { - ss << " "; - } - m = object_it.getNext(); - ss << m->getMovableType() << ": " << m->getName() << std::endl; - } - while ( node_it.hasMoreElements() ) { - dumpSceneNodes( ss, node_it.getNext(), level + 2 ); - } -} - -std::string dumpSceneNodes( Ogre::Node * n ) { - std::stringstream ss; - ss << std::endl << "Node Hierarchy:" << std::endl; - dumpSceneNodes( ss, n, 0 ); - return ss.str(); -} - int split(const std::string& input, const std::string& delimiter, std::list<std::string>& results) { int pos = 0; int offset = 0; Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/common.h 2007-09-24 22:15:55 UTC (rev 793) @@ -36,13 +36,12 @@ #include <config.h> #endif -#include <OgrePrerequisites.h> - #include <sstream> #include <fstream> #include <iostream> #include <vector> #include <string> +#include <list> #include <cmath> #include <algorithm> #include <sys/timeb.h> @@ -133,7 +132,7 @@ } /*! Convert string to OgreVector3, Example: ToVector3( "3.3, 4.45, 5.23", ',' ) */ -Ogre::Vector3 toVector3( const std::string & vecStr, const char delimiter = ',' ); +std::vector< float > toVector3( const std::string & vecStr, const char delimiter = ',' ); /*! * \brief This method converts a string to int @@ -178,12 +177,6 @@ */ void myMSleep( int s ); -/*! For debugging purposes dump scene node tree to a string */ -void dumpSceneNodes( std::stringstream & ss, Ogre::Node * n, int level ); - -/*! For debugging purposes dump scene node tree to a string */ -std::string dumpSceneNodes( Ogre::Node * n ); - class Stopwatch { public: Stopwatch() { state = undefined; } Added: trunk/src/commonWithOgre.cpp =================================================================== --- trunk/src/commonWithOgre.cpp (rev 0) +++ trunk/src/commonWithOgre.cpp 2007-09-24 22:15:55 UTC (rev 793) @@ -0,0 +1,54 @@ +/*************************************************************************** + * Copyright (C) 2006-2007 by OpenGate development team * + * spo...@us... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "commonWithOgre.h" + +#include <OgreSceneNode.h> +#include <OgreVector3.h> +#include <OgreMovableObject.h> + +void dumpSceneNodes( std::stringstream & ss, Ogre::Node * n, int level ) { + for ( int i = 0; i < level; i++ ) { + ss << " "; + } + ss << "SceneNode: " << n->getName() << std::endl; + + Ogre::SceneNode::ObjectIterator object_it = ((Ogre::SceneNode *)n)->getAttachedObjectIterator(); + Ogre::Node::ChildNodeIterator node_it = n->getChildIterator(); + + Ogre::MovableObject *m; + while ( object_it.hasMoreElements() ){ + for ( int i = 0; i < level + 2; i++ ) { + ss << " "; + } + m = object_it.getNext(); + ss << m->getMovableType() << ": " << m->getName() << std::endl; + } + while ( node_it.hasMoreElements() ) { + dumpSceneNodes( ss, node_it.getNext(), level + 2 ); + } +} + +std::string dumpSceneNodes( Ogre::Node * n ) { + std::stringstream ss; + ss << std::endl << "Node Hierarchy:" << std::endl; + dumpSceneNodes( ss, n, 0 ); + return ss.str(); +} Added: trunk/src/commonWithOgre.h =================================================================== --- trunk/src/commonWithOgre.h (rev 0) +++ trunk/src/commonWithOgre.h 2007-09-24 22:15:55 UTC (rev 793) @@ -0,0 +1,65 @@ +/*************************************************************************** + * Copyright (C) 2006-2007 by OpenGate development team * + * spo...@us... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +/*! + * \file + * + * \brief This file contains several functions that can be used in common with ogre. + * + * For example you can find methods here that are used to enable opengate to be + * cross platform. + * + * \author Carsten <spo...@us...> + */ + +#ifndef _OPENGATE_COMMONWITHOGRE__H +#define _OPENGATE_COMMONWITHOGRE__H + +#include "common.h" + +#include <OgrePrerequisites.h> +#include <OgreVector3.h> +#include <OgreQuaternion.h> + +inline Ogre::Vector3 toOgreVec( const std::vector < float > & vec ){ + if ( vec.size() == 3 ){ + return Ogre::Vector3( &vec[ 0 ] ); + } else { + return Ogre::Vector3::ZERO; + } +} + +inline Ogre::Quaternion toOgreQuat( const std::vector < float > & vec ){ + if ( vec.size() == 4 ){ + return Ogre::Quaternion( (Ogre::Real*)&vec[ 0 ] ); + } else { + return Ogre::Quaternion::ZERO; + } +} + +/*! For debugging purposes dump scene node tree to a string */ +void dumpSceneNodes( std::stringstream & ss, Ogre::Node * n, int level ); + +// /*! For debugging purposes dump scene node tree to a string */ +std::string dumpSceneNodes( Ogre::Node * n ); + +#endif + + Modified: trunk/src/metaserver.cpp =================================================================== --- trunk/src/metaserver.cpp 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/metaserver.cpp 2007-09-24 22:15:55 UTC (rev 793) @@ -19,6 +19,7 @@ ***************************************************************************/ #include "metaserver.h" +#include "LogManagerBase.h" //#include <boost/regex.hpp> //#include "config.h" @@ -28,11 +29,10 @@ namespace OpenGate{ -MetaConnection::MetaConnection(asio::io_service & io_service) : - io_service_( io_service ), socket_( io_service ), resolver_( io_service ) { + MetaConnection::MetaConnection(asio::io_service & io_service, LogManagerBase & log ) : + io_service_( io_service ), socket_( io_service ), resolver_( io_service ), log_( &log ) { // Get instance to the log manager - log_ = LogManager::getSingletonPtr(); hostname_ = std::string( "opacma.ontheserver.de" ); log_->info( std::string( "Querying " ) + hostname_); Modified: trunk/src/metaserver.h =================================================================== --- trunk/src/metaserver.h 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/metaserver.h 2007-09-24 22:15:55 UTC (rev 793) @@ -22,15 +22,16 @@ #define _OPENGATE_METASERVER__H #include <asio.hpp> -#include "LogManager.h" using asio::ip::tcp; namespace OpenGate{ + class LogManagerBase; + class MetaConnection { public: - MetaConnection(asio::io_service & io_service); + MetaConnection(asio::io_service & io_service, LogManagerBase & log); ~MetaConnection(); int login( const std::string & userName, const std::string & passwd = "" ); @@ -43,7 +44,7 @@ private: - LogManager *log_; + LogManagerBase *log_; std::string hostname_; asio::io_service & io_service_; Modified: trunk/src/networkProtocol.cpp =================================================================== --- trunk/src/networkProtocol.cpp 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/networkProtocol.cpp 2007-09-24 22:15:55 UTC (rev 793) @@ -20,18 +20,19 @@ #include "networkProtocol.h" -#include <OgreVector3.h> -#include <OgreQuaternion.h> +// #include <OgreVector3.h> +// #include <OgreQuaternion.h> namespace OpenGate{ MessageBodyShipRegister::MessageBodyShipRegister( const Uint32 senderID, const Uint8 childID, const std::string & name, - const Ogre::Vector3 & pos, Uint16 vesselID, + const Float * pos, Uint16 vesselID, Uint32 mass, Uint32 maxShield, Uint32 maxThrust ) - : MessageBodyShipBase( childID ), name_( name ), pos_( pos ), vesselID_( vesselID ), + : MessageBodyShipBase( childID ), name_( name ), pos_( 3 ), vesselID_( vesselID ), mass_( mass ), maxShield_( maxShield ), maxThrust_( maxThrust ){ senderID_ = senderID; type_ = (Uint8)PROTO_SHIP_REGISTER; + pos_[ 0 ] = pos[ 0 ]; pos_[ 1 ] = pos[ 1 ]; pos_[ 2 ] = pos[ 2 ]; } MessageBodyShipRegister::MessageBodyShipRegister( const char * data ) : MessageBodyShipBase( data ){ @@ -62,16 +63,20 @@ writeToOut( out_, maxThrust_ ); } -Ogre::Vector3 MessageBodyShipRegister::position() const { return pos_; } +FVector3 MessageBodyShipRegister::position() const { return pos_; } -MessageBodyShipMovement::MessageBodyShipMovement( Uint8 childID, const Ogre::Vector3 & pos, - const Ogre::Vector3 & vel, const Ogre::Quaternion & orient, +MessageBodyShipMovement::MessageBodyShipMovement( Uint8 childID, const Float * pos, + const Float * vel, const Float * orient, Uint32 thrust, float yaw, float pitch, float roll, int seq ) - : MessageBodyShipBase( childID ), pos_( pos ), vel_( vel ), orient_( orient ), + : MessageBodyShipBase( childID ), pos_( 3 ), vel_( 3 ), orient_( 4 ), thrust_( thrust ), yaw_( yaw ), pitch_( pitch ), roll_( roll ), seqNr_( seq ) { type_ = (Uint8)PROTO_SHIP_MOVEMENT; + pos_[ 0 ] = pos[ 0 ]; pos_[ 1 ] = pos[ 1 ]; pos_[ 2 ] = pos[ 2 ]; + vel_[ 0 ] = vel[ 0 ]; vel_[ 1 ] = vel[ 1 ]; vel_[ 2 ] = vel[ 2 ]; + orient_[ 0 ] = orient[ 0 ]; orient_[ 1 ] = orient[ 1 ]; + orient_[ 2 ] = orient[ 2 ]; orient_[ 3 ] = orient[ 3 ]; } MessageBodyShipMovement::MessageBodyShipMovement( const char * data ) : MessageBodyShipBase( data ){ @@ -106,19 +111,21 @@ return str; } -Ogre::Vector3 MessageBodyShipMovement::velocity() const { return vel_; } +FVector3 MessageBodyShipMovement::velocity() const { return vel_; } -Ogre::Vector3 MessageBodyShipMovement::position() const { return pos_; } +FVector3 MessageBodyShipMovement::position() const { return pos_; } -Ogre::Quaternion MessageBodyShipMovement::orientation() const { return orient_; } +FVector4 MessageBodyShipMovement::orientation() const { return orient_; } +MessageBodyShipProjectileFired::MessageBodyShipProjectileFired( Uint8 childID, Uint16 shotCount, const Float * pos, + const Float * vel, Uint32 damage, Float liveTime ) + : MessageBodyShipBase( childID ), shotCount_( shotCount ), pos_( 3 ), vel_( 3 ), + damage_( damage ), liveTime_( liveTime ) { + type_ = (Uint8)PROTO_SHIP_PROJECTILEFIRED; + pos_[ 0 ] = pos[ 0 ]; pos_[ 1 ] = pos[ 1 ]; pos_[ 2 ] = pos[ 2 ]; + vel_[ 0 ] = vel[ 0 ]; vel_[ 1 ] = vel[ 1 ]; vel_[ 2 ] = vel[ 2 ]; -MessageBodyShipProjectileFired::MessageBodyShipProjectileFired( Uint8 childID, Uint16 shotCount, const Ogre::Vector3 & pos, - const Ogre::Vector3 & vel, Uint32 damage, Ogre::Real liveTime ) - : MessageBodyShipBase( childID ), shotCount_( shotCount ), pos_( pos ), - vel_( vel ), damage_( damage ), liveTime_( liveTime ) { - type_ = (Uint8)PROTO_SHIP_PROJECTILEFIRED; } MessageBodyShipProjectileFired::MessageBodyShipProjectileFired( const char * data ) @@ -140,9 +147,9 @@ writeToOut( out_, liveTime_ ); } -Ogre::Vector3 MessageBodyShipProjectileFired::position() const { return pos_; } +FVector3 MessageBodyShipProjectileFired::position() const { return pos_; } -Ogre::Vector3 MessageBodyShipProjectileFired::velocity() const { return vel_; } +FVector3 MessageBodyShipProjectileFired::velocity() const { return vel_; } } // namespace OpenGate{ Modified: trunk/src/networkProtocol.h =================================================================== --- trunk/src/networkProtocol.h 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/networkProtocol.h 2007-09-24 22:15:55 UTC (rev 793) @@ -21,7 +21,8 @@ #ifndef _OPENGATE_NETWORK_PROTOCOL__H #define _OPENGATE_NETWORK_PROTOCOL__H -#include <OgreVector3.h> +//#include <OgreVector3.h> + #include "common.h" #include <iostream> @@ -30,6 +31,18 @@ namespace OpenGate{ +// typedef Ogre::Vector3 FVector3; +// typedef Ogre::Quaternion FVector4; +// typedef Ogre::Real Float; +typedef std::vector< float > FVector3; +typedef std::vector< float > FVector4; +typedef float Float; + +inline std::ostream & operator << ( std::ostream & str, const std::vector< float > & vec ){ + for ( int i = 0; i < vec.size(); i ++ ) str << vec[ i ] << " "; + return str; +} + #define OG_PORT 1234 #define PROTO_BASE 1 @@ -305,7 +318,7 @@ public: MessageBodyShipRegister( const Uint32 senderID, const Uint8 childID, const std::string & name, - const Ogre::Vector3 & pos, Uint16 vesselID, Uint32 mass, Uint32 maxShield, Uint32 maxThrust ); + const Float * pos, Uint16 vesselID, Uint32 mass, Uint32 maxShield, Uint32 maxThrust ); MessageBodyShipRegister( const char * data ); @@ -315,7 +328,7 @@ inline std::string name() const { return name_; } - Ogre::Vector3 position() const; + FVector3 position() const; inline Uint16 vesselID() const { return vesselID_; } @@ -330,7 +343,7 @@ std::string name_; - Ogre::Vector3 pos_; + FVector3 pos_; Uint16 vesselID_; Uint32 mass_; @@ -386,8 +399,7 @@ class MessageBodyShipMovement : public MessageBodyShipBase { public: - MessageBodyShipMovement( Uint8 childID, const Ogre::Vector3 & pos, const Ogre::Vector3 & vel, - const Ogre::Quaternion & orient, + MessageBodyShipMovement( Uint8 childID, const Float * pos, const Float * vel, const Float * orient, Uint32 thrust, float yaw, float pitch, float roll, int seq ); MessageBodyShipMovement( const char * data ); @@ -396,11 +408,11 @@ void createOutStream(); - Ogre::Vector3 velocity() const; + FVector3 velocity() const; - Ogre::Vector3 position() const; + FVector3 position() const; - Ogre::Quaternion orientation() const; + FVector4 orientation() const; inline Uint32 thrust() const { return thrust_; } @@ -415,9 +427,9 @@ friend std::ostream & operator << ( std::ostream & str, const MessageBodyShipMovement & msg ); protected: - Ogre::Vector3 pos_; - Ogre::Vector3 vel_; - Ogre::Quaternion orient_; + FVector3 pos_; + FVector3 vel_; + FVector4 orient_; Uint32 thrust_; @@ -481,8 +493,8 @@ class MessageBodyShipProjectileFired : public MessageBodyShipBase { public: - MessageBodyShipProjectileFired( Uint8 childID, Uint16 shotCount, const Ogre::Vector3 & pos, - const Ogre::Vector3 & vel, Uint32 damage, Ogre::Real liveTime ); + MessageBodyShipProjectileFired( Uint8 childID, Uint16 shotCount, const Float * pos, const Float * vel, + Uint32 damage, Float liveTime ); MessageBodyShipProjectileFired( const char * data ); @@ -491,17 +503,17 @@ void createOutStream(); Uint16 shotCount() const { return shotCount_ ; } - Ogre::Vector3 position() const; - Ogre::Vector3 velocity() const; + FVector3 position() const; + FVector3 velocity() const; Uint32 damage() const { return damage_; } - Ogre::Real liveTime() const { return liveTime_; } + Float liveTime() const { return liveTime_; } protected: Uint16 shotCount_; - Ogre::Vector3 pos_; - Ogre::Vector3 vel_; + FVector3 pos_; + FVector3 vel_; Uint32 damage_; - Ogre::Real liveTime_; + Float liveTime_; }; class MessageBodyShipAmmoHit : public MessageBodyShipBase { Modified: trunk/src/networkServer.cpp =================================================================== --- trunk/src/networkServer.cpp 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/networkServer.cpp 2007-09-24 22:15:55 UTC (rev 793) @@ -22,6 +22,7 @@ #include "networkServer.h" #include <iostream> #include <string> +#include "LogManagerBase.h" #include <boost/bind.hpp> @@ -29,10 +30,9 @@ namespace OpenGate{ -Server::Server( asio::io_service & io_service, const tcp::endpoint & endpoint ) - : io_service_( io_service ), acceptor_( io_service ), userIDCounter_( 1000 ) { +Server::Server( asio::io_service & io_service, const tcp::endpoint & endpoint, LogManagerBase & log ) + : io_service_( io_service ), acceptor_( io_service ), userIDCounter_( 1000 ), log_( & log ) { - log_ = LogManager::getSingletonPtr(); acceptor_.open( endpoint.protocol() ); acceptor_.set_option( asio::ip::tcp::acceptor::reuse_address( true ) ); acceptor_.bind( endpoint ); @@ -164,12 +164,12 @@ } void Server::receiveShipRegister( UserSession * user, const MessageBodyShipRegister & msgIn ){ - std::string name = msgIn.name(); + std::string name( msgIn.name() ); int userID = user->userID(); int childID = msgIn.childID(); int vesselID = msgIn.vesselID(); int senderID = msgIn.senderID(); - Ogre::Vector3 pos = msgIn.position(); + FVector3 pos( msgIn.position() ); log_->info( std::string( "receiveShipRegister from " ) + toStr( senderID ) + " " + name + " " + " " + toStr( vesselID ) ); @@ -198,7 +198,7 @@ log_->info( std::string( "\tSend register: " ) + obj->userName() + " <- " + it->second->name() ); MessageBodyShipRegister msg( it->second->userID(), it->second->childID(), - it->second->name(), it->second->position(), + it->second->name(), &it->second->position()[0], it->second->vesselID(), it->second->mass(), it->second->maxShield(), it->second->maxThrust() ); obj->parent()->send( msg ); @@ -206,7 +206,7 @@ } //** second register the new object to all existing objects in range; - MessageBodyShipRegister msg( obj->userID(), obj->childID(), obj->name(), obj->position(), obj->vesselID(), + MessageBodyShipRegister msg( obj->userID(), obj->childID(), obj->name(), &obj->position()[ 0 ], obj->vesselID(), obj->mass(), obj->maxShield(), obj->maxThrust() ); // ** atm just global; for ( std::map < long, UserObject * >::iterator it = userObjects_.begin(); it != userObjects_.end(); it ++ ){ Modified: trunk/src/networkServer.h =================================================================== --- trunk/src/networkServer.h 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/networkServer.h 2007-09-24 22:15:55 UTC (rev 793) @@ -27,7 +27,6 @@ #include <asio.hpp> #include <boost/bind.hpp> -#include "LogManager.h" #include "networkProtocol.h" #include "networkServerUser.h" @@ -35,6 +34,7 @@ namespace OpenGate{ +class LogManagerBase; class UserSession; class UserObject; @@ -58,7 +58,7 @@ class Server{ public: - Server( asio::io_service & io_service, const tcp::endpoint & endpoint ); + Server( asio::io_service & io_service, const tcp::endpoint & endpoint, LogManagerBase & log ); ~Server(); @@ -96,7 +96,7 @@ std::set < std::string > userNames_; UserSessionGroup allUsers_; - LogManager * log_; + LogManagerBase * log_; }; } // namespace OpenGate Modified: trunk/src/networkServerUser.cpp =================================================================== --- trunk/src/networkServerUser.cpp 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/networkServerUser.cpp 2007-09-24 22:15:55 UTC (rev 793) @@ -100,8 +100,7 @@ } } } else { - LogManager::getSingleton().info( std::string( "Received msg for unknown object: " ) - + userName() + " child: " + toStr( childID ) ); + std::cerr << std::string( "Received msg for unknown object: " ) + userName() + " child: " + toStr( childID ) << std::endl; } } @@ -169,7 +168,8 @@ sendToRange( msg ); } break; default: - LogManager::getSingleton().fatal( std::string( "PROTO_UNKNOWN: " ) + toStr( (int)base.type() ) ); + std::cerr << std::string( "PROTO_UNKNOWN: " ) + toStr( (int)base.type() ) << std::endl; + // std:LogManager::getSingleton().fatal( std::string( "PROTO_UNKNOWN: " ) + toStr( (int)base.type() ) ); break; } // std::cout << "User::handle_read_body: " << userID_ << std::endl; @@ -177,8 +177,9 @@ asio::async_read( socket_, asio::buffer( readMsg_.data(), Message::HeaderLength ), boost::bind( & UserSession::handleReadHeader, this, asio::placeholders::error ) ); } else { - LogManager::getSingleton().fatal( std::string( "Cannot read body: " ) - + toStr( userID_ ) + " " + error.what() ); + std::cerr << std::string( "Cannot read body: " ) + toStr( userID_ ) + " " + error.what() << std::endl; +// LogManager::getSingleton().fatal( std::string( "Cannot read body: " ) +// + toStr( userID_ ) + " " + error.what() ); // room_.leave( this ); } } @@ -193,7 +194,8 @@ boost::bind( & UserSession::handleWrite, this, asio::placeholders::error ) ); } } else { - LogManager::getSingleton().fatal( std::string( "Cannot write to user: " ) + toStr( userID_ ) + error.what() ); + std::cerr << std::string( "Cannot write to user: " ) + toStr( userID_ ) + error.what() << std::endl; + // LogManager::getSingleton().fatal( std::string( "Cannot write to user: " ) + toStr( userID_ ) + error.what() ); // room_.leave( this ); } } Modified: trunk/src/networkServerUser.h =================================================================== --- trunk/src/networkServerUser.h 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/networkServerUser.h 2007-09-24 22:15:55 UTC (rev 793) @@ -124,9 +124,9 @@ const std::string userName( ) const { return parent_->userName(); } - void setPosition( const Ogre::Vector3 & pos ){ pos_ = pos; } + void setPosition( const FVector3 & pos ){ pos_ = pos; } - Ogre::Vector3 position( ) const { return pos_; } + FVector3 position( ) const { return pos_; } void sendToRange( MessageBodyBase & body ); @@ -164,7 +164,7 @@ ObjectStatus status_; - Ogre::Vector3 pos_; + FVector3 pos_; std::set < UserObject * > inRange_; Uint32 mass_; Modified: trunk/src/opengateclient.cpp =================================================================== --- trunk/src/opengateclient.cpp 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/opengateclient.cpp 2007-09-24 22:15:55 UTC (rev 793) @@ -144,7 +144,7 @@ asio::io_service io_service; if ( withMetaServer ){ - OpenGate::MetaConnection meta( io_service ); + OpenGate::MetaConnection meta( io_service, *log ); int user_id = meta.login( username, password ); if (( user_id > 0 ) && ( option_version == 1)) { int response = meta.check_version( user_id ); Modified: trunk/src/opengateserver.cpp =================================================================== --- trunk/src/opengateserver.cpp 2007-09-24 20:40:42 UTC (rev 792) +++ trunk/src/opengateserver.cpp 2007-09-24 22:15:55 UTC (rev 793) @@ -28,15 +28,12 @@ #include "common.h" #include "networkServer.h" -#include "LogManager.h" +#include "LogManagerBase.h" #include "metaserver.h" using namespace OpenGate; -#include "Console.h" -void Console::print( const std::string & text ){} - -LogManager *logMgr = NULL; +LogManagerBase *logMgr = NULL; asio::io_service *io_servicePtr = NULL; Server *serverPtr = NULL; OpenGate::MetaConnection *metaPtr = NULL; @@ -71,7 +68,7 @@ int main( int argc, char *argv[] ) { - logMgr = new LogManager( ); + logMgr = new LogManagerBase( ); logMgr->setLogFile( "OGserver.log" ); logMgr->setChatLogFile( "OGserverChat.log" ); logMgr->info( std::string("Starting up server ") + PACKAGE_STRING ); @@ -83,14 +80,14 @@ asio::io_service io_service; io_servicePtr = &io_service; - OpenGate::MetaConnection meta( io_service ); + OpenGate::MetaConnection meta( io_service, *logMgr ); metaPtr = &meta; int error = 0; if ((error = meta.add_game_server()) < 0) { logMgr->warn( std::string("Could not add game server " + toStr (error) ) ); } tcp::endpoint endpoint( tcp::v4(), OG_PORT ); - Server server( io_service, endpoint ); + Server server( io_service, endpoint, *logMgr ); serverPtr = &server; io_service.run(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spo...@us...> - 2007-09-27 17:32:20
|
Revision: 798 http://opengate.svn.sourceforge.net/opengate/?rev=798&view=rev Author: spom_spom Date: 2007-09-27 10:32:13 -0700 (Thu, 27 Sep 2007) Log Message: ----------- no compilation problems Modified Paths: -------------- trunk/src/metaserver.cpp trunk/src/opengateserver.cpp Modified: trunk/src/metaserver.cpp =================================================================== --- trunk/src/metaserver.cpp 2007-09-26 20:28:50 UTC (rev 797) +++ trunk/src/metaserver.cpp 2007-09-27 17:32:13 UTC (rev 798) @@ -29,10 +29,9 @@ namespace OpenGate{ - MetaConnection::MetaConnection(asio::io_service & io_service, LogManagerBase & log ) : +MetaConnection::MetaConnection(asio::io_service & io_service, LogManagerBase & log ) : io_service_( io_service ), socket_( io_service ), resolver_( io_service ), log_( &log ) { - // Get instance to the log manager hostname_ = std::string( "opacma.ontheserver.de" ); log_->info( std::string( "Querying " ) + hostname_); @@ -237,7 +236,6 @@ } } - } catch ( asio::error & e) { log_->fatal( std::string( "asio::error: " ) + e.what() ); return -5; @@ -358,8 +356,8 @@ // Read the response status line. #ifdef WIN32 - // we dont have boost:regex within win32, i will fix this later (carsten) - //asio::read_until(socket_, response, "\n"); + // we dont have boost:regex within win32, i will fix this later (carsten) +//asio::read_until(socket_, response, "\n"); #else asio::read_until(socket_, response, boost::regex("\r\n")); #endif @@ -383,7 +381,7 @@ // Read the response headers, which are terminated by a blank line. #ifdef WIN32 - // we dont have boost:regex within win32, i will fix this later (carsten) + // we dont have boost:regex within win32, i will fix this later (carsten) //asio::read_until(socket_, response, "\n"); #else asio::read_until(socket_, response, boost::regex("\r\n\r\n")); Modified: trunk/src/opengateserver.cpp =================================================================== --- trunk/src/opengateserver.cpp 2007-09-26 20:28:50 UTC (rev 797) +++ trunk/src/opengateserver.cpp 2007-09-27 17:32:13 UTC (rev 798) @@ -42,8 +42,8 @@ if ( metaPtr ) { logMgr->info("Remove server from server list!"); int error = 0; - if ((error = metaPtr->remove_game_server()) < 0) { - logMgr->warn( std::string("Could not remove game server " + toStr (error)) ); + if ( (error = metaPtr->remove_game_server() ) < 0) { + logMgr->warn( std::string("Could not remove game server " + toStr ( error ) ) ); } } if ( serverPtr ) { @@ -78,7 +78,7 @@ //** das k\xF6nnte mal vielleicht als option rausreichen, das man wie beim clienten die Wahl hat; //** -M = (withMetaServer = true); - bool withMetaServer = false; + bool withMetaServer = true; try { asio::io_service io_service; @@ -90,7 +90,11 @@ int error = 0; if ((error = meta.add_game_server()) < 0) { logMgr->warn( std::string("Could not add game server " + toStr (error) ) ); - } + } + + //** ein bissle mehr verbose output, kommt sp\xE4ter wieder weg.; + std::list< std::string > serverOnline( meta.list_game_server() ); + copy( serverOnline.begin(), serverOnline.end(), std::ostream_iterator< std::string >( std::cout, " " ) ); } tcp::endpoint endpoint( tcp::v4(), OG_PORT ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spo...@us...> - 2007-11-15 21:34:10
|
Revision: 839 http://opengate.svn.sourceforge.net/opengate/?rev=839&view=rev Author: spom_spom Date: 2007-11-15 13:34:08 -0800 (Thu, 15 Nov 2007) Log Message: ----------- add support for optional server comment Modified Paths: -------------- trunk/src/Console.cpp trunk/src/common.cpp trunk/src/common.h trunk/src/metaserver.cpp trunk/src/metaserver.h trunk/src/opengateclient.cpp trunk/src/opengateserver.cpp Modified: trunk/src/Console.cpp =================================================================== --- trunk/src/Console.cpp 2007-11-14 20:58:39 UTC (rev 838) +++ trunk/src/Console.cpp 2007-11-15 21:34:08 UTC (rev 839) @@ -99,7 +99,7 @@ } bool Console::handleEditTextAccepted( const CEGUI::EventArgs & args ){ - CEGUI::String text = editBox_->getText( ); + CEGUI::String text( editBox_->getText( ) ); if ( text.size() > 0 ){ std::vector < std::string > commandline( getSubstrings( text.c_str() ) ); @@ -111,6 +111,7 @@ } else { MessageBodyChat chat( std::string( text.c_str() ) ); resources_->network->send( chat ); + // LogManager::getSingleton().debug( std::string( "Chattest: " ) + text.c_str() ); } editBox_->setText(""); } Modified: trunk/src/common.cpp =================================================================== --- trunk/src/common.cpp 2007-11-14 20:58:39 UTC (rev 838) +++ trunk/src/common.cpp 2007-11-15 21:34:08 UTC (rev 839) @@ -58,7 +58,7 @@ vect[ count ] = toDouble( str ); count ++; } - if ( count > 2 ) return vect; + if ( count > 2 ) return vect; pos = nextPos + 1; } @@ -66,24 +66,3 @@ if ( str.size() > 0 ) vect[ count ] = toDouble( str ); return vect; } - -int split(const std::string& input, const std::string& delimiter, std::list<std::string>& results) { - int pos = 0; - int offset = 0; - int lengthDelimiter = (int)delimiter.size(); - int lengthInput = (int)input.size(); - - if ( ( lengthInput == 0 ) || ( lengthDelimiter == 0 ) ) { - return 0; - } - - while (pos = input.find (delimiter, offset)) { - results.push_back(input.substr(offset, pos-offset)); - if (pos == (int)std::string::npos) { - break; - } - offset = pos+1; - } - - return results.size(); -} Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2007-11-14 20:58:39 UTC (rev 838) +++ trunk/src/common.h 2007-11-15 21:34:08 UTC (rev 839) @@ -208,6 +208,27 @@ enum watchstate {undefined,halted,running} state; }; -int split(const std::string& input, const std::string& delimiter, std::list<std::string>& results); +template < class Container > int split( const std::string & input, + const std::string & delimiter, Container & results ){ + int pos = 0; + int offset = 0; + int lengthDelimiter = (int)delimiter.size(); + int lengthInput = (int)input.size(); + + if ( ( lengthInput == 0 ) || ( lengthDelimiter == 0 ) ) { + return 0; + } + + while (pos = input.find( delimiter, offset ) ) { + results.push_back( input.substr( offset, pos-offset ) ); + if ( pos == (int)std::string::npos ) { + break; + } + offset = pos+1; + } + + return results.size(); +} + #endif // _OPENGATE_COMMON__H Modified: trunk/src/metaserver.cpp =================================================================== --- trunk/src/metaserver.cpp 2007-11-14 20:58:39 UTC (rev 838) +++ trunk/src/metaserver.cpp 2007-11-15 21:34:08 UTC (rev 839) @@ -29,7 +29,7 @@ namespace OpenGate{ -MetaConnection::MetaConnection( asio::io_service & io_service, LogManagerBase & log ) : + MetaConnection::MetaConnection( asio::io_service & io_service, LogManagerBase & log ) : io_service_( io_service ), socket_( io_service ), resolver_( io_service ), log_( &log ) { isConnected_ = true; @@ -215,12 +215,27 @@ return META_NOT_CONNECTED; } -int MetaConnection::add_game_server() { +int MetaConnection::add_game_server( const std::string & servername ) { if ( isConnected_ ) { try { asio::streambuf response; std::string parameters( "add_game_server" ); + + if ( servername.length() > 0 ) parameters += "&comment="+strReplaceBlankWithUnderscore(servername); + +// kay, max 256 zeichen, gameserver einf\xFCgen mit opacma.ontheserver.de/script/schnittstelle/?action=add_game_server&comment=blablabla + +// http://opacma.ontheserver.de/script/schnittstelle/?action=list_game_servers +// ausgabeformat ist + +// reset($IPs); +// while(current($IPs)){ +// $Output .= current($IPs) . ',' . $Kommentare[current($IPs)] . ';'; + +// next($IPs); +// } + int retval = request( parameters, response ); if ( retval < 0 ) { return retval; @@ -262,12 +277,11 @@ } } -std::list<std::string> MetaConnection::list_game_server() { - std::list<std::string> mylist; +std::list< std::pair < std::string, std::string > > MetaConnection::list_game_servers() { + std::list< std::pair < std::string, std::string > > mylist; if ( isConnected_ ) { try { asio::streambuf response; - //** typo, server oder servers? std::string parameters( "list_game_servers" ); int retval = request(parameters, response); if ( retval < 0 ) { @@ -286,7 +300,16 @@ case -15: log_->warn ( std::string ("no game server available -15") ); return mylist; default: if ( stream.str().length() > 5 ) { - split(stream.str(), " ", mylist); + + std::vector < std::string > serverlist; + split( stream.str(), ";", serverlist ); + for ( int i = 0; i < serverlist.size(); i ++ ){ + std::vector < std::string > server; + split( serverlist[ i ], ",", server ); + if ( server.size() == 1 ) mylist.push_back( std::pair < std::string, std::string >( server[ 0 ], "" ) ); + if ( server.size() == 2 ) mylist.push_back( std::pair < std::string, std::string >( server[ 0 ], server[ 1 ] ) ); + } + } else { log_->warn ( std::string ("unkown return code for ") + parameters + toStr( returncode ) ); return mylist; Modified: trunk/src/metaserver.h =================================================================== --- trunk/src/metaserver.h 2007-11-14 20:58:39 UTC (rev 838) +++ trunk/src/metaserver.h 2007-11-15 21:34:08 UTC (rev 839) @@ -40,8 +40,11 @@ int check_version( int user_id ); int logout( int user_id ); - int add_game_server(); - std::list<std::string> list_game_server(); + //** register the current ip to the metaserver, you can specify a symbolic name + int add_game_server( const std::string & servername = ""); + + std::list< std::pair < std::string, std::string > > list_game_servers(); + int remove_game_server(); bool isConnected() const { return isConnected_; } @@ -50,6 +53,7 @@ LogManagerBase *log_; std::string hostname_; + std::string servername_; bool isConnected_; asio::io_service & io_service_; Modified: trunk/src/opengateclient.cpp =================================================================== --- trunk/src/opengateclient.cpp 2007-11-14 20:58:39 UTC (rev 838) +++ trunk/src/opengateclient.cpp 2007-11-15 21:34:08 UTC (rev 839) @@ -159,14 +159,14 @@ // } // }; - log->info( std::string( "Request game server from meta server: " ) ); - std::list< std::string > serverOnline( meta.list_game_server() ); - for ( std::list< std::string >::iterator it = serverOnline.begin(); it != serverOnline.end(); it ++ ){ - log->info( *it ); + log->info( std::string( "Request game servers from meta server: " ) ); + std::list< std::pair < std::string, std::string > > serverOnline( meta.list_game_servers() ); + for ( std::list< std::pair < std::string, std::string > >::iterator it = serverOnline.begin(); it != serverOnline.end(); it ++ ){ + log->info( it->second + ": " + it->first ); } if ( serverOnline.size() > 0 ){ log->info( std::string( "choosing the first for connection." ) ); - hostname = *serverOnline.begin(); + hostname = serverOnline.begin()->first; } } Modified: trunk/src/opengateserver.cpp =================================================================== --- trunk/src/opengateserver.cpp 2007-11-14 20:58:39 UTC (rev 838) +++ trunk/src/opengateserver.cpp 2007-11-15 21:34:08 UTC (rev 839) @@ -84,7 +84,7 @@ //** das k\xF6nnte mal vielleicht als option rausreichen, das man wie beim clienten die Wahl hat; //** -M = (withMetaServer = true); bool withMetaServer = true; - + std::string servername( "testserver Sim 1" ); try { asio::io_service io_service; io_servicePtr = &io_service; @@ -93,15 +93,17 @@ metaPtr = new OpenGate::MetaConnection( io_service, *logMgr ); int error = 0; - if ( ( error = metaPtr->add_game_server() ) < 0 ) { + if ( ( error = metaPtr->add_game_server( servername ) ) < 0 ) { logMgr->warn( std::string( "Could not add game server " + toStr ( error ) ) ); } else { logMgr->info( std::string( "server added to meta server " ) ); } - logMgr->info( std::string( "Request game server from meta server: " ) ); - std::list< std::string > serverOnline( metaPtr->list_game_server() ); - copy( serverOnline.begin(), serverOnline.end(), std::ostream_iterator< std::string >( std::cout, "\n" ) ); + logMgr->info( std::string( "Request game servers from meta server: " ) ); + std::list< std::pair < std::string, std::string > > serverOnline( metaPtr->list_game_servers() ); + for ( std::list< std::pair < std::string, std::string > >::iterator it = serverOnline.begin(); it != serverOnline.end(); it ++ ){ + logMgr->info( it->second + ": " + it->first ); + } } tcp::endpoint endpoint( tcp::v4(), OG_PORT ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spo...@us...> - 2007-11-22 22:35:19
|
Revision: 858 http://opengate.svn.sourceforge.net/opengate/?rev=858&view=rev Author: spom_spom Date: 2007-11-22 14:35:17 -0800 (Thu, 22 Nov 2007) Log Message: ----------- small fix Modified Paths: -------------- trunk/src/Console.cpp trunk/src/KeyMap.cpp trunk/src/KeyMap.h trunk/src/MarketDialog.cpp trunk/src/OpcodeWrapper.cpp trunk/src/Sector.cpp trunk/src/SectorObjects.cpp trunk/src/Station.cpp trunk/src/UnDockedState.cpp Modified: trunk/src/Console.cpp =================================================================== --- trunk/src/Console.cpp 2007-11-21 23:17:14 UTC (rev 857) +++ trunk/src/Console.cpp 2007-11-22 22:35:17 UTC (rev 858) @@ -125,7 +125,7 @@ CEGUI::System::getSingleton().injectChar( e.text ); //** for testings - if ( e.key == OIS::KC_BACK && resources_->keymap()->globalKeyModifier( ) == KEY_LCONTROL ){ + if ( e.key == OIS::KC_BACK && resources_->keymap()->globalKeyModifier( ) == KEY_CONTROL ){ resources_->renderWindow->setFullscreen( true, resources_->renderWindow->getWidth(), resources_->renderWindow->getHeight() ); @@ -133,7 +133,8 @@ std::cout << "Fullscreen: " << resources_->renderWindow->isFullScreen() << std::endl; } - if ( e.key == OIS::KC_LCONTROL) resources_->keymap()->setGlobalKeyModifier( KEY_LCONTROL ); + if ( e.key == OIS::KC_LCONTROL) resources_->keymap()->setGlobalKeyModifier( KEY_CONTROL ); + if ( e.key == OIS::KC_RCONTROL) resources_->keymap()->setGlobalKeyModifier( KEY_CONTROL ); if ( e.key == OIS::KC_LSHIFT) resources_->keymap()->setGlobalKeyModifier( KEY_SHIFT ); if ( e.key == OIS::KC_RSHIFT) resources_->keymap()->setGlobalKeyModifier( KEY_SHIFT ); @@ -146,6 +147,7 @@ CEGUI::System::getSingleton().injectKeyUp( e.key ); if ( e.key == OIS::KC_LCONTROL ) resources_->keymap()->setGlobalKeyModifier( KEY_NONE ); + if ( e.key == OIS::KC_RCONTROL ) resources_->keymap()->setGlobalKeyModifier( KEY_NONE ); if ( e.key == OIS::KC_LSHIFT ) resources_->keymap()->setGlobalKeyModifier( KEY_NONE ); if ( e.key == OIS::KC_RSHIFT ) resources_->keymap()->setGlobalKeyModifier( KEY_NONE ); Modified: trunk/src/KeyMap.cpp =================================================================== --- trunk/src/KeyMap.cpp 2007-11-21 23:17:14 UTC (rev 857) +++ trunk/src/KeyMap.cpp 2007-11-22 22:35:17 UTC (rev 858) @@ -69,7 +69,7 @@ /*! Actions for development, will removed later. */ unDockedActionMap_[ keycode( OIS::KC_F ) ] = &UnDockedState::keyActionToggleFiltering_DEV; - unDockedActionMap_[ keycode( OIS::KC_R ) ] = &UnDockedState::keyActionTogglePolygonMode_DEV; + unDockedActionMap_[ keycode( OIS::KC_R, KEY_CONTROL ) ] = &UnDockedState::keyActionTogglePolygonMode_DEV; unDockedActionMap_[ keycode( OIS::KC_L, KEY_SHIFT ) ] = &UnDockedState::keyActionIncreaseAmbientLight_DEV; unDockedActionMap_[ keycode( OIS::KC_L ) ] = &UnDockedState::keyActionDecreaseAmbientLight_DEV; Modified: trunk/src/KeyMap.h =================================================================== --- trunk/src/KeyMap.h 2007-11-21 23:17:14 UTC (rev 857) +++ trunk/src/KeyMap.h 2007-11-22 22:35:17 UTC (rev 858) @@ -45,7 +45,7 @@ Object object_; }; -enum GlobalKeyModifier{KEY_NONE, KEY_LCONTROL, KEY_SHIFT}; +enum GlobalKeyModifier{KEY_NONE, KEY_CONTROL, KEY_SHIFT}; class KeyMap{ public: Modified: trunk/src/MarketDialog.cpp =================================================================== --- trunk/src/MarketDialog.cpp 2007-11-21 23:17:14 UTC (rev 857) +++ trunk/src/MarketDialog.cpp 2007-11-22 22:35:17 UTC (rev 858) @@ -469,7 +469,7 @@ if ( item ){ buyMode_ = true; - if ( ResourceManager::getSingleton().keymap()->globalKeyModifier() == KEY_LCONTROL ){ + if ( ResourceManager::getSingleton().keymap()->globalKeyModifier() == KEY_CONTROL ){ buyItems( item, 1 ); } else { CEGUI::WindowManager::getSingleton().getWindow( (CEGUI::utf8*)"MarketWindow")->hide(); @@ -491,7 +491,7 @@ if ( item ){ buyMode_ = false; - if ( ResourceManager::getSingleton().keymap()->globalKeyModifier() == KEY_LCONTROL ){ + if ( ResourceManager::getSingleton().keymap()->globalKeyModifier() == KEY_CONTROL ){ sellItems( item, 1 ); } else { CEGUI::WindowManager::getSingleton().getWindow( (CEGUI::utf8*)"MarketWindow")->hide(); Modified: trunk/src/OpcodeWrapper.cpp =================================================================== --- trunk/src/OpcodeWrapper.cpp 2007-11-21 23:17:14 UTC (rev 857) +++ trunk/src/OpcodeWrapper.cpp 2007-11-22 22:35:17 UTC (rev 858) @@ -135,9 +135,9 @@ OgreOpcode::CollisionObject* col1 = rayPickReport[ i ]->this_object; OgreOpcode::CollisionObject* col2 = rayPickReport[ i ]->other_object; - std::cout << "checkCollideRay: " << i << " " - << static_cast< BaseObject * >( col1->getClientData() )->name() << "<->" - << static_cast< BaseObject * >( col2->getClientData() )->name() << std::endl; +// std::cout << "checkCollideRay: " << i << " " +// << static_cast< BaseObject * >( col1->getClientData() )->name() << "<->" +// << static_cast< BaseObject * >( col2->getClientData() )->name() << std::endl; if ( obj->getTypeID() == PROJECTILE_RTTI ){ if ( dynamic_cast< Projectile * >( obj )->parent() != static_cast< BaseObject * >( col1->getClientData() ) ){ Modified: trunk/src/Sector.cpp =================================================================== --- trunk/src/Sector.cpp 2007-11-21 23:17:14 UTC (rev 857) +++ trunk/src/Sector.cpp 2007-11-22 22:35:17 UTC (rev 858) @@ -552,7 +552,7 @@ obj = NULL; } break; default: - std::cerr << "object type unknown. this should not happen." << obj->getTypeID() << std::endl; + log_->fatal( "destructSectorObject: object type unknown. this should not happen: " + toStr( obj->getTypeID() ) ); } } @@ -588,7 +588,7 @@ obj = NULL; } break; default: - std::cerr << "object type unknown. this should not happen." << obj->getTypeID() << std::endl; + log_->fatal( "destructMoveableObject: object type unknown. this should not happen: " + toStr( obj->getTypeID() ) ); } } @@ -911,10 +911,10 @@ if ( ( it = movableObjects_.find( i->first ) ) != movableObjects_.end() ){ it->second->setFlightProperties( (*i->second) ); } else { - std::cerr << "Requested non existant object for shipmovement: " - << network_->userName( i->second->senderID() ) - << " child: " << (int)i->second->childID() << " at: " - << i->second->position() << " this should not happen." << std::endl; + log_->fatal( "Requested non existant object for shipmovement: " + + toStr( network_->userName( i->second->senderID() ) ) + + " child: " + toStr( (int)i->second->childID() ) + + " this should not happen." ); } } for ( size_t i = 0; i < movements.size(); i ++ ){ @@ -948,8 +948,8 @@ void Sector::sendVesselAmmoHit( const Projectile & projectile, BaseObject * victim ){ if ( projectile.parent().userID() == network_->userID() ){ - std::cout << "Send: Projectile from " << projectile.name() << " collide with: " << victim->name() - << " " << victim->userID() << " " << victim->childID() << std::endl; +// std::cout << "Send: Projectile from " << projectile.name() << " collide with: " << victim->name() +// << " " << victim->userID() << " " << victim->childID() << std::endl; MessageBodyShipAmmoHit msg( projectile.parent().childID(), victim->userID(), victim->childID(), projectile.damage() ); network_->send( msg ); @@ -972,10 +972,10 @@ " child: " + toStr( msg.targetChildID() ) + " damage: " + toStr( msg.damage() ) + " this should not happen." ) ; - std::cerr << "Available objects: " << std::endl; - for ( std::map< long, SectorObjectMoveable * >::iterator i = movableObjects_.begin(); i != movableObjects_.end(); i++){ - std::cerr << "\t" << i->first << " " << i->second->name() << " " << std::endl; - } +// std::cerr << "Available objects: " << std::endl; +// for ( std::map< long, SectorObjectMoveable * >::iterator i = movableObjects_.begin(); i != movableObjects_.end(); i++){ +// std::cerr << "\t" << i->first << " " << i->second->name() << " " << std::endl; +// } } } } Modified: trunk/src/SectorObjects.cpp =================================================================== --- trunk/src/SectorObjects.cpp 2007-11-21 23:17:14 UTC (rev 857) +++ trunk/src/SectorObjects.cpp 2007-11-22 22:35:17 UTC (rev 858) @@ -75,9 +75,9 @@ sceneMgr_ = sector_->sceneManager(); try{ - mainNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode( name + "_MainNode" ); + mainNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode( name + "_MainNode" ); } catch( Ogre::Exception & e ) { - std::cout << e.getFullDescription().c_str() << std::endl; + LogManager::getSingleton().fatal( e.getFullDescription() ); } lifeTime_ = 0.0; @@ -302,7 +302,7 @@ if ( mass_ > 0 ){ acc_ = ( - trustDir * thrust() - flightDir * friction ) / mass_; } else { - std::cerr << "mass: " << mass_ << std::endl; + LogManager::getSingleton().fatal( name_ + " mass: " + toStr( mass_ ) ); } if ( breakPressed_ == true ) { @@ -440,7 +440,7 @@ } void SectorObjectMoveable::collide( BaseObject * object ){ - std::cout << "SectorObjectMoveable: " << name() << " collide with " << object->getTypeID() << " " << object->name() << std::endl; + // std::cout << "SectorObjectMoveable: " << name() << " collide with " << object->getTypeID() << " " << object->name() << std::endl; if ( name_ != object->name() ){ if ( object->getTypeID( ) == PROJECTILE_RTTI ){ // hitByProjectile( dynamic_cast< Projectile* >( object ) ); Modified: trunk/src/Station.cpp =================================================================== --- trunk/src/Station.cpp 2007-11-21 23:17:14 UTC (rev 857) +++ trunk/src/Station.cpp 2007-11-22 22:35:17 UTC (rev 858) @@ -140,7 +140,7 @@ } void StationDockPad::collide( BaseObject * object ){ - std::cout << "StationDockPad::collide" << std::endl; + // std::cout << "StationDockPad::collide" << std::endl; sector_->listener()->changeToDockedState(); } @@ -164,9 +164,9 @@ OpcodeCollisionDetection::getSingleton().changeCollClass( collObj_, "Station" ); for ( uint i = 0; i < entity()->getNumSubEntities(); i ++ ){ - std::cout << entity()->getSubEntity( i )->getMaterialName() << " Techniques: " - << entity()->getSubEntity( i )->getMaterial()->getNumTechniques() << " used: " - << entity()->getSubEntity( i )->getTechnique()->getName() << std::endl; +// std::cout << entity()->getSubEntity( i )->getMaterialName() << " Techniques: " +// << entity()->getSubEntity( i )->getMaterial()->getNumTechniques() << " used: " +// << entity()->getSubEntity( i )->getTechnique()->getName() << std::endl; // for ( uint j = 0; j < entity()->getSubEntity( i )->getMaterial()->getNumTechniques(); j ++ ){ // std::cout << entity()->getSubEntity( i )->getMaterial()->getTechnique( j )->getName() << std::endl; @@ -232,7 +232,7 @@ } void StationObject::collide( BaseObject * object ){ - std::cout << "Sector: " << name_ << " collide with " << object->getTypeID() << " " << object->name()<< std::endl; + // std::cout << "Sector: " << name_ << " collide with " << object->getTypeID() << " " << object->name()<< std::endl; } void StationObject::showRings( bool show ){ ringNode_->setVisible( show ); } Modified: trunk/src/UnDockedState.cpp =================================================================== --- trunk/src/UnDockedState.cpp 2007-11-21 23:17:14 UTC (rev 857) +++ trunk/src/UnDockedState.cpp 2007-11-22 22:35:17 UTC (rev 858) @@ -389,7 +389,7 @@ bool UnDockedState::keyPressed( const OIS::KeyEvent & e ){ // std::cout << "UnDockedState: " << e.key << " " << (char)e.key<< std::endl; - if ( e.key == OIS::KC_ESCAPE) { + if ( e.key == OIS::KC_ESCAPE && !chatMode_ ) { switchConfigDialog(); } @@ -402,7 +402,8 @@ chatMode_ = true; } } else { // ** chatmode - if ( e.key == OIS::KC_RETURN) { + if ( e.key == OIS::KC_RETURN && resources_->keymap()->globalKeyModifier( ) == KEY_CONTROL || + e.key == OIS::KC_ESCAPE ) { CEGUI::WindowManager::getSingleton().getWindow( (CEGUI::utf8*)"ConsoleEdit")->deactivate(); chatMode_ = false; } @@ -1340,7 +1341,7 @@ } void UnDockedState::setAmbientLight_(){ - std::cout << ambientLight_ << std::endl; + // std::cout << ambientLight_ << std::endl; sceneMgr_->setAmbientLight( Ogre::ColourValue( (double)ambientLight_/10.0, (double)ambientLight_/10.0, (double)ambientLight_/10.0 ) ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spo...@us...> - 2007-12-27 19:07:55
|
Revision: 880 http://opengate.svn.sourceforge.net/opengate/?rev=880&view=rev Author: spom_spom Date: 2007-12-27 11:07:56 -0800 (Thu, 27 Dec 2007) Log Message: ----------- Add surface/norm/spec-mapping shader for planet objects Modified Paths: -------------- trunk/src/Makefile.am trunk/src/Sector.cpp trunk/src/Sector.h trunk/src/SectorObjects.cpp trunk/src/UnDockedState.cpp Added Paths: ----------- trunk/src/Planet.cpp trunk/src/Planet.h Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-12-08 12:45:39 UTC (rev 879) +++ trunk/src/Makefile.am 2007-12-27 19:07:56 UTC (rev 880) @@ -50,6 +50,8 @@ OpcodeWrapper.cpp \ OpenALSoundManager.h \ OpenALSoundManager.cpp \ + Planet.h \ + Planet.cpp \ Projectile.h \ Projectile.cpp \ ResourceManager.h \ Added: trunk/src/Planet.cpp =================================================================== --- trunk/src/Planet.cpp (rev 0) +++ trunk/src/Planet.cpp 2007-12-27 19:07:56 UTC (rev 880) @@ -0,0 +1,157 @@ +/*************************************************************************** + * Copyright (C) 2006-2007 by OpenGate development team * + * spo...@us... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "Planet.h" + +#include <OgreSceneManager.h> +#include <OgreEntity.h> +#include <OgreSceneNode.h> +#include <OgreMeshManager.h> +#include <OgreSubMesh.h> +#include <OgreVector3.h> + +namespace OpenGate{ + +Planet::Planet( const std::string & name, Ogre::SceneManager * SceneMgr, const Ogre::Vector3 & relPos, + Ogre::Real radius, int segments ) + : name_( name ), sceneMgr_( SceneMgr ){ + createSphere_( name + "_Mesh", radius, segments, segments ); + + Ogre::Entity * planetEntity = sceneMgr_->createEntity( name + "_Entity", name + "_Mesh" ); + planetNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode(); + planetEntity->setMaterialName( "Planet" ); + planetNode_->attachObject( planetEntity ); + planetNode_->setPosition( relPos ); + //planetNode_->pitch( Ogre::Degree(30) ); + + Ogre::Entity * planetCloudEntity = planetEntity->clone( planetEntity->getName() + "_Cloud" ); + planetCloudEntity->setMaterialName( "Planet/Cloud" ); + planetCloudNode_ = planetNode_->createChildSceneNode(); + planetCloudNode_->attachObject( planetCloudEntity ); + planetCloudNode_->scale(1.015, 1.015, 1.015); + } + +void Planet::update( float elapsedTime ){ + planetNode_->yaw( Ogre::Degree( 0.2 * elapsedTime ) ); + planetCloudNode_->yaw( Ogre::Degree( 0.1 * elapsedTime ) ); +} + +void Planet::createSphere_( const std::string & strName, const float r, const int nRings, const int nSegments ){ + Ogre::MeshPtr pSphere = Ogre::MeshManager::getSingleton().createManual(strName, + Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); + Ogre::SubMesh *pSphereVertex = pSphere->createSubMesh(); + + pSphere->sharedVertexData = new Ogre::VertexData(); + Ogre::VertexData* vertexData = pSphere->sharedVertexData; + + // define the vertex format + Ogre::VertexDeclaration* vertexDecl = vertexData->vertexDeclaration; + size_t currOffset = 0; + // positions + vertexDecl->addElement(0, currOffset, Ogre::VET_FLOAT3, Ogre::VES_POSITION); + currOffset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3); + // normals + vertexDecl->addElement(0, currOffset, Ogre::VET_FLOAT3, Ogre::VES_NORMAL); + currOffset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3); + // two dimensional texture coordinates + vertexDecl->addElement(0, currOffset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 0); + currOffset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT2); + + // allocate the vertex buffer + vertexData->vertexCount = (nRings + 1) * (nSegments+1); + Ogre::HardwareVertexBufferSharedPtr vBuf = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer( vertexDecl->getVertexSize(0), vertexData->vertexCount, + Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY, false); + Ogre::VertexBufferBinding* binding = vertexData->vertexBufferBinding; + binding->setBinding(0, vBuf); + float* pVertex = static_cast<float*>(vBuf->lock(Ogre::HardwareBuffer::HBL_DISCARD)); + + // allocate index buffer + pSphereVertex->indexData->indexCount = 6 * nRings * (nSegments + 1); + pSphereVertex->indexData->indexBuffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer( + Ogre::HardwareIndexBuffer::IT_16BIT, pSphereVertex->indexData->indexCount, + Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY, false); + Ogre::HardwareIndexBufferSharedPtr iBuf = pSphereVertex->indexData->indexBuffer; + unsigned short* pIndices = static_cast<unsigned short*>(iBuf->lock(Ogre::HardwareBuffer::HBL_DISCARD)); + + float fDeltaRingAngle = (Ogre::Math::PI / nRings); + float fDeltaSegAngle = (2.0 * Ogre::Math::PI / nSegments); + unsigned short wVerticeIndex = 0 ; + + // Generate the group of rings for the sphere + for ( int ring = 0; ring <= nRings; ring++ ) { + float r0 = r * sinf (ring * fDeltaRingAngle); + float y0 = r * cosf (ring * fDeltaRingAngle); + + // Generate the group of segments for the current ring + for (int seg = 0; seg <= nSegments; seg++) { + float x0 = r0 * sinf(seg * fDeltaSegAngle); + float z0 = r0 * cosf(seg * fDeltaSegAngle); + + // Add one vertex to the strip which makes up the sphere + *pVertex++ = x0; + *pVertex++ = y0; + *pVertex++ = z0; + + Ogre::Vector3 vNormal = Ogre::Vector3(x0, y0, z0).normalisedCopy(); + *pVertex++ = vNormal.x; + *pVertex++ = vNormal.y; + *pVertex++ = vNormal.z; + + *pVertex++ = (float) seg / (float) nSegments; + *pVertex++ = (float) ring / (float) nRings; + + if (ring != nRings) { + // each vertex (except the last) has six indices pointing to it + *pIndices++ = wVerticeIndex + nSegments + 1; + *pIndices++ = wVerticeIndex; + *pIndices++ = wVerticeIndex + nSegments; + *pIndices++ = wVerticeIndex + nSegments + 1; + *pIndices++ = wVerticeIndex + 1; + *pIndices++ = wVerticeIndex; + wVerticeIndex ++; + } + }; // end for seg + } // end for ring + + // Unlock + vBuf->unlock(); + iBuf->unlock(); + // Generate face list + pSphereVertex->useSharedVertices = true; + + // the original code was missing this line: + pSphere->_setBounds( Ogre::AxisAlignedBox( Ogre::Vector3(-r, -r, -r), Ogre::Vector3(r, r, r) ), false ); + pSphere->_setBoundingSphereRadius( r ); + // this line makes clear the mesh is loaded (avoids memory leaks) + pSphere->load(); + + Ogre::MeshPtr pMesh = Ogre::MeshManager::getSingleton().load( strName, + Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, + Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, + Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY, true, true); + unsigned short src, dest; + + if ( !pMesh->suggestTangentVectorBuildParams( Ogre::VES_TANGENT, src, dest) ) { + pMesh->buildTangentVectors( Ogre::VES_TANGENT, src, dest ); + } +} + +} // namespace OpenGate + Added: trunk/src/Planet.h =================================================================== --- trunk/src/Planet.h (rev 0) +++ trunk/src/Planet.h 2007-12-27 19:07:56 UTC (rev 880) @@ -0,0 +1,49 @@ +/*************************************************************************** + * Copyright (C) 2006-2007 by OpenGate development team * + * spo...@us... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _OPENGATE_PLANET__H +#define _OPENGATE_PLANET__H + +#include <OgrePrerequisites.h> + +namespace OpenGate{ + +class Planet { +public: + + Planet( const std::string & name, Ogre::SceneManager * SceneMgr, const Ogre::Vector3 & relPos, Ogre::Real radius, int segments ); + void update( float elapsedTime ); + +protected: + + //** taken from ogre wiki: http://www.ogre3d.org/wiki/index.php/ManualSphereMeshes + void createSphere_( const std::string & strName, const float r, const int nRings, const int nSegments ); + + std::string name_; + Ogre::SceneManager * sceneMgr_; + + Ogre::SceneNode * planetNode_; + Ogre::SceneNode * planetCloudNode_; +}; + +} // namespace OpenGate + + +#endif // _OPENGATE_SECTOR__H Modified: trunk/src/Sector.cpp =================================================================== --- trunk/src/Sector.cpp 2007-12-08 12:45:39 UTC (rev 879) +++ trunk/src/Sector.cpp 2007-12-27 19:07:56 UTC (rev 880) @@ -25,6 +25,7 @@ #include "ResourceManager.h" #include "Projectile.h" #include "Station.h" +#include "Planet.h" #include <OgreManualObject.h> #include <OgreMaterialManager.h> @@ -66,12 +67,13 @@ Sector::Sector( Ogre::SceneManager * sceneMgr, NetworkClient * network ) : sceneMgr_( sceneMgr ), network_( network ) { - log_ = LogManager::getSingletonPtr(); - radar_ = true; + radar_ = true; planetNode_ = NULL; - starsNode_ = NULL; - avatar_ = NULL; - station_ = NULL; + planet_ = NULL; + starsNode_ = NULL; + avatar_ = NULL; + station_ = NULL; + log_ = LogManager::getSingletonPtr(); avatarDeathSequenceTime_ = 0.0; @@ -114,9 +116,21 @@ //*** end starfield test 2; + Ogre::Light * mainLight = sceneMgr_->createLight("MainLight" ); + mainLight->setDiffuseColour( 0.1, 0.1, 0.1 ); + mainLight->setSpecularColour( 0.4, 0.4, 0.4 ); + mainLight->setPosition(-50000, 0, -40000 ); + sceneMgr_->setAmbientLight( Ogre::ColourValue( 0.1, 0.1, 0.1 ) ); + if ( 1 ) { + // planet_ = new Planet( "planet", sceneMgr_, Ogre::Vector3( 20000.0, 10000.0, 40000 ), 15000.0f, 32 ); + planet_ = new Planet( "planet", sceneMgr_, Ogre::Vector3( 0000.0, 0000.0, 50000 ), 15000.0f, 64 ); + } + + if ( !1 ) { planetNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode( "PlanetNode" ); + Ogre::ManualObject * planet = sceneMgr_->createManualObject( "Planet" ); // planet->setUseIdentityProjection( true ); // planet->setUseIdentityView( true ); @@ -139,8 +153,6 @@ planetNode_->setPosition( Ogre::Vector3( 20000.0, 10000.0, 50000 ) ); } - sceneMgr_->setAmbientLight( Ogre::ColourValue( 0.2, 0.2, 0.2 ) ); - populate( "testsector.xml" ); // createCircle(); @@ -219,7 +231,7 @@ if ( pElem ){ sceneMgr_->setSkyBox( true, pElem->FirstChild()->Value(), 10000 ); } else{ -// sceneMgr_->setSkyBox( true, "OpenGate/SimpleSkyBox1" ); + sceneMgr_->setSkyBox( true, "OpenGate/SimpleSkyBox1" ); } pElem = hRoot.ChildElement( "vesselschool", 0 ).Element(); @@ -368,6 +380,9 @@ if ( collisionDetection_ ) collisionDetection_->update( elapsedTime ); if ( avatar_ ) { + if ( planet_ ){ + planet_->update( elapsedTime ); + } if ( planetNode_ ){ Ogre::Vector3 src = planetNode_->getWorldOrientation() * Ogre::Vector3::UNIT_Z; src.normalise(); Modified: trunk/src/Sector.h =================================================================== --- trunk/src/Sector.h 2007-12-08 12:45:39 UTC (rev 879) +++ trunk/src/Sector.h 2007-12-27 19:07:56 UTC (rev 880) @@ -31,6 +31,7 @@ class Avatar; class Station; +class Planet; class StationObject; class Sector { @@ -122,6 +123,8 @@ std::string sectorname_; SectorObjectAvatar * avatar_; + Planet * planet_; + Ogre::SceneNode * planetNode_; Ogre::SceneNode * starsNode_; Modified: trunk/src/SectorObjects.cpp =================================================================== --- trunk/src/SectorObjects.cpp 2007-12-08 12:45:39 UTC (rev 879) +++ trunk/src/SectorObjects.cpp 2007-12-27 19:07:56 UTC (rev 880) @@ -847,7 +847,7 @@ Ogre::Light * l = sceneMgr_->createLight("AvatarLight" ); l->setDiffuseColour( Ogre::ColourValue(1.0, 1.0, 1.0) ); l->setSpecularColour( Ogre::ColourValue(1.0, 1.0, 1.0) ); - l->setVisible( true ); + l->setVisible( false ); lightNode_ = mainNode_->createChildSceneNode( "AvatarLightNode" ); lightNode_->translate(50,0,10); lightNode_->attachObject( l ); Modified: trunk/src/UnDockedState.cpp =================================================================== --- trunk/src/UnDockedState.cpp 2007-12-08 12:45:39 UTC (rev 879) +++ trunk/src/UnDockedState.cpp 2007-12-27 19:07:56 UTC (rev 880) @@ -174,7 +174,7 @@ Ogre::Viewport* vp = window_->addViewport( sceneMgr_->getCamera( "MainCamera" ), 0, 0.0, 0.0, 1.0f, 1.0f ); vp->setBackgroundColour( Ogre::ColourValue( 0, 0, 0) ); - // camera->setAspectRatio( Real(vp->getActualWidth()) / Real(vp->getActualHeight())); + sceneMgr_->getCamera( "MainCamera" )->setAspectRatio( Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); Ogre::Viewport* vp1 = window_->addViewport( sceneMgr_->getCamera( "SecondCamera" ), 1, 0.01, 0.84, 0.15, 0.15 ); vp1->setBackgroundColour( Ogre::ColourValue( 0.1, 0.1, 0.1 ) ); @@ -383,6 +383,7 @@ return false; } + myMSleep( (int)min( 0.0f, 1 - ( evt.timeSinceLastFrame ) ) ); return true; } @@ -402,10 +403,18 @@ chatMode_ = true; } } else { // ** chatmode - if ( e.key == OIS::KC_RETURN && resources_->keymap()->globalKeyModifier( ) == KEY_CONTROL || - e.key == OIS::KC_ESCAPE ) { - CEGUI::WindowManager::getSingleton().getWindow( (CEGUI::utf8*)"ConsoleEdit")->deactivate(); - chatMode_ = false; + bool EnterHoldChatFokus = false; + if ( EnterHoldChatFokus ){ + if ( e.key == OIS::KC_RETURN && resources_->keymap()->globalKeyModifier( ) == KEY_CONTROL || + e.key == OIS::KC_ESCAPE ) { + CEGUI::WindowManager::getSingleton().getWindow( (CEGUI::utf8*)"ConsoleEdit")->deactivate(); + chatMode_ = false; + } + } else { + if ( e.key == OIS::KC_RETURN ) { + CEGUI::WindowManager::getSingleton().getWindow( (CEGUI::utf8*)"ConsoleEdit")->deactivate(); + chatMode_ = false; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spo...@us...> - 2008-05-04 15:50:26
|
Revision: 889 http://opengate.svn.sourceforge.net/opengate/?rev=889&view=rev Author: spom_spom Date: 2008-05-04 08:50:32 -0700 (Sun, 04 May 2008) Log Message: ----------- Add docking assistant. Shift-A toggle on/off Modified Paths: -------------- trunk/src/AiCommands.cpp trunk/src/AiManager.cpp trunk/src/AiManager.h trunk/src/AiObject.cpp trunk/src/AiObject.h trunk/src/BaseObject.h trunk/src/KeyMap.cpp trunk/src/OpenALSoundManager.cpp trunk/src/Projectile.cpp trunk/src/Sector.cpp trunk/src/SectorObject.h trunk/src/SectorObjectMoveable.cpp trunk/src/SectorObjectMoveable.h trunk/src/SectorObjectVessel.cpp trunk/src/Station.cpp trunk/src/Station.h trunk/src/UnDockedState.cpp trunk/src/UnDockedState.h Modified: trunk/src/AiCommands.cpp =================================================================== --- trunk/src/AiCommands.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/AiCommands.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -64,7 +64,13 @@ } -void AiCommandSelfDestruct::stop(){ ai_->kill(); } +void AiCommandSelfDestruct::stop(){ + if ( ai_->vesselObject() ){ + ai_->vesselObject()->setControler( NULL ); + ai_->vesselObject()->destroy(); + } + ai_->kill(); +} void AiCommandYaw::start(){ Modified: trunk/src/AiManager.cpp =================================================================== --- trunk/src/AiManager.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/AiManager.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -41,7 +41,7 @@ namespace OpenGate{ AiManager::AiManager( ResourceManager * resources ) : resources_( resources ){ - eraseAiObjectCB_ = new AiManagerCB( this, &AiManager::eraseAiObject ); + eraseAiObjectCB_ = new AiManagerCB( this, &AiManager::eraseAiObject_ ); aiID_ = 1; } @@ -143,14 +143,11 @@ // dynamic_cast < UnDockedState *>(resources_->gameStateRoot->activeState() // )->sector()->station()->launchPadOrientation() ); - ai->land( *dynamic_cast < UnDockedState *>(resources_->gameStateRoot->activeState() )->sector()->station() ); + ai->land( dynamic_cast < UnDockedState *>(resources_->gameStateRoot->activeState() )->sector()->station() ); } + startAiObject( ai ); - std::cout << "starting: " << ai->name() << std::endl; - - RunAiObject aio( ai, eraseAiObjectCB_ ); - aiThreads_.create_thread( aio ); return ai; } @@ -170,19 +167,28 @@ return ai; } -void AiManager::eraseAiObject( AiObject * ai ){ +void AiManager::startAiObject( AiObject * ai ){ + std::cout << "starting: " << ai->name() << std::endl; + RunAiObject aio( ai, eraseAiObjectCB_ ); + aiThreads_.create_thread( aio ); +} + +void AiManager::stopAiObject( AiObject * ai ){ + ai->kill(); +} + +void AiManager::eraseAiObject_( AiObject * ai ){ boost::mutex::scoped_lock lock( eraseMutex_ ); SectorObjectVessel *obj = ai->vesselObject( ); if ( obj ){ __D( obj->name() ) - obj->destroy(); + obj->setControler( NULL ); } aiObjects_.erase( ai ); + recycle_( ai ); } -void AiManager::recycle( AiObject * ai ){ - aiObjectHeap_.push_back( ai ); -} +void AiManager::recycle_( AiObject * ai ){ aiObjectHeap_.push_back( ai ); } } // namespace OpenGate{ Modified: trunk/src/AiManager.h =================================================================== --- trunk/src/AiManager.h 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/AiManager.h 2008-05-04 15:50:32 UTC (rev 889) @@ -58,29 +58,38 @@ ~AiManager( ); - void cmd( const std::vector < std::string > & argv ); + void cmd( const std::vector < std::string > & argv ); - AiObject * spawnAi( ); - - /*! Create new ai an put to set of active ai, instance is taken from heap if available else create new*/ - AiObject * createAiObject( const std::string & name ); + /*! Create new ai and put it to the set of active ai. The instance is taken from heap if available else create new. + The object will start its work when startAiObject is called. + The object will destoyed automaticaly either there work is done or stopAiObject is called.*/ + AiObject * createAiObject( const std::string & name ); - /*! Erase ai from set of active ai's. The instance will not destroyd but put on a heap for the next usage*/ - void eraseAiObject( AiObject * ai ); + /*! Create new thread for the ai and start running */ + void startAiObject( AiObject * ai ); + + /*! Send kill signal to aiObject. The object will erased automaticaly */ + void stopAiObject( AiObject * ai ); + + /*! Check for any active ai's. */ + inline bool hasActiveObjects() const { return ( aiObjects_.size() > 0 ); } - /*! The ai is dead and can be recycled. */ - void recycle( AiObject * ai ); - - /*! Check for any active ai's. */ - inline bool hasActiveObjects() const { return ( aiObjects_.size() > 0 ); } + /*!Send kill signal to all ai and join all threads. Mainly used for shutdown the manager.*/ + void killall(); + + /*! ID of the last created ai */ + uint aiID() const { return aiID_; } - /*!Send kill signal to all ai and join all threads. Mainly used for shutdown the manager.*/ - void killall(); + AiObject * spawnAi( ); - /*! ID of the last created ai */ - uint aiID() const { return aiID_; } - protected: + /*! The ai is dead and can be recycled. */ + void recycle_( AiObject * ai ); + + /*! Erase ai from set of active ai's. The instance will not destroyd but put on a heap for the next usage*/ + void eraseAiObject_( AiObject * ai ); + + ResourceManager * resources_; std::set< AiObject * > aiObjects_; Modified: trunk/src/AiObject.cpp =================================================================== --- trunk/src/AiObject.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/AiObject.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -37,13 +37,13 @@ namespace OpenGate{ AiObject::AiObject( uint id ) : id_( id ), vesselObject_( NULL ){ - livetime_ = new Ogre::Timer(); + lifeTimer_ = new Ogre::Timer(); reset(); } AiObject::~AiObject(){ for_each( cmdQueue_.begin(), cmdQueue_.end(), deletePtr() ); - delete livetime_; + delete lifeTimer_; } //** protected copy constructor @@ -62,7 +62,8 @@ } void AiObject::reset( ){ - livetime_->reset(); + vesselObject_ = NULL; + lifeTimer_->reset(); lasttime_ = 0; refCounter_ = 0; name_ = "unknown"; @@ -79,12 +80,18 @@ } } +void AiObject::kill() { + if ( vesselObject_ ) vesselObject_->setControler( NULL ); + vesselObject_ = NULL; + isAlive_ = false; +} + void AiObject::run(){ __D( name_ ) isAlive_ = true; - livetime_->reset(); + lifeTimer_->reset(); do { if ( activeCmd_ ){ - unsigned long tmpTime = livetime_->getMicroseconds(); + unsigned long tmpTime = lifeTimer_->getMicroseconds(); // std::cout << tmpTime << " " << lasttime_ << std::endl; if ( !activeCmd_->update( ( tmpTime - lasttime_ ) / 1e6 ) ) { delete activeCmd_; @@ -167,24 +174,22 @@ cmdQueue_.push_back( new AiCommandLookAt( this, Ogre::Vector3( 0.0, 0.0, 1.0 ) ) ); } -void AiObject::land( const StationObject & station ){ - cmdQueue_.push_back( new AiCommandWait( this, 2.0 ) ); - //Vector3(-0.563038, -77.3473, -1348.36) // dockpad - std::cout << "station docking pad: " << station.dockPadPosition( ) << std::endl; +void AiObject::land( StationObject * station ){ + if ( station ){ + cmdQueue_.push_back( new AiCommandWait( this, 1.0 ) ); +// std::cout << "station docking pad: " << station.dockPadPosition( ) << std::endl; +// std::cout << "station ring end:" << station.dockingRingEnd( ) << std::endl; +// std::cout << "station ring start:" << station.dockingRingStart( ) << std::endl; +// station->sector()->koordAxis()->setPosition( station.dockPadPosition( ) ); +// std::cout << "station launch pad: " << station.launchPadPosition( ) << std::endl; - std::cout << "station ring end:" << station.dockingRingEnd( ) << std::endl; - // Vector3(-66.7835, -78.9126, -433.894) - std::cout << "station ring start:" << station.dockingRingStart( ) << std::endl; - - const_cast< StationObject * > (&station)->sector()->koordAxis()->setPosition( station.dockPadPosition( ) ) ; - // Vector3(-261.482, -5.00386, -1384.19) - std::cout << "station launch pad: " << station.launchPadPosition( ) << std::endl; - //cmdQueue_.push_back( new AiCommandApproach( this, station.dockingRingStart( ), true ) ); - cmdQueue_.push_back( new AiCommandApproach( this, station.dockingRingStart( ), true ) ); - cmdQueue_.push_back( new AiCommandWait( this, 1.0 ) ); - cmdQueue_.push_back( new AiCommandApproach( this, station.dockPadPosition( ), true ) ); - + cmdQueue_.push_back( new AiCommandApproach( this, station->dockingRingStart( ), true ) ); + cmdQueue_.push_back( new AiCommandWait( this, 1.0 ) ); + cmdQueue_.push_back( new AiCommandApproach( this, station->dockPadPosition( ), true ) ); + } else { + std::cerr << "Station is not valid" << std::endl; + } cmdQueue_.push_back( new AiCommandWait( this, 5.0 ) ); cmdQueue_.push_back( new AiCommandSelfDestruct( this ) ); } Modified: trunk/src/AiObject.h =================================================================== --- trunk/src/AiObject.h 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/AiObject.h 2008-05-04 15:50:32 UTC (rev 889) @@ -64,8 +64,8 @@ bool isAlive() const { return isAlive_; } - void kill() { isAlive_ = false; } - + void kill(); + void reset(); void setName ( const std::string & name ){ name_ = name; } @@ -78,10 +78,10 @@ void test( ); - void land( const StationObject & station ); + void land( StationObject * station ); /*! Idle and look every second for new orders */ - bool cmdIdle( ); + //bool cmdIdle( ); /*! Wait and do nothing */ bool cmdWait( double time ); /*! Accelerate a given time with a given thrustRate */ @@ -130,7 +130,7 @@ bool die_; //! holds objects livetime - Ogre::Timer * livetime_; + Ogre::Timer * lifeTimer_; //! time from last livecyle in microseconds unsigned long lasttime_; Modified: trunk/src/BaseObject.h =================================================================== --- trunk/src/BaseObject.h 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/BaseObject.h 2008-05-04 15:50:32 UTC (rev 889) @@ -83,12 +83,14 @@ Ogre::Vector3 position() const; - /*! Mark the object for destruction. - To keep destruction thread safe, we just notify and let the update cycle do the job */ + /*! Mark the object for destruction + To keep destruction thread safe, we just notify and let the update cycle do the job */ void destroy() { destroyRequest_ = true; } - + bool isSetDestroyRequest() const { return destroyRequest_; } - + + virtual void setVisible( bool visible ) { mainNode_->setVisible( visible ); } + protected: Ogre::String name_; Sector * sector_; Modified: trunk/src/KeyMap.cpp =================================================================== --- trunk/src/KeyMap.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/KeyMap.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -63,6 +63,8 @@ unDockedActionMap_[ keycode( OIS::KC_4 ) ] = &UnDockedState::keyActionCameraUp; unDockedActionMap_[ keycode( OIS::KC_5 ) ] = &UnDockedState::keyActionCameraDown; unDockedActionMap_[ keycode( OIS::KC_6 ) ] = &UnDockedState::keyActionCameraToggle; + + unDockedActionMap_[ keycode( OIS::KC_A, KEY_SHIFT ) ] = &UnDockedState::keyActionDockAssist; /*! Actions for console. */ consoleActionMap_[ keycode( OIS::KC_SYSRQ ) ] = &Console::keyActionScreenshot; Modified: trunk/src/OpenALSoundManager.cpp =================================================================== --- trunk/src/OpenALSoundManager.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/OpenALSoundManager.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -278,10 +278,10 @@ } bool OpenALOggStreamSource::release(){ - alSourceStop( source_ ); + stop(); empty_(); - //** alDeleteSources(1, & source_ ); + alDeleteSources(1, & source_ ); //** valgrind says:; // Invalid read of size 4 // ==10954== at 0x6129E42: (within /usr/lib64/libopenal.so.0.0.0) @@ -298,7 +298,7 @@ } void OpenALOggStreamSource::showInfos(){ - std::cout << "version " << vorbisInfo_->version << "\n" + std::cout << "version " << vorbisInfo_->version << "\n" << "channels " << vorbisInfo_->channels << "\n" << "rate (hz) " << vorbisInfo_->rate << "\n" << "bitrate upper " << vorbisInfo_->bitrate_upper << "\n" @@ -401,7 +401,7 @@ return true; } - OpenALListener::OpenALListener( OpenALSoundManager * soundMgr, bool dummy ) : soundMgr_( soundMgr ), dummy_( dummy ){ +OpenALListener::OpenALListener( OpenALSoundManager * soundMgr, bool dummy ) : soundMgr_( soundMgr ), dummy_( dummy ){ reset(); } Modified: trunk/src/Projectile.cpp =================================================================== --- trunk/src/Projectile.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/Projectile.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -32,7 +32,7 @@ namespace OpenGate{ - Projectile::Projectile( BaseObject * parent, long shotCount, Gun & gun, const Ogre::Vector3 & pos, const Ogre::Vector3 & vel ) +Projectile::Projectile( BaseObject * parent, long shotCount, Gun & gun, const Ogre::Vector3 & pos, const Ogre::Vector3 & vel ) : BaseObject( parent->name() + "_" + toStr( shotCount ), parent->sector() ), parent_( parent ), shotCount_( shotCount ), gun_( &gun ), damage_( gun.damage() ), maxLifeTime_( gun.lifeTime() ), vel_( vel ){ @@ -48,8 +48,9 @@ } Projectile::Projectile( BaseObject * parent, long shotCounter, const GunObject & gun, const Ogre::Vector3 & mountPoint ) - : BaseObject( parent->name() + "_" + toStr( shotCounter ), parent->sector() ), parent_( parent ), - shotCount_( shotCounter), gun_( gun.gun() ), damage_( gun.gun()->damage() ), maxLifeTime_( gun.gun()->lifeTime() ){ + : BaseObject( parent->name() + "_" + toStr( shotCounter ), parent->sector() ), + parent_( parent ), shotCount_( shotCounter), gun_( gun.gun() ), + damage_( gun.gun()->damage() ), maxLifeTime_( gun.gun()->lifeTime() ){ selectable_ = false; beam_ = NULL; @@ -60,6 +61,7 @@ maxRange_ = gun.gun()->speed() * maxLifeTime_; Ogre::Quaternion direction( parent_->mainNode()->getOrientation() ); + vel_ = gun.gun()->speed() * -direction.zAxis().normalisedCopy() + parent->velocity(); Ogre::Vector3 relGunPos( ( gun.sceneNode().getParentSceneNode()->getOrientation() * gun.sceneNode().getPosition() ) * @@ -67,6 +69,8 @@ Ogre::Vector3 pos( gun.sceneNode().getWorldPosition() - direction.zAxis() * relGunPos[ 2 ] ); +// std::cout << parent_->name() << std::endl; +// std::cout << pos << " " << relGunPos << std::endl; fire( pos, relGunPos ); } @@ -103,7 +107,7 @@ Ogre::Quaternion direction( parent_->mainNode()->getOrientation() ); mainNode_->setOrientation( direction ); mainNode_->setPosition( pos ); - mainNode_->_update( true, true ); + //mainNode_->_update( true, true ); lifeTime_ = 0.0; oldTime_ = 0.0; @@ -138,6 +142,7 @@ } if ( manuObject ){ +// std::cout << "createManualObject" << std::endl; beam_ = sceneMgr_->createManualObject( bulletName + "_ManualObj" ); Ogre::Real width = 0.25; beam_->begin( "BeamGreen", Ogre::RenderOperation::OT_TRIANGLE_LIST); @@ -150,13 +155,14 @@ beam_->end(); shape_->attachObject( beam_ ); } else { +// std::cout << "createRibbonTrail" << std::endl; trail_ = sceneMgr_->createRibbonTrail( bulletName + "_RibbonTrail"); trail_->setMaterialName( "BeamGreen" ); trail_->setTrailLength( maxRange_ ); trail_->setWidthChange( 0, 2.0 ); trail_->setMaxChainElements( 1000 ); trail_->setInitialWidth( 0, 1.0 ); - trail_->addNode( shape_ ); + trail_->addNode( mainNode_ ); trailNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode(); trailNode_->attachObject( trail_ ); } @@ -210,7 +216,7 @@ // trail_->setTrailLength( beamLength ); } } - } else { + } else { // if not ammoHit_ Ogre::Real beamLength = min( (vel_ * lifeTime_).length(), maxRange_ / 2.0f ); beamLength -= ( parent_->mainNode()->getWorldPosition() + ( vel_ * lifeTime_ ) - mainNode_->getWorldPosition() ).length(); Modified: trunk/src/Sector.cpp =================================================================== --- trunk/src/Sector.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/Sector.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -166,10 +166,6 @@ populate( "testsector.xml" ); createKoordAxis( ); - SectorObject *obj = createStaticObject( "Firefly.mesh", "Firefly/static", Ogre::Vector3( 0.0, 0.0, 0.0 )); -obj->mainNode()->showBoundingBox( true ); - - std::cout << "Firefly: " << obj->mainNode()->_getWorldAABB() << std::endl; } Sector::~Sector( ){ Modified: trunk/src/SectorObject.h =================================================================== --- trunk/src/SectorObject.h 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/SectorObject.h 2008-05-04 15:50:32 UTC (rev 889) @@ -54,25 +54,25 @@ virtual bool update( Ogre::Real elapsedTime ){ return true; } - void setShape( const Ogre::String & meshname ); - void setShape( Ogre::MeshPtr & mesh ); - Ogre::Entity * entity(){ return entity_; } + void setShape( const Ogre::String & meshname ); + void setShape( Ogre::MeshPtr & mesh ); + Ogre::Entity * entity(){ return entity_; } - void scale( const Ogre::Vector3 & scale ); + void scale( const Ogre::Vector3 & scale ); - void setBaseSize( const Ogre::Vector3 & targetSize ); - void setBaseRot( const Ogre::Real & yaw, const Ogre::Real & pitch = 0, const Ogre::Real & roll = 0 ); + void setBaseSize( const Ogre::Vector3 & targetSize ); + void setBaseRot( const Ogre::Real & yaw, const Ogre::Real & pitch = 0, const Ogre::Real & roll = 0 ); - Ogre::Vector3 baseSize( ) const { return baseSize_; } - Ogre::Real maxBaseSize( ) const { return max( max( baseSize_[0], baseSize_[1] ), baseSize_[2] ); } + Ogre::Vector3 baseSize( ) const { return baseSize_; } + Ogre::Real maxBaseSize( ) const { return max( max( baseSize_[0], baseSize_[1] ), baseSize_[2] ); } - bool isOnRadar() const { return isOnRadar_; } - void onRadar( bool onradar ) { isOnRadar_ = onradar; } + bool isOnRadar() const { return isOnRadar_; } + void onRadar( bool onradar ) { isOnRadar_ = onradar; } - virtual Ogre::Vector3 velocity() const { return Ogre::Vector3(0.0, 0.0, 0.0 ); } + virtual Ogre::Vector3 velocity() const { return Ogre::Vector3(0.0, 0.0, 0.0 ); } - Ogre::OverlayElement * dotA() { return dotA_; } - Ogre::OverlayElement * dotB() { return dotB_; } + Ogre::OverlayElement * dotA() { return dotA_; } + Ogre::OverlayElement * dotB() { return dotB_; } /*! Add an object to the set of observers e.g. selected as target, dot on radar. When this object dies the observers have to informed. */ @@ -90,10 +90,6 @@ /*! Return the current target. */ virtual SectorObject * target( ){ return target_; } - virtual void setVisible( bool visible ){ mainNode_->setVisible( false ); } - void show( ){ setVisible( true ); } - void hide( ){ setVisible( false ); } - protected: Ogre::SceneNode * mainNodeEntityScale_; // Main character node for base size Modified: trunk/src/SectorObjectMoveable.cpp =================================================================== --- trunk/src/SectorObjectMoveable.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/SectorObjectMoveable.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -100,51 +100,50 @@ roll_ = 0.0; pitch_ = 0.0; - mass_ = 1; - armor_ = maxArmor_; - thrust_ = 0; - maxThrust_ = 0; + mass_ = 1; + armor_ = maxArmor_; + thrust_ = 0; + maxThrust_ = 0; + thrustRate_ = 0; - - shieldGlowActive_ = false; - shieldGlowTime_ = 0.0; + shieldGlowActive_ = false; + shieldGlowTime_ = 0.0; vel_ = Ogre::Vector3( 0.0, 0.0, 0.0 ); - interpolateRot_ = Ogre::Quaternion( 1.0, 0.0, 0.0, 0.0 ); - interpolateVel_ = Ogre::Vector3( 0.0, 0.0, 0.0 ); + interpolateRot_ = Ogre::Quaternion( 1.0, 0.0, 0.0, 0.0 ); + interpolateVel_ = Ogre::Vector3( 0.0, 0.0, 0.0 ); - explosion_ = NULL; + explosion_ = NULL; explodeSequenceTime_ = 5.0; - deathSequence_ = false; - breakPressed_ = false; + deathSequence_ = false; + breakPressed_ = false; - netSequence_ = 0; - lifeTime_ = 0.0; - lastLifeTime_ = 0.0; - forceMovement_ = false; - statusChanged_ = false; + netSequence_ = 0; + lifeTime_ = 0.0; + lastLifeTime_ = 0.0; + forceMovement_ = false; + statusChanged_ = false; - lastFrameCount_ = 0; - //** increase this value to add some fog-friction; - ethernalDensity_ = 1.0; - explosion_ = NULL; + lastFrameCount_ = 0; + + ethernalDensity_ = 1.0; } bool SectorObjectMoveable::update( Ogre::Real elapsedTime ){ - if ( elapsedTime < 0.001 ) return true; + if ( elapsedTime < 0.001 ) return true; - if ( destroyRequest_ ){ - std::cout << "SectorObjectMoveable::update( Ogre::Real elapsedTime ) destroy: " << name_ << " " << destroyRequest_ << std::endl; - - return false; - } + if ( destroyRequest_ ){ + std::cout << "SectorObjectMoveable::update( Ogre::Real elapsedTime ) destroy: " << name_ << " " + << destroyRequest_ << std::endl; + return false; + } - lifeTime_ += elapsedTime; - lastFrameCount_ ++; + lifeTime_ += elapsedTime; + lastFrameCount_ ++; - Ogre::Real rotFric = rotFriction(); + Ogre::Real rotFric = rotFriction(); if ( !isChild() ){ mainNode_->yaw( Ogre::Degree( yaw_ * ( moveable_->yaw() * rotFric ) * elapsedTime ) ); @@ -192,7 +191,7 @@ mainNode_->translate( ( vel_ + interpolateVel_ ) * elapsedTime ); //** because of the discrete jumps between to frames we have to check for collisions via ray; - if ( !destroyRequest_ && collObj_ ){ + if ( collObj_ ){ Ogre::Ray rayNoNextPos( mainNode_->getPosition(), vel_.normalisedCopy() ); //** bitte bitte check, ob das vor oder nach dem Move soll bzw, ob die richtung stimmt Modified: trunk/src/SectorObjectMoveable.h =================================================================== --- trunk/src/SectorObjectMoveable.h 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/SectorObjectMoveable.h 2008-05-04 15:50:32 UTC (rev 889) @@ -163,35 +163,35 @@ Ogre::Entity * shieldEntity_; Ogre::SceneNode * shieldEntityNode_; - Ogre::Real yaw_; - Ogre::Real pitch_; - Ogre::Real roll_; + Ogre::Real yaw_; + Ogre::Real pitch_; + Ogre::Real roll_; - Ogre::Vector3 acc_; - Ogre::Vector3 vel_; + Ogre::Vector3 acc_; + Ogre::Vector3 vel_; - Uint32 mass_; + Uint32 mass_; - Uint32 thrust_; - Uint32 maxThrust_; - Ogre::Real thrustRate_; + Uint32 thrust_; + Uint32 maxThrust_; + Ogre::Real thrustRate_; - Uint32 armor_; - Uint32 maxArmor_; + Uint32 armor_; + Uint32 maxArmor_; - Ogre::Real maxSpeed_; + Ogre::Real maxSpeed_; - Uint32 shield_; - Uint32 maxShield_; - bool shieldGlowActive_; - Ogre::Real shieldGlowTime_; + Uint32 shield_; + Uint32 maxShield_; + bool shieldGlowActive_; + Ogre::Real shieldGlowTime_; - bool deathSequence_; - bool breakPressed_; + bool deathSequence_; + bool breakPressed_; - Ogre::Real ethernalDensity_; + Ogre::Real ethernalDensity_; - Ogre::Real explodeSequenceTime_; + Ogre::Real explodeSequenceTime_; Ogre::Quaternion interpolateRot_; Ogre::Vector3 interpolateVel_; Modified: trunk/src/SectorObjectVessel.cpp =================================================================== --- trunk/src/SectorObjectVessel.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/SectorObjectVessel.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -75,7 +75,10 @@ } SectorObjectVessel::~SectorObjectVessel(){ __D( name_ ) - if ( controler_ ) ResourceManager::getSingleton().aiManager->recycle( controler_ ); + if ( controler_ ) { + ResourceManager::getSingleton().aiManager->stopAiObject( controler_ ); + controler_ = NULL; + } shieldEntityNode_->detachObject( shieldEntity_ ); mainNodeEntityRot_->removeAndDestroyChild( shieldEntityNode_->getName() ); @@ -118,9 +121,7 @@ flashfire_ = false; firePressed_ = false; lastShieldSend_ = 0; - maxCapacity_ = 0; - - thrustRate_ = 0; + maxCapacity_ = 0; } bool SectorObjectVessel::update( Ogre::Real elapsedTime ){ @@ -135,8 +136,10 @@ //** object died if ( armor_ <= 0 || deathSequence_ || !SectorObjectMoveable::update( elapsedTime ) ) { - //** we only can destroy this object when all projectiles are end of life - if ( !deathSequence( elapsedTime ) && projectiles_.empty() ) return false; + //** we only can destroy this object when all projectiles are end of life + if ( destroyRequest_ && projectiles_.empty() ) { + return false; + } else if ( !deathSequence( elapsedTime ) && projectiles_.empty() ) return false; return true; } @@ -241,8 +244,8 @@ void SectorObjectVessel::fireMissile( SectorObject * target ){ std::cout << "SectorObjectVessel::fireMissile()" << std::endl; - SectorObjectMissile *missile = sector_->createMissile( "Firefly", userID_, 0, - *EquipmentManager::getSingleton().missile( "Firefly" ) ); + SectorObjectMissile *missile = sector_->createMissile( "firefly", userID_, 0, + *EquipmentManager::getSingleton().missile( "firefly" ) ); missile->setTarget( target ); missile->mainNode()->setOrientation( mainNode_->getWorldOrientation() ); Modified: trunk/src/Station.cpp =================================================================== --- trunk/src/Station.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/Station.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -144,6 +144,7 @@ } else if ( object->rtti() == SECTOROBJECTVESSEL_RTTI ){ std::cout << "docking request for " << object->name() << std::endl; dynamic_cast< SectorObjectVessel * >( object )->controler()->kill(); + object->destroy( ); } } Modified: trunk/src/Station.h =================================================================== --- trunk/src/Station.h 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/Station.h 2008-05-04 15:50:32 UTC (rev 889) @@ -103,7 +103,7 @@ virtual ~StationObject( ); - virtual long getTypeID() const { return STATION_RTTI; } + virtual long rtti() const { return STATION_RTTI; } void collide( BaseObject * object ); Modified: trunk/src/UnDockedState.cpp =================================================================== --- trunk/src/UnDockedState.cpp 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/UnDockedState.cpp 2008-05-04 15:50:32 UTC (rev 889) @@ -21,6 +21,7 @@ #include "UnDockedState.h" #include "AiManager.h" +#include "AiObject.h" #include "Avatar.h" #include "Sector.h" #include "networkProtocol.h" @@ -31,6 +32,7 @@ #include "KeyMap.h" #include "OpenALSoundManager.h" #include "SectorObjectAvatar.h" +#include "Station.h" #include <iostream> @@ -1201,10 +1203,38 @@ } bool UnDockedState::keyActionSelectPreviousTarget( bool pressed ){ - if ( pressed ) setTarget( sector_->prevTarget() ); - return true; + if ( pressed ) setTarget( sector_->prevTarget() ); + return true; } +bool UnDockedState::keyActionDockAssist( bool pressed ){ + if ( pressed ){ + if ( target_ ){ + if ( target_->rtti() == STATION_RTTI ){ + if ( !sector_->avatarObject()->controler() ){ + log_->info( "Docking started." ); + AiObject * ai = resources_->aiManager->createAiObject( "autodocker" ); + ai->setVesselObject( sector_->avatarObject() ); + ai->land( dynamic_cast< StationObject * >( target_ ) ); + resources_->aiManager->startAiObject( ai ); + } else { + log_->info( "Docking aborted." ); + sector_->avatarObject()->setThrustRate( 0.0 ); + sector_->avatarObject()->setScaledYaw( 0.0 ); + sector_->avatarObject()->setScaledPitch( 0.0 ); + sector_->avatarObject()->setScaledRoll( 0.0 ); + sector_->avatarObject()->controler()->kill(); + } + } else { + log_->info( "Selected target is not dockable: " + target_->name() ); + } + } else { + log_->info("No target selected." ); + } + } + return true; +} + bool UnDockedState::keyActionCameraNormal( bool pressed ){ if ( pressed ){ if ( cameraMode_ == 0 ) showHud(); Modified: trunk/src/UnDockedState.h =================================================================== --- trunk/src/UnDockedState.h 2008-05-04 12:13:52 UTC (rev 888) +++ trunk/src/UnDockedState.h 2008-05-04 15:50:32 UTC (rev 889) @@ -41,222 +41,225 @@ class UnDockedState : public GameState{ public: - DECLARE_GAMESTATE_CLASS( UnDockedState ); + DECLARE_GAMESTATE_CLASS( UnDockedState ); - void createContent( ); + void createContent( ); - void destroyContent( ); + void destroyContent( ); - void enter(); + void enter(); - void exit(); + void exit(); - void changeToDockedState(); + void changeToDockedState(); - bool switchConfigDialog( ); + bool switchConfigDialog( ); - virtual void setupEventHandlers(); + virtual void setupEventHandlers(); - virtual bool frameStarted( const Ogre::FrameEvent & evt ); - virtual bool frameEnded( const Ogre::FrameEvent & evt ); + virtual bool frameStarted( const Ogre::FrameEvent & evt ); + virtual bool frameEnded( const Ogre::FrameEvent & evt ); - virtual bool keyPressed( const OIS::KeyEvent & e ); - virtual bool keyReleased( const OIS::KeyEvent & e ); + virtual bool keyPressed( const OIS::KeyEvent & e ); + virtual bool keyReleased( const OIS::KeyEvent & e ); - virtual bool mouseMoved(const OIS::MouseEvent & e ); - virtual bool mousePressed(const OIS::MouseEvent & e, OIS::MouseButtonID id ); - virtual bool mouseReleased(const OIS::MouseEvent & e, OIS::MouseButtonID id ); + virtual bool mouseMoved(const OIS::MouseEvent & e ); + virtual bool mousePressed(const OIS::MouseEvent & e, OIS::MouseButtonID id ); + virtual bool mouseReleased(const OIS::MouseEvent & e, OIS::MouseButtonID id ); - virtual bool axisMoved( const OIS::JoyStickEvent & e, int axis ); - virtual bool buttonPressed( const OIS::JoyStickEvent & e, int axis ); - virtual bool buttonReleased( const OIS::JoyStickEvent & e, int axis ); + virtual bool axisMoved( const OIS::JoyStickEvent & e, int axis ); + virtual bool buttonPressed( const OIS::JoyStickEvent & e, int axis ); + virtual bool buttonReleased( const OIS::JoyStickEvent & e, int axis ); - virtual void avatarDeathSequence( bool on ); + virtual void avatarDeathSequence( bool on ); - bool renderSpaceDust(); + bool renderSpaceDust(); - void setTarget( SectorObject * target ); + void setTarget( SectorObject * target ); - bool maximiseConsole( ); - bool minimiseConsole( ); + bool maximiseConsole( ); + bool minimiseConsole( ); - SectorObject * target( ) { return target_; } + SectorObject * target( ) { return target_; } - Sector * sector( ) { return sector_; } + Sector * sector( ) { return sector_; } - void showHud(); - void hideHud(); + void showHud(); + void hideHud(); - bool keyActionDoNothing( bool pressed = true ) { return false; } - bool keyActionSwitchMinMaxConsole( bool pressed = true ); + bool keyActionDoNothing( bool pressed = true ) { return false; } + bool keyActionSwitchMinMaxConsole( bool pressed = true ); - bool keyActionAvatarIncreaseYaw( bool pressed = true ); - bool keyActionAvatarDecreaseYaw( bool pressed = true ); - bool keyActionAvatarIncreasePitch( bool pressed = true ); - bool keyActionAvatarDecreasePitch( bool pressed = true ); - bool keyActionAvatarIncreaseRoll( bool pressed = true ); - bool keyActionAvatarDecreaseRoll( bool pressed = true ); + bool keyActionAvatarIncreaseYaw( bool pressed = true ); + bool keyActionAvatarDecreaseYaw( bool pressed = true ); + bool keyActionAvatarIncreasePitch( bool pressed = true ); + bool keyActionAvatarDecreasePitch( bool pressed = true ); + bool keyActionAvatarIncreaseRoll( bool pressed = true ); + bool keyActionAvatarDecreaseRoll( bool pressed = true ); - bool keyActionSelectTextTarget( bool pressed = true ); - bool keyActionSelectPreviousTarget( bool pressed = true ); + /*! Start docking assistent. A dockable station must selected */ + bool keyActionDockAssist( bool pressed = true ); - bool keyActionCameraNormal( bool pressed = true ); - bool keyActionCameraLeft( bool pressed = true ); - bool keyActionCameraRight( bool pressed = true ); - bool keyActionCameraUp( bool pressed = true ); - bool keyActionCameraDown( bool pressed = true ); - bool keyActionCameraToggle( bool pressed = true ); + bool keyActionSelectTextTarget( bool pressed = true ); + bool keyActionSelectPreviousTarget( bool pressed = true ); - /*! center avatar stop yaw/pitch/roll */ - bool keyActionAvatarCenter( bool pressed = true ); + bool keyActionCameraNormal( bool pressed = true ); + bool keyActionCameraLeft( bool pressed = true ); + bool keyActionCameraRight( bool pressed = true ); + bool keyActionCameraUp( bool pressed = true ); + bool keyActionCameraDown( bool pressed = true ); + bool keyActionCameraToggle( bool pressed = true ); - /*! Avatar increase thrust by 10% */ - bool keyActionAvatarIncrementThrust( bool pressed = true ); + /*! center avatar stop yaw/pitch/roll */ + bool keyActionAvatarCenter( bool pressed = true ); - /*! Avatar decrease thrust by 10% */ - bool keyActionAvatarDecrementThrust( bool pressed = true ); + /*! Avatar increase thrust by 10% */ + bool keyActionAvatarIncrementThrust( bool pressed = true ); - bool keyActionAvatarBreakPressed( bool pressed = true ); - bool keyActionAvatarAfterburnerPressed( bool pressed = true ); + /*! Avatar decrease thrust by 10% */ + bool keyActionAvatarDecrementThrust( bool pressed = true ); - /*! Actions for development, will removed later. */ - bool keyActionTogglePolygonMode_DEV( bool pressed = true ); - bool keyActionToggleFiltering_DEV( bool pressed = true ); + bool keyActionAvatarBreakPressed( bool pressed = true ); + bool keyActionAvatarAfterburnerPressed( bool pressed = true ); - bool keyActionIncreaseAmbientLight_DEV( bool pressed = true ); - bool keyActionDecreaseAmbientLight_DEV( bool pressed = true ); + /*! Actions for development, will removed later. */ + bool keyActionTogglePolygonMode_DEV( bool pressed = true ); + bool keyActionToggleFiltering_DEV( bool pressed = true ); - bool keyActionIncreaseShaderScheme_DEV( bool pressed = true ); - bool keyActionDecreaseShaderScheme_DEV( bool pressed = true ); + bool keyActionIncreaseAmbientLight_DEV( bool pressed = true ); + bool keyActionDecreaseAmbientLight_DEV( bool pressed = true ); - bool keyActionAvatarSwitchDuelistPilot_DEV( bool pressed = true ); - bool keyActionAvatarSwitchDuelistTarget_DEV( bool pressed = true ); - bool keyActionAvatarChangeDockedState_DEV( bool pressed = true ); - bool keyActionAvatarSelfDestruct_DEV( bool pressed = true ); - bool keyActionSpawnAi_DEV( bool pressed = true ); - bool keyActionShowInfos_DEV( bool pressed = true ); -protected: - UnDockedState( ); - virtual ~UnDockedState( ){} + bool keyActionIncreaseShaderScheme_DEV( bool pressed = true ); + bool keyActionDecreaseShaderScheme_DEV( bool pressed = true ); - inline bool handleMaximiseConsole( const CEGUI::EventArgs & e ){ maximiseConsole(); return true; } - inline bool handleMinimiseConsole( const CEGUI::EventArgs & e ){ minimiseConsole(); return true; } - inline bool handleConfigBackButton( const CEGUI::EventArgs & e ){ return switchConfigDialog( ); } + bool keyActionAvatarSwitchDuelistPilot_DEV( bool pressed = true ); + bool keyActionAvatarSwitchDuelistTarget_DEV( bool pressed = true ); + bool keyActionAvatarChangeDockedState_DEV( bool pressed = true ); + bool keyActionAvatarSelfDestruct_DEV( bool pressed = true ); + bool keyActionSpawnAi_DEV( bool pressed = true ); + bool keyActionShowInfos_DEV( bool pressed = true ); - void setAmbientLight_(); - void setScheme_(); - void toggleNextCamera_( int mode = -1 ); - void updateCamera_( Ogre::Real elapsedTime ); - void updateHUD_( Ogre::Real elapsedTime ); +protected: + UnDockedState( ); + virtual ~UnDockedState( ){} - bool projectionPos_( Ogre::Camera * cam, const Ogre::Vector3 & pos, Ogre::Vector3 & screenPos ); - bool projectionPosAndSize_( Ogre::Camera * cam, const Ogre::Vector3 & pos, const Ogre::Real rad, - Ogre::Real & x, Ogre::Real & y, Ogre::Real & cx, Ogre::Real & cy ); + inline bool handleMaximiseConsole( const CEGUI::EventArgs & e ){ maximiseConsole(); return true; } + inline bool handleMinimiseConsole( const CEGUI::EventArgs & e ){ minimiseConsole(); return true; } + inline bool handleConfigBackButton( const CEGUI::EventArgs & e ){ return switchConfigDialog( ); } - Ogre::RenderWindow * window_; - Ogre::Root * root_; - Ogre::SceneManager * sceneMgr_; + void setAmbientLight_(); + void setScheme_(); + void toggleNextCamera_( int mode = -1 ); + void updateCamera_( Ogre::Real elapsedTime ); + void updateHUD_( Ogre::Real elapsedTime ); - Ogre::Camera * mainCamera_; - Ogre::Camera * secondCamera_; - Sector * sector_; - NetworkClient * network_; + bool projectionPos_( Ogre::Camera * cam, const Ogre::Vector3 & pos, Ogre::Vector3 & screenPos ); + bool projectionPosAndSize_( Ogre::Camera * cam, const Ogre::Vector3 & pos, const Ogre::Real rad, + Ogre::Real & x, Ogre::Real & y, Ogre::Real & cx, Ogre::Real & cy ); - Ogre::Vector2 flightCursorPos_; - CEGUI::Window * flightCursor_; - Ogre::Real flightCursorHalfWidth_; - Ogre::Real flightCursorHalfHeight_; + Ogre::RenderWindow * window_; + Ogre::Root * root_; + Ogre::SceneManager * sceneMgr_; - CEGUI::Window * targetCursor_; - Ogre::Real targetCursorHalfWidth_; - Ogre::Real targetCursorHalfHeight_; + Ogre::Camera * mainCamera_; + Ogre::Camera * secondCamera_; + Sector * sector_; + NetworkClient * network_; - CEGUI::Window * pilotFlightCursor_; - Ogre::Real pilotFlightCursorHalfWidth_; - Ogre::Real pilotFlightCursorHalfHeight_; + Ogre::Vector2 flightCursorPos_; + CEGUI::Window * flightCursor_; + Ogre::Real flightCursorHalfWidth_; + Ogre::Real flightCursorHalfHeight_; - CEGUI::Window * targetFlightCursor_; - Ogre::Real targetFlightCursorHalfWidth_; - Ogre::Real targetFlightCursorHalfHeight_; + CEGUI::Window * targetCursor_; + Ogre::Real targetCursorHalfWidth_; + Ogre::Real targetCursorHalfHeight_; - CEGUI::Window * velocityProgress_; - CEGUI::Window * velocityProgressImg_; - Ogre::Real velocityProgressHeight_; + CEGUI::Window * pilotFlightCursor_; + Ogre::Real pilotFlightCursorHalfWidth_; + Ogre::Real pilotFlightCursorHalfHeight_; - CEGUI::Window * thrustProgress_; - CEGUI::Window * thrustProgressImg_; - Ogre::Real thrustProgressHeight_; + CEGUI::Window * targetFlightCursor_; + Ogre::Real targetFlightCursorHalfWidth_; + Ogre::Real targetFlightCursorHalfHeight_; - CEGUI::Window * fuelProgress_; - CEGUI::Window * fuelProgressImg_; - Ogre::Real fuelProgressHeight_; + CEGUI::Window * velocityProgress_; + CEGUI::Window * velocityProgressImg_; + Ogre::Real velocityProgressHeight_; - CEGUI::Window * capacitorProgress_; - CEGUI::Window * capacitorProgressImg_; - Ogre::Real capacitorProgressHeight_; + CEGUI::Window * thrustProgress_; + CEGUI::Window * thrustProgressImg_; + Ogre::Real thrustProgressHeight_; - CEGUI::Window * armorProgress_; - CEGUI::Window * armorProgressLeftImg_; - CEGUI::Window * armorProgressRightImg_; - Ogre::Real armorProgressHeight_; + CEGUI::Window * fuelProgress_; + CEGUI::Window * fuelProgressImg_; + Ogre::Real fuelProgressHeight_; - CEGUI::Window * shieldProgress_; - CEGUI::Window * shieldProgressLeftImg_; - CEGUI::Window * shieldProgressRightImg_; - Ogre::Real shieldProgressHeight_; + CEGUI::Window * capacitorProgress_; + CEGUI::Window * capacitorProgressImg_; + Ogre::Real capacitorProgressHeight_; - CEGUI::Window * velocityText_; - CEGUI::Window * conText_; - CEGUI::Window * armorText_; - CEGUI::Window * shieldText_; + CEGUI::Window * armorProgress_; + CEGUI::Window * armorProgressLeftImg_; + CEGUI::Window * armorProgressRightImg_; + Ogre::Real armorProgressHeight_; - CEGUI::Window * targetDistanceText_; - CEGUI::Window * targetVelocity_; - CEGUI::Window * targetShieldText_; - CEGUI::Window * targetArmorText_; + CEGUI::Window * shieldProgress_; + CEGUI::Window * shieldProgressLeftImg_; + CEGUI::Window * shieldProgressRightImg_; + Ogre::Real shieldProgressHeight_; - std::string overlayName_; - bool hudIsVisible_; - Ogre::Overlay * hudOverlay_; - Ogre::OverlayElement * mousePointer_; - // Ogre::SceneNode * hudTarget_; - // Ogre::SceneNode * targetPointer_; - SectorObject * target_; - // Ogre::Billboard *targetPointerBB_; + CEGUI::Window * velocityText_; + CEGUI::Window * conText_; + CEGUI::Window * armorText_; + CEGUI::Window * shieldText_; - Ogre::ParticleSystem * spaceDustParticleSystem_; + CEGUI::Window * targetDistanceText_; + CEGUI::Window * targetVelocity_; + CEGUI::Window * targetShieldText_; + CEGUI::Window * targetArmorText_; - bool enterDockedState_; + std::string overlayName_; + bool hudIsVisible_; + Ogre::Overlay * hudOverlay_; + Ogre::OverlayElement * mousePointer_; + // Ogre::SceneNode * hudTarget_; + // Ogre::SceneNode * targetPointer_; + SectorObject * target_; + // Ogre::Billboard *targetPointerBB_; - double timeSinceLastSectorUpdate_; - double timeSinceLastNetworkUpdate_; - double timeSinceLastHudUpdate_; - int cameraMode_; - int cameraViewKey_; - Ogre::Real cameraZoom_; - Ogre::Degree cameraRotateX_; - Ogre::Degree cameraRotateY_; + Ogre::ParticleSystem * spaceDustParticleSystem_; - int windowsWidth_; - int windowsHeight_; - int windowsHalfWidth_; - int windowsHalfHeight_; + bool enterDockedState_; - std::string chatString_; - bool chatMode_; - bool configMode_; - bool consoleMax_; - bool duelistPilot_; - bool duelistTarget_; + double timeSinceLastSectorUpdate_; + double timeSinceLastNetworkUpdate_; + double timeSinceLastHudUpdate_; + int cameraMode_; + int cameraViewKey_; + Ogre::Real cameraZoom_; + Ogre::Degree cameraRotateX_; + Ogre::Degree cameraRotateY_; - int sceneDetailIndex_ ; - int ambientLight_; - int schemeIdx_; - Ogre::TextureFilterOptions filtering_; - int aniso_; + int windowsWidth_; + int windowsHeight_; + int windowsHalfWidth_; + int windowsHalfHeight_; + std::string chatString_; + bool chatMode_; + bool configMode_; + bool consoleMax_; + bool duelistPilot_; + bool duelistTarget_; - OpenALSoundSource * soundBackround_; + int sceneDetailIndex_ ; + int ambientLight_; + int schemeIdx_; + Ogre::TextureFilterOptions filtering_; + int aniso_; + + OpenALSoundSource * soundBackround_; }; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spo...@us...> - 2008-05-12 13:08:07
|
Revision: 894 http://opengate.svn.sourceforge.net/opengate/?rev=894&view=rev Author: spom_spom Date: 2008-05-12 06:08:10 -0700 (Mon, 12 May 2008) Log Message: ----------- Cleaning opcodewrapper and remove a related bug Modified Paths: -------------- trunk/src/AiCommands.cpp trunk/src/AiCommands.h trunk/src/BaseObject.cpp trunk/src/BaseObject.h trunk/src/OpcodeWrapper.cpp trunk/src/OpcodeWrapper.h trunk/src/Sector.cpp trunk/src/SectorObject.cpp trunk/src/SectorObject.h trunk/src/SectorObjectMissile.cpp trunk/src/SectorObjectMoveable.cpp trunk/src/SectorObjectVessel.cpp trunk/src/Station.cpp trunk/src/Station.h Modified: trunk/src/AiCommands.cpp =================================================================== --- trunk/src/AiCommands.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/AiCommands.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -31,7 +31,7 @@ namespace OpenGate{ void AiCommandStop::start(){ - std::cout << "AiCommandStop start" << std::endl; + std::cout << "AiCommandStop start" << std::endl; if ( ai_->vesselObject( ) ) ai_->vesselObject( )->setThrustRate( 0.0 ); if ( turnaround_ ){ addCommand( new AiCommandPitch( ai_, 180.0 ) ); @@ -40,9 +40,9 @@ addCommand( new AiCommandStop( ai_ ) ); } else { if ( ai_->vesselObject( ) ) ai_->vesselObject( )->setBreakPressed( true ); - std::cout << "braking speed: " << ai_->vesselObject( )->speed() << std::endl; - std::cout << "braking time est: " << ai_->brakingTime( ai_->vesselObject( )->speed() ) << std::endl; - std::cout << "braking way est: " << ai_->brakingDistance( ai_->vesselObject( )->speed() ) << std::endl; +// std::cout << "braking speed: " << ai_->vesselObject( )->speed() << std::endl; +// std::cout << "braking time est: " << ai_->brakingTime( ai_->vesselObject( )->speed() ) << std::endl; +// std::cout << "braking way est: " << ai_->brakingDistance( ai_->vesselObject( )->speed() ) << std::endl; startPos_ = ai_->vesselObject( )->mainNode()->getWorldPosition(); } } @@ -56,10 +56,10 @@ std::cout << "AiCommandStop stop" << std::endl; if ( ai_->vesselObject( ) ) { ai_->vesselObject( )->setBreakPressed( false ); - std::cout << "braking time real: " << runtime_ << std::endl; - std::cout << "braking way real: " - << ( ai_->vesselObject( )->mainNode()->getWorldPosition()- startPos_ ).length() - << std::endl; +// std::cout << "braking time real: " << runtime_ << std::endl; +// std::cout << "braking way real: " +// << ( ai_->vesselObject( )->mainNode()->getWorldPosition()- startPos_ ).length() +// << std::endl; } } @@ -95,14 +95,14 @@ std::cout << "AiCommandLookAt::start()" << std::endl; if ( ai_->vesselObject() ){ if ( isPosition_ ) { - std::cout << "ai pos: " << ai_->vesselObject()->mainNode()->getWorldPosition() << std::endl; - std::cout << "target: " << targetDir_ << std::endl; +// std::cout << "ai pos: " << ai_->vesselObject()->mainNode()->getWorldPosition() << std::endl; +// std::cout << "target: " << targetDir_ << std::endl; targetDir_ = targetDir_ - ai_->vesselObject()->mainNode()->getWorldPosition(); } targetDir_.normalise(); - std::cout << "ai dir: " << ai_->vesselObject()->mainNode()->getWorldOrientation() - * Ogre::Vector3::NEGATIVE_UNIT_Z << std::endl; - std::cout << "target: " << targetDir_ << std::endl; +// std::cout << "ai dir: " << ai_->vesselObject()->mainNode()->getWorldOrientation() +// * Ogre::Vector3::NEGATIVE_UNIT_Z << std::endl; +// std::cout << "target: " << targetDir_ << std::endl; } } bool AiCommandLookAt::update( ){ @@ -199,8 +199,8 @@ ai_->vesselObject()->setScaledYaw( 0.0 ); ai_->vesselObject()->setScaledPitch( 0.0 ); ai_->vesselObject()->setScaledRoll( 0.0 ); - std::cout << "curr: " << ai_->vesselObject()->mainNode()->getWorldOrientation() - * Ogre::Vector3::NEGATIVE_UNIT_Z << std::endl; +// std::cout << "curr: " << ai_->vesselObject()->mainNode()->getWorldOrientation() +// * Ogre::Vector3::NEGATIVE_UNIT_Z << std::endl; } } @@ -247,10 +247,10 @@ std::cout << "AiCommandTimedAccelerate stop" << std::endl; if ( ai_->vesselObject( ) ){ ai_->vesselObject( )->setThrustRate( 0.0 ); - std::cout << " reclined way(real): " - << (ai_->vesselObject( )->mainNode()->getWorldPosition()- initPos_).length() << std::endl; - std::cout << " reclined way(ana): " - << ai_->wayAfterTime( runtime_, rate_ ) << std::endl; +// std::cout << " reclined way(real): " +// << (ai_->vesselObject( )->mainNode()->getWorldPosition()- initPos_).length() << std::endl; +// std::cout << " reclined way(ana): " +// << ai_->wayAfterTime( runtime_, rate_ ) << std::endl; } } @@ -285,10 +285,10 @@ void AiCommandAccelerate::stop(){ std::cout << "AiCommandAccelerate::stop" << std::endl; if ( ai_->vesselObject( ) ) ai_->vesselObject( )->setThrustRate( 0.0 ); - std::cout << " reclined way(real): " - << (ai_->vesselObject( )->mainNode()->getWorldPosition()- initPos_).length() << std::endl; - std::cout << " reclined way(ana): " - << ai_->wayAfterTime( runtime_, thrustRate_ ) << std::endl; +// std::cout << " reclined way(real): " +// << (ai_->vesselObject( )->mainNode()->getWorldPosition()- initPos_).length() << std::endl; +// std::cout << " reclined way(ana): " +// << ai_->wayAfterTime( runtime_, thrustRate_ ) << std::endl; } @@ -297,9 +297,9 @@ if ( ai_->vesselObject( ) ) { startPos_ = ai_->vesselObject( )->mainNode()->getWorldPosition(); initDist_ = ( pos_ - ai_->vesselObject( )->mainNode()->getWorldPosition() ).length(); - std::cout << "ai pos: " << startPos_ << std::endl; - std::cout << "dist: " << initDist_ << std::endl; - std::cout << "target: " << pos_ << std::endl; +// std::cout << "ai pos: " << startPos_ << std::endl; +// std::cout << "dist: " << initDist_ << std::endl; +// std::cout << "target: " << pos_ << std::endl; } addCommand( new AiCommandLookAt( ai_, pos_, true ) ); addCommand( new AiCommandSetThrust( ai_, 1.0 ) ); @@ -318,7 +318,7 @@ } if ( ai_->vesselObject( )->speed() < 0.05 ){ - std::cout << "dist: " << dist << std::endl; +// std::cout << "dist: " << dist << std::endl; if ( dist < 10.0 ) { // 10m snapping return false; } else { @@ -339,12 +339,12 @@ std::cout << "AiCommandApproach::stop():" << std::endl; if ( ai_->vesselObject( ) ) { ai_->vesselObject( )->setThrustRate( 0.0 ); - std::cout << "ai pos: " << ai_->vesselObject( )->mainNode()->getWorldPosition() << std::endl; - std::cout << "dir: " << -ai_->vesselObject( )->mainNode()->getWorldOrientation().zAxis() - << std::endl; - std::cout << "pos: " - << startPos_ + initDist_ * -ai_->vesselObject( )->mainNode()->getWorldOrientation().zAxis() - << std::endl; +// std::cout << "ai pos: " << ai_->vesselObject( )->mainNode()->getWorldPosition() << std::endl; +// std::cout << "dir: " << -ai_->vesselObject( )->mainNode()->getWorldOrientation().zAxis() +// << std::endl; +// std::cout << "pos: " +// << startPos_ + initDist_ * -ai_->vesselObject( )->mainNode()->getWorldOrientation().zAxis() +// << std::endl; } } Modified: trunk/src/AiCommands.h =================================================================== --- trunk/src/AiCommands.h 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/AiCommands.h 2008-05-12 13:08:10 UTC (rev 894) @@ -81,9 +81,9 @@ bool abort( ) { abort_ = true; } - virtual void start() { std::cout << "AiCommand start" << std::endl; } + virtual void start() { std::cout << "AiCommand start (virtual) " << std::endl; } virtual bool update( ) { return false; } - virtual void stop() { std::cout << "AiCommand stop" << std::endl; } + virtual void stop() { std::cout << "AiCommand stop (virtual)" << std::endl; } void addCommand( AiCommand * cmd ) { cmdQueue_.push_back( cmd ); } Modified: trunk/src/BaseObject.cpp =================================================================== --- trunk/src/BaseObject.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/BaseObject.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -63,4 +63,8 @@ } } +void BaseObject::destroy(){ + destroyRequest_ = true; +} + } // namespace OpenGate Modified: trunk/src/BaseObject.h =================================================================== --- trunk/src/BaseObject.h 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/BaseObject.h 2008-05-12 13:08:10 UTC (rev 894) @@ -91,7 +91,7 @@ /*! Mark the object for destruction To keep destruction thread safe, we just notify and let the update cycle do the job */ - void destroy() { destroyRequest_ = true; } + void destroy(); bool isSetDestroyRequest() const { return destroyRequest_; } @@ -101,6 +101,14 @@ inline virtual bool isActive() const { return active_; } + OgreOpcode::CollisionObject * collisionObject( ){ return collObj_; } + + void setCollisionObject( OgreOpcode::CollisionObject * obj ){ collObj_ = obj; } + + virtual std::string collisionClass() const { return "SectorObject"; } + + virtual Ogre::Entity * entity(){ return NULL; } + protected: virtual void deactivate_(){ } Modified: trunk/src/OpcodeWrapper.cpp =================================================================== --- trunk/src/OpcodeWrapper.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/OpcodeWrapper.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -71,10 +71,6 @@ void OpcodeCollisionDetection::free( ){ - std::vector< OgreOpcode::CollisionObject * > activeObjects( collideInSectorContext_->getAttachedObjects() ); - - std::cout << "OpcodeCollisionDetection::free( ) " << activeObjects.size() << std::endl; - if ( collisionManager_ ) delete collisionManager_; collisionManager_ = NULL; } @@ -87,91 +83,79 @@ int nCollids = report.getNumCollisions(); if ( nCollids > 0 ){ - // std::cout << "Collisions: " << nCollids << std::endl; +// std::cout << "OpcodeCollisionDetection::update() " << nCollids << std::endl; OgreOpcode::CollisionPair **collisionReport; report.getAllCollisions( collisionReport ); - for ( int i = 0; i < nCollids; i ++ ){ - OgreOpcode::CollisionObject* col1 = collisionReport[ i ]->this_object; - OgreOpcode::CollisionObject* col2 = collisionReport[ i ]->other_object; - - static_cast< BaseObject * >( col1->getClientData() )->collide( static_cast< BaseObject * >( + for ( int i = 0; i < nCollids; i ++ ){ + OgreOpcode::CollisionObject* col1 = collisionReport[ i ]->this_object; + OgreOpcode::CollisionObject* col2 = collisionReport[ i ]->other_object; + +// std::cout << i << ": "<< col1->getName() << "<->" << col2->getName() << std::endl; + + static_cast< BaseObject * >( col1->getClientData() )->collide( static_cast< BaseObject * >( col2->getClientData() ) ); - static_cast< BaseObject * >( col2->getClientData() )->collide( static_cast< BaseObject * >( + 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(collisionManager_->getShapeCount())<< std::endl; - + } } // if ncols } return true; } -OgreOpcode::CollisionObject * OpcodeCollisionDetection::createObject( Ogre::Entity * entity, BaseObject * obj, - const std::string & collClass ){ - OgreOpcode::CollisionObject * collObj = NULL; +void OpcodeCollisionDetection::createObject( BaseObject * obj ){ - if ( active_ ){ - OgreOpcode::EntityCollisionShape * collShape = collisionManager_->createEntityCollisionShape( obj->name() + "/CollShape" ); - collShape->load( entity ); + if ( obj && active_ ){ + if ( !obj->collisionObject() ){ + + OgreOpcode::EntityCollisionShape * collShape = collisionManager_->createEntityCollisionShape( obj->name() + "/CollShape" ); + if ( obj->entity() ){ + collShape->load( obj->entity() ); + } else { + std::cout << "OpcodeCollisionDetection::createObject( BaseObject * obj ), no entity defined for obj: " << obj->name(); + } - collObj = collideInSectorContext_->createObject( obj->name() + "/CollObj" ); - collObj->setCollClass( collisionManager_->queryCollClass( collClass ) ); - collObj->setShape( collShape ); - collideInSectorContext_->addObject( collObj ); - attachedSet_.insert( collObj ); - collObj->setClientData( obj ); + OgreOpcode::CollisionObject * collObj = collideInSectorContext_->createObject( obj->name() + "/CollObj" ); + collObj->setContext( collideInSectorContext_ ); + collObj->setCollClass( collisionManager_->queryCollClass( obj->collisionClass() ) ); + collObj->setShape( collShape ); + collideInSectorContext_->addObject( collObj ); + collObj->setClientData( obj ); + obj->setCollisionObject( collObj ); + } } - return collObj; } -OgreOpcode::CollisionObject * OpcodeCollisionDetection::createObject( SectorObject * obj ){ - return createObject( obj->entity(), obj, "SectorObject" ); +void OpcodeCollisionDetection::destroyObject( BaseObject * obj ){ + + if ( obj && active_ ){ + if ( obj->collisionObject() ){ + + OgreOpcode::CollisionObject * collObj = obj->collisionObject(); + OgreOpcode::ICollisionShape * shape = collObj->getShape(); + collideInSectorContext_->destroyObject( collObj ); + + collisionManager_->detachShape( shape ); + collisionManager_->destroyShape( shape ); + obj->setCollisionObject( NULL ); + } + } } -void OpcodeCollisionDetection::dettach( OgreOpcode::CollisionObject * obj ){ +void OpcodeCollisionDetection::dettach( SectorObject * obj ){ if ( obj && active_ ){ - - if ( attachedSet_.find( obj ) != attachedSet_.end() ){ - // std::cout << "dettach"<< std::endl; - collideInSectorContext_->removeObject( obj ); - attachedSet_.erase( obj ); - } + destroyObject( obj ); } } -void OpcodeCollisionDetection::attach( OgreOpcode::CollisionObject * obj ){ +void OpcodeCollisionDetection::attach( SectorObject * obj ){ if ( obj && active_ ){ - - if ( attachedSet_.find( obj ) == attachedSet_.end() ){ - - collideInSectorContext_->addObject( obj ); - attachedSet_.insert( obj ); - } + createObject( obj ); } } -void OpcodeCollisionDetection::destroyObject( OgreOpcode::CollisionObject * obj ){ - - if ( active_ ){ - OgreOpcode::ICollisionShape * shape = obj->getShape(); - if ( obj && attachedSet_.find( obj ) == attachedSet_.end() ){ - attach( obj ); - } - collideInSectorContext_->destroyObject( obj ); - attachedSet_.erase( obj ); - - collisionManager_->detachShape( shape ); - collisionManager_->destroyShape( shape ); - obj = NULL; - } -} - bool OpcodeCollisionDetection::checkCollideRay( BaseObject * obj, const Ogre::Ray & ray, double rayLength){ if ( active_ ){ if ( !obj->isSetDestroyRequest() ){ @@ -180,7 +164,7 @@ uint nColl = collideInSectorContext_->rayCheck( ray, rayLength, OgreOpcode::COLLTYPE_EXACT, OgreOpcode::COLLTYPE_ALWAYS_EXACT, rayPickReport ); - // std::cout << "checkCollideRay: " << " " << rayLength << " " << nColl <<std::endl; + std::cout << "OpcodeCollisionDetection::checkCollideRay()" << " " << rayLength << " " << nColl <<std::endl; for ( uint i = 0; i < nColl; i ++ ){ OgreOpcode::CollisionObject* col1 = rayPickReport[ i ]->this_object; @@ -208,22 +192,22 @@ return false; } -void OpcodeCollisionDetection::changeCollClass( OgreOpcode::CollisionObject * collObj, const std::string & collClass ){ - if ( collObj ) collObj->setCollClass( collisionManager_->queryCollClass( collClass ) ); +void OpcodeCollisionDetection::info( ){ + std::cout << "OpcodeCollisionDetection::info( )" << std::endl; + + std::vector< OgreOpcode::CollisionObject * > activeObjects( collideInSectorContext_->getAttachedObjects() ); + std::cout << "CollisionContext attached objects: " + Ogre::StringConverter::toString(collideInSectorContext_->getAttachedObjectCount()) << std::endl; + for ( uint i = 0; i < activeObjects.size(); i ++ ){ + std::cout << i << ": " << activeObjects[ i ]->getName() << std::endl; + } + + std::vector< OgreOpcode::CollisionObject * > ownedObjects( collideInSectorContext_->getOwnedObjects() ); + std::cout << "CollisionContext owned objects: " + Ogre::StringConverter::toString(collideInSectorContext_->getOwnedObjectCount()) << std::endl; + for ( uint i = 0; i < ownedObjects.size(); i ++ ){ + std::cout << i << ": " << ownedObjects[ i ]->getName() << std::endl; + } + std::cout << "CollisionManager shapes: " + Ogre::StringConverter::toString(collisionManager_->getShapeCount())<< std::endl; + } -// OpcodeCollisionDetection & OpcodeCollisionDetection::getSingleton( ){ -// assert( ms_Singleton ); -// return ( *ms_Singleton ); -// } -// -// OpcodeCollisionDetection * OpcodeCollisionDetection::getSingletonPtr( ){ -// if ( ms_Singleton == NULL ){ -// std::cerr << "OpcodeCollisionDetection not initialized." << std::endl; -// return NULL; -// } -// return ms_Singleton; -// } - - } // namespace OpenGate{ Modified: trunk/src/OpcodeWrapper.h =================================================================== --- trunk/src/OpcodeWrapper.h 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/OpcodeWrapper.h 2008-05-12 13:08:10 UTC (rev 894) @@ -50,27 +50,22 @@ bool update( Ogre::Real elapsedTime ); - OgreOpcode::CollisionObject * createObject( Ogre::Entity * entity, BaseObject * obj, const std::string & collClass ); - - OgreOpcode::CollisionObject * createObject( SectorObject * obj ); + void createObject( BaseObject * obj ); - void destroyObject( OgreOpcode::CollisionObject * obj ); + void destroyObject( BaseObject * obj ); - void dettach( OgreOpcode::CollisionObject * obj ); + void dettach( SectorObject * obj ); - void attach( OgreOpcode::CollisionObject * obj ); + void attach( SectorObject * obj ); bool checkCollideRay( BaseObject * obj, const Ogre::Ray & ray, double rayLength ); - - void changeCollClass( OgreOpcode::CollisionObject * collObj, const std::string & collClass ); + void info( ); + protected: OgreOpcode::CollisionContext * collideInSectorContext_; OgreOpcode::CollisionManager * collisionManager_; bool active_; - - //** das brauchen zum einfachen dettach/attach, OgreOpcode gibt uns diese Infos nicht. - std::set < OgreOpcode::CollisionObject * > attachedSet_; }; Modified: trunk/src/Sector.cpp =================================================================== --- trunk/src/Sector.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/Sector.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -588,7 +588,7 @@ void Sector::destruct_( SectorObject * obj ){ if ( obj ){ - log_->debug( "Sector::destruct_ object: " + obj->name() + " " + toStr( obj->rtti() ) ); +// log_->debug( "Sector::destruct_ object: " + obj->name() + " " + toStr( obj->rtti() ) ); sectorObjects_.erase( obj ); if ( listener_->target() == obj ) selectNextTarget( ); Modified: trunk/src/SectorObject.cpp =================================================================== --- trunk/src/SectorObject.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/SectorObject.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -63,9 +63,8 @@ Ogre::OverlayManager::getSingleton().destroyOverlayElement( "Radar/Map/DotA_" + name_ ); Ogre::OverlayManager::getSingleton().destroyOverlayElement( "Radar/Map/DotB_" + name_ ); - if ( collObj_ ) ResourceManager::getSingleton().collisionManager->destroyObject( collObj_ ); - collObj_ = NULL; - + ResourceManager::getSingleton().collisionManager->destroyObject( this ); + mainNodeEntityRot_->detachObject( entity_ ); sceneMgr_->destroyEntity( entity_ ); @@ -86,7 +85,7 @@ void SectorObject::setShape( const Ogre::String & meshname ){ entity_ = sceneMgr_->createEntity( name_ + "_shape", meshname ); mainNodeEntityRot_->attachObject( entity_ ); - collObj_ = ResourceManager::getSingleton().collisionManager->createObject( this ); + ResourceManager::getSingleton().collisionManager->createObject( this ); } void SectorObject::setBaseRot( const Ogre::Real & yaw, const Ogre::Real & pitch, const Ogre::Real & roll ){ Modified: trunk/src/SectorObject.h =================================================================== --- trunk/src/SectorObject.h 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/SectorObject.h 2008-05-12 13:08:10 UTC (rev 894) @@ -56,7 +56,7 @@ void setShape( const Ogre::String & meshname ); void setShape( Ogre::MeshPtr & mesh ); - Ogre::Entity * entity(){ return entity_; } + virtual Ogre::Entity * entity(){ return entity_; } void scale( const Ogre::Vector3 & scale ); Modified: trunk/src/SectorObjectMissile.cpp =================================================================== --- trunk/src/SectorObjectMissile.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/SectorObjectMissile.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -62,7 +62,7 @@ } bool SectorObjectMissile::update( Ogre::Real elapsedTime ){ - if ( launched_ ) { + if ( launched_ && !destroyRequest_) { if ( target_ != NULL && elapsedTime > 1e-4 ) { Ogre::Vector3 currDir = mainNode_->getWorldOrientation() * Ogre::Vector3::NEGATIVE_UNIT_Z; @@ -119,7 +119,7 @@ missileLifetime_ -= elapsedTime; } - if ( missileLifetime_ < 0 ) explode(); + if ( missileLifetime_ < 0 && ! destroyRequest_ ) explode(); return SectorObjectMoveable::update( elapsedTime ); } @@ -127,7 +127,7 @@ void SectorObjectMissile::collide( BaseObject * object ){ if ( ( this->missile()->lifetime() - missileLifetime_ ) > 0.1 ){ - std::cout << "SectorObjectMissile::collide: " << name_ << "<->" << object->name() << std::endl; + std::cout << "SectorObjectMissile::collide: " << name_ << "<->" << object->name() << " " << missileLifetime_<< std::endl; this->setVelocity( Ogre::Vector3::ZERO ); this->explode(); this->setVisible( false ); @@ -140,7 +140,6 @@ thrustTrail_->removeNode( mainNode_ ); thrustTrailNode_->setVisible( false ); } - launched_ = false; } void SectorObjectMissile::launch( ){ @@ -161,7 +160,7 @@ } SectorObjectMoveable::inititialize_(); inititialize_(); - ResourceManager::getSingleton().collisionManager->attach( collObj_ ); + ResourceManager::getSingleton().collisionManager->attach( this ); setThrustRate( 1.0 ); updateThruster(); launched_ = true; Modified: trunk/src/SectorObjectMoveable.cpp =================================================================== --- trunk/src/SectorObjectMoveable.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/SectorObjectMoveable.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -118,7 +118,7 @@ shieldGlowActive_ = false; shieldGlowTime_ = 0.0; - vel_ = Ogre::Vector3( 0.0, 0.0, 0.0 ); + vel_ = Ogre::Vector3( 0.0, 0.0, 0.0 ); interpolateRot_ = Ogre::Quaternion( 1.0, 0.0, 0.0, 0.0 ); interpolateVel_ = Ogre::Vector3( 0.0, 0.0, 0.0 ); @@ -150,7 +150,7 @@ } if ( destroyRequest_ || destroyWithExplosion_ ){ - ResourceManager::getSingleton().collisionManager->dettach( collObj_ ); + ResourceManager::getSingleton().collisionManager->dettach( this ); this->unsubscribeToObservers(); Modified: trunk/src/SectorObjectVessel.cpp =================================================================== --- trunk/src/SectorObjectVessel.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/SectorObjectVessel.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -129,11 +129,10 @@ setThrustRate( 0.0 ); updateThruster(); - ResourceManager::getSingleton().collisionManager->attach( collObj_ ); + ResourceManager::getSingleton().collisionManager->attach( this ); setVisible( true ); } - bool SectorObjectVessel::update( Ogre::Real elapsedTime ){ if ( armor_ <= 0 ) { explode(); Modified: trunk/src/Station.cpp =================================================================== --- trunk/src/Station.cpp 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/Station.cpp 2008-05-12 13:08:10 UTC (rev 894) @@ -121,14 +121,14 @@ padMesh_ = padManualObject_->convertToMesh( padManualObject_->getName() + "/Mesh" ); padEntity_ = sceneMgr_->createEntity( padMesh_->getName() + "/Entity", padMesh_->getName() ); padNode_->attachObject( padEntity_ ); - - if ( docking_ ){ collObj_ = ResourceManager::getSingleton().collisionManager->createObject( padEntity_, this, "DockPad" ); + padNode_->translate( direction_.normalisedCopy() * 0.1 ); + if ( docking_ ){ + ResourceManager::getSingleton().collisionManager->createObject( this ); } } StationPad::~StationPad( ){ - if ( collObj_ ) ResourceManager::getSingleton().collisionManager->destroyObject( collObj_ ); - collObj_ = NULL; + ResourceManager::getSingleton().collisionManager->destroyObject( this ); padNode_->detachObject( padEntity_ ); sceneMgr_->destroyEntity( padEntity_ ); Ogre::MeshManager::getSingleton().remove( padMesh_->getName() ); @@ -142,8 +142,9 @@ if ( object->rtti() == AVATAR_RTTI ){ sector_->listener()->changeToDockedState(); } else if ( object->rtti() == SECTOROBJECTVESSEL_RTTI ){ - std::cout << "docking request for " << object->name() << std::endl; - dynamic_cast< SectorObjectVessel * >( object )->controler()->kill(); + std::cout << "StationPad::collide() docking request for " << object->name() << std::endl; + //dynamic_cast< SectorObjectVessel * >( object )->controler()->kill(); +// ResourceManager::getSingleton().collisionManager->dettachObject( padEntity_, this, "DockPad" ); object->destroy( ); } } @@ -168,11 +169,10 @@ unsigned short src = 0, dest = 0; if ( !pMesh->suggestTangentVectorBuildParams( Ogre::VES_TANGENT, src, dest) ) { - pMesh->buildTangentVectors( Ogre::VES_TANGENT, src, dest); + pMesh->buildTangentVectors( Ogre::VES_TANGENT, src, dest); } setShape( station_->meshName() ); - ResourceManager::getSingleton().collisionManager->changeCollClass( collObj_, "Station" ); for ( uint i = 0; i < entity()->getNumSubEntities(); i ++ ){ std::cout << entity()->getSubEntity( i )->getMaterialName() << " Techniques: " @@ -193,17 +193,14 @@ launchPad_ = new StationPad( name_ + "LaunchPad", this, entity()->getSubEntity( i ) ); } } - std::cout << " Station base size " << station_->baseSize() << std::endl; setBaseRot( station_->baseYaw(), station_->basePitch(), station_->baseRoll() ); - std::cout << " Station base size " << station_->baseSize() << std::endl; setBaseSize( station_->baseSize() ); - if ( dockPad_ ){ - createRings( dockPad_->position(), dockPad_->radius(), - dockPad_->direction() ); - ringNode_->setVisible( false ); - } + if ( dockPad_ ){ + createRings( dockPad_->position(), dockPad_->radius(), dockPad_->direction() ); + ringNode_->setVisible( false ); + } } StationObject::~StationObject( ) { Modified: trunk/src/Station.h =================================================================== --- trunk/src/Station.h 2008-05-11 22:19:57 UTC (rev 893) +++ trunk/src/Station.h 2008-05-12 13:08:10 UTC (rev 894) @@ -64,6 +64,8 @@ /*! Return runtime type information */ virtual long rtti() const { return STATIONPAD_RTTI; } + virtual std::string collisionClass() const { return "DockPad"; } + /*! What happen on collision */ void collide( BaseObject * object ); @@ -83,6 +85,8 @@ Ogre::SceneNode * padNode(){ return padNode_; } + virtual Ogre::Entity * entity( ) { return padEntity_; } + protected: StationObject * station_; bool docking_; @@ -104,7 +108,9 @@ virtual ~StationObject( ); virtual long rtti() const { return STATION_RTTI; } - + + virtual std::string collisionClass() const { return "Station"; } + void collide( BaseObject * object ); void createRings( const Ogre::Vector3 & position, Ogre::Real rMin, const Ogre::Vector3 & direction = Ogre::Vector3::ZERO ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spo...@us...> - 2008-05-12 16:19:09
|
Revision: 896 http://opengate.svn.sourceforge.net/opengate/?rev=896&view=rev Author: spom_spom Date: 2008-05-12 09:19:10 -0700 (Mon, 12 May 2008) Log Message: ----------- Just another fix Modified Paths: -------------- trunk/src/OpcodeWrapper.cpp trunk/src/SectorObjectMissile.cpp trunk/src/SectorObjectMoveable.cpp Modified: trunk/src/OpcodeWrapper.cpp =================================================================== --- trunk/src/OpcodeWrapper.cpp 2008-05-12 13:50:09 UTC (rev 895) +++ trunk/src/OpcodeWrapper.cpp 2008-05-12 16:19:10 UTC (rev 896) @@ -108,7 +108,9 @@ void OpcodeCollisionDetection::createObject( BaseObject * obj ){ if ( obj && active_ ){ - if ( !obj->collisionObject() ){ + OgreOpcode::CollisionObject * collObj = obj->collisionObject(); + + if ( !collObj ){ OgreOpcode::EntityCollisionShape * collShape = collisionManager_->createEntityCollisionShape( obj->name() + "/CollShape" ); if ( obj->entity() ){ @@ -117,12 +119,13 @@ std::cout << "OpcodeCollisionDetection::createObject( BaseObject * obj ), no entity defined for obj: " << obj->name(); } - OgreOpcode::CollisionObject * collObj = collideInSectorContext_->createObject( obj->name() + "/CollObj" ); - collObj->setContext( collideInSectorContext_ ); + collObj = collideInSectorContext_->createObject( obj->name() + "/CollObj" ); collObj->setCollClass( collisionManager_->queryCollClass( obj->collisionClass() ) ); collObj->setShape( collShape ); + + collObj->setClientData( obj ); collideInSectorContext_->addObject( collObj ); - collObj->setClientData( obj ); + obj->setCollisionObject( collObj ); } } @@ -131,14 +134,14 @@ void OpcodeCollisionDetection::destroyObject( BaseObject * obj ){ if ( obj && active_ ){ - if ( obj->collisionObject() ){ - - OgreOpcode::CollisionObject * collObj = obj->collisionObject(); + OgreOpcode::CollisionObject * collObj = obj->collisionObject(); + if ( collObj ){ OgreOpcode::ICollisionShape * shape = collObj->getShape(); collideInSectorContext_->destroyObject( collObj ); - + collisionManager_->detachShape( shape ); collisionManager_->destroyShape( shape ); + obj->setCollisionObject( NULL ); } } @@ -164,9 +167,11 @@ uint nColl = collideInSectorContext_->rayCheck( ray, rayLength, OgreOpcode::COLLTYPE_EXACT, OgreOpcode::COLLTYPE_ALWAYS_EXACT, rayPickReport ); - std::cout << "OpcodeCollisionDetection::checkCollideRay()" << " " << rayLength << " " << nColl <<std::endl; + // std::cout << "OpcodeCollisionDetection::checkCollideRay()" << " " << rayLength << " " << nColl <<std::endl; for ( uint i = 0; i < nColl; i ++ ){ +/* std::cout << "OpcodeCollisionDetection::checkCollideRay()" << " " << rayLength << " " << nColl <<std::endl;*/ + OgreOpcode::CollisionObject* col1 = rayPickReport[ i ]->this_object; OgreOpcode::CollisionObject* col2 = rayPickReport[ i ]->other_object; Modified: trunk/src/SectorObjectMissile.cpp =================================================================== --- trunk/src/SectorObjectMissile.cpp 2008-05-12 13:50:09 UTC (rev 895) +++ trunk/src/SectorObjectMissile.cpp 2008-05-12 16:19:10 UTC (rev 896) @@ -148,7 +148,8 @@ thrustTrail_ = sceneMgr_->createRibbonTrail( name_ + "_RibbonTrail"); thrustTrail_->setMaterialName( "BeamGreen" ); thrustTrail_->setTrailLength( 1000 ); - thrustTrail_->setWidthChange( 0, 2.0 ); + thrustTrail_->setColourChange( 0, Ogre::ColourValue( 0.0, 0.0, 0.0, 0.3 ) ); + thrustTrail_->setWidthChange( 0, 0.5 ); thrustTrail_->setMaxChainElements( 100 ); thrustTrail_->setInitialWidth( 0, 1.0 ); thrustTrail_->addNode( mainNode_ ); Modified: trunk/src/SectorObjectMoveable.cpp =================================================================== --- trunk/src/SectorObjectMoveable.cpp 2008-05-12 13:50:09 UTC (rev 895) +++ trunk/src/SectorObjectMoveable.cpp 2008-05-12 16:19:10 UTC (rev 896) @@ -183,40 +183,53 @@ //** friction = drag * v^2; Ogre::Real v = speed(); - Ogre::Real friction = ethernalDensity_ * moveable_->dragFactor() * v * v; + double friction = ethernalDensity_ * moveable_->dragFactor() * v * v; - Ogre::Vector3 trustDir( mainNode_->getWorldOrientation().zAxis().normalisedCopy() ); - Ogre::Vector3 flightDir( vel_ ); flightDir.normalise(); - + Ogre::Vector3 thrustDir( mainNode_->getWorldOrientation().zAxis().normalisedCopy() ); + Ogre::Vector3 flightDir( vel_.normalisedCopy() ); + + thrustDir.x = round( thrustDir.x, 7 ); thrustDir.y = round( thrustDir.y, 7 ); thrustDir.z = round( thrustDir.z, 7 ); + flightDir.x = round( flightDir.x, 7 ); flightDir.y = round( flightDir.y, 7 ); flightDir.z = round( flightDir.z, 7 ); + + //** thrust = mass * a; if ( mass_ > 0 ){ - acc_ = ( - trustDir * thrust_ - flightDir * friction ) / mass_; + acc_ = ( - thrustDir * (double)thrust_ - flightDir * friction ) / mass_; } else { LogManager::getSingleton().fatal( name_ + " mass: " + toStr( mass_ ) ); } - if ( breakPressed_ == true ) { - if ( speed() > 0 ) { - acc_ -= flightDir * brakingAcc(); - } - } // if ( thrust_ > 0 ){ +// std::cout << name_ << " " << thrustDir << " " << flightDir << " " << thrustDir + flightDir << std::endl; // std::cout << name_ << " " << acc_.normalisedCopy() << " " << vel_.normalisedCopy() << std::endl; // std::cout << name_ << " " << acc_ << " " << vel_ << std::endl; // std::cout << yaw_ << " " << pitch_ << " " << roll_ << std::endl; // std::cout << thrust_ << " " << moveable_->dragFactor() << " " << breakPressed_ // << " " << friction << " " << v << " " << mass_ << std::endl; // } - //** v = a * t; - vel_ += acc_ * elapsedTime; - mainNode_->translate( ( vel_ + interpolateVel_ ) * elapsedTime ); + if ( breakPressed_ == true ) { + if ( speed() > 0 ) { + acc_ -= flightDir * brakingAcc(); + } + } + + //** v = a * t; + vel_ += acc_ * elapsedTime; + double speed = vel_.length(); + + if ( speed > maxSpeed() ){ + vel_ *= maxSpeed() / speed; + } else if ( speed < 0.1 ){ + vel_ *= 0.0; + } + + mainNode_->translate( ( vel_ + interpolateVel_ ) * elapsedTime ); + //** because of the discrete jumps between to frames we have to check for collisions via ray; if ( collObj_ ){ - //Ogre::Ray rayNoNextPos( mainNode_->getPosition(), vel_.normalisedCopy() ); - - //** bitte bitte check, ob das vor oder nach dem Move soll bzw, ob die richtung stimmt - //OpcodeCollisionDetection::getSingleton().checkCollideRay( this, rayNoNextPos, (vel_ * elapsedTime).length() ); + Ogre::Ray rayNoNextPos( mainNode_->getWorldPosition(), vel_.normalisedCopy() ); + ResourceManager::getSingleton().collisionManager->checkCollideRay( this, rayNoNextPos, (vel_ * elapsedTime).length() ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spo...@us...> - 2008-05-20 21:26:58
|
Revision: 901 http://opengate.svn.sourceforge.net/opengate/?rev=901&view=rev Author: spom_spom Date: 2008-05-20 14:26:54 -0700 (Tue, 20 May 2008) Log Message: ----------- ogEditor can now load and show the testsector and its content Modified Paths: -------------- branches/ogEditor/ogEditor.py branches/ogEditor/plugins.cfg branches/ogEditor/propgridtest.py branches/ogEditor/resources.cfg branches/ogEditor/src/ObjectInspectorPanels.py branches/ogEditor/src/OgreWindowWx.py branches/ogEditor/src/PropertyGrid.py trunk/data/misc/testsector.xml trunk/src/AiCommands.h trunk/src/BaseObject.cpp trunk/src/Entity.cpp trunk/src/Entity.h trunk/src/EntityManager.cpp trunk/src/EntityManager.h trunk/src/GameStateManager.cpp trunk/src/Moveable.cpp trunk/src/Moveable.h trunk/src/Planet.cpp trunk/src/ResourceManager.cpp trunk/src/ResourceManager.h trunk/src/Sector.cpp trunk/src/Sector.h trunk/src/SectorObject.cpp trunk/src/SectorObjectMoveable.cpp trunk/src/Station.cpp trunk/src/Station.h trunk/src/Vessel.cpp trunk/src/Vessel.h Modified: branches/ogEditor/ogEditor.py =================================================================== --- branches/ogEditor/ogEditor.py 2008-05-18 19:30:59 UTC (rev 900) +++ branches/ogEditor/ogEditor.py 2008-05-20 21:26:54 UTC (rev 901) @@ -21,15 +21,17 @@ import opengate as og -class OGView3D( OgreWindow ): - def _PopulateScene(self): - #automatic called by parent init -# self.headEnt = self.sceneManager.createEntity("ogreHead", "athene.mesh") - self.headEnt = self.sceneManager.createEntity("ogreHead", "ogrehead.mesh") - #self.headEnt = self.sceneManager.createEntity("ogreHead", "Firefly.mesh") - self.headNode = self.sceneManager.getRootSceneNode().createChildSceneNode( ) - self.headNode.attachObject( self.headEnt ) - #self.sceneManager.setAmbientLight( (0.0, 0.0, 1.0, 1.0) ) +#class OGView3D( OgreWindow ): + #def _PopulateScene(self): + ##automatic called by parent init +## self.headEnt = self.sceneManager.createEntity("ogreHead", "athene.mesh") + ##self.headEnt = self.sceneManager.createEntity("ogreHead", "ogrehead.mesh") + ###self.headEnt = self.sceneManager.createEntity("ogreHead", "Firefly.mesh") + ##self.headNode = self.sceneManager.getRootSceneNode().createChildSceneNode( ) + ##self.headNode.attachObject( self.headEnt ) + ##self.sceneManager.setAmbientLight( (0.0, 0.0, 1.0, 1.0) ) + #sector = og.Sector( self.sceneManager, None ) + ##sector.populate("testsector") ID_MB_FILE_EXIT = wx.NewId() ID_MB_VIEW_SCENETREE = wx.NewId() @@ -59,7 +61,9 @@ self.initFrameManager_() self.initOpenGateResources_(); + self.sector = og.Sector( self.ogreRenderWindow.sceneManager, None ); + self.setDefaultProperties_(); self.auiMgr.Update() @@ -142,7 +146,7 @@ ################################################################################# def createRenderWindow_( self ): - self.ogreRenderWindow = OGView3D( self, -1, ogResourceMan = self.ogResourceManager ) + self.ogreRenderWindow = OgreWindow( self, -1, ogResourceMan = self.ogResourceManager ) return self.ogreRenderWindow def createCrustWindow_( self ): @@ -191,6 +195,7 @@ entityManager.load( self.ogResourceManager.resourceLocations( "General" ), "guns" ); entityManager.load( self.ogResourceManager.resourceLocations( "General" ), "missiles" ); entityManager.load( self.ogResourceManager.resourceLocations( "General" ), "ships" ); + entityManager.load( self.ogResourceManager.resourceLocations( "General" ), "stations" ); def setDefaultProperties_( self ): self.SetTitle("ogEditor") @@ -248,14 +253,24 @@ event.Skip() def doSelectTreeObject( self, event ): - self.objectInspector.showData( event.GetEventObject().GetPyData( event.GetEventObject().GetSelection() ) ); + + obj = event.GetEventObject().GetPyData( event.GetEventObject().GetSelection() ) + self.ogreRenderWindow.camera.lookAt( obj.getWorldPosition() ) + self.objectInspector.showData( obj ); event.Skip() ################################################################################# # utils ################################################################################# + def createObject( self, name, meshname ): + sceneManager = self.ogreRenderWindow.sceneManager; + node = sceneManager.getRootSceneNode().createChildSceneNode( name ); + entity = sceneManager.createEntity( name, meshname ); + node.attachObject( entity ); + def UpdateSceneGraphEvent(self, event): + self.sceneTree.DeleteAllItems() root = self.sceneTree.AddRoot( "SceneManager" ) self.sceneTree.SetPyData( root, self.ogreRenderWindow.sceneManager ) @@ -285,7 +300,8 @@ object_it = scenenode.getAttachedObjectIterator() while object_it.hasMoreElements(): m = object_it.getNext() - item = self.sceneTree.AppendItem( treenode, m.getMovableType() + "-" + m.getName() ) + item = self.sceneTree.AppendItem( treenode, m.getName() ) + #item = self.sceneTree.AppendItem( treenode, m.getMovableType() + "-" + m.getName() ) if m.getMovableType() == "Entity": id = self.SceneEntityIconID Modified: branches/ogEditor/plugins.cfg =================================================================== --- branches/ogEditor/plugins.cfg 2008-05-18 19:30:59 UTC (rev 900) +++ branches/ogEditor/plugins.cfg 2008-05-20 21:26:54 UTC (rev 901) @@ -17,4 +17,4 @@ Plugin=Plugin_ParticleFX #Plugin=Plugin_BSPSceneManager #Plugin=Plugin_OctreeSceneManager -#Plugin=Plugin_CgProgramManager +Plugin=Plugin_CgProgramManager Modified: branches/ogEditor/propgridtest.py =================================================================== --- branches/ogEditor/propgridtest.py 2008-05-18 19:30:59 UTC (rev 900) +++ branches/ogEditor/propgridtest.py 2008-05-20 21:26:54 UTC (rev 901) @@ -1,11 +1,13 @@ - +#!/usr/bin/python import wxversion wxversion.ensureMinimal('2.8') +import sys +import wx +sys.path.append( './src/' ) + from PropertyGrid import * -import sys -import wx class testClass(): def printValue(self, value): @@ -22,8 +24,11 @@ self.propertyGrid = PropertyMainGrid( self, -1, wx.DefaultPosition, wx.DefaultSize ) self.propertyGrid.appendRowItemName( "Main", "name" ) + self.propertyGrid.appendRowItemName( "float", value = 10.1, format = FORMAT_FLOAT, cback = test.printValue ) + self.propertyGrid.appendRowItemName( "int", value = 10, format = FORMAT_INT, cback = test.printValue ) + self.propertyGrid.appendRowItemSlider( "slider", cback = test.printValue ) - self.propertyGrid.appendPaneColourSelect( "Colour", cback = test.printValue ) + self.propertyGrid.appendRowItemColourSelect( "Colour", cback = test.printValue ) pane = PropertyPaneItem( self.propertyGrid, "testPane " ) self.propertyGrid.appendPane( pane ) @@ -32,13 +37,22 @@ pane.appendRow( text ) self.propertyGrid.appendRowItemSlider( "expDensity", 0.0001, 0.0002, - format = SLIDER_LOG10, + format = FORMAT_LOG10, cback = test.printValue ) modes = ("one", "two", "three" ) - self.propertyGrid.appendRowItemChoice( "Choice", itemList = modes, cback = test.printValue ) + self.propertyGrid.appendRowItemChoice( "Choice set", value = "one", + itemList = modes, cback = test.printValue ) + dic = ( (1, "eins"), (2, "zwei"), (3, "drei")) - self.propertyGrid.appendRowItemChoice( "Choice", itemMap = dic, cback = test.printValue ) + self.propertyGrid.appendRowItemChoice( "Choice map", value = 1, + itemMap = dic, cback = test.printValue ) + self.propertyGrid.appendRowItemFileSelect( "File", cback = test.printValue ) + self.propertyGrid.appendRowItemFileSelect( "Files", cback = test.printValue, + flag = wx.MULTIPLE ) + + self.propertyGrid.appendRowItemButton( "Button", cback = test.printValue ) + self.propertyGrid.appendRowItemInfo( "here is a long an verbose text entry" ) if __name__ == "__main__": ogEditor = wx.PySimpleApp(0) Modified: branches/ogEditor/resources.cfg =================================================================== --- branches/ogEditor/resources.cfg 2008-05-18 19:30:59 UTC (rev 900) +++ branches/ogEditor/resources.cfg 2008-05-20 21:26:54 UTC (rev 901) @@ -5,32 +5,32 @@ # Resource locations to be added to the default path [General] FileSystem=../../trunk/data/ +FileSystem=../../trunk/data/asteroids +FileSystem=../../trunk/data/capacitors FileSystem=../../trunk/data/commodities -FileSystem=../../trunk/data/capacitors +FileSystem=../../trunk/data/gui +FileSystem=../../trunk/data/gui/fonts +FileSystem=../../trunk/data/gui/layouts +FileSystem=../../trunk/data/gui/imagesets +FileSystem=../../trunk/data/gui/schemes +FileSystem=../../trunk/data/gui/looknfeel +FileSystem=../../trunk/data/gui/overlays +FileSystem=../../trunk/data/ecms FileSystem=../../trunk/data/engines +FileSystem=../../trunk/data/guns +FileSystem=../../trunk/data/materials +FileSystem=../../trunk/data/misc +FileSystem=../../trunk/data/missiles +FileSystem=../../trunk/data/power_plants FileSystem=../../trunk/data/radars FileSystem=../../trunk/data/shields -FileSystem=../../trunk/data/ecms -FileSystem=../../trunk/data/power_plants -FileSystem=../../trunk/data/guns -FileSystem=../../trunk/data/missiles FileSystem=../../trunk/data/ships/octavius/apteryx FileSystem=../../trunk/data/ships/quantar/storm +FileSystem=../../trunk/data/ships/squadrok/squid FileSystem=../../trunk/data/ships/tauseti/lady_kickstart -FileSystem=../../trunk/data/ships/squadrok/squid FileSystem=../../trunk/data/skybox FileSystem=../../trunk/data/stations -FileSystem=../../trunk/data/materials FileSystem=../../trunk/data/textures -FileSystem=../../trunk/data/asteroids -FileSystem=../../trunk/data/misc -FileSystem=../../trunk/data/gui -FileSystem=../../trunk/data/gui/fonts -FileSystem=../../trunk/data/gui/layouts -FileSystem=../../trunk/data/gui/imagesets -FileSystem=../../trunk/data/gui/schemes -FileSystem=../../trunk/data/gui/looknfeel -FileSystem=../../trunk/data/gui/overlays Zip=../../trunk/data/skybox/simpleSkybox.zip Modified: branches/ogEditor/src/ObjectInspectorPanels.py =================================================================== --- branches/ogEditor/src/ObjectInspectorPanels.py 2008-05-18 19:30:59 UTC (rev 900) +++ branches/ogEditor/src/ObjectInspectorPanels.py 2008-05-20 21:26:54 UTC (rev 901) @@ -176,13 +176,15 @@ def showSceneNode( self, data ): self.typeStaticText.SetLabel( "SceneNode" ) - self.showName( data ); - + self.showName( data ) + print data.getWorldPosition() + self.propertyGrid.appendRowItemInfo( "world position (%g, %g, %g)"%(data.getWorldPosition().x, data.getWorldPosition().y, data.getWorldPosition().z) ) + def showResource( self, data ): self.typeStaticText.SetLabel( "Resource: " + data.getCreator().getResourceType() ) self.showName( data ); - self.appendRowItemName( "Group", data.getGroup() ) - self.appendRowItemName( "Origin", data.getOrigin() ) + self.propertyGrid.appendRowItemName( "Group", data.getGroup() ) + self.propertyGrid.appendRowItemName( "Origin", data.getOrigin() ) # params = data.getParameters() # if len( params ) > 0: Modified: branches/ogEditor/src/OgreWindowWx.py =================================================================== --- branches/ogEditor/src/OgreWindowWx.py 2008-05-18 19:30:59 UTC (rev 900) +++ branches/ogEditor/src/OgreWindowWx.py 2008-05-20 21:26:54 UTC (rev 901) @@ -207,26 +207,25 @@ def _CreateCamera(self): "create a Camera" - camera = self.sceneManager.createCamera('Camera') - camera.lookAt(ogre.Vector3(0, 0, 0)) - camera.nearClipDistance = 1 - camera.setAutoAspectRatio( True ) + self.camera = self.sceneManager.createCamera('Camera') + self.camera.lookAt(ogre.Vector3(0, 0, 0)) + self.camera.nearClipDistance = 1 + self.camera.setAutoAspectRatio( True ) - self.sceneEntities.camera = camera - # create the camera nodes & attach camera - cameraNode = self.sceneManager.getRootSceneNode().createChildSceneNode( camera.getName() + "/Node", + cameraNode = self.sceneManager.getRootSceneNode().createChildSceneNode( self.camera.getName(), ogre.Vector3( 0, 0, 250 ) ) pitchNode = cameraNode.createChildSceneNode( cameraNode.getName() + "/PitchNode" ) - pitchNode.attachObject( camera ) + pitchNode.attachObject( self.camera ) + self.sceneEntities.camera = self.camera self.sceneEntities.cameraNode = cameraNode self.sceneEntities.cameraPitchNode = pitchNode def _CreateViewport(self): "create a Viewport" renderWindow=self.renderWindow - viewport = renderWindow.addViewport( self.sceneEntities.camera, 0, 0.0, 0.0, 1.0, 1.0) + viewport = renderWindow.addViewport( self.camera, 0, 0.0, 0.0, 1.0, 1.0) viewport.backgroundColour = ogre.ColourValue(0, 0, 0) def _PopulateScene(self): @@ -236,21 +235,34 @@ def _MouseAndKeysBindings(self): "Some Additional mouse and keys bindings" d=10.0 #displacement for key strokes - self.ControlKeyDict={ wx.WXK_LEFT :ogre.Vector3( -d, 0.0, 0.0), - wx.WXK_RIGHT :ogre.Vector3( d, 0.0, 0.0), - wx.WXK_UP :ogre.Vector3( 0.0, 0.0, -d), - wx.WXK_DOWN :ogre.Vector3( 0.0, 0.0, d), - wx.WXK_PAGEUP :ogre.Vector3( 0.0, d, 0.0), - wx.WXK_PAGEDOWN :ogre.Vector3( 0.0, -d, 0.0)} + self.moveKeyDict={ ord('W') :ogre.Vector3( 0.0, 0.0, -d), + ord('S') :ogre.Vector3( 0.0, 0.0, d), + ord('A') :ogre.Vector3( -d, 0.0, 0.0), + ord('D') :ogre.Vector3( d, 0.0, 0.0), + ord('R') :ogre.Vector3( 0.0, d, 0.0), + ord('F') :ogre.Vector3( 0.0, -d, 0.0), + wx.WXK_LEFT :ogre.Vector3( -d, 0.0, 0.0), + wx.WXK_RIGHT :ogre.Vector3( d, 0.0, 0.0), + wx.WXK_UP :ogre.Vector3( 0.0, 0.0, -d), + wx.WXK_DOWN :ogre.Vector3( 0.0, 0.0, d), + wx.WXK_PAGEUP :ogre.Vector3( 0.0, d, 0.0), + wx.WXK_PAGEDOWN :ogre.Vector3( 0.0, -d, 0.0)} + #ord('Q') :ogre.Vector3( 0.0, d, 0.0), + #ord('E') :ogre.Vector3( 0.0, -d, 0.0), + self.Bind( wx.EVT_KEY_DOWN, self._DefaultKeyDownManager ) self.Bind( wx.EVT_MOUSE_EVENTS, self._DefaultMouseEventManager) ##self.Bind(wx.EVT_ENTER_WINDOW,lambda evt : self.SetFocus()) def _DefaultKeyDownManager( self, event ): "If you want to implement a similar callback function, do not forget the event.Skip() at the end" - validMove = self.ControlKeyDict.get( event.m_keyCode, False ) + validMove = self.moveKeyDict.get( event.m_keyCode, False ) if validMove: - self.sceneEntities.cameraNode.translate( validMove, self.sceneEntities.cameraNode.TS_LOCAL ) + self.sceneEntities.cameraNode.translate( validMove, self.sceneEntities.cameraNode.TS_LOCAL ) + + #validRot = self.rotKeyDict.get( event.m_keyCode, False ) + #if validRot: + #self.sceneEntities.cameraNode.translate( validMove, self.sceneEntities.cameraNode.TS_LOCAL ) event.Skip() def _DefaultMouseEventManager( self, event ): @@ -262,10 +274,11 @@ if event.Dragging() and event.RightIsDown(): #Dragging with RMB x,y = event.GetPosition() - dx = x-self.StartDragX - dy = y-self.StartDragY + dx = self.StartDragX -x + dy = self.StartDragY -y self.StartDragX, self.StartDragY = x, y - self.sceneEntities.cameraNode.yaw( ogre.Degree( dx / 3.0 ) ) - self.sceneEntities.cameraPitchNode.pitch( ogre.Degree( dy / 3.0 ) ) + self.sceneEntities.cameraNode.yaw( ogre.Degree( dx / 3.0 ), ogre.Node.TS_LOCAL ) + self.sceneEntities.cameraNode.pitch( ogre.Degree( dy / 3.0 ), ogre.Node.TS_LOCAL ) + #self.sceneEntities.cameraPitchNode.pitch( ogre.Degree( dy / 3.0 ), ogre.Node.TS_LOCAL ) event.Skip() Modified: branches/ogEditor/src/PropertyGrid.py =================================================================== --- branches/ogEditor/src/PropertyGrid.py 2008-05-18 19:30:59 UTC (rev 900) +++ branches/ogEditor/src/PropertyGrid.py 2008-05-20 21:26:54 UTC (rev 901) @@ -1,23 +1,77 @@ -#!/usr/bin/env python - -import wx +import os, os.path, wx +import string import wx.combo import wx.lib.colourselect as csel -SLIDER_INT=0 -SLIDER_FLOAT=1 -SLIDER_LOG10=2 +FORMAT_INT=0 +FORMAT_FLOAT=1 +FORMAT_LOG10=2 +FORMAT_STRING=3 +ALPHA_ONLY = 1 +DIGIT_ONLY = 2 + class NullLog: - def write(*args): + def write(self, *args): pass class SimpleLog: - def write(*args): + def write(self, *args): print args +class MyValidator(wx.PyValidator): + def __init__(self, flag=None, pyVar=None): + wx.PyValidator.__init__(self) + self.flag = flag + self.Bind(wx.EVT_CHAR, self.OnChar) + def Clone(self): + return MyValidator(self.flag) + + def Validate(self, win): + tc = self.GetWindow() + val = tc.GetValue() + + if self.flag == ALPHA_ONLY: + for x in val: + if x not in string.letters: + return False + + elif self.flag == DIGIT_ONLY: + for x in val: + if x not in string.digits: + return False + + return True + + def OnChar(self, event): + key = event.GetKeyCode() + + if key < wx.WXK_SPACE or key == wx.WXK_DELETE or key > 255: + event.Skip() + return + + if self.flag == ALPHA_ONLY and chr(key) in string.letters: + event.Skip() + return + + if self.flag == DIGIT_ONLY and chr(key) in string.digits: + event.Skip() + return + + if not wx.Validator_IsSilent(): + wx.Bell() + + if self.flag == None: + event.Skip() + + # Returning without calling even.Skip eats the event before it + # gets to the text control + return + class ListCtrlComboPopup( wx.ListCtrl, wx.combo.ComboPopup ): + value = -1 + curritem = -1 def __init__( self, log = None, cback = None ): if log: self.log = log @@ -38,6 +92,14 @@ def AddItem(self, txt): self.InsertStringItem(self.GetItemCount(), txt) + def AddItems(self, txt): + for i in txt: + self.InsertStringItem(self.GetItemCount(), i) + + def SetItems(self, txt): + self.ClearAll() + self.AddItems( txt ) + def OnMotion(self, evt): item, flags = self.HitTest(evt.GetPosition()) if item >= 0: @@ -137,85 +199,271 @@ self.log.write("ListCtrlComboPopup.LazyCreate") return wx.combo.ComboPopup.LazyCreate(self) +class PropertyRowItem( ): + cback_ = None + parent_ = None + size_ = None + labelTextCtrl_ = None + rowHeight_ = 10 -class PropertyRowItem( ): + def __init__( self, parent, name, cback = None ): + self.cback_ = cback + self.parent_ = parent + self.sizer_ = wx.BoxSizer( wx.HORIZONTAL ) + + self.labelTextCtrl_ = wx.TextCtrl( parent, -1, name, + style = wx.NO_BORDER | wx.ALIGN_LEFT ) + self.rowHeight_ = self.labelTextCtrl_.GetSize()[ 1 ] + self.labelTextCtrl_.SetEditable( False ) + self.sizer_.Add( self.labelTextCtrl_, 0, wx.EXPAND | wx.ALIGN_RIGHT ) + + def Disable(self): + for item in self.sizer_.GetChildren(): + if item.GetWindow() != None: + item.GetWindow().Disable() + + def Enable(self, value ): + for item in self.sizer_.GetChildren(): + if item.GetWindow() != None: + item.GetWindow().Enable( value ) + +class PropertyRowItemInfo( PropertyRowItem ): def __init__( self, parent, name ): - self.sizer = wx.BoxSizer( wx.HORIZONTAL ) - - labelTextCtrl = wx.TextCtrl( parent, -1, name, + self.sizer_ = wx.BoxSizer( wx.HORIZONTAL ) + self.labelTextCtrl_ = wx.TextCtrl( parent, -1, name, style = wx.NO_BORDER | wx.ALIGN_LEFT ) - self.rowHeight = labelTextCtrl.GetSize()[ 1 ] - labelTextCtrl.SetEditable( False ) - self.sizer.Add( labelTextCtrl, 0, wx.EXPAND | wx.ALIGN_RIGHT ) - + self.labelTextCtrl_.SetEditable( False ) + self.sizer_.Add( self.labelTextCtrl_, 1, wx.EXPAND | wx.ALIGN_RIGHT ) + class PropertyRowItemName( PropertyRowItem ): - def __init__( self, parent, name, value = "" ): - PropertyRowItem.__init__( self, parent, name ) - self.valueTextCtrl = wx.TextCtrl( parent, -1, value, - size = wx.Size( 30, self.rowHeight ), - style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND) - self.sizer.AddSpacer( 1 ) - self.sizer.Add( self.valueTextCtrl, 1, wx.EXPAND | wx.ALIGN_LEFT ) + valueTextCtrl_ = None + format_ = None + def __init__( self, parent, name, value = None, format = FORMAT_STRING, cback = None): + PropertyRowItem.__init__( self, parent, name, cback = cback ) + self.format_ = format + self.validator = MyValidator() + + if format == FORMAT_INT: + self.validator = MyValidator( DIGIT_ONLY ) + + self.valueTextCtrl_ = wx.TextCtrl( parent, -1, "", + size = wx.Size( 40, self.rowHeight_ ), + style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND, + validator = self.validator ) + + if ( format == FORMAT_STRING ): + self.valueTextCtrl_.SetValue( "%s" % value ); + elif ( format == FORMAT_INT ): + self.valueTextCtrl_.SetValue( "%d" % value ); + elif ( format == FORMAT_FLOAT ): + self.valueTextCtrl_.SetValue( "%g" % value ); + + self.sizer_.AddSpacer( 1 ) + self.sizer_.Add( self.valueTextCtrl_, 1, wx.EXPAND | wx.ALIGN_LEFT ) + + self.valueTextCtrl_.Bind( wx.EVT_KILL_FOCUS, self.onText ) + + def onText(self, event): + self.value = self.valueTextCtrl_.GetValue() + self.applyValue( True ) + + def applyValue( self, update = True ): + if self.format_ == FORMAT_INT: + self.value = int(self.value) + elif self.format_ == FORMAT_FLOAT: + self.value = float(self.value) + + if update == True: + if self.cback_ != None: + self.cback_( self.value ) +class PropertyRowItemButton( PropertyRowItem ): + button_ = None + + def __init__( self, parent, name, cback = None ): + PropertyRowItem.__init__( self, parent, name, cback = cback ) + self.button_ = wx.Button( parent, -1, + size = wx.Size( 40, self.rowHeight_ ), + style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND) + self.sizer_.AddSpacer( 1 ) + self.sizer_.Add( self.button_, 1, wx.EXPAND | wx.ALIGN_LEFT ) + self.button_.Bind( wx.EVT_BUTTON, self.cback_ ) + +class PropertyRowItemFileSelect( PropertyRowItem ): + def __init__( self, parent, name, value = "", cback = None, flag = 0, + wildcard = "All files (*.*)|*.*" ): + PropertyRowItem.__init__( self, parent, name, cback = cback ) + self.value = value + self.filename = self.value + self.paths = [] + self.wildcard = wildcard + self.flag = flag + if self.flag == wx.MULTIPLE: + self.choice = wx.combo.ComboCtrl( parent, -1, + size = wx.Size( 100, self.rowHeight_ ), + style = wx.NO_BORDER | wx.NO_3D | wx.CB_READONLY ) + self.popup = ListCtrlComboPopup( cback = self.setFilenameIdx ) + self.popup.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) + self.choice.SetPopupControl( self.popup ) + + self.sizer_.AddSpacer( 1 ) + self.sizer_.Add( self.choice, 1, wx.EXPAND | wx.ALIGN_LEFT ) + else: + self.valueTextCtrl = wx.TextCtrl( parent, -1, value, + size = wx.Size( 40, self.rowHeight_ ), + style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND) + self.sizer_.AddSpacer( 1 ) + self.sizer_.Add( self.valueTextCtrl, 1, wx.EXPAND | wx.ALIGN_LEFT ) + + self.fileSelectButton = wx.Button( parent, -1, "'''", + size = wx.Size( self.rowHeight_, self.rowHeight_ ), + style = wx.NO_BORDER + ) + + self.sizer_.AddSpacer( 1 ) + self.sizer_.Add( self.fileSelectButton, 0, wx.EXPAND ) + self.fileSelectButton.Bind( wx.EVT_BUTTON, self.OnButton ) + + def OnButton( self, event): + dlg = wx.FileDialog( self.parent, message="Choose a file", + defaultDir=os.getcwd(), + defaultFile="", + wildcard=self.wildcard, + style=wx.OPEN | wx.CHANGE_DIR | self.flag) + + if dlg.ShowModal() == wx.ID_OK: + self.paths = dlg.GetPaths() + self.filename = self.paths[0] + + if self.flag == wx.MULTIPLE: + self.popup.ClearAll() + for path in self.paths: + self.popup.AddItem( os.path.basename( path ) ) + self.popup.Select(0) + self.applyValue() + #self.choice.SetSelection(0) + self.choice.SetValue(os.path.basename( self.filename )) + else: + self.valueTextCtrl.SetValue( os.path.basename( self.filename ) ) + self.applyValue() + + dlg.Destroy() + + def setFilenameIdx(self, idx ): + if idx >= 0: + self.filename = self.paths[ idx ] + self.applyValue() + + def applyValue( self, update = True ): + + if type( self.filename ) == unicode: + self.filename = self.filename.encode("iso-8859-1", "ignore") + + if update == True: + if self.cback_ != None: + self.cback_( self.filename ) + +class PropertyRowItemCheck( PropertyRowItem ): + def __init__( self, parent, name, value = False, cback = None): + PropertyRowItem.__init__( self, parent, name, cback = cback ) + self.isChecked = value + self.checkbox = wx.CheckBox( parent, -1 ) + self.sizer_.AddSpacer( 1 ) + self.sizer_.Add( self.checkbox, 1, wx.EXPAND | wx.ALIGN_LEFT ) + self.checkbox.Bind( wx.EVT_CHECKBOX, self.onChecked ) + self.checkbox.SetValue( self.isChecked ) + + def onChecked( self, event ): + self.isChecked = event.IsChecked() + self.applyValue() + + def applyValue( self, update = True ): + if update == True: + if self.cback_ != None: + self.cback_( self.isChecked ) + class PropertyRowItemSlider( PropertyRowItem ): - def __init__( self, parent, name, start = 0, end = 100, format = SLIDER_INT, cback = None ): - PropertyRowItem.__init__( self, parent, name ) + def __init__( self, parent, name, value = 0, start = 0, end = 100, + format = FORMAT_INT, cback = None ): + PropertyRowItem.__init__( self, parent, name, cback = cback ) self.format = format - self.cback = cback - self.value = 0 + self.value = value self.start = start self.end = end + if self.end == self.start: + self.end = self.end +1 + self.sliderValue = 0 - if self.format == SLIDER_INT: + if self.format == FORMAT_INT: + self.validator = MyValidator( DIGIT_ONLY ) self.sliderStart = start self.sliderEnd = end else: + self.validator = MyValidator( DIGIT_ONLY ) self.sliderStart = 0 self.sliderEnd = 100 + self.start = float( self.start ) + self.end = float( self.end ) self.scale = float( self.end - self.start )/( self.sliderEnd - self.sliderStart ) self.valueTextCtrl = wx.TextCtrl( parent, -1, "", - size = wx.Size( 30, self.rowHeight ), - style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND) + size = wx.Size( 40, self.rowHeight_ ), + style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND, + validator = self.validator) self.slider = wx.Slider( parent, -1, self.sliderValue, self.sliderStart, self.sliderEnd, - size = wx.Size( 100, self.rowHeight ), + size = wx.Size( 100, self.rowHeight_ ), style = wx.NO_BORDER | wx.NO_3D ) - self.sizer.AddSpacer( 1 ) - self.sizer.Add( self.valueTextCtrl, 0, wx.EXPAND | wx.ALIGN_LEFT ) - self.sizer.Add( self.slider, 1, wx.EXPAND | wx.ALIGN_LEFT ) - self.slider.Bind(wx.EVT_SLIDER, self.OnSlide ) + self.sizer_.AddSpacer( 1 ) + self.sizer_.Add( self.valueTextCtrl, 0, wx.EXPAND | wx.ALIGN_LEFT ) + self.sizer_.Add( self.slider, 1, wx.EXPAND | wx.ALIGN_LEFT ) + + self.valueTextCtrl.Bind( wx.EVT_KILL_FOCUS, self.onText ) + + self.slider.Bind(wx.EVT_SLIDER, self.onSlide ) + self.slider.Bind(wx.EVT_COMMAND_SCROLL_ENDSCROLL, self.onSlideEnd ) + self.applyValue( False ) - def OnSlide(self, event): + def onText(self, event): + self.value = self.valueTextCtrl.GetValue() + self.applyValue( True ) + + def onSlideEnd(self, event): val = event.GetEventObject().GetValue() self.value = self.start + self.scale * val; - self.applyValue() + self.applyValue( True ) + + def onSlide(self, event): + val = event.GetEventObject().GetValue() + self.value = self.start + self.scale * val; + self.applyValue( False ) def setValue(self, value): self.value = value self.applyValue( False ) def applyValue( self, update = True ): - if self.format == SLIDER_INT: + if self.format == FORMAT_INT: + self.value = int(self.value) self.valueTextCtrl.SetValue( "%d" % self.value ) else: - self.valueTextCtrl.SetValue( "%.1g" % self.value ) + self.value = float(self.value) + self.valueTextCtrl.SetValue( "%.1f" % self.value ) self.slider.SetValue( (self.value -self.start)/ self.scale ) if update == True: - if self.cback != None: - self.cback( self.value ) + if self.cback_ != None: + self.cback_( self.value ) class PropertyRowItemChoice( PropertyRowItem ): - def __init__( self, parent, name, itemList = None, itemMap = None, cback = None): - PropertyRowItem.__init__( self, parent, name ) - - self.cback = cback - self.value = "None" + def __init__( self, parent, name, value = None, itemList = None, itemMap = None, cback = None): + PropertyRowItem.__init__( self, parent, name, cback = cback ) + + self.value = "" if itemList != None: self.ITEMDICT = False @@ -225,34 +473,38 @@ self.itemList = itemMap self.choice = wx.combo.ComboCtrl( parent, -1, - size = wx.Size( 100, self.rowHeight ), + size = wx.Size( 100, self.rowHeight_ ), style = wx.NO_BORDER | wx.NO_3D | wx.CB_READONLY ) - - #self.choice.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) - self.popup = ListCtrlComboPopup( cback = self.choiceChanged ) self.popup.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) - self.choice.SetPopupControl( self.popup ) - - + if self.ITEMDICT == False: for i in self.itemList: self.popup.AddItem( i ) + if i == value: + self.value = value + self.valueName = i else: for i in self.itemList: self.popup.AddItem( i[ 1 ] ) + if i[0] == value: + self.value = i[0] + self.valueName = i[1] - self.sizer.AddSpacer( 1 ) - self.sizer.Add( self.choice, 1, wx.EXPAND | wx.ALIGN_LEFT ) + self.sizer_.AddSpacer( 1 ) + self.sizer_.Add( self.choice, 1, wx.EXPAND | wx.ALIGN_LEFT ) + self.popup.Select(0) + self.choice.SetValue( self.valueName ) def choiceChanged(self, idx): - if self.ITEMDICT == False: - self.value = self.itemList[ idx ] - else: - self.value = self.itemList[idx][ 0 ] + if idx != -1: + if self.ITEMDICT == False: + self.value = self.itemList[ idx ] + else: + self.value = self.itemList[idx][ 0 ] - self.applyValue() + self.applyValue() def setValue(self, value): self.value = value @@ -271,22 +523,21 @@ # print item if update == True: - if self.cback != None: - self.cback( self.value ) + if self.cback_ != None: + self.cback_( self.value ) class PropertyRowItemColourSelect( PropertyRowItemName ): def __init__( self, parent, name, cback = None ): - PropertyRowItemName.__init__( self, parent, name ) - self.cback = cback + PropertyRowItemName.__init__( self, parent, name, cback = cback ) self.value = wx.Colour(0,0,0) self.colourButton = csel.ColourSelect( parent, -1, "", colour = self.value, - size = wx.Size( self.rowHeight,self.rowHeight ), + size = wx.Size( self.rowHeight_, self.rowHeight_ ), style = wx.NO_BORDER ) - self.sizer.AddSpacer( 1 ) - self.sizer.Add( self.colourButton, 0, wx.EXPAND ) + self.sizer_.AddSpacer( 1 ) + self.sizer_.Add( self.colourButton, 0, wx.EXPAND ) self.colourButton.Bind( csel.EVT_COLOURSELECT, self.OnColour ) def OnColour(self, event): @@ -298,48 +549,72 @@ self.applyValue( False ) def applyValue( self, update = True ): - self.valueTextCtrl.SetValue( "%d,%d,%d" % (self.value[0],self.value[1],self.value[2]) ) + self.valueTextCtrl_.SetValue( "%d,%d,%d" % (self.value[0],self.value[1],self.value[2]) ) self.colourButton.SetColour( self.value ) if update == True: - if self.cback != None: - self.cback( self.value ) + if self.cback_ != None: + self.cback_( self.value ) class PropertyGrid( ): def __init__(self): - self.sizer = wx.BoxSizer( wx.VERTICAL ) - self.SetSizer( self.sizer ) - self.widthCol0 = 70 + self.sizer_ = wx.BoxSizer( wx.VERTICAL ) + self.SetSizer( self.sizer_ ) + self.widthCol0 = 50 self.widthCol2 = 24 self.xOffset = 17 def appendRow(self, row ): - self.sizer.AddSpacer(1) - self.sizer.Add( row.sizer, 0, wx.EXPAND ) + self.sizer_.AddSpacer(1) + self.sizer_.Add( row.sizer_, 0, wx.EXPAND ) - def appendRowItemName(self, name, value = "" ): - item = PropertyRowItemName( self.pane, name, value ) + def appendRowItemInfo(self, name ): + item = PropertyRowItemInfo( self.pane, name ) self.appendRow( item ) return item - def appendRowItemChoice(self, name, itemList = None, itemMap = None, cback = None ): - item = PropertyRowItemChoice( self.pane, name, itemList, itemMap, cback ) + def appendRowItemName(self, name, value = None, format = FORMAT_STRING, cback = None ): + item = PropertyRowItemName( self.pane, name, value, format, cback ) + self.appendRow( item ) + return item + + def appendRowItemButton(self, name, cback = None ): + item = PropertyRowItemButton( self.pane, name, cback = cback) + self.appendRow( item ) + return item + + def appendRowItemCheck(self, name, value = False, cback = None ): + item = PropertyRowItemCheck( self.pane, name, value, cback = cback) + self.appendRow( item ) + return item + + def appendRowItemChoice(self, name, value = None, itemList = None, itemMap = None, cback = None ): + item = PropertyRowItemChoice( self.pane, name, value, itemList, itemMap, cback ) self.appendRow( item ) return item - def appendRowItemSlider(self, name, start = 0, end = 100, format = SLIDER_INT, cback = None ): - item = PropertyRowItemSlider( self.pane, name, start, end, format, cback ) + def appendRowItemFileSelect(self, name, value = "", cback = None, flag = 0, + wildcard = "All files (*.*)|*.*" ): + item = PropertyRowItemFileSelect( self.pane, name, value = value, + cback = cback, flag = flag, + wildcard = wildcard ) self.appendRow( item ) return item + def appendRowItemSlider( self, name, value = 0, start = 0, end = 100, + format = FORMAT_INT, cback = None ): + item = PropertyRowItemSlider( self.pane, name, value, start, end, format, cback ) + self.appendRow( item ) + return item + def appendRowItemColourSelect( self, name, cback = None ): - item = PropertyRowItemColourSelect( self.pane, name, cback ) + item = PropertyRowItemColourSelect( self.pane, name, cback = cback ) self.appendRow( item ) return item def appendPane(self, pane ): - self.sizer.AddSpacer(1) - self.sizer.Add( pane, 0, wx.EXPAND ) + self.sizer_.AddSpacer(1) + self.sizer_.Add( pane, 0, wx.EXPAND ) def appendPaneColourSelect( self, name, cfront = None, cback = None ): pane = PropertyPaneItemColour( self.pane, name, cfront, cback ) @@ -370,7 +645,7 @@ event.GetEventObject().GetPane().Hide() else: event.GetEventObject().GetPane().Show() - parent = self.GetParent().Layout() + self.GetParent().Layout() class PropertyPaneItemColour( PropertyPaneItem ): @@ -386,7 +661,7 @@ self.g = self.appendRowItemSlider( "green", 0, 255, cback = self.setGreen ) self.b = self.appendRowItemSlider( "blue", 0, 255, cback = self.setBlue ) self.a = self.appendRowItemSlider( "alpha", 0, 255, cback = self.setAlpha ) - + if self.cfront != None: colour = self.cfront() self.value = map(lambda x: x * self.scale, [colour[0], colour[1], colour[2], colour[3]] ) @@ -430,6 +705,6 @@ self.pane = self def clean( self ): - self.sizer.Clear( True ) - self.sizer.Layout() + self.sizer_.Clear( True ) + self.sizer_.Layout() Modified: trunk/data/misc/testsector.xml =================================================================== --- trunk/data/misc/testsector.xml 2008-05-18 19:30:59 UTC (rev 900) +++ trunk/data/misc/testsector.xml 2008-05-20 21:26:54 UTC (rev 901) @@ -55,8 +55,8 @@ <position> -250, 0, 500</position> <scale>20, 20, 20</scale> <material>Asteroid</material> - </sectorobject> - <sectorobject> + </sectorobject>--> +- <sectorobject> <name>ring</name> <mesh>ring</mesh> <position> -650, 100, 800</position> Modified: trunk/src/AiCommands.h =================================================================== --- trunk/src/AiCommands.h 2008-05-18 19:30:59 UTC (rev 900) +++ trunk/src/AiCommands.h 2008-05-20 21:26:54 UTC (rev 901) @@ -29,7 +29,6 @@ namespace Ogre{ class Timer; - class Vector3; } #include <OgreVector3.h> Modified: trunk/src/BaseObject.cpp =================================================================== --- trunk/src/BaseObject.cpp 2008-05-18 19:30:59 UTC (rev 900) +++ trunk/src/BaseObject.cpp 2008-05-20 21:26:54 UTC (rev 901) @@ -34,7 +34,7 @@ sceneMgr_ = sector_->sceneManager(); try{ - mainNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode( name + "_MainNode" ); + mainNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode( name ); } catch( Ogre::Exception & e ) { LogManager::getSingleton().fatal( e.getFullDescription() ); } Modified: trunk/src/Entity.cpp =================================================================== --- trunk/src/Entity.cpp 2008-05-18 19:30:59 UTC (rev 900) +++ trunk/src/Entity.cpp 2008-05-20 21:26:54 UTC (rev 901) @@ -28,6 +28,7 @@ #include <OgreException.h> #include <OgreCEGUITexture.h> +#include <OgreMeshManager.h> #include <CEGUIImageset.h> #include <CEGUIExceptions.h> #include <CEGUIBase.h> @@ -41,62 +42,62 @@ // addProperty< float >( "baseYaw", this, setBaseYaw, baseYaw, mandatory, default, description ) //Property * prop = new Property< Uint32 >( "mass", this, &OpenGate::Entity::setMass, &OpenGate::Entity::mass ); //properties_.push_back( new Property< Uint32 >( "mass", this, &OpenGate::Entity::setMass, &OpenGate::Entity::mass ) ); - - id_ = 0; - techLevel_ = 0; - mass_ = 1; - size_ = 1; - rtti_ = ENTITY; - factionID_ = 1; - baseSize_ = Ogre::Vector3::ZERO; - baseYaw_ = 0; - basePitch_ = 0; - baseRoll_ = 0; + id_ = 0; + techLevel_ = 0; + mass_ = 1; + size_ = 1; + rtti_ = ENTITY; + factionID_ = 1; - imageInitialised_ = false; - setFactionName_( ResourceManager::getSingleton().factionName( factionID_ ) ); -} - -void Entity::setFactionID( int id ){ - factionID_ = id; + imageInitialised_ = false; setFactionName_( ResourceManager::getSingleton().factionName( factionID_ ) ); } -void Entity::setBaseSize( float length, float width, float height ){ - baseSize_[ 0 ] = length; - baseSize_[ 1 ] = width; - baseSize_[ 2 ] = height; -} +void Entity::readPropertiesFromXML( TiXmlHandle & hRoot ){ + readXMLNode< std::string >( hRoot, "name_"+ ResourceManager::getSingleton().languageSuffix() + " name_en name", + this, &OpenGate::Entity::setName, true ); - /*! If size is a scalar value, the length of the entity. */ -void Entity::setBaseSize( float size ){ baseSize_[ 2 ] = size; } + readXMLNode< Uint16 >( hRoot, "object_id", this, &OpenGate::Entity::setID, true ); + readXMLNode< Uint8 >( hRoot, "faction_id", this, &OpenGate::Entity::setFactionID, true ); -Ogre::Vector3 Entity::baseSize( ) const { return baseSize_; } + // what is that for + //readXMLNode< Uint8 >( hRoot, "class_id", this, &OpenGate::Entity::setClassID, false ); + readXMLNode< Uint8 >( hRoot, "techlevel required_rank", this, &OpenGate::Entity::setTechLevel, false ); + + readXMLNode< int >( hRoot, "size", this, &OpenGate::Entity::setSize, false ); + readXMLNode< int >( hRoot, "mass", this, &OpenGate::Entity::setMass, false ); + + readXMLNode< std::string >( hRoot, "description_" + ResourceManager::getSingleton().languageSuffix() + + " description_en description", this, &OpenGate::Entity::setDescription, false ); + + readXMLNodes< std::string >( hRoot, "production-center", this, &OpenGate::Entity::addProductionCenter ); +} + void Entity::loadImages_( ) { - imageInitialised_ = true; - bool haveSmall = true; + imageInitialised_ = true; + bool haveSmall = true; - if ( imageFileName_ == "unknown" ) imageFileName_ = name_; + if ( imageFileName_ == "unknown" ) imageFileName_ = name_; - if ( !initialiseImage( imageFileName_ + "_small.png", imageFileName_ + "Small" ) ){ - haveSmall = false; - } + if ( !initialiseImage( imageFileName_ + "_small.png", imageFileName_ + "Small" ) ){ + haveSmall = false; + } - if ( haveSmall ){ - ceguiSmallImageName_ = ceguiImageName_; - } + if ( haveSmall ){ + ceguiSmallImageName_ = ceguiImageName_; + } - if ( !initialiseImage( imageFileName_ + "_big.png", imageFileName_ ) ){ + if ( !initialiseImage( imageFileName_ + "_big.png", imageFileName_ ) ){ //**fallback; - initialiseImage( imageFileName_ + ".png", imageFileName_, true ); - } + initialiseImage( imageFileName_ + ".png", imageFileName_, true ); + } - if ( !haveSmall ) { - initialiseImage( imageFileName_ + ".png", imageFileName_ + "Small" ); - ceguiSmallImageName_ = ceguiImageName_; - } + if ( !haveSmall ) { + initialiseImage( imageFileName_ + ".png", imageFileName_ + "Small" ); + ceguiSmallImageName_ = ceguiImageName_; + } } bool Entity::initialiseImage( const std::string & imageName, const std::string & targetName, bool verbose ){ @@ -128,27 +129,26 @@ return !fail; } -void Entity::readPropertiesFromXML( TiXmlHandle & hRoot ){ - readXMLNode< std::string >( hRoot, "name_"+ ResourceManager::getSingleton().languageSuffix() + " name_en name", - this, &OpenGate::Entity::setName, true ); +void Entity::setFactionID( int id ){ + factionID_ = id; + setFactionName_( ResourceManager::getSingleton().factionName( factionID_ ) ); +} - readXMLNode< Uint16 >( hRoot, "object_id", this, &OpenGate::Entity::setID, true ); - readXMLNode< Uint8 >( hRoot, "faction_id", this, &OpenGate::Entity::setFactionID, true ); +MeshEntity::MeshEntity(): Entity(){ + baseSize_ = Ogre::Vector3::ZERO; + baseYaw_ = 0; + basePitch_ = 0; + baseRoll_ = 0; +} - // what is that for - //readXMLNode< Uint8 >( hRoot, "class_id", this, &OpenGate::Entity::setClassID, false ); - readXMLNode< Uint8 >( hRoot, "techlevel required_rank", this, &OpenGate::Entity::setTechLevel, false ); - - readXMLNode< int >( hRoot, "size", this, &OpenGate::Entity::setSize, false ); - readXMLNode< int >( hRoot, "mass", this, &OpenGate::Entity::setMass, false ); +MeshEntity::~MeshEntity(){} + +void MeshEntity::readPropertiesFromXML( TiXmlHandle & hRoot ){ + Entity::readPropertiesFromXML( hRoot ); - readXMLNode< std::string >( hRoot, "description_" + ResourceManager::getSingleton().languageSuffix() + - " description_en description", this, &OpenGate::Entity::setDescription, false ); - - readXMLNodes< std::string >( hRoot, "production-center", this, &OpenGate::Entity::addProductionCenter ); - readXMLNode< float >( hRoot, "baseyaw", this, &OpenGate::Entity::setBaseYaw, false ); - readXMLNode< float >( hRoot, "basepitch", this, &OpenGate::Entity::setBasePitch, false ); - readXMLNode< float >( hRoot, "baseroll", this, &OpenGate::Entity::setBaseRoll, false ); + readXMLNode< float >( hRoot, "baseyaw", this, &OpenGate::MeshEntity::setBaseYaw, false ); + readXMLNode< float >( hRoot, "basepitch", this, &OpenGate::MeshEntity::setBasePitch, false ); + readXMLNode< float >( hRoot, "baseroll", this, &OpenGate::MeshEntity::setBaseRoll, false ); TiXmlElement * pElem; @@ -171,8 +171,44 @@ if ( pElem ) height = toDouble( pElem->FirstChild()->Value() ); if ( length > 0 && width > 0 && height > 0 ) this->setBaseSize( width, height, length ); - + + if ( !readXMLNode< std::string >( hRoot, "mesh", this, &OpenGate::MeshEntity::setMesh, false ) ){ + + try { + setMesh( createMeshName( name_ ) ); + } catch( Ogre::Exception & e ){ + LogManager::getSingleton().warn( e.what() ); + } + } } + +void MeshEntity::setBaseSize( float length, float width, float height ){ + baseSize_[ 0 ] = length; + baseSize_[ 1 ] = width; + baseSize_[ 2 ] = height; +} + /*! If size is a scalar value, the length of the entity. */ +void MeshEntity::setBaseSize( float size ){ baseSize_[ 2 ] = size; } +Ogre::Vector3 MeshEntity::baseSize( ) const { return baseSize_; } + +std::string MeshEntity::createMeshName( const std::string & meshName ){ + return strReplaceBlankWithUnderscore( strCopyToLowerCase( meshName ) ); +} + +void MeshEntity::setMesh( const std::string & meshName ){ + meshName_ = meshName.substr( 0, meshName.rfind( ".mesh" ) ) + ".mesh" ; + + pMesh_ = Ogre::MeshManager::getSingleton().load( meshName_, + "General", + Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, + Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY, + true, true); + + unsigned short src = 0, dest = 0; + if ( !pMesh_->suggestTangentVectorBuildParams( Ogre::VES_TANGENT, src, dest) ) { + pMesh_->buildTangentVectors( Ogre::VES_TANGENT, src, dest); + } +} } // namespace OpenGate Modified: trunk/src/Entity.h =================================================================== --- trunk/src/Entity.h 2008-05-18 19:30:59 UTC (rev 900) +++ trunk/src/Entity.h 2008-05-20 21:26:54 UTC (rev 901) @@ -27,6 +27,7 @@ #include "common.h" #include <OgreVector3.h> +#include <OgreMesh.h> // namespace Ogre{ // class Vector3; @@ -35,7 +36,7 @@ namespace OpenGate{ -enum EntityType{NONE,ENTITY,VESSEL,COMMODITY,POWERPLANT,ENGINE,RADAR,ECM,CAPACITOR,SHIELD,GUN,MISSILE,MODX}; +enum EntityType{NONE,ENTITY,VESSEL,COMMODITY,POWERPLANT,ENGINE,RADAR,ECM,CAPACITOR,SHIELD,GUN,MISSILE,MODX,STATION}; enum GunType{UNKNOWN,LASER,MININGLASER,BULLET}; class Commodity; @@ -92,26 +93,6 @@ inline void setID( int id ){ id_ = id; } inline int id( ) const { return id_; } - /*! Base sizes are necessary for resizing the ogremesh */ - void setBaseSize( float length, float width, float height ); - - /*! If size is a scalar value, the length of the entity.*/ - void setBaseSize( float size ); - - Ogre::Vector3 baseSize( ) const; - - /*! Base sizes are necessary for resizing the ogremesh */ - inline void setBaseYaw( Ogre::Real baseYaw ){ baseYaw_ = baseYaw; } - inline Ogre::Real baseYaw( ) const { return baseYaw_; } - - /*! Base sizes are necessary for resizing the ogremesh */ - inline void setBasePitch( Ogre::Real basePitch ){ basePitch_ = basePitch; } - inline Ogre::Real basePitch( ) const { return basePitch_; } - - /*! Base sizes are necessary for resizing the ogremesh */ - inline void setBaseRoll( Ogre::Real baseRoll ){ baseRoll_ = baseRoll; } - inline Ogre::Real baseRoll( ) const { return baseRoll_; } - inline void setTechLevel( int level ){ techLevel_ = level; } inline int techLevel( ) const { return techLevel_; } @@ -153,12 +134,6 @@ std::string factionName_; int factionID_; - //** geometric parameters - Ogre::Vector3 baseSize_; - Ogre::Real baseYaw_; - Ogre::Real basePitch_; - Ogre::Real baseRoll_; - std::string imageFileName_; std::string ceguiSmallImageName_; std::string ceguiImageName_; @@ -185,6 +160,67 @@ //std::vector < Property< class ValueType > * > properties_; }; +class MeshEntity : public Entity{ +public: + MeshEntity(); + + virtual ~MeshEntity(); + + void readPropertiesFromXML( TiXmlHandle & hRoot ); + + /*! Base sizes are necessary for resizing the ogremesh */ + void setBaseSize( float length, float width, float height ); + + /*! If size is a scalar value, the length of the entity.*/ + void setBaseSize( float size ); + Ogre::Vector3 baseSize( ) const; + + /*! Base sizes are necessary for resizing the ogremesh */ + inline void setBaseYaw( Ogre::Real baseYaw ){ baseYaw_ = baseYaw; } + inline Ogre::Real baseYaw( ) const { return baseYaw_; } + + /*! Base sizes are necessary for resizing the ogremesh */ + inline void setBasePitch( Ogre::Real basePitch ){ basePitch_ = basePitch; } + inline Ogre::Real basePitch( ) const { return basePitch_; } + + /*! Base sizes are necessary for resizing the ogremesh */ + inline void setBaseRoll( Ogre::Real baseRoll ){ baseRoll_ = baseRoll; } + inline Ogre::Real baseRoll( ) const { return baseRoll_; } + + void setMesh( const std::string & meshName ); + std::string meshName( ) const { return meshName_; } + virtual std::string createMeshName( const std::string & meshName ); + Ogre::MeshPtr & meshPtr( ){ return pMesh_; } + +protected: + //** geometric parameters + Ogre::Vector3 baseSize_; + Ogre::Real baseYaw_; + Ogre::Real basePitch_; + Ogre::Real baseRoll_; + + Ogre::MeshPtr pMesh_; + + std::string meshName_; +}; + +//! +/*!*/ +class Station : public MeshEntity{ +public: + Station( ) : MeshEntity(){ + rtti_ = STATION; + } + + virtual ~Station( ){} + + void readPropertiesFromXML( TiXmlHandle & hRoot ){ + MeshEntity::readPropertiesFromXML( hRoot ); + } + +protected: +}; + } // namespace OpenGate #endif //_OPENGATE_ENTITY_H Modified: trunk/src/EntityManager.cpp =================================================================== --- trunk/src/EntityManager.cpp 2008-05-18 19:30:59 UTC (rev 900) +++ trunk/src/EntityManager.cpp 2008-05-20 21:26:54 UTC (rev 901) @@ -73,7 +73,10 @@ category == "modx" || category == "modxs" ) return MODX; else if ( category == "Vessel" || category == "Vessels" || category == "vessel" || category == "vessels" ) return VESSEL; + else if ( category == "Station" || category == "Stations" || + category == "station" || category == "stations" ) return VESSEL; + LogManager::getSingleton().warn("Requested entity rtti for " + category + " unknown" ); return ENTITY; } @@ -93,6 +96,7 @@ case MISSILE: return "MISSILE"; case MODX: return "MODx"; case VESSEL: return "Vessel"; + case STATION: return "Station"; } LogManager::getSingleton().warn("Requested name for category " + toStr( type ) + " unknown" ); @@ -129,6 +133,7 @@ Ecm * EntityManager::ecm( const std::string & name ){ return entity_< Ecm >( name ); } Vessel * EntityManager::vessel( const std::string & name ){ return entity_< Vessel >( name ); } Vessel * EntityManager::vessel( Uint16 ID ){ return entity_< Vessel >( ID ); } +Station * EntityManager::station( const std::string & name ){ return entity_< Station >( name ); } std::vector < Entity * > EntityManager::allByCategory( const std::string & category ){ EntityType rtti = NONE; @@ -212,15 +217,16 @@ int category = toInt( pElem->FirstChild()->Value() ); switch( category ){ - case 1: entity = new Commodity(); break; + case 1: entity = new Commodity(); break; case 2: entity = new PowerPlant(); break; - case 4: entity = new Capacitor(); break; - case 6: entity = new Engine(); break; - case 7: entity = new Shield(); break; - case 8: entity = new Radar(); break; - case 9: entity = new Vessel(); break; - case 10: entity = new Gun(); break; - case 11: entity = new Missile(); break; + case 3: entity = new Station(); break; + case 4: entity = new Capacitor(); break; + case 6: entity = new Engine(); break; + case 7: entity = new Shield(); break; + case 8: entity = new Radar(); break; + case 9: entity = new Vessel(); break; + case 10: entity = new Gun(); break; + case 11: entity = new Missile(); break; default: log_->fatal( fileName + " category_id " + toStr( category ) + " unknown." ); return NULL; @@ -254,467 +260,7 @@ categories_.insert( entity->categoryName() ); return entity; } - -// template<> EquipmentManager * Ogre::Singleton< EquipmentManager >::ms_Singleton = 0; -// -// EquipmentManager::EquipmentManager(): EntityManager(){ -// Entity * entity = new Missile(); -// entity->setName( "firefly" ); -// entity->setID( 10001 ); -// dynamic_cast< Missile * >( entity )->setDamage( 10400 ); -// dynamic_cast< Missile * >( entity )->setThrust( 150000 ); -// // dynamic_cast< Missile * >( entity )->setYaw( 90 ); -// // dynamic_cast< Missile * >( entity )->setPitch( 90 ); -// // dynamic_cast< Missile * >( entity )->setRoll( 90 ); -// //dynamic_cast< Missile * >( entity )->setArmor( 1 ); -// //dynamic_cast< Missile * >( entity )->setMass( 150 ); -// dynamic_cast< Missile * >( entity )->setLifeTime( 20 ); -// // dynamic_cast< Missile * >( entity )->setDragFactor( 1 ); -// dynamic_cast< Missile * >( entity )->setBaseSize(0.2, 0.2, 1.0 ); -// try{ -// dynamic_cast< Missile * >(entity)->setMesh( "firefly.mesh", false ); -// -// -// } catch( Ogre::Exception & e ){ -// LogManager::getSingleton().warn( e.what() ); -// } -// templatesByName_[ entity->name() ] = entity; -// templatesByID_[ entity->id() ] = entity; -// } -// -// EquipmentManager::~EquipmentManager() { -// } -// -// EquipmentManager & EquipmentManager::getSingleton( ){ -// assert( ms_Singleton ); -// return ( *ms_Singleton ); -// } -// -// EquipmentManager * EquipmentManager::getSingletonPtr( ){ -// if ( ms_Singleton == NULL ){ -// LogManager::getSingleton().fatal( "CommodityManager not initialized." ); -// } -// return ms_Singl... [truncated message content] |
From: <spo...@us...> - 2008-05-21 20:06:12
|
Revision: 902 http://opengate.svn.sourceforge.net/opengate/?rev=902&view=rev Author: spom_spom Date: 2008-05-21 13:04:57 -0700 (Wed, 21 May 2008) Log Message: ----------- ogEditor loads and show the testsector identical to the client. Some refactoring and cleaning. Add a screenshot to the web site Modified Paths: -------------- branches/ogEditor/ogEditor.py branches/ogEditor/propgridtest.py branches/ogEditor/resources.cfg branches/ogEditor/src/ObjectInspectorPanels.py branches/ogEditor/src/OgreWindowWx.py branches/ogEditor/src/PropertyGrid.py trunk/plugins.cfg trunk/src/BaseObject.cpp trunk/src/BaseObject.h trunk/src/SectorObject.cpp trunk/src/Station.cpp trunk/src/Station.h Modified: branches/ogEditor/ogEditor.py =================================================================== --- branches/ogEditor/ogEditor.py 2008-05-20 21:26:54 UTC (rev 901) +++ branches/ogEditor/ogEditor.py 2008-05-21 20:04:57 UTC (rev 902) @@ -46,24 +46,66 @@ NAME_RESOURCE = "Resource browser" NAME_PYCRUST = "PyCrust" +class WorkSpace: + activeResource = None; + def __init__(self): + Pass + +class Opengate: + resourceManager_ = None + + def __init__( self, ): + self.resourceManager_ = og.ResourceManager() + self.resourceManager_.logManager = og.LogManager() + self.resourceManager_.entityManager = og.EntityManager( ) + + def initOpenGateResources_( self ): + self.resourceManager_.loadGlobalIDs( "ids.xml" ) + entityManager = self.resourceManager_.entityManager + entityManager.load( self.resourceManager_.resourceLocations( "General" ), "commodities" ); + entityManager.load( self.resourceManager_.resourceLocations( "General" ), "engines" ); + entityManager.load( self.resourceManager_.resourceLocations( "General" ), "capacitors" ); + entityManager.load( self.resourceManager_.resourceLocations( "General" ), "radars" ); + entityManager.load( self.resourceManager_.resourceLocations( "General" ), "shields" ); + entityManager.load( self.resourceManager_.resourceLocations( "General" ), "ecms" ); + entityManager.load( self.resourceManager_.resourceLocations( "General" ), "power_plants" ); + entityManager.load( self.resourceManager_.resourceLocations( "General" ), "guns" ); + entityManager.load( self.resourceManager_.resourceLocations( "General" ), "missiles" ); + entityManager.load( self.resourceManager_.resourceLocations( "General" ), "ships" ); + entityManager.load( self.resourceManager_.resourceLocations( "General" ), "stations" ); + + def getName( self ): + return "Opengate" + + def fillProperties( self, objectInspectorPanel ): + objectInspectorPanel.typeStaticText.SetLabel( "Opengate" ) + shaderSchemes = ( "Default", "vpOnly", "vpfp" ) + vp = self.resourceManager_.renderWindow.getViewport( 0 ) + self.interpolModeChosser = objectInspectorPanel.propertyGrid.appendRowItemChoice( "shader scheme", + value = "Default", + itemList = shaderSchemes, + cback = vp.setMaterialScheme ) + + class MainFrame(wx.Frame): def __init__(self, *args, **kwds): kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.SetSize( wx.Size( 1024, 768 ) ) - self.ogResourceManager = og.ResourceManager() - self.ogResourceManager.logManager = og.LogManager() + global ws + ws = WorkSpace + self.og = Opengate() + self.initMenuBar_() self.initToolBar_() self.initStatusBar_() self.initFrameManager_() - self.initOpenGateResources_(); - self.sector = og.Sector( self.ogreRenderWindow.sceneManager, None ); + self.og.initOpenGateResources_(); + self.og.sector = og.Sector( self.ogreRenderWindow.sceneManager, None ); - self.setDefaultProperties_(); self.auiMgr.Update() @@ -146,7 +188,7 @@ ################################################################################# def createRenderWindow_( self ): - self.ogreRenderWindow = OgreWindow( self, -1, ogResourceMan = self.ogResourceManager ) + self.ogreRenderWindow = OgreWindow( self, -1, ogResourceMan = self.og.resourceManager_ ) return self.ogreRenderWindow def createCrustWindow_( self ): @@ -179,23 +221,6 @@ wx.TR_DEFAULT_STYLE | wx.NO_BORDER ); self.Bind( wx.EVT_TREE_SEL_CHANGED, self.doSelectTreeObject, self.resourceTree ) return self.resourceTree - - def initOpenGateResources_( self ): - self.ogResourceManager.loadGlobalIDs( "ids.xml" ) - entityManager = og.EntityManager( ) - self.ogResourceManager.entityManager = entityManager - - entityManager.load( self.ogResourceManager.resourceLocations( "General" ), "commodities" ); - entityManager.load( self.ogResourceManager.resourceLocations( "General" ), "engines" ); - entityManager.load( self.ogResourceManager.resourceLocations( "General" ), "capacitors" ); - entityManager.load( self.ogResourceManager.resourceLocations( "General" ), "radars" ); - entityManager.load( self.ogResourceManager.resourceLocations( "General" ), "shields" ); - entityManager.load( self.ogResourceManager.resourceLocations( "General" ), "ecms" ); - entityManager.load( self.ogResourceManager.resourceLocations( "General" ), "power_plants" ); - entityManager.load( self.ogResourceManager.resourceLocations( "General" ), "guns" ); - entityManager.load( self.ogResourceManager.resourceLocations( "General" ), "missiles" ); - entityManager.load( self.ogResourceManager.resourceLocations( "General" ), "ships" ); - entityManager.load( self.ogResourceManager.resourceLocations( "General" ), "stations" ); def setDefaultProperties_( self ): self.SetTitle("ogEditor") @@ -255,8 +280,18 @@ def doSelectTreeObject( self, event ): obj = event.GetEventObject().GetPyData( event.GetEventObject().GetSelection() ) - self.ogreRenderWindow.camera.lookAt( obj.getWorldPosition() ) + if type( obj ) == ogre.SceneNode: + self.ogreRenderWindow.camera.lookAt( obj.getWorldPosition() ) self.objectInspector.showData( obj ); + + if ws.activeResource: + if type( ws.activeResource ) == ogre.SceneNode: + ws.activeResource.showBoundingBox( False ); + + if type( obj ) == ogre.SceneNode: + obj.showBoundingBox( True ); + + ws.activeResource = obj event.Skip() ################################################################################# @@ -280,6 +315,10 @@ self.dumpSceneNode_( rootSceneNodeTreeNode, rootSceneNode ) self.sceneTree.Expand( root ) + + opengateNode = self.sceneTree.AppendItem( root, "Opengate" ) + self.sceneTree.SetPyData( opengateNode, self.og ) + if event != None: event.Skip() @@ -293,6 +332,12 @@ self.sceneTree.SetItemImage(nexttreenode, self.SceneNodeIconID, CT.TreeItemIcon_Selected) self.sceneTree.SetPyData( nexttreenode, nextnode ) + self.sceneTree.CheckItem( nexttreenode, True ); + #if nextnode.getAttachedObject( 0 ).isVisible(): + #self.sceneTree.CheckItem( nexttreenode, True ); + #else: + #self.sceneTree.CheckItem( nexttreenode, False ); + self.dumpAttachedMovableObjects_( nexttreenode, nextnode ) self.dumpSceneNode_( nexttreenode, nextnode ) Modified: branches/ogEditor/propgridtest.py =================================================================== --- branches/ogEditor/propgridtest.py 2008-05-20 21:26:54 UTC (rev 901) +++ branches/ogEditor/propgridtest.py 2008-05-21 20:04:57 UTC (rev 902) @@ -35,6 +35,8 @@ text = PropertyRowItemName( pane.GetPane(), "Name", "Val") pane.appendRow( text ) + pane.Layout() + pane.Show() self.propertyGrid.appendRowItemSlider( "expDensity", 0.0001, 0.0002, format = FORMAT_LOG10, @@ -47,12 +49,14 @@ dic = ( (1, "eins"), (2, "zwei"), (3, "drei")) self.propertyGrid.appendRowItemChoice( "Choice map", value = 1, itemMap = dic, cback = test.printValue ) + self.propertyGrid.appendRowItemFileSelect( "File", cback = test.printValue ) self.propertyGrid.appendRowItemFileSelect( "Files", cback = test.printValue, flag = wx.MULTIPLE ) self.propertyGrid.appendRowItemButton( "Button", cback = test.printValue ) self.propertyGrid.appendRowItemInfo( "here is a long an verbose text entry" ) + if __name__ == "__main__": ogEditor = wx.PySimpleApp(0) Modified: branches/ogEditor/resources.cfg =================================================================== --- branches/ogEditor/resources.cfg 2008-05-20 21:26:54 UTC (rev 901) +++ branches/ogEditor/resources.cfg 2008-05-21 20:04:57 UTC (rev 902) @@ -5,7 +5,6 @@ # Resource locations to be added to the default path [General] FileSystem=../../trunk/data/ -FileSystem=../../trunk/data/asteroids FileSystem=../../trunk/data/capacitors FileSystem=../../trunk/data/commodities FileSystem=../../trunk/data/gui @@ -19,6 +18,7 @@ FileSystem=../../trunk/data/engines FileSystem=../../trunk/data/guns FileSystem=../../trunk/data/materials +FileSystem=../../trunk/data/asteroids FileSystem=../../trunk/data/misc FileSystem=../../trunk/data/missiles FileSystem=../../trunk/data/power_plants Modified: branches/ogEditor/src/ObjectInspectorPanels.py =================================================================== --- branches/ogEditor/src/ObjectInspectorPanels.py 2008-05-20 21:26:54 UTC (rev 901) +++ branches/ogEditor/src/ObjectInspectorPanels.py 2008-05-21 20:04:57 UTC (rev 902) @@ -10,6 +10,9 @@ from PropertyGrid import * +def toStr( vec ): + return ("%g, %g, %g"%(vec.x, vec.y, vec.z)) + class PropertyCollapsibleOgreFogPane( PropertyPaneItem ): def __init__( self, parent, name, object = None ): PropertyPaneItem.__init__(self, parent, name) @@ -30,11 +33,11 @@ (ogre.FOG_EXP2, "FOG_EXP2"), (ogre.FOG_LINEAR,"FOG_LINEAR")) - self.m = self.appendRowItemChoice( "Mode", itemMap=modes, cback = self.setMode ) + self.m = self.appendRowItemChoice( "Mode", value = ogre.FOG_NONE, itemMap=modes, cback = self.setMode ) self.c = self.appendRowItemColourSelect( "Colour", cback = self.setRGBA ) - self.min = self.appendRowItemSlider( "linearStart", 0, 1, format = SLIDER_FLOAT, cback = self.setLinMin ) - self.max = self.appendRowItemSlider( "linearEnd", 0, 1, format = SLIDER_FLOAT, cback = self.setLinMax ) - self.exp = self.appendRowItemSlider( "expDensity", 0.0001, 0.01, format = SLIDER_LOG10, cback = self.setExpDens ) + self.min = self.appendRowItemSlider( "linearStart", 0, 1, format = FORMAT_FLOAT, cback = self.setLinMin ) + self.max = self.appendRowItemSlider( "linearEnd", 0, 1, format = FORMAT_FLOAT, cback = self.setLinMax ) + self.exp = self.appendRowItemSlider( "expDensity", 0.0001, 0.01, format = FORMAT_FLOAT, cback = self.setExpDens ) if object != None: mode = object.getFogMode() @@ -111,21 +114,26 @@ def showData( self, data ): self.propertyGrid.clean() - if type( data ) == None: - self.showNone() - if type( data ) == ogre.SceneNode: - self.showSceneNode( data ) - elif issubclass( type( data ), ogre.SceneManager): - self.showSceneManager( data ) - elif issubclass( type( data ), ogre.Resource ): - self.showResource( data ) - elif issubclass( type( data ), ogre.MovableObject ): - self.showMovableObject( data ) - elif issubclass( type( data ), ogre.ResourceManager ): - self.showResourceManager( data ) + if hasattr( data, "fillProperties" ): + data.fillProperties( self ) else: - self.showUnknown( data ) - self.propertyGrid.sizer.Layout() + if type( data ) == None: + self.showNone() + if type( data ) == ogre.SceneNode: + self.showSceneNode( data ) + elif type( data ) == ogre.Entity: + self.showEntity( data ) + elif issubclass( type( data ), ogre.SceneManager): + self.showSceneManager( data ) + elif issubclass( type( data ), ogre.Resource ): + self.showResource( data ) + elif issubclass( type( data ), ogre.MovableObject ): + self.showMovableObject( data ) + elif issubclass( type( data ), ogre.ResourceManager ): + self.showResourceManager( data ) + else: + self.showUnknown( data ) + self.propertyGrid.sizer_.Layout() def showNone( self ): self.typeStaticText.SetLabel( "None" ) @@ -177,9 +185,22 @@ def showSceneNode( self, data ): self.typeStaticText.SetLabel( "SceneNode" ) self.showName( data ) - print data.getWorldPosition() - self.propertyGrid.appendRowItemInfo( "world position (%g, %g, %g)"%(data.getWorldPosition().x, data.getWorldPosition().y, data.getWorldPosition().z) ) + self.propertyGrid.appendRowItemInfo( "world AABB min %s" % toStr( data._getWorldAABB().getMinimum() ) ) + self.propertyGrid.appendRowItemInfo( "world AABB max %s" % toStr( data._getWorldAABB().getMaximum() ) ) + self.propertyGrid.appendRowItemInfo( "world size %s" % toStr(data._getWorldAABB().getMaximum()-data._getWorldAABB().getMinimum() ) ) + + self.propertyGrid.appendRowItemInfo( "world position %s" % toStr(data.getWorldPosition() ) ) + self.propertyGrid.appendRowItemInfo( "scale %s" % toStr( data.getScale() ) ) + + #getWorldOrientation + #getOrientation + #_getWorldAABB + + def showEntity( self, data ): + self.typeStaticText.SetLabel( "ogre.Entity" ) + self.showName( data ) + def showResource( self, data ): self.typeStaticText.SetLabel( "Resource: " + data.getCreator().getResourceType() ) self.showName( data ); Modified: branches/ogEditor/src/OgreWindowWx.py =================================================================== --- branches/ogEditor/src/OgreWindowWx.py 2008-05-20 21:26:54 UTC (rev 901) +++ branches/ogEditor/src/OgreWindowWx.py 2008-05-21 20:04:57 UTC (rev 902) @@ -213,8 +213,7 @@ self.camera.setAutoAspectRatio( True ) # create the camera nodes & attach camera - cameraNode = self.sceneManager.getRootSceneNode().createChildSceneNode( self.camera.getName(), - ogre.Vector3( 0, 0, 250 ) ) + cameraNode = self.sceneManager.getRootSceneNode().createChildSceneNode( self.camera.getName(), ogre.Vector3( 0, 0, 0 ) ) pitchNode = cameraNode.createChildSceneNode( cameraNode.getName() + "/PitchNode" ) pitchNode.attachObject( self.camera ) @@ -278,7 +277,7 @@ dy = self.StartDragY -y self.StartDragX, self.StartDragY = x, y - self.sceneEntities.cameraNode.yaw( ogre.Degree( dx / 3.0 ), ogre.Node.TS_LOCAL ) - self.sceneEntities.cameraNode.pitch( ogre.Degree( dy / 3.0 ), ogre.Node.TS_LOCAL ) + self.sceneEntities.cameraNode.yaw( ogre.Degree( dx / 5.0 ), ogre.Node.TS_LOCAL ) + self.sceneEntities.cameraNode.pitch( ogre.Degree( dy / 5.0 ), ogre.Node.TS_LOCAL ) #self.sceneEntities.cameraPitchNode.pitch( ogre.Degree( dy / 3.0 ), ogre.Node.TS_LOCAL ) event.Skip() Modified: branches/ogEditor/src/PropertyGrid.py =================================================================== --- branches/ogEditor/src/PropertyGrid.py 2008-05-20 21:26:54 UTC (rev 901) +++ branches/ogEditor/src/PropertyGrid.py 2008-05-21 20:04:57 UTC (rev 902) @@ -278,16 +278,16 @@ self.cback_( self.value ) class PropertyRowItemButton( PropertyRowItem ): - button_ = None + button_ = None - def __init__( self, parent, name, cback = None ): - PropertyRowItem.__init__( self, parent, name, cback = cback ) - self.button_ = wx.Button( parent, -1, - size = wx.Size( 40, self.rowHeight_ ), - style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND) - self.sizer_.AddSpacer( 1 ) - self.sizer_.Add( self.button_, 1, wx.EXPAND | wx.ALIGN_LEFT ) - self.button_.Bind( wx.EVT_BUTTON, self.cback_ ) + def __init__( self, parent, name, cback = None ): + PropertyRowItem.__init__( self, parent, name, cback = cback ) + self.button_ = wx.Button( parent, -1, + size = wx.Size( 40, self.rowHeight_ ), + style = wx.NO_BORDER | wx.ALIGN_LEFT | wx.EXPAND) + self.sizer_.AddSpacer( 1 ) + self.sizer_.Add( self.button_, 1, wx.EXPAND | wx.ALIGN_LEFT ) + self.button_.Bind( wx.EVT_BUTTON, self.cback_ ) class PropertyRowItemFileSelect( PropertyRowItem ): def __init__( self, parent, name, value = "", cback = None, flag = 0, @@ -589,7 +589,7 @@ return item def appendRowItemChoice(self, name, value = None, itemList = None, itemMap = None, cback = None ): - item = PropertyRowItemChoice( self.pane, name, value, itemList, itemMap, cback ) + item = PropertyRowItemChoice( self.pane, name = name , value = value, itemList = itemList, itemMap = itemMap, cback = cback ) self.appendRow( item ) return item @@ -613,7 +613,8 @@ return item def appendPane(self, pane ): - self.sizer_.AddSpacer(1) + self.sizer_.AddSpacer( 1 ) + #self.sizer_.Add( pane, 0, wx.EXPAND ) self.sizer_.Add( pane, 0, wx.EXPAND ) def appendPaneColourSelect( self, name, cfront = None, cback = None ): @@ -622,29 +623,39 @@ return pane +#class PropertyPaneItem( wx.Panel, PropertyGrid ): class PropertyPaneItem( wx.CollapsiblePane, PropertyGrid ): def __init__(self, parent, name): + self.parent_ = parent wx.CollapsiblePane.__init__( self, parent, -1, name, style = wx.CP_DEFAULT_STYLE - | wx.CP_NO_TLW_RESIZE ) - PropertyGrid.__init__(self) + | wx.CP_NO_TLW_RESIZE + ) + #wx.Panel.__init__( self, parent, -1 ) + PropertyGrid.__init__( self ) - self.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) - self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnPaneChanged ) + self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnPaneChanged, self ) self.pane = self.GetPane() self.pane.SetFont( wx.Font( 8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "" ) ) - self.sizer = wx.BoxSizer( wx.VERTICAL ) - self.pane.SetSizer( self.sizer ) + + self.sizer_ = wx.BoxSizer( wx.VERTICAL ) + self.pane.SetSizer( self.sizer_ ) + #def GetPane( self ): + #return self.pane + def OnPaneChanged(self, event = None): if event: if ( event.Collapsed ): event.GetEventObject().GetPane().Hide() else: event.GetEventObject().GetPane().Show() + #self.pane.Show() + #self.Layout() + #self.parent_.Layout() self.GetParent().Layout() @@ -657,10 +668,10 @@ self.scale = 255.0 self.c = self.appendRowItemColourSelect( "Colour", cback = self.setRGB ) - self.r = self.appendRowItemSlider( "red", 0, 255, cback = self.setRed ) - self.g = self.appendRowItemSlider( "green", 0, 255, cback = self.setGreen ) - self.b = self.appendRowItemSlider( "blue", 0, 255, cback = self.setBlue ) - self.a = self.appendRowItemSlider( "alpha", 0, 255, cback = self.setAlpha ) + self.r = self.appendRowItemSlider( "red", start = 0, end = 255, format = FORMAT_INT, cback = self.setRed ) + self.g = self.appendRowItemSlider( "green", start = 0, end = 255, format = FORMAT_INT, cback = self.setGreen ) + self.b = self.appendRowItemSlider( "blue", start = 0, end = 255, format = FORMAT_INT, cback = self.setBlue ) + self.a = self.appendRowItemSlider( "alpha", start = 0, end = 255, format = FORMAT_INT, cback = self.setAlpha ) if self.cfront != None: colour = self.cfront() Modified: trunk/plugins.cfg =================================================================== --- trunk/plugins.cfg 2008-05-20 21:26:54 UTC (rev 901) +++ trunk/plugins.cfg 2008-05-21 20:04:57 UTC (rev 902) @@ -6,5 +6,5 @@ # Define D3D rendering implementation plugin Plugin=RenderSystem_GL.so Plugin=Plugin_ParticleFX.so -Plugin=Plugin_CgProgramManager.so +#Plugin=Plugin_CgProgramManager.so Modified: trunk/src/BaseObject.cpp =================================================================== --- trunk/src/BaseObject.cpp 2008-05-20 21:26:54 UTC (rev 901) +++ trunk/src/BaseObject.cpp 2008-05-21 20:04:57 UTC (rev 902) @@ -28,13 +28,15 @@ namespace OpenGate{ -BaseObject::BaseObject( const Ogre::String & name, Sector * sector, Uint32 userID, Uint8 childID ) - : name_( name ), sector_( sector ), userID_( userID ), childID_( childID ), mainNode_( NULL ), collObj_( NULL ){ +BaseObject::BaseObject( const Ogre::String & name, Sector * sector, Uint32 userID, Uint8 childID, Ogre::SceneNode * parentNode ) + : name_( name ), sector_( sector ), userID_( userID ), childID_( childID ), mainNode_( NULL ), parentNode_( parentNode ), collObj_( NULL ){ globalID_ = createGlobalID( userID, childID ); sceneMgr_ = sector_->sceneManager(); + if ( !parentNode_ ) parentNode_ = sceneMgr_->getRootSceneNode(); + try{ - mainNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode( name ); + mainNode_ = parentNode_->createChildSceneNode( name_ ); } catch( Ogre::Exception & e ) { LogManager::getSingleton().fatal( e.getFullDescription() ); } @@ -46,7 +48,7 @@ } BaseObject::~BaseObject(){ - sceneMgr_->getRootSceneNode()->removeAndDestroyChild( mainNode_->getName() ); + parentNode_->removeAndDestroyChild( mainNode_->getName() ); } void BaseObject::setActive( bool activate ){ Modified: trunk/src/BaseObject.h =================================================================== --- trunk/src/BaseObject.h 2008-05-20 21:26:54 UTC (rev 901) +++ trunk/src/BaseObject.h 2008-05-21 20:04:57 UTC (rev 902) @@ -48,7 +48,7 @@ class BaseObject{ public: - BaseObject( const Ogre::String & name, Sector * sector, Uint32 userId = 0, Uint8 childId = 0 ); + BaseObject( const Ogre::String & name, Sector * sector, Uint32 userId = 0, Uint8 childId = 0, Ogre::SceneNode * parentNode = NULL ); virtual ~BaseObject(); @@ -119,6 +119,7 @@ Uint32 globalID_; Ogre::SceneNode * mainNode_; + Ogre::SceneNode * parentNode_; Ogre::SceneManager * sceneMgr_; Ogre::Real lifeTime_; Modified: trunk/src/SectorObject.cpp =================================================================== --- trunk/src/SectorObject.cpp 2008-05-20 21:26:54 UTC (rev 901) +++ trunk/src/SectorObject.cpp 2008-05-21 20:04:57 UTC (rev 902) @@ -125,10 +125,12 @@ void SectorObject::setBaseSize( const Ogre::Vector3 & size ){ if ( size == Ogre::Vector3::ZERO ) return; - Ogre::Vector3 oldSize( mainNodeEntityRot_->getOrientation() * ( + /* Ogre::Vector3 oldSize( mainNodeEntityRot_->getOrientation() * ( mainNodeEntityRot_->_getWorldAABB().getMaximum()- mainNodeEntityRot_->_getWorldAABB().getMinimum() ) ); - + */ + Ogre::Vector3 oldSize( entity_->getBoundingBox().getMaximum()- entity_->getBoundingBox().getMinimum() ); + Ogre::Vector3 scale( size / oldSize ); scale[ 0 ] = fabs( scale[ 0 ] ); @@ -145,24 +147,24 @@ scale[ 2 ] = scale[ 0 ]; scale[ 1 ] = scale[ 0 ]; } -// std::cout << name_ << std::endl; -// std::cout << "sol: " << size << std::endl; -// std::cout << "ist: " << oldSize << std::endl; -// std::cout << scale << std::endl; -// -// std::cout << mainNodeEntityRot_->_getWorldAABB().getMaximum() << " " << -// mainNodeEntityRot_->_getWorldAABB().getMinimum() << " " << -// mainNodeEntityRot_->_getWorldAABB().getMaximum()-mainNodeEntityRot_->_getWorldAABB().getMinimum() -// << std::endl; -// -// std::cout << entity_->getBoundingBox().getMaximum()- entity_->getBoundingBox().getMinimum() << std::endl; -// -// std::cout << mainNodeEntityRot_->getOrientation() * ( entity_->getBoundingBox().getMaximum()- -// entity_->getBoundingBox().getMinimum() ) << std::endl; -// -// std::cout << mainNode_->_getWorldAABB().getMaximum() - mainNode_->_getWorldAABB().getMinimum() << std::endl; -// std::cout << mainNode_->_getDerivedScale() << std::endl; + std::cout << name_ << std::endl; + std::cout << "sol: " << size << std::endl; + std::cout << "ist: " << oldSize << std::endl; + std::cout << scale << std::endl; + + std::cout << mainNodeEntityRot_->_getWorldAABB().getMaximum() << " " << + mainNodeEntityRot_->_getWorldAABB().getMinimum() << " " << + mainNodeEntityRot_->_getWorldAABB().getMaximum()-mainNodeEntityRot_->_getWorldAABB().getMinimum() + << std::endl; + std::cout << entity_->getBoundingBox().getMaximum()- entity_->getBoundingBox().getMinimum() << std::endl; + + std::cout << mainNodeEntityRot_->getOrientation() * ( entity_->getBoundingBox().getMaximum()- + entity_->getBoundingBox().getMinimum() ) << std::endl; + + std::cout << mainNode_->_getWorldAABB().getMaximum() - mainNode_->_getWorldAABB().getMinimum() << std::endl; + std::cout << mainNode_->_getDerivedScale() << std::endl; + mainNodeEntityScale_->scale( scale ); baseSize_ = size; baseScale_ = scale; Modified: trunk/src/Station.cpp =================================================================== --- trunk/src/Station.cpp 2008-05-20 21:26:54 UTC (rev 901) +++ trunk/src/Station.cpp 2008-05-21 20:04:57 UTC (rev 902) @@ -77,12 +77,9 @@ } Pad::Pad( const std::string & name, SectorObject * parent, Ogre::SubEntity * padSubEntity ) - : BaseObject( name, parent->sector() ), parent_( parent ){ + : BaseObject( name, parent->sector(), 0, 0, parent->rotnode() ), parent_( parent ){ - //** hier gibt es eine mainNode die nicht genutzt wird. C. - //** mach das sauber!! ersetzt getPosition, getDirection, padNode - padNode_ = parent_->rotnode()->createChildSceneNode( parent_->name() + "/" + name_ ); - padManualObject_ = sceneMgr_->createManualObject( padNode_->getName() + "/ManualObject" ); + padManualObject_ = sceneMgr_->createManualObject( mainNode_->getName() + "/ManualObject" ); std::vector < Ogre::Vector3 > verts; std::vector < Triangle > tris; @@ -120,16 +117,15 @@ padMesh_ = padManualObject_->convertToMesh( padManualObject_->getName() + "/Mesh" ); padEntity_ = sceneMgr_->createEntity( padMesh_->getName() + "/Entity", padMesh_->getName() ); - padNode_->attachObject( padEntity_ ); - padNode_->translate( direction_.normalisedCopy() * 0.1 ); + mainNode_->attachObject( padEntity_ ); + mainNode_->translate( direction_.normalisedCopy() * 0.1 ); } Pad::~Pad( ){ - padNode_->detachObject( padEntity_ ); + mainNode_->detachObject( padEntity_ ); sceneMgr_->destroyEntity( padEntity_ ); Ogre::MeshManager::getSingleton().remove( padMesh_->getName() ); sceneMgr_->destroyManualObject( padManualObject_ ); - parent_->rotnode()->removeAndDestroyChild( padNode_->getName() ); } StationPad::StationPad( const std::string & name, StationObject * station, Ogre::SubEntity * padSubEntity, @@ -167,33 +163,33 @@ StationObject::StationObject( Station & station, Sector * sector ) : SectorObject( station.name(), sector ), station_( &station ){ - dockPad_ = NULL; - flashLights_ = NULL; + dockPad_ = NULL; + flashLights_ = NULL; - setShape( station_->meshName() ); + setShape( station_->meshName() ); - for ( uint i = 0; i < entity()->getNumSubEntities(); i ++ ){ - std::cout << entity()->getSubEntity( i )->getMaterialName() << " Techniques: " - << entity()->getSubEntity( i )->getMaterial()->getNumTechniques() << " used: " - << entity()->getSubEntity( i )->getTechnique()->getName() << std::endl; + for ( uint i = 0; i < entity()->getNumSubEntities(); i ++ ){ + std::cout << entity()->getSubEntity( i )->getMaterialName() << " Techniques: " + << entity()->getSubEntity( i )->getMaterial()->getNumTechniques() << " used: " + << entity()->getSubEntity( i )->getTechnique()->getName() << std::endl; // for ( uint j = 0; j < entity()->getSubEntity( i )->getMaterial()->getNumTechniques(); j ++ ){ // std::cout << entity()->getSubEntity( i )->getMaterial()->getTechnique( j )->getName() << std::endl; // } - if ( entity()->getSubEntity( i )->getMaterialName() == "Flashlight/Red" ){ - createFlashLights( entity()->getSubEntity( i ) ); + if ( entity()->getSubEntity( i )->getMaterialName() == "Flashlight/Red" ){ + createFlashLights( entity()->getSubEntity( i ) ); + } + if ( entity()->getSubEntity( i )->getMaterialName() == "Station/DockPad" ){ + dockPad_ = new StationPad( name_ + "DockPad", this, entity()->getSubEntity( i ), true ); + } + if ( entity()->getSubEntity( i )->getMaterialName() == "Station/LaunchPad.001" ){ + launchPad_ = new StationPad( name_ + "LaunchPad", this, entity()->getSubEntity( i ), false ); + } } - if ( entity()->getSubEntity( i )->getMaterialName() == "Station/DockPad" ){ - dockPad_ = new StationPad( name_ + "DockPad", this, entity()->getSubEntity( i ), true ); - } - if ( entity()->getSubEntity( i )->getMaterialName() == "Station/LaunchPad.001" ){ - launchPad_ = new StationPad( name_ + "LaunchPad", this, entity()->getSubEntity( i ), false ); - } - } - setBaseRot( station_->baseYaw(), station_->basePitch(), station_->baseRoll() ); - setBaseSize( station_->baseSize() ); + setBaseRot( station_->baseYaw(), station_->basePitch(), station_->baseRoll() ); + setBaseSize( station_->baseSize() ); if ( dockPad_ ){ createRings( dockPad_->position(), dockPad_->radius(), dockPad_->direction() ); @@ -370,11 +366,11 @@ if ( ResourceManager::getSingleton().collisionManager ){ ResourceManager::getSingleton().collisionManager->detach( this ); } - padNode_->detachObject( padEntity_ ); + mainNode_->detachObject( padEntity_ ); sceneMgr_->destroyEntity( padEntity_ ); padEntity_ = sceneMgr_->createEntity( name_ + "/Entity", meshname ); - padNode_->attachObject( padEntity_ ); - padNode_->translate( position_ ); + mainNode_->attachObject( padEntity_ ); + mainNode_->translate( position_ ); if ( ResourceManager::getSingleton().collisionManager ){ ResourceManager::getSingleton().collisionManager->attach( this ); } Modified: trunk/src/Station.h =================================================================== --- trunk/src/Station.h 2008-05-20 21:26:54 UTC (rev 901) +++ trunk/src/Station.h 2008-05-21 20:04:57 UTC (rev 902) @@ -70,13 +70,13 @@ /*! Radius of the pad */ Ogre::Real radius() const { return radius_; } - Ogre::SceneNode * padNode(){ return padNode_; } + Ogre::SceneNode * padNode(){ return mainNode_; } virtual Ogre::Entity * entity( ) { return padEntity_; } protected: SectorObject * parent_; - Ogre::SceneNode * padNode_; + //Ogre::SceneNode * padNode_; Ogre::ManualObject * padManualObject_; Ogre::MeshPtr padMesh_; Ogre::Entity * padEntity_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spo...@us...> - 2008-05-25 11:51:07
|
Revision: 905 http://opengate.svn.sourceforge.net/opengate/?rev=905&view=rev Author: spom_spom Date: 2008-05-25 04:51:13 -0700 (Sun, 25 May 2008) Log Message: ----------- ogEditor: integrate opengate as module Modified Paths: -------------- branches/ogEditor/ogEditor.py branches/ogEditor/opengate-resources.cfg branches/ogEditor/resources.cfg branches/ogEditor/src/OgreWindowWx.py branches/ogEditor/src/ResourceTreePane.py trunk/resources.cfg trunk/src/Entity.cpp trunk/src/GameStateManager.cpp trunk/src/ResourceManager.cpp Modified: branches/ogEditor/ogEditor.py =================================================================== --- branches/ogEditor/ogEditor.py 2008-05-25 09:10:42 UTC (rev 904) +++ branches/ogEditor/ogEditor.py 2008-05-25 11:51:13 UTC (rev 905) @@ -21,6 +21,7 @@ try: import opengate as og + haveOpenGatePlugin = True except: haveOpenGatePlugin = False pass @@ -56,24 +57,27 @@ self.resourceManager_.ogreRoot = OgreWindow.ogreRoot self.resourceManager_.renderWindow = OgreWindow.renderWindow + OgreWindow.AddResources( "opengate-resources.cfg" ) + ogre.ResourceGroupManager.getSingleton().initialiseResourceGroup( "Opengate" ) + + for res in OgreWindow.resourceLocations: self.resourceManager_.addResourceLocation( res[0], res[1] ) - def initOpenGateResources_( self ): self.resourceManager_.loadGlobalIDs( "ids.xml" ) entityManager = self.resourceManager_.entityManager - entityManager.load( self.resourceManager_.resourceLocations( "General" ), "commodities" ); - entityManager.load( self.resourceManager_.resourceLocations( "General" ), "engines" ); - entityManager.load( self.resourceManager_.resourceLocations( "General" ), "capacitors" ); - entityManager.load( self.resourceManager_.resourceLocations( "General" ), "radars" ); - entityManager.load( self.resourceManager_.resourceLocations( "General" ), "shields" ); - entityManager.load( self.resourceManager_.resourceLocations( "General" ), "ecms" ); - entityManager.load( self.resourceManager_.resourceLocations( "General" ), "power_plants" ); - entityManager.load( self.resourceManager_.resourceLocations( "General" ), "guns" ); - entityManager.load( self.resourceManager_.resourceLocations( "General" ), "missiles" ); - entityManager.load( self.resourceManager_.resourceLocations( "General" ), "ships" ); - entityManager.load( self.resourceManager_.resourceLocations( "General" ), "stations" ); + entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "commodities" ); + entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "engines" ); + entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "capacitors" ); + entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "radars" ); + entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "shields" ); + entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "ecms" ); + entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "power_plants" ); + entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "guns" ); + entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "missiles" ); + entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "ships" ); + entityManager.load( self.resourceManager_.resourceLocations( "Opengate" ), "stations" ); def getName( self ): return "Opengate" @@ -140,7 +144,9 @@ self.og = Opengate( self.ogreRenderWindow ) self.og.initOpenGateResources_(); self.og.sector = og.Sector( self.ogreRenderWindow.sceneManager, None ) - self.og.AddToSceneGraph( self.sceneTree, self.sceneTree.root_ ) + self.resourceTree.buildResourceTree( ) + self.UpdateSceneGraphEvent() + self.og.AddToSceneGraph( self.sceneTree, self.sceneTree.GetRootItem() ) self.og.AddToResourcesTree( self.resourceTree, self.resourceTree.root_ ) else: Modified: branches/ogEditor/opengate-resources.cfg =================================================================== --- branches/ogEditor/opengate-resources.cfg 2008-05-25 09:10:42 UTC (rev 904) +++ branches/ogEditor/opengate-resources.cfg 2008-05-25 11:51:13 UTC (rev 905) @@ -1,14 +1,14 @@ -[General] +[Opengate] FileSystem=../../trunk/data/ FileSystem=../../trunk/data/capacitors FileSystem=../../trunk/data/commodities FileSystem=../../trunk/data/gui -FileSystem=../../trunk/data/gui/fonts -FileSystem=../../trunk/data/gui/layouts -FileSystem=../../trunk/data/gui/imagesets -FileSystem=../../trunk/data/gui/schemes -FileSystem=../../trunk/data/gui/looknfeel -FileSystem=../../trunk/data/gui/overlays +#FileSystem=../../trunk/data/gui/fonts +#FileSystem=../../trunk/data/gui/layouts +#FileSystem=../../trunk/data/gui/imagesets +#FileSystem=../../trunk/data/gui/schemes +#FileSystem=../../trunk/data/gui/looknfeel +#FileSystem=../../trunk/data/gui/overlays FileSystem=../../trunk/data/ecms FileSystem=../../trunk/data/engines FileSystem=../../trunk/data/guns @@ -29,5 +29,5 @@ Zip=../../trunk/data/skybox/simpleSkybox.zip -FileSystem=../../trunk/data/MediaFromOgre -FileSystem=../../trunk/data/MediaFromOgre/AdvancedMaterials +#FileSystem=../../trunk/data/MediaFromOgre +#FileSystem=../../trunk/data/MediaFromOgre/AdvancedMaterials Modified: branches/ogEditor/resources.cfg =================================================================== --- branches/ogEditor/resources.cfg 2008-05-25 09:10:42 UTC (rev 904) +++ branches/ogEditor/resources.cfg 2008-05-25 11:51:13 UTC (rev 905) @@ -1,15 +1,14 @@ [Bootstrap] -Zip=../../local/python-ogre/python-ogre/demos/media/packs/OgreCore.zip +Zip=../../../../local/python-ogre/python-ogre/demos/media/packs/OgreCore.zip [General] -FileSystem=../../local/python-ogre/python-ogre/demos/imemodels -FileSystem=../../local/python-ogre/python-ogre/demos/media -FileSystem=../../local/python-ogre/python-ogre/demos/media/fonts -FileSystem=../../local/python-ogre/python-ogre/demos/media/materials/programs -FileSystem=../../local/python-ogre/python-ogre/demos/media/materials/scripts -FileSystem=../../local/python-ogre/python-ogre/demos/media/materials/textures -FileSystem=../../local/python-ogre/python-ogre/demos/media/models -FileSystem=../../local/python-ogre/python-ogre/demos/media/overlays -FileSystem=../../local/python-ogre/python-ogre/demos/media/particle -FileSystem=../../local/python-ogre/python-ogre/demos/media/gui - +FileSystem=../../../../local/python-ogre/python-ogre/demos/imemodels +FileSystem=../../../../local/python-ogre/python-ogre/demos/media +FileSystem=../../../../local/python-ogre/python-ogre/demos/media/fonts +FileSystem=../../../../local/python-ogre/python-ogre/demos/media/materials/programs +FileSystem=../../../../local/python-ogre/python-ogre/demos/media/materials/scripts +FileSystem=../../../../local/python-ogre/python-ogre/demos/media/materials/textures +FileSystem=../../../../local/python-ogre/python-ogre/demos/media/models +FileSystem=../../../../local/python-ogre/python-ogre/demos/media/overlays +FileSystem=../../../../local/python-ogre/python-ogre/demos/media/particle +FileSystem=../../../../local/python-ogre/python-ogre/demos/media/gui Modified: branches/ogEditor/src/OgreWindowWx.py =================================================================== --- branches/ogEditor/src/OgreWindowWx.py 2008-05-25 09:10:42 UTC (rev 904) +++ branches/ogEditor/src/OgreWindowWx.py 2008-05-25 11:51:13 UTC (rev 905) @@ -63,14 +63,10 @@ self.SceneInitialisation() self.UpdateRender() self.SetFocus() #Gives KeyboardFocus - - def _OgreInit(self,size,renderSystem): - #Root creation - self.ogreRoot = ogre.Root( getPluginPath(), "ogre.cfg" ) - # setup resources + def AddResources( self, resourceFile ): config = ogre.ConfigFile() - config.load( 'resources.cfg' ) + config.load( resourceFile ) self.resourceLocations = [] section_iter = config.getSectionIterator() @@ -80,6 +76,13 @@ for key, path in settings: ogre.ResourceGroupManager.getSingleton().addResourceLocation( path, key, section_name, False) self.resourceLocations.append( (path, section_name ) ) + + def _OgreInit(self,size,renderSystem): + #Root creation + self.ogreRoot = ogre.Root( getPluginPath(), "ogre.cfg" ) + + # setup resources + self.AddResources( "resources.cfg" ); if os.path.exists( "ogre.cfg" ): self.ogreRoot.restoreConfig() Modified: branches/ogEditor/src/ResourceTreePane.py =================================================================== --- branches/ogEditor/src/ResourceTreePane.py 2008-05-25 09:10:42 UTC (rev 904) +++ branches/ogEditor/src/ResourceTreePane.py 2008-05-25 11:51:13 UTC (rev 905) @@ -33,6 +33,7 @@ return newNode def buildResourceTree( self ): + self.DeleteAllItems() self.root_ = root = self.AddRoot( "Resources" ) resManNode = self.AppendItem( root, "Ogre resource manager" ) Modified: trunk/resources.cfg =================================================================== --- trunk/resources.cfg 2008-05-25 09:10:42 UTC (rev 904) +++ trunk/resources.cfg 2008-05-25 11:51:13 UTC (rev 905) @@ -1,7 +1,7 @@ [Bootstrap] FileSystem=./data/startup -[General] +[Opengate] FileSystem=./data/ FileSystem=./data/commodities FileSystem=./data/capacitors Modified: trunk/src/Entity.cpp =================================================================== --- trunk/src/Entity.cpp 2008-05-25 09:10:42 UTC (rev 904) +++ trunk/src/Entity.cpp 2008-05-25 11:51:13 UTC (rev 905) @@ -105,7 +105,7 @@ CEGUI::Texture * texture = NULL; try { - texture = dynamic_cast< CEGUI::OgreCEGUIRenderer * >( ResourceManager::getSingleton().guiRenderer )->createTexture( imageName, "General"); + texture = dynamic_cast< CEGUI::OgreCEGUIRenderer * >( ResourceManager::getSingleton().guiRenderer )->createTexture( imageName, "Opengate"); } catch( CEGUI::Exception & e ){ if ( verbose ) LogManager::getSingleton().warn( e.getMessage().c_str() ); fail = true; @@ -201,7 +201,7 @@ meshName_ = meshName.substr( 0, meshName.rfind( ".mesh" ) ) + ".mesh" ; pMesh_ = Ogre::MeshManager::getSingleton().load( meshName_, - "General", + "Opengate", Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY, true, true); Modified: trunk/src/GameStateManager.cpp =================================================================== --- trunk/src/GameStateManager.cpp 2008-05-25 09:10:42 UTC (rev 904) +++ trunk/src/GameStateManager.cpp 2008-05-25 11:51:13 UTC (rev 905) @@ -268,17 +268,17 @@ bool GameStateManager::initialiseEntityManager(){ resources_.entityManager = new EntityManager( ); - resources_.entityManager->load( resources_.resourceLocations( "General" ), "commodities" ); - resources_.entityManager->load( resources_.resourceLocations( "General" ), "engines" ); - resources_.entityManager->load( resources_.resourceLocations( "General" ), "capacitors" ); - resources_.entityManager->load( resources_.resourceLocations( "General" ), "radars" ); - resources_.entityManager->load( resources_.resourceLocations( "General" ), "shields" ); - resources_.entityManager->load( resources_.resourceLocations( "General" ), "ecms" ); - resources_.entityManager->load( resources_.resourceLocations( "General" ), "power_plants" ); - resources_.entityManager->load( resources_.resourceLocations( "General" ), "guns" ); - resources_.entityManager->load( resources_.resourceLocations( "General" ), "missiles" ); - resources_.entityManager->load( resources_.resourceLocations( "General" ), "ships" ); - resources_.entityManager->load( resources_.resourceLocations( "General" ), "stations" ); + resources_.entityManager->load( resources_.resourceLocations( "Opengate" ), "commodities" ); + resources_.entityManager->load( resources_.resourceLocations( "Opengate" ), "engines" ); + resources_.entityManager->load( resources_.resourceLocations( "Opengate" ), "capacitors" ); + resources_.entityManager->load( resources_.resourceLocations( "Opengate" ), "radars" ); + resources_.entityManager->load( resources_.resourceLocations( "Opengate" ), "shields" ); + resources_.entityManager->load( resources_.resourceLocations( "Opengate" ), "ecms" ); + resources_.entityManager->load( resources_.resourceLocations( "Opengate" ), "power_plants" ); + resources_.entityManager->load( resources_.resourceLocations( "Opengate" ), "guns" ); + resources_.entityManager->load( resources_.resourceLocations( "Opengate" ), "missiles" ); + resources_.entityManager->load( resources_.resourceLocations( "Opengate" ), "ships" ); + resources_.entityManager->load( resources_.resourceLocations( "Opengate" ), "stations" ); return true; } @@ -352,9 +352,9 @@ } } - Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup( "General" ); - std::cout << "Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup( General ); " << std::endl; - Ogre::ResourceGroupManager::ResourceDeclarationList li = Ogre::ResourceGroupManager::getSingleton().getResourceDeclarationList( "General" ); + Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup( "Opengate" ); + std::cout << "Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup( Opengate ); " << std::endl; + Ogre::ResourceGroupManager::ResourceDeclarationList li = Ogre::ResourceGroupManager::getSingleton().getResourceDeclarationList( "Opengate" ); std::cout << li.size() << std::endl; for ( std::list<Ogre::ResourceGroupManager::ResourceDeclaration>::iterator it = li.begin(); it != li.end(); it ++ ){ std::cout << (*it).resourceName << std::endl; Modified: trunk/src/ResourceManager.cpp =================================================================== --- trunk/src/ResourceManager.cpp 2008-05-25 09:10:42 UTC (rev 904) +++ trunk/src/ResourceManager.cpp 2008-05-25 11:51:13 UTC (rev 905) @@ -134,11 +134,11 @@ std::string ResourceManager::findFullFileName( const std::string & fileName ){ - Ogre::FileSystemArchive pArch = Ogre::FileSystemArchive( (*resourceLocations_["General"].begin()), "FileSystem" ); + Ogre::FileSystemArchive pArch = Ogre::FileSystemArchive( (*resourceLocations_["Opengate"].begin()), "FileSystem" ); Ogre::StringVectorPtr file = pArch.find( fileName, true, false); if ( (*file).size() > 0 ){ - return (*resourceLocations_["General"].begin() ) + "/" + (*file)[ 0 ] ; + return (*resourceLocations_["Opengate"].begin() ) + "/" + (*file)[ 0 ] ; } // for ( unsigned int i = 0; i < (*file).size(); i ++ ){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eg...@us...> - 2008-06-11 21:07:35
|
Revision: 908 http://opengate.svn.sourceforge.net/opengate/?rev=908&view=rev Author: egore Date: 2008-06-11 14:07:06 -0700 (Wed, 11 Jun 2008) Log Message: ----------- Fix compilation with GCC 4.3.1 Modified Paths: -------------- trunk/src/KeyMap.h trunk/src/LogManagerBase.cpp Modified: trunk/src/KeyMap.h =================================================================== --- trunk/src/KeyMap.h 2008-05-31 21:57:05 UTC (rev 907) +++ trunk/src/KeyMap.h 2008-06-11 21:07:06 UTC (rev 908) @@ -22,6 +22,7 @@ #define _OPENGATE_KEYMAP__H #include <map> +#include <sys/types.h> //#include "InputManager.h" namespace OIS{ Modified: trunk/src/LogManagerBase.cpp =================================================================== --- trunk/src/LogManagerBase.cpp 2008-05-31 21:57:05 UTC (rev 907) +++ trunk/src/LogManagerBase.cpp 2008-06-11 21:07:06 UTC (rev 908) @@ -19,6 +19,7 @@ ***************************************************************************/ #include "LogManagerBase.h" +#include <ctime> namespace OpenGate{ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |