From: <spo...@us...> - 2009-02-07 22:37:40
|
Revision: 1019 http://opengate.svn.sourceforge.net/opengate/?rev=1019&view=rev Author: spom_spom Date: 2009-02-07 22:37:37 +0000 (Sat, 07 Feb 2009) Log Message: ----------- fixed some small isssues Modified Paths: -------------- trunk/ToDo trunk/src/GunObject.cpp trunk/src/GunObject.h trunk/src/RadarObject.cpp trunk/src/SectorMeshObject.cpp trunk/src/SectorMeshObject.h trunk/src/SectorMovableObject.cpp trunk/src/SectorVesselObject.cpp trunk/src/opengateserver.cpp Modified: trunk/ToDo =================================================================== --- trunk/ToDo 2009-02-07 20:33:19 UTC (rev 1018) +++ trunk/ToDo 2009-02-07 22:37:37 UTC (rev 1019) @@ -215,5 +215,3 @@ Possible Refaktor: (Hier steht Kram den man vielleicht mal aufr\xE4umen kann oder sollte, das ist entweder: alter schief gewachsener code, unsicherheiten, als ich das machte konnte ichs nicht besser, einfach nur Mist, etc... ) - /*! Returns the set of known resource paths, maybee this this can be saver by using ogre resource Manager directly instead of holding our own set. */ - std::set < std::string > & ResourceManager::resourcePaths(); Modified: trunk/src/GunObject.cpp =================================================================== --- trunk/src/GunObject.cpp 2009-02-07 20:33:19 UTC (rev 1018) +++ trunk/src/GunObject.cpp 2009-02-07 22:37:37 UTC (rev 1019) @@ -77,18 +77,16 @@ return false; } -EngineObject::EngineObject( Engine * engineBluePrint ) - : engineBluePrint_( engineBluePrint ), parent_( NULL ){ +EngineObject::EngineObject( Engine * engineBluePrint, const std::string & name, Ogre::SceneNode * mountNode, const Ogre::Vector3 & position ) + : engineBluePrint_( engineBluePrint ), name_( name ), mountNode_( mountNode ){ + thrustRate_ = 0.0; thrusterParticles_ = NULL; -} -EngineObject::~EngineObject(){ -} + mainNode_ = mountNode_->createChildSceneNode( name_ + "_EngineMountPoint" ); + mainNode_->setPosition( position ); -void EngineObject::mount( SectorMovableObject * parent, Ogre::SceneNode * mountPoint ){ - parent_ = parent; - thrusterParticles_ = parent->sector()->sceneManager()->createParticleSystem( mountPoint->getName() + "/Thruster" ); + thrusterParticles_ = mountNode_->getCreator()->createParticleSystem( mainNode_->getName() + "/Thruster" ); thrusterParticles_->setMaterialName( "Examples/Flare" ); thrusterParticles_->setDefaultDimensions( 2, 1 ); @@ -97,9 +95,35 @@ // pEmit->setPosition( ( mainNodeEntityRot_->getOrientation() * engineMountPoints[ i ] ) * mainNodeEntityScale_->getScale() ); pEmit_->setColour( Ogre::ColourValue::Blue, Ogre::ColourValue::Green ); - mountPoint->attachObject( thrusterParticles_ ); + mainNode_->attachObject( thrusterParticles_ ); + } + +EngineObject::~EngineObject(){ + + if ( thrusterParticles_ ){ + mainNode_->detachObject( thrusterParticles_ ); + mainNode_->getCreator()->destroyParticleSystem( thrusterParticles_ ); + mountNode_->removeAndDestroyChild( mainNode_->getName() ); + } +} + +// void EngineObject::mount( SectorMovableObject * parent, Ogre::SceneNode * mountPoint ){ +// parent_ = parent; +// mountPoint_ = mountPoint; +// thrusterParticles_ = parent->sector()->sceneManager()->createParticleSystem( mountPoint->getName() + "/Thruster" ); +// thrusterParticles_->setMaterialName( "Examples/Flare" ); +// thrusterParticles_->setDefaultDimensions( 2, 1 ); +// +// pEmit_ = thrusterParticles_->addEmitter( "Point" ); +// // pEmit->setDirection( mainNode_->getOrientation().zAxis() ); +// // pEmit->setPosition( ( mainNodeEntityRot_->getOrientation() * engineMountPoints[ i ] ) * mainNodeEntityScale_->getScale() ); +// pEmit_->setColour( Ogre::ColourValue::Blue, Ogre::ColourValue::Green ); +// +// mountPoint->attachObject( thrusterParticles_ ); +// } + void EngineObject::setThrustRate( double thrustRate ){ thrustRate_ = thrustRate; Modified: trunk/src/GunObject.h =================================================================== --- trunk/src/GunObject.h 2009-02-07 20:33:19 UTC (rev 1018) +++ trunk/src/GunObject.h 2009-02-07 22:37:37 UTC (rev 1019) @@ -62,27 +62,37 @@ }; +/*! Construct an engine with a grafical representation i.e. thruster effects. */ class EngineObject{ public: - EngineObject( Engine * engineBluePrint ); + /*! Construct an engine object, with a Blueprint, a uniqe name, the mountNode on the parent vessel and the absolute position for the emmesive parts of the engine.*/ + EngineObject( Engine * engineBluePrint, const std::string & name, Ogre::SceneNode * mountNode, const Ogre::Vector3 & position ); + /*! Destruct the engine and associated particle or grafical effects. */ ~EngineObject( ); - void mount( SectorMovableObject * parent, Ogre::SceneNode * mountPoint ); + /*! Return corresponding main Ogre::SceneNode for this engine. */ + inline Ogre::SceneNode * sceneNode() { return mainNode_; } + /*! Change the thrust rate. Causes a change of the thruster particle effect and determine the amount of power is consumed, by getting the thrust through update powerline cycle. */ void setThrustRate( double rate ); + /*! Return the preset thrustrate from 0 to 1 */ inline double thrustRate( double rate ){ return thrustRate_; } + /*! Return the amount of power that the engine provide for a given thrustRate. */ Uint32 thrust( Uint32 & powerLine ); protected: Engine * engineBluePrint_; - SectorMovableObject * parent_; - double thrustRate_; - + std::string name_; + Ogre::SceneNode * mountNode_; + Ogre::SceneNode * mainNode_; + Ogre::ParticleEmitter * pEmit_; Ogre::ParticleSystem * thrusterParticles_; + + double thrustRate_; }; } //namespace OpenGate Modified: trunk/src/RadarObject.cpp =================================================================== --- trunk/src/RadarObject.cpp 2009-02-07 20:33:19 UTC (rev 1018) +++ trunk/src/RadarObject.cpp 2009-02-07 22:37:37 UTC (rev 1019) @@ -78,6 +78,9 @@ } RadarObject::~RadarObject( ){ + for ( std::map< SectorMeshObject *, RadarViewable * >::iterator it = objects_.begin(), itmax = objects_.end(); it != itmax; ){ + delObject( (it++)->first ); + } objects_.clear(); } @@ -138,6 +141,7 @@ } void RadarObject::delObject( SectorMeshObject * obj ){ + std::cout << "RadarObject::delObject( "<< obj->name() << std::endl; std::map< SectorMeshObject *, RadarViewable * >::iterator itTarget = objects_.find( obj ); if ( itTarget != objects_.end() ) delete itTarget->second; objects_.erase( obj ); Modified: trunk/src/SectorMeshObject.cpp =================================================================== --- trunk/src/SectorMeshObject.cpp 2009-02-07 20:33:19 UTC (rev 1018) +++ trunk/src/SectorMeshObject.cpp 2009-02-07 22:37:37 UTC (rev 1019) @@ -47,6 +47,11 @@ mainNode_->removeAndDestroyChild( entityScaleNode_->getName() ); } +void SectorMeshObject::reset( ){ + target_ = NULL; + observers_.clear(); +} + void SectorMeshObject::collide( SectorCollisionObject * object ){ std::cout << "SectorMeshObject: " << this->name() << " collide with " << object->rtti() << " " << object->name() << std::endl; Modified: trunk/src/SectorMeshObject.h =================================================================== --- trunk/src/SectorMeshObject.h 2009-02-07 20:33:19 UTC (rev 1018) +++ trunk/src/SectorMeshObject.h 2009-02-07 22:37:37 UTC (rev 1019) @@ -89,6 +89,9 @@ /*! Destroy the object without explosion */ virtual void destroy(); + /*! Reset the object, clear target_ pointer and list of observers_; */ + virtual void reset( ); + protected: Ogre::SceneNode * entityScaleNode_; // Main character node for base size Ogre::SceneNode * entityRotNode_; // Main character node for base rotation Modified: trunk/src/SectorMovableObject.cpp =================================================================== --- trunk/src/SectorMovableObject.cpp 2009-02-07 20:33:19 UTC (rev 1018) +++ trunk/src/SectorMovableObject.cpp 2009-02-07 22:37:37 UTC (rev 1019) @@ -50,6 +50,7 @@ } void SectorMovableObject::reset( ){ + SectorMeshObject::reset(); yaw_ = 0.0; pitch_ = 0.0; roll_ = 0.0; Modified: trunk/src/SectorVesselObject.cpp =================================================================== --- trunk/src/SectorVesselObject.cpp 2009-02-07 20:33:19 UTC (rev 1018) +++ trunk/src/SectorVesselObject.cpp 2009-02-07 22:37:37 UTC (rev 1019) @@ -55,12 +55,8 @@ std::vector < Ogre::Vector3 > engineMountPoints( this->vessel()->engineMountPoints() ); for ( uint i = 0; i < engineMountPoints.size(); i ++ ){ - Ogre::SceneNode * mountPoint = entityRotNode_->createChildSceneNode( name_ + "_EngineMountPoint" + toStr( i ) ); - mountPoint->setPosition( engineMountPoints[ i ] ); - - EngineObject * engine = new EngineObject( this->vessel()->engine() ); + EngineObject * engine = new EngineObject( this->vessel()->engine(), name_ + "_engine_" + toStr( i ), entityRotNode_, engineMountPoints[ i ] ); engines_.push_back( engine ); - engine->mount( this, mountPoint ); } reset(); } @@ -79,6 +75,10 @@ } activeGuns_.clear(); + for ( std::list < EngineObject * >::iterator it = engines_.begin(); it != engines_.end(); it++){ + delete (*it); + } + } void SectorVesselObject::reset( ){ Modified: trunk/src/opengateserver.cpp =================================================================== --- trunk/src/opengateserver.cpp 2009-02-07 20:33:19 UTC (rev 1018) +++ trunk/src/opengateserver.cpp 2009-02-07 22:37:37 UTC (rev 1019) @@ -83,32 +83,32 @@ //** ein bissle mehr verbose output, kommt sp\xE4ter wieder weg.; //** das k\xF6nnte mal vielleicht als option rausreichen, das man wie beim clienten die Wahl hat; //** -M = (withMetaServer = true); - bool withMetaServer = true; + bool withMetaServer = false; std::string servername( "testserver Sim 1" ); - try { - boost::asio::io_service io_service; - io_servicePtr = &io_service; + try { + boost::asio::io_service io_service; + io_servicePtr = &io_service; - if ( withMetaServer ){ - metaPtr = new OpenGate::MetaConnection( io_service, *logMgr ); - int error = 0; + if ( withMetaServer ){ + metaPtr = new OpenGate::MetaConnection( io_service, *logMgr ); + int error = 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 " ) ); - } + 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 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 ); - } - } + 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 ); + } + } - serverPtr = new Server( io_service, *logMgr ); - io_service.run(); -// } catch ( boost::asio::error & e ) { + serverPtr = new Server( io_service, *logMgr ); + io_service.run(); + //} catch ( boost::asio::error & e ) { // logMgr->fatal( std::string("opengateserver asio exception: " )+ e.what() ); // server_shutdown(); // return EXIT_FAILURE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |