From: <spo...@us...> - 2008-05-14 21:33:25
|
Revision: 897 http://opengate.svn.sourceforge.net/opengate/?rev=897&view=rev Author: spom_spom Date: 2008-05-14 14:33:27 -0700 (Wed, 14 May 2008) Log Message: ----------- Added beacon as sector object Modified Paths: -------------- trunk/data/misc/beacon.mesh trunk/data/misc/testsector.xml trunk/src/AiCommands.h trunk/src/AiManager.cpp trunk/src/AiObject.cpp trunk/src/AiObject.h trunk/src/Entity.cpp trunk/src/Entity.h trunk/src/EntityManager.cpp trunk/src/Equipment.h trunk/src/Moveable.cpp trunk/src/Moveable.h trunk/src/OpcodeWrapper.cpp trunk/src/OpcodeWrapper.h trunk/src/Projectile.h trunk/src/Sector.cpp trunk/src/Sector.h trunk/src/SectorObject.cpp trunk/src/SectorObject.h trunk/src/SectorObjectMissile.cpp 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/Vessel.cpp trunk/src/Vessel.h trunk/src/common.h trunk/src/metaserver.cpp trunk/src/metaserver.h trunk/src/networkProtocol.cpp trunk/src/networkProtocol.h Added Paths: ----------- trunk/data/misc/beacon.material trunk/data/misc/beacon_pad.mesh Added: trunk/data/misc/beacon.material =================================================================== --- trunk/data/misc/beacon.material (rev 0) +++ trunk/data/misc/beacon.material 2008-05-14 21:33:27 UTC (rev 897) @@ -0,0 +1,45 @@ +material beacon/pad_mount_0 +{ + receive_shadows on + technique + { + pass + { + depth_check on + depth_write off + scene_blend add + ambient 1.000000 0.00000 0.00000 1.000000 + diffuse 0.517647 0.018824 0.018824 1.000000 + specular 1.000000 0.000000 0.000000 1.000000 12.500000 + emissive 1.000000 0.000000 0.000000 1.000000 + } + } +} +material beacon/pad_mount_1 +{ + receive_shadows on + technique + { + pass + { + ambient 0.500000 0.500000 0.500000 1.000000 + diffuse 0.517647 0.018824 0.018824 1.000000 + specular 0.500000 0.500000 0.500000 1.000000 12.500000 + emissive 0.000000 0.000000 0.000000 1.000000 + } + } +} +material beacon/bg +{ + receive_shadows on + technique + { + pass + { + ambient 0.500000 0.500000 0.500000 1.000000 + diffuse 0.439216 0.621176 0.533333 1.000000 + specular 0.213726 0.382353 0.290196 1.000000 12.500000 + emissive 0.000000 0.000000 0.000000 1.000000 + } + } +} Modified: trunk/data/misc/beacon.mesh =================================================================== (Binary files differ) Added: trunk/data/misc/beacon_pad.mesh =================================================================== (Binary files differ) Property changes on: trunk/data/misc/beacon_pad.mesh ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/data/misc/testsector.xml =================================================================== --- trunk/data/misc/testsector.xml 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/data/misc/testsector.xml 2008-05-14 21:33:27 UTC (rev 897) @@ -26,14 +26,23 @@ <!-- <position>position of this object</position> --> <!-- Optional --> <!-- <direction>desired front direction</direction> --> -<!-- </sectorobject> --> +<!-- </station> --> - <station> +<!-- <beacon> --> +<!-- <position>position of this object</position> --> +<!-- <direction>desired front direction</direction> --> +<!-- </beacon> --> + + <station> <name>Tauseti Wake</name> <position>0, 0, -1480</position> <direction>0.0, 0.0, 1.0 </direction> </station> - <sectorobject> + <beacon> + <position> -650, 0, 800</position> + <direction>0.0, 0.0, 1.0 </direction> + </beacon> + <sectorobject> <name>astro with bump</name> <mesh>asteroid01</mesh> <position> -250, 0, 440</position> @@ -48,13 +57,6 @@ <material>Asteroid</material> </sectorobject> <sectorobject> - <name>beacon</name> - <mesh>beacon</mesh> - <position> -650, 0, 800</position> - <scale>20, 20, 20</scale> - <material>Sta/TS/Background</material> - </sectorobject> - <sectorobject> <name>ring</name> <mesh>ring</mesh> <position> -650, 100, 800</position> Modified: trunk/src/AiCommands.h =================================================================== --- trunk/src/AiCommands.h 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/AiCommands.h 2008-05-14 21:33:27 UTC (rev 897) @@ -79,7 +79,7 @@ return true; } - bool abort( ) { abort_ = true; } + void abort( ) { abort_ = true; } virtual void start() { std::cout << "AiCommand start (virtual) " << std::endl; } virtual bool update( ) { return false; } Modified: trunk/src/AiManager.cpp =================================================================== --- trunk/src/AiManager.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/AiManager.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -95,7 +95,8 @@ std::copy( argv.begin(), argv.end(), std::ostream_iterator< std::string >( std::cout, " " ) ); std::cout << std::endl; - AiObject * ai = spawnAi( ); + //AiObject * ai = + spawnAi( ); } AiObject * AiManager::spawnAi( ){ Modified: trunk/src/AiObject.cpp =================================================================== --- trunk/src/AiObject.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/AiObject.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -241,7 +241,7 @@ double AiObject::speedAfterTime( double time, double thrustRate ) const { //** v[ t ] := vmax * tanh( th / m / vmax * t ) ** P - double d = vesselObject_->vessel()->dragFactor(); + // double d = vesselObject_->vessel()->dragFactor(); double m = vesselObject_->mass(); double th = vesselObject_->maxThrust() * thrustRate; double vmax = maxSpeed( thrustRate ); @@ -255,7 +255,7 @@ //** v[ t ] := vmax * tanh( th / m / vmax * t ) //** s[t]:=integrate(v[t], t) //** s = vmax^2/a * log( cosh( a / vmax * t ) ) ** P - double d = vesselObject_->vessel()->dragFactor(); + // double d = vesselObject_->vessel()->dragFactor(); double m = vesselObject_->mass(); double th = vesselObject_->maxThrust() * thrustRate; double vmax = maxSpeed( thrustRate ); @@ -269,7 +269,7 @@ double d = vesselObject_->vessel()->dragFactor(); double m = vesselObject_->mass(); double a = vesselObject_->brakingAcc(); - double th = m * a; + // double th = m * a; //std::cout << " th: " << th << "; m: " << m << "; d: " << d << "; v: " << v << "; t: " << time << std::endl; double t = ( m * atan( ( d * v ) / sqrt( a * d * m ) ) ) / sqrt( a * d * m ); //see physics.m return t; @@ -279,7 +279,7 @@ double d = vesselObject_->vessel()->dragFactor(); double m = vesselObject_->mass(); double a = vesselObject_->brakingAcc(); - double th = m * a; + // double th = m * a; double t = brakingTime( v ); double s = ( m * std::log( 1.0 / std::cos( (std::sqrt( a * d * m ) * t ) / m) ) ) / d; //see physics.m Modified: trunk/src/AiObject.h =================================================================== --- trunk/src/AiObject.h 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/AiObject.h 2008-05-14 21:33:27 UTC (rev 897) @@ -116,6 +116,9 @@ void copy_( const AiObject & ai ); + //! unique id + uint id_; + //! the graphical representation SectorObjectVessel * vesselObject_; @@ -137,10 +140,7 @@ //! objects name std::string name_; - - //! unique id - uint id_; - + //! reference counter for threadholder uint refCounter_; Modified: trunk/src/Entity.cpp =================================================================== --- trunk/src/Entity.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/Entity.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -124,7 +124,7 @@ return !fail; } -bool Entity::readPropertiesFromXML( TiXmlHandle & hRoot ){ +void Entity::readPropertiesFromXML( TiXmlHandle & hRoot ){ readXMLNode< std::string >( hRoot, "name_"+ ResourceManager::getSingleton().languageSuffix() + " name_en name", this, &OpenGate::Entity::setName, true ); @@ -166,8 +166,7 @@ if ( pElem ) height = toDouble( pElem->FirstChild()->Value() ); if ( length > 0 && width > 0 && height > 0 ) this->setBaseSize( width, height, length ); - - return true; + } Modified: trunk/src/Entity.h =================================================================== --- trunk/src/Entity.h 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/Entity.h 2008-05-14 21:33:27 UTC (rev 897) @@ -70,7 +70,7 @@ virtual EntityType entityType() const { return rtti_; } - virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ); + virtual void readPropertiesFromXML( TiXmlHandle & hRoot ); inline std::string factionName( ) const { return factionName_; } Modified: trunk/src/EntityManager.cpp =================================================================== --- trunk/src/EntityManager.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/EntityManager.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -79,6 +79,8 @@ std::string EntityManager::categoryName( EntityType type ){ switch( type ){ + case NONE: return "None"; + case ENTITY: return "Entity"; case COMMODITY: return "Commodity"; case POWERPLANT: return "Powerplant"; case CAPACITOR: return "Capacitor"; Modified: trunk/src/Equipment.h =================================================================== --- trunk/src/Equipment.h 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/Equipment.h 2008-05-14 21:33:27 UTC (rev 897) @@ -47,7 +47,7 @@ meltingPoint_ = 0; graviticSig_ = 0.0; } - virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){ + virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){ Entity::readPropertiesFromXML( hRoot ); readXMLNode< int >( hRoot, "melting-point", this, &OpenGate::Commodity::setMeltingPoint, false ); readXMLNode< double >( hRoot, "gravitic-sig", this, &OpenGate::Commodity::setGraviticSig, false ); @@ -84,7 +84,7 @@ class Equipment : public Entity{ public: - virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){ + virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){ Entity::readPropertiesFromXML( hRoot ); readXMLNode< double >( hRoot, "efficency", this, &OpenGate::Equipment::setEfficiency, false ); readXMLNode< std::string >( hRoot, "Manufacturer", this, &OpenGate::Equipment::setManufacturer, false ); @@ -138,7 +138,7 @@ rtti_ = POWERPLANT; powerOutput_ = 0; } - virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){ + virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){ Equipment::readPropertiesFromXML( hRoot ); readXMLNode< Uint32 >( hRoot, "power_output", this, &OpenGate::PowerPlant::setPowerOutput, false ); } @@ -170,7 +170,7 @@ maxThrust_ = 0; } - virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){ + virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){ Equipment::readPropertiesFromXML( hRoot ); readXMLNode< Uint32 >( hRoot, "maximum_thrust", this, &OpenGate::Engine::setMaxThrust, false ); } @@ -202,7 +202,7 @@ Radar() : Equipment(){ rtti_ = RADAR; } - virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){ + virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){ Equipment::readPropertiesFromXML( hRoot ); readXMLNode< Uint32 >( hRoot, "maximum_range", this, &OpenGate::Radar::setMaxRange, false ); } @@ -229,7 +229,7 @@ rtti_ = ECM; sensorLevel_ = 0; } - virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){ + virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){ Equipment::readPropertiesFromXML( hRoot ); readXMLNode< Uint8 >( hRoot, "sensorlevel", this, &OpenGate::Ecm::setSensorLevel, false ); } @@ -255,7 +255,7 @@ Shield() : Equipment(){ rtti_ = SHIELD; } - virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){ + virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){ Equipment::readPropertiesFromXML( hRoot ); readXMLNode< Uint32 >( hRoot, "regeneration_rate", this, &OpenGate::Shield::setRegenerationRate, false ); readXMLNode< Uint32 >( hRoot, "maximum_deflection", this, &OpenGate::Shield::setMaxDeflection, false ); @@ -297,7 +297,7 @@ rtti_ = CAPACITOR; capacity_ = 0; } - virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){ + virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){ Equipment::readPropertiesFromXML( hRoot ); readXMLNode< Uint32 >( hRoot, "capacity", this, &OpenGate::Capacitor::setCapacity, false ); } @@ -320,7 +320,7 @@ rtti_ = GUN; type_ = UNKNOWN; } - virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ){ + virtual void readPropertiesFromXML( TiXmlHandle & hRoot ){ Equipment::readPropertiesFromXML( hRoot ); readXMLNode< Uint32 >( hRoot, "damage", this, &OpenGate::Gun::setDamage, false ); readXMLNode< Uint32 >( hRoot, "velocity", this, &OpenGate::Gun::setSpeed, false ); Modified: trunk/src/Moveable.cpp =================================================================== --- trunk/src/Moveable.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/Moveable.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -29,17 +29,17 @@ yaw_ = 1.0; pitch_ = 1.0; roll_ = 1.0; - armor_ = 1.0; + armor_ = 1; dragFactor_ = 1.0; } -bool Moveable::readPropertiesFromXML( TiXmlHandle & hRoot ){ +void Moveable::readPropertiesFromXML( TiXmlHandle & hRoot ){ Entity::readPropertiesFromXML( hRoot ); readXMLNode< float >( hRoot, "yaw", this, &OpenGate::Moveable::setYaw, false ); readXMLNode< float >( hRoot, "pitch", this, &OpenGate::Moveable::setPitch, false ); readXMLNode< float >( hRoot, "roll", this, &OpenGate::Moveable::setRoll, false ); - readXMLNode< float >( hRoot, "armor", this, &OpenGate::Moveable::setArmor, false ); + readXMLNode< Uint32 >( hRoot, "armor", this, &OpenGate::Moveable::setArmor, false ); readXMLNode< float >( hRoot, "dragfactor drag_factor", this, &OpenGate::Moveable::setDragFactor, false ); if ( !readXMLNode< std::string >( hRoot, "mesh", this, &OpenGate::Moveable::setMesh, false ) ){ Modified: trunk/src/Moveable.h =================================================================== --- trunk/src/Moveable.h 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/Moveable.h 2008-05-14 21:33:27 UTC (rev 897) @@ -32,7 +32,7 @@ Moveable(); virtual ~Moveable(){} - virtual bool readPropertiesFromXML( TiXmlHandle & hRoot ); + virtual void readPropertiesFromXML( TiXmlHandle & hRoot ); inline void setArmor( Uint32 armor ){ armor_ = armor * 1000; } inline Uint32 armor( ) const { return armor_; } Modified: trunk/src/OpcodeWrapper.cpp =================================================================== --- trunk/src/OpcodeWrapper.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/OpcodeWrapper.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -147,13 +147,13 @@ } } -void OpcodeCollisionDetection::dettach( SectorObject * obj ){ +void OpcodeCollisionDetection::detach( BaseObject * obj ){ if ( obj && active_ ){ destroyObject( obj ); } } -void OpcodeCollisionDetection::attach( SectorObject * obj ){ +void OpcodeCollisionDetection::attach( BaseObject * obj ){ if ( obj && active_ ){ createObject( obj ); } Modified: trunk/src/OpcodeWrapper.h =================================================================== --- trunk/src/OpcodeWrapper.h 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/OpcodeWrapper.h 2008-05-14 21:33:27 UTC (rev 897) @@ -54,9 +54,9 @@ void destroyObject( BaseObject * obj ); - void dettach( SectorObject * obj ); + void detach( BaseObject * obj ); - void attach( SectorObject * obj ); + void attach( BaseObject * obj ); bool checkCollideRay( BaseObject * obj, const Ogre::Ray & ray, double rayLength ); Modified: trunk/src/Projectile.h =================================================================== --- trunk/src/Projectile.h 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/Projectile.h 2008-05-14 21:33:27 UTC (rev 897) @@ -60,22 +60,23 @@ protected: - BaseObject * parent_; - Uint16 shotCount_; - Uint32 damage_; - Gun * gun_; - + BaseObject * parent_; + Uint16 shotCount_; + Gun * gun_; + + Uint32 damage_; + Ogre::Real maxLifeTime_; + Ogre::Vector3 vel_; + // Ogre::BillboardChain * chain_; Ogre::BillboardSet * bullet_; Ogre::ManualObject * beam_; Ogre::RibbonTrail * trail_; Ogre::SceneNode * trailNode_; - Ogre::Vector3 vel_; Ogre::SceneNode * shape_; - Ogre::Real maxLifeTime_; Ogre::Real oldTime_; Ogre::Real maxRange_; bool ammoHit_; Modified: trunk/src/Sector.cpp =================================================================== --- trunk/src/Sector.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/Sector.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -77,16 +77,17 @@ Sector::Sector( Ogre::SceneManager * sceneMgr, NetworkClient * network ) : sceneMgr_( sceneMgr ), network_( network ) { - radar_ = true; - planet_ = NULL; - koordAxisNode_ = NULL; - starsNode_ = NULL; - avatar_ = NULL; - station_ = NULL; - childIDCounter_= 0; - log_ = LogManager::getSingletonPtr(); + radar_ = true; + planet_ = NULL; + koordAxisNode_ = NULL; + starsNode_ = NULL; + avatar_ = NULL; + station_ = NULL; + name_ = "unknown"; + childIDCounter_ = 0; + log_ = LogManager::getSingletonPtr(); - avatarDeathSequenceTime_ = 0.0; + avatarDeathSequenceTime_ = 0.0; //*** starfield test 1 // Ogre::ManualObject* myManualObject = sceneMgr_->createManualObject("manual1"); @@ -175,7 +176,6 @@ // delete (*it).second[ i ]; // } } - } void Sector::populate( const std::string & fileName ){ @@ -203,14 +203,9 @@ log_->fatal( fileName + " is no sector description" ); return; } + + readXMLNode< std::string >( hRoot, "name_en name", this, &OpenGate::Sector::setName, false ); - pElem = hRoot.ChildElement( "name_en", 0 ).Element(); - if ( pElem ){ - sectorname_ = pElem->FirstChild()->Value(); - } else { - sectorname_ = "Testsector"; - } - pElem = hRoot.ChildElement( "skybox", 0 ).Element(); if ( pElem ){ sceneMgr_->setSkyBox( true, pElem->FirstChild()->Value(), 10000 ); @@ -272,12 +267,31 @@ } } - //** Load passive sector objects - for ( pElem = hRoot.FirstChild( "sectorobject" ).Element(); pElem != 0; - pElem = pElem->NextSiblingElement("sectorobject") ) { - std::string name; - pSubElem = pElem->FirstChildElement( "name" ); - if ( pSubElem ){ + //** load beacon + pElem = hRoot.FirstChild( "beacon" ).Element(); + if ( pElem ){ + Ogre::Vector3 beaconPos( 0.0, 0.0, 0.0); + pSubElem = pElem->FirstChildElement( "position" ); + if ( pSubElem ){ + beaconPos = Ogre::Vector3( &toVector3( pSubElem->FirstChild()->Value(), ',' )[ 0 ] ); + } else { + log_->warn( "missing pos for beacon" ); + } + SectorObject * obj = createBeacon( beaconPos ); + Ogre::Vector3 beaconDir( 0.0, 0.0, 0.0); + pSubElem = pElem->FirstChildElement( "direction" ); + if ( pSubElem ){ + beaconDir = Ogre::Vector3( &toVector3( pSubElem->FirstChild()->Value(), ',' )[ 0 ] ); + obj->mainNode()->setDirection( beaconDir ); + } + } + + //** Load passive sector objects + for ( pElem = hRoot.FirstChild( "sectorobject" ).Element(); pElem != 0; + pElem = pElem->NextSiblingElement("sectorobject") ) { + std::string name; + pSubElem = pElem->FirstChildElement( "name" ); + if ( pSubElem ){ name = pSubElem->FirstChild()->Value(); } else { log_->warn( "missing name for sectorobject " ); @@ -291,9 +305,9 @@ Ogre::MeshPtr pMesh = Ogre::MeshManager::getSingleton().load( mesh, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, - Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, - Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY, - true, true); + 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); @@ -498,6 +512,14 @@ return obj; } +SectorObject * Sector::createBeacon( const Ogre::Vector3 & pos ){ + SectorObject * obj = new BeaconObject( this ); + obj->mainNode()->setPosition( pos ); + obj->scale( Ogre::Vector3( 20.0, 20.0, 20.0 ) ); + sectorObjects_.insert( obj ); + return obj; +} + SectorObjectMoveable * Sector::createMoveable( const Ogre::String & name, Uint32 userID, Uint8 childID, Moveable & moveable ){ SectorObjectMoveable * obj = new SectorObjectMoveable( name, this, userID, childID, @@ -705,15 +727,27 @@ koordAxisNode_ = sceneMgr_->getRootSceneNode()->createChildSceneNode( "axisnode" ); koordAxisMO_ = sceneMgr_->createManualObject( koordAxisNode_->getName()+ "/manualObject" ); Ogre::Real length = 20; - koordAxisMO_->begin( "BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST); - unsigned point_index = 0; + + koordAxisMO_->begin( "singleColor", Ogre::RenderOperation::OT_LINE_LIST); + koordAxisMO_->getSection( 0 )->setCustomParameter( 0, Ogre::Vector4( 1.0, 0.0, 0.0, 1.0 ) ); koordAxisMO_->position( 0.0, 0.0, 0.0 ); koordAxisMO_->position( 1.0, 0.0, 0.0 ); koordAxisMO_->position( 0.0, 0.0, 0.0 ); + koordAxisMO_->end(); + + koordAxisMO_->begin( "singleColor", Ogre::RenderOperation::OT_LINE_LIST); + koordAxisMO_->getSection( 1 )->setCustomParameter( 0, Ogre::Vector4( 0.0, 1.0, 0.0, 1.0 ) ); koordAxisMO_->position( 0.0, 1.0, 0.0 ); koordAxisMO_->position( 0.0, 0.0, 0.0 ); + koordAxisMO_->end(); + + koordAxisMO_->begin( "singleColor", Ogre::RenderOperation::OT_LINE_LIST); + koordAxisMO_->getSection( 2 )->setCustomParameter( 0, Ogre::Vector4( 0.0, 0.0, 1.0, 1.0 ) ); koordAxisMO_->position( 0.0, 0.0, 1.0 ); koordAxisMO_->position( 0.0, 0.0, 0.0 ); + koordAxisMO_->end(); + + koordAxisMO_->begin( "BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST); koordAxisMO_->position( -1.0, 0.0, 0.0 ); koordAxisMO_->position( 0.0, 0.0, 0.0 ); koordAxisMO_->position( 0.0, -1.0, 0.0 ); @@ -771,11 +805,6 @@ void Sector::sendAllVesselMovements( ){ if ( avatar_ ) sendVesselMovement( avatar_ ); - -// for ( std::map< int, SectorObjectMoveableAi * >::iterator it = localAiObjects_.begin(); it != localAiObjects_.end(); it ++ ){ -// sendVesselMovement( it->second ); -// } - } void Sector::sendAllVesselInfos( ){ @@ -798,6 +827,7 @@ obj->velocity().ptr(), obj->mainNode()->getOrientation().ptr(), obj->thrustRate(), + obj->thrust(), obj->scaledYaw(), obj->scaledPitch(), obj->scaledRoll(), @@ -807,6 +837,62 @@ } } +void Sector::receiveVesselMovement( const std::vector < MessageBodyShipMovement * > & movements ){ + + std::map < long, const MessageBodyShipMovement * > singleMsg; + + //** we sort the movement messaged + for ( size_t i = 0; i < movements.size(); i ++ ){ +// LogManager::getSingleton().debug( std::string( "Movement: " ) + +// movableObjects_[ createGlobalID( movements[ i ]->senderID(), movements[ i ]->childID() )]->name() + " " + toStr( movements[ i ]->senderID() ) + " " + toStr( (int)movements[ i ]->childID() ) + +// " " + toStr( movements[ i ]->position() ) ); + + if ( movements[ i ]->senderID() != network_->userID() ){ + //** apply only foreign movements, and take just the actual movement + singleMsg[ createGlobalID( movements[ i ]->senderID(), movements[ i ]->childID() ) ] = movements[ i ]; + } + } + + std::map< long, SectorObjectMoveable * >::iterator it; + + for ( std::map < long, const MessageBodyShipMovement * >::iterator i = singleMsg.begin(); i != singleMsg.end(); i++ ){ + if ( ( it = movableObjects_.find( i->first ) ) != movableObjects_.end() ){ + it->second->setFlightProperties( (*i->second) ); + } else { + 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 ++ ){ + delete movements[ i ]; + } + +} + +void Sector::sendVesselStatus( SectorObjectVessel * obj ){ + if ( obj ){ + MessageBodyShipStatus msg( obj->childID(), obj->shield(), obj->armor(), 0, 0, 0 ); + network_->send( msg ); + } +} + +void Sector::receiveVesselStatus( const MessageBodyShipStatus & msg ){ + if ( msg.senderID() != network_->userID() ){ + + std::map< long, SectorObjectMoveable * >::iterator it; + + if ( ( it = movableObjects_.find( createGlobalID( msg.senderID(), msg.childID() ) ) ) != movableObjects_.end() ){ + // log_->debug( "ReceiveVesselStatus for " + it->second->name( ) ); + it->second->setStatus( msg ); + } else { + log_->fatal( "Requested non existant object for shipstatus: " + + network_->userName( msg.senderID() ) + " this should not happen." ); + } + } +} + void Sector::sendVesselRegister( SectorObjectVessel * obj ){ if ( obj ) { log_->info( std::string( "Send register " ) + obj->name() + " id:" + toStr( obj->vessel()->id() ) ); @@ -826,12 +912,11 @@ *ResourceManager::getSingleton().entityManager->vessel( msg.vesselID() ) ); obj->mainNode()->setPosition( toOgreVec( msg.position() ) ); obj->setMass( msg.mass() ); - - log_->info( "FIXTHIS: void Sector::receiveVesselRegister( " ); -// obj->setMaxShield( msg.maxShield() ); -// obj->setMaxThrust( msg.maxThrust() ); + obj->setMaxShield( msg.maxShield() ); + obj->setMaxThrust( msg.maxThrust() ); + obj->setMaxSpeed( std::sqrt( msg.maxThrust() / obj->moveable()->dragFactor() ) ); + std::cout << msg << std::endl; - } else { log_->info( "Create ai object " + msg.name()+ " " + toStr( msg.senderID() ) + " " + toStr( (int)msg.childID() ) + " " + toStr( msg.vesselID() ) ); @@ -895,62 +980,6 @@ } } -void Sector::receiveVesselMovement( const std::vector < MessageBodyShipMovement * > & movements ){ - - std::map < long, const MessageBodyShipMovement * > singleMsg; - - //** we sort the movement messaged - for ( size_t i = 0; i < movements.size(); i ++ ){ -// LogManager::getSingleton().debug( std::string( "Movement: " ) + -// movableObjects_[ createGlobalID( movements[ i ]->senderID(), movements[ i ]->childID() )]->name() + " " + toStr( movements[ i ]->senderID() ) + " " + toStr( (int)movements[ i ]->childID() ) + -// " " + toStr( movements[ i ]->position() ) ); - - if ( movements[ i ]->senderID() != network_->userID() ){ - //** apply only foreign movements, and take just the actual movement - singleMsg[ createGlobalID( movements[ i ]->senderID(), movements[ i ]->childID() ) ] = movements[ i ]; - } - } - - std::map< long, SectorObjectMoveable * >::iterator it; - - for ( std::map < long, const MessageBodyShipMovement * >::iterator i = singleMsg.begin(); i != singleMsg.end(); i++ ){ - if ( ( it = movableObjects_.find( i->first ) ) != movableObjects_.end() ){ - it->second->setFlightProperties( (*i->second) ); - } else { - 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 ++ ){ - delete movements[ i ]; - } - -} - -void Sector::sendVesselStatus( SectorObjectVessel * obj ){ - if ( obj ){ - MessageBodyShipStatus msg( obj->childID(), obj->shield(), obj->armor(), 0, 0, 0 ); - network_->send( msg ); - } -} - -void Sector::receiveVesselStatus( const MessageBodyShipStatus & msg ){ - if ( msg.senderID() != network_->userID() ){ - - std::map< long, SectorObjectMoveable * >::iterator it; - - if ( ( it = movableObjects_.find( createGlobalID( msg.senderID(), msg.childID() ) ) ) != movableObjects_.end() ){ - // log_->debug( "ReceiveVesselStatus for " + it->second->name( ) ); - it->second->setStatus( msg ); - } else { - log_->fatal( "Requested non existant object for shipstatus: " + - network_->userName( msg.senderID() ) + " this should not happen." ); - } - } -} - void Sector::sendVesselAmmoHit( const Projectile & projectile, BaseObject * victim ){ if ( projectile.parent().userID() == network_->userID() ){ Modified: trunk/src/Sector.h =================================================================== --- trunk/src/Sector.h 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/Sector.h 2008-05-14 21:33:27 UTC (rev 897) @@ -56,6 +56,12 @@ void setListener( UnDockedState * listener ){ listener_ = listener; } UnDockedState * listener( ){ return listener_; } + + /*! Set the name of this sector */ + void setName( const std::string & name ) { name_ = name; } + + /*! Return the name of this sector. Set during population from xml-file */ + std::string name() const { return name_; } void update( Ogre::Real elapsedTime ); @@ -65,6 +71,8 @@ const Ogre::Vector3 & pos, const Ogre::Vector3 & targetSize, Ogre::Degree yaw ); SectorObject * createStation( const Ogre::String & stationName, Ogre::Vector3 & pos ); + + SectorObject * createBeacon( const Ogre::Vector3 & pos ); SectorObjectMoveable * createMoveable( const Ogre::String & name, Uint32 userId, Uint8 childId, Moveable & moveable ); @@ -119,38 +127,38 @@ StationObject * station() { return station_; } protected: - + //** do not destruct objects manualy, let them send false during update loop void destruct_( SectorObject * obj ); - Ogre::SceneManager * sceneMgr_; - NetworkClient * network_; - LogManager * log_; + Ogre::SceneManager * sceneMgr_; + NetworkClient * network_; + LogManager * log_; - UnDockedState * listener_; + UnDockedState * listener_; - std::string sectorname_; + std::string name_; - SectorObjectAvatar * avatar_; - Planet * planet_; + SectorObjectAvatar * avatar_; + Planet * planet_; - Ogre::SceneNode * starsNode_; - Ogre::SceneNode * koordAxisNode_; - Ogre::ManualObject * koordAxisMO_; - - std::set< SectorObject * > sectorObjects_; + Ogre::SceneNode * starsNode_; + Ogre::SceneNode * koordAxisNode_; + Ogre::ManualObject * koordAxisMO_; - std::map< long, SectorObjectMoveable * > movableObjects_; - std::map< long, SectorObjectMissile * > localAiObjects_; + std::set< SectorObject * > sectorObjects_; - float avatarDeathSequenceTime_; + std::map< long, SectorObjectMoveable * > movableObjects_; + std::map< long, SectorObjectMissile * > localAiObjects_; - bool radar_ ; + float avatarDeathSequenceTime_; - StationObject * station_; - - std::map< std::string, std::deque< SectorObject * > > objectHeap_; - uint childIDCounter_; + bool radar_ ; + + StationObject * station_; + + std::map< std::string, std::deque< SectorObject * > > objectHeap_; + uint childIDCounter_; }; } // namespace OpenGate Modified: trunk/src/SectorObject.cpp =================================================================== --- trunk/src/SectorObject.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/SectorObject.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -31,7 +31,7 @@ namespace OpenGate{ SectorObject::SectorObject( const Ogre::String & name, Sector * sector, Uint32 userID, Uint8 childID ) - : BaseObject( name, sector, userID, childID ), target_( NULL ) { __D( name ) + : BaseObject( name, sector, userID, childID ), target_( NULL ), entity_( NULL ) { __D( name ) isOnRadar_ = false; mainNodeEntityScale_ = mainNode_->createChildSceneNode( name_ + "_baseScale" ); @@ -65,8 +65,10 @@ ResourceManager::getSingleton().collisionManager->destroyObject( this ); - mainNodeEntityRot_->detachObject( entity_ ); - sceneMgr_->destroyEntity( entity_ ); + if ( entity_ ){ + mainNodeEntityRot_->detachObject( entity_ ); + sceneMgr_->destroyEntity( entity_ ); + } mainNodeEntityScale_->removeAndDestroyChild( mainNodeEntityRot_->getName() ); mainNode_->removeAndDestroyChild( mainNodeEntityScale_->getName() ); @@ -78,12 +80,23 @@ if ( target_ ){ std::cerr << WHERE_AM_I << "*************** this should not happen" << " " << target_->name() << std::endl; } else { - target_ == NULL; + target_ = NULL; } } void SectorObject::setShape( const Ogre::String & meshname ){ - entity_ = sceneMgr_->createEntity( name_ + "_shape", meshname ); + try { + entity_ = sceneMgr_->createEntity( name_ + "_shape", meshname ); + } catch( Ogre::Exception & e ){ + LogManager::getSingleton().warn( e.what() ); + entity_ = NULL; + return ; + } catch( ... ){ + LogManager::getSingleton().warn( "Unknown exception" ); + entity_ = NULL; + return ; + } + mainNodeEntityRot_->attachObject( entity_ ); ResourceManager::getSingleton().collisionManager->createObject( this ); } Modified: trunk/src/SectorObject.h =================================================================== --- trunk/src/SectorObject.h 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/SectorObject.h 2008-05-14 21:33:27 UTC (rev 897) @@ -51,7 +51,12 @@ virtual void collide( BaseObject * object ){ // std::cout << "SectorObject " << name_ << " collide with " << object->rtti() << " " << object->name()<< std::endl; } - + + /*! Return pointer to the active sector.*/ + Sector * sector() { return sector_; } + + Ogre::SceneNode * rotnode() { return mainNodeEntityRot_;} + virtual bool update( Ogre::Real elapsedTime ){ return true; } void setShape( const Ogre::String & meshname ); @@ -97,19 +102,21 @@ virtual void inititialize_(); - Ogre::SceneNode * mainNodeEntityScale_; // Main character node for base size - Ogre::SceneNode * mainNodeEntityRot_; // Main character node for base rotation - Ogre::Entity * entity_; + SectorObject * target_; + Ogre::Entity * entity_; + + Ogre::SceneNode * mainNodeEntityScale_; // Main character node for base size + Ogre::SceneNode * mainNodeEntityRot_; // Main character node for base rotation + + Ogre::OverlayElement * dotA_; + Ogre::OverlayElement * dotB_; - Ogre::OverlayElement * dotA_; - Ogre::OverlayElement * dotB_; - bool isOnRadar_; Ogre::Vector3 baseSize_; Ogre::Vector3 baseScale_; std::set < SectorObject * > observers_; // better listener / e.g. radar - SectorObject * target_; + }; Modified: trunk/src/SectorObjectMissile.cpp =================================================================== --- trunk/src/SectorObjectMissile.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/SectorObjectMissile.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -110,7 +110,7 @@ Ogre::Real scaledYaw = yawTo.valueDegrees() / ( elapsedTime * rotFric * moveable_->yaw() ); Ogre::Real scaledPitch = pitchTo.valueDegrees() / ( elapsedTime * rotFric * moveable_->pitch() ); - Ogre::Real scaledRoll = rollTo.valueDegrees() / ( elapsedTime * rotFric * moveable_->yaw() ); + // Ogre::Real scaledRoll = rollTo.valueDegrees() / ( elapsedTime * rotFric * moveable_->yaw() ); yaw_ = max( -1.0f, scaledYaw ); yaw_ = min( yaw_, 1.0f ); pitch_ = max( -1.0f, scaledPitch ); pitch_ = min( pitch_, 1.0f ); @@ -149,7 +149,7 @@ thrustTrail_->setMaterialName( "BeamGreen" ); thrustTrail_->setTrailLength( 1000 ); thrustTrail_->setColourChange( 0, Ogre::ColourValue( 0.0, 0.0, 0.0, 0.3 ) ); - thrustTrail_->setWidthChange( 0, 0.5 ); + thrustTrail_->setWidthChange( 0, 0.3 ); thrustTrail_->setMaxChainElements( 100 ); thrustTrail_->setInitialWidth( 0, 1.0 ); thrustTrail_->addNode( mainNode_ ); Modified: trunk/src/SectorObjectMoveable.cpp =================================================================== --- trunk/src/SectorObjectMoveable.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/SectorObjectMoveable.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -97,7 +97,7 @@ void SectorObjectMoveable::inititialize_(){ - if ( moveable_ ) maxArmor_ = moveable_->armor(); else maxArmor_ = 1.0; + if ( moveable_ ) maxArmor_ = moveable_->armor(); else maxArmor_ = 1; if ( moveable_ ) maxSpeed_ = moveable_->maxSpeed(); else maxSpeed_ = 0.0; mass_ = 1; @@ -130,7 +130,7 @@ netSequence_ = 0; lifeTime_ = 0.0; lastLifeTime_ = 0.0; - forceMovement_ = false; + forceMovement_ = true; statusChanged_ = false; selectable_ = true; @@ -150,7 +150,7 @@ } if ( destroyRequest_ || destroyWithExplosion_ ){ - ResourceManager::getSingleton().collisionManager->dettach( this ); + ResourceManager::getSingleton().collisionManager->detach( this ); this->unsubscribeToObservers(); @@ -220,7 +220,7 @@ if ( speed > maxSpeed() ){ vel_ *= maxSpeed() / speed; - } else if ( speed < 0.1 ){ + } else if ( speed < 0.01 ){ vel_ *= 0.0; } @@ -231,9 +231,6 @@ Ogre::Ray rayNoNextPos( mainNode_->getWorldPosition(), vel_.normalisedCopy() ); ResourceManager::getSingleton().collisionManager->checkCollideRay( this, rayNoNextPos, (vel_ * elapsedTime).length() ); } - - - // //** snap quaternion // Ogre::Quaternion rnd( mainNode_->getOrientation() ); @@ -246,15 +243,20 @@ void SectorObjectMoveable::setFlightProperties( const MessageBodyShipMovement & msg ){ setThrustRate( msg.thrustRate() ); + thrust_ = msg.thrust(); + + updateThruster(); + + std::cout << name_ << " " << msg << std::endl; if ( forceMovement_ ){ - mainNode_->setPosition( toOgreVec( msg.position() ) ); - mainNode_->setOrientation( toOgreQuat( msg.orientation() ) ); - vel_ = toOgreVec( msg.velocity() ); - setScaledYaw( msg.yaw() ); - setScaledPitch( msg.pitch() ); - setScaledRoll( msg.roll() ); - forceMovement_ = false; - } else { + mainNode_->setPosition( toOgreVec( msg.position() ) ); + mainNode_->setOrientation( toOgreQuat( msg.orientation() ) ); + vel_ = toOgreVec( msg.velocity() ); + setScaledYaw( msg.yaw() ); + setScaledPitch( msg.pitch() ); + setScaledRoll( msg.roll() ); + forceMovement_ = false; + } else { // if ( ( fabs( msg.yaw() ) -1.0f ) < 1e-4 ) { // setScaledYaw( msg.yaw() ); @@ -272,36 +274,36 @@ // setScaledRoll( 0.0 ); // } - setScaledYaw( msg.yaw() ); - setScaledRoll( msg.roll() ); - setScaledPitch( msg.pitch() ); + setScaledYaw( msg.yaw() ); + setScaledRoll( msg.roll() ); + setScaledPitch( msg.pitch() ); - vel_ = toOgreVec( msg.velocity() ); + vel_ = toOgreVec( msg.velocity() ); - Ogre::Vector3 srcP( mainNode_->getPosition( ) ); - Ogre::Quaternion srcQ( mainNode_->getOrientation( ) ); - Ogre::Vector3 destP( toOgreVec( msg.position( ) ) ); + Ogre::Vector3 srcP( mainNode_->getPosition( ) ); + Ogre::Quaternion srcQ( mainNode_->getOrientation( ) ); + Ogre::Vector3 destP( toOgreVec( msg.position( ) ) ); - //** try Slerp - Ogre::Quaternion diff = Ogre::Quaternion::nlerp( 1, srcQ, toOgreQuat( msg.orientation() ) ); - interpolateRot_ = diff * srcQ.Inverse(); + //** try Slerp + Ogre::Quaternion diff = Ogre::Quaternion::nlerp( 1, srcQ, toOgreQuat( msg.orientation() ) ); + interpolateRot_ = diff * srcQ.Inverse(); // if ( msg.childID() > 0 ){ - if ( !1 ){ + if ( !1 ){ - std::cout << std::endl; - std::cout << msg.sequenceNr() << "LastFrameCount: " << lastFrameCount_ - << " life: " << lifeTime_ << " last: " << lastLifeTime_ - << " diff: "<< lifeTime_ - lastLifeTime_ << std::endl; + std::cout << std::endl; + std::cout << msg.sequenceNr() << "LastFrameCount: " << lastFrameCount_ + << " life: " << lifeTime_ << " last: " << lastLifeTime_ + << " diff: "<< lifeTime_ - lastLifeTime_ << std::endl; // std::cout << "Ist: " << mainNode_->getOrientation( ) // << " " << mainNode_->getOrientation( ).getYaw().valueDegrees() << std::endl; // std::cout << "Soll: " << msg.orientation() << " " << msg.orientation().getYaw().valueDegrees() << std::endl; - std::cout << "Diff: send: " << msg.yaw() << " " << msg.pitch() << " " << msg.roll() << std::endl; + std::cout << "Diff: send: " << msg.yaw() << " " << msg.pitch() << " " << msg.roll() << std::endl; - std::cout << "Diff: Pos: " << (srcP-destP).length() + std::cout << "Diff: Pos: " << (srcP-destP).length() << " Y:" << interpolateRot_.getYaw().valueDegrees() << " P:" << interpolateRot_.getPitch().valueDegrees() << " R:" << interpolateRot_.getRoll().valueDegrees() << std::endl; Modified: trunk/src/SectorObjectMoveable.h =================================================================== --- trunk/src/SectorObjectMoveable.h 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/SectorObjectMoveable.h 2008-05-14 21:33:27 UTC (rev 897) @@ -100,6 +100,8 @@ /*! Return the maximum thrust */ inline Uint32 maxThrust() const { return maxThrust_; } + inline Uint32 thrust() const { return thrust_; } + /*! Update visual feedback for thrusters */ void updateThruster(); @@ -113,6 +115,9 @@ inline Ogre::Real speed() const { return vel_.length(); } /*! Returns the maximum speed depend on vessel and mounted engine */ + inline void setMaxSpeed( Ogre::Real speed ) { maxSpeed_ = speed; } + + /*! Returns the maximum speed depend on vessel and mounted engine */ inline Ogre::Real maxSpeed() const { return maxSpeed_; } /*! Returns the relative speed */ Modified: trunk/src/SectorObjectVessel.cpp =================================================================== --- trunk/src/SectorObjectVessel.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/SectorObjectVessel.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -101,12 +101,12 @@ if ( this->vessel()->engine() ){ maxThrust_ = this->vessel()->engine()->maxThrust(); } else { - maxThrust_ = 0.0; + maxThrust_ = 0; } if ( this->vessel()->shield() ) { maxShield_ = this->vessel()->shield()->maxDeflection(); } else { - maxShield_ = 0.0; + maxShield_ = 0; } controler_ = NULL; Modified: trunk/src/Station.cpp =================================================================== --- trunk/src/Station.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/Station.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -76,12 +76,12 @@ ibuf->unlock(); } -StationPad::StationPad( const std::string & name, StationObject * station, Ogre::SubEntity * padSubEntity, bool docking ) - : BaseObject( name, station->sector() ), station_( station ), docking_( docking ){ +Pad::Pad( const std::string & name, SectorObject * parent, Ogre::SubEntity * padSubEntity ) + : BaseObject( name, parent->sector() ), parent_( parent ){ //** hier gibt es eine mainNode die nicht genutzt wird. C. //** mach das sauber!! ersetzt getPosition, getDirection, padNode - padNode_ = station_->rotnode()->createChildSceneNode( station_->name() + "/" + name_ ); + padNode_ = parent_->rotnode()->createChildSceneNode( parent_->name() + "/" + name_ ); padManualObject_ = sceneMgr_->createManualObject( padNode_->getName() + "/ManualObject" ); std::vector < Ogre::Vector3 > verts; @@ -122,24 +122,33 @@ padEntity_ = sceneMgr_->createEntity( padMesh_->getName() + "/Entity", padMesh_->getName() ); padNode_->attachObject( padEntity_ ); padNode_->translate( direction_.normalisedCopy() * 0.1 ); - if ( docking_ ){ - ResourceManager::getSingleton().collisionManager->createObject( this ); - } } - -StationPad::~StationPad( ){ - ResourceManager::getSingleton().collisionManager->destroyObject( this ); + +Pad::~Pad( ){ padNode_->detachObject( padEntity_ ); sceneMgr_->destroyEntity( padEntity_ ); Ogre::MeshManager::getSingleton().remove( padMesh_->getName() ); sceneMgr_->destroyManualObject( padManualObject_ ); - station_->rotnode()->removeAndDestroyChild( padNode_->getName() ); + parent_->rotnode()->removeAndDestroyChild( padNode_->getName() ); } +StationPad::StationPad( const std::string & name, StationObject * station, Ogre::SubEntity * padSubEntity, + bool docking ) + : Pad( name, station, padSubEntity), docking_( docking ){ + + if ( docking_ ){ + ResourceManager::getSingleton().collisionManager->createObject( this ); + } +} + +StationPad::~StationPad( ){ + ResourceManager::getSingleton().collisionManager->destroyObject( this ); +} + void StationPad::collide( BaseObject * object ){ - if ( docking_ ) { if ( object->rtti() == AVATAR_RTTI ){ + std::cout << "StationPad::collide() docking request for " << object->name() << std::endl; sector_->listener()->changeToDockedState(); } else if ( object->rtti() == SECTOROBJECTVESSEL_RTTI ){ std::cout << "StationPad::collide() docking request for " << object->name() << std::endl; @@ -190,7 +199,7 @@ 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 ) ); + launchPad_ = new StationPad( name_ + "LaunchPad", this, entity()->getSubEntity( i ), false ); } } @@ -346,4 +355,98 @@ ringNode_->attachObject( ringEntity_ ); } +BeaconPad::BeaconPad( const std::string & name, BeaconObject * beacon, Ogre::SubEntity * padSubEntity ) + : Pad( name, beacon, padSubEntity){ + + ResourceManager::getSingleton().collisionManager->createObject( this ); +} + +BeaconPad::~BeaconPad( ){ + ResourceManager::getSingleton().collisionManager->destroyObject( this ); +} + +void BeaconPad::collide( BaseObject * object ){ + if ( object->rtti() == AVATAR_RTTI ){ + std::cout << "BeaconPad::collide() bcu for " << object->name() << std::endl; + } else if ( object->rtti() == SECTOROBJECTVESSEL_RTTI ){ + std::cout << "BeaconPad::collide() bcu for " << object->name() << std::endl; + } +} + +void BeaconPad::changeEntity( const std::string & meshname ){ + ResourceManager::getSingleton().collisionManager->detach( this ); + padNode_->detachObject( padEntity_ ); + sceneMgr_->destroyEntity( padEntity_ ); + padEntity_ = sceneMgr_->createEntity( name_ + "/Entity", meshname ); + padNode_->attachObject( padEntity_ ); + padNode_->translate( position_ ); + ResourceManager::getSingleton().collisionManager->attach( this ); +} + + +BeaconObject::BeaconObject( Sector * sector ) + : SectorObject ( sector->name() + "/Beacon ", sector ), entryPad_( NULL ), exitPad_( NULL ) { + + Ogre::MeshPtr pMesh = Ogre::MeshManager::getSingleton().load( "beacon.mesh", + Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, + 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); + } + setShape( "beacon.mesh" ); + //entity_->setMaterialName( "Sta/TS/Background" ); + + 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; + + if ( entity()->getSubEntity( i )->getMaterialName() == "beacon/bg" ){ + entity()->getSubEntity( i )->setMaterialName( "Sta/TS/Background" ); + } + + if ( entity()->getSubEntity( i )->getMaterialName() == "beacon/pad_mount_0" ){ + entity()->getSubEntity( i )->setMaterialName( "singleColor" ); + entity()->getSubEntity( i )->setCustomParameter( 0, Ogre::Vector4( 0.5, 0.5, 0.5, 1.0 ) ); + entryPad_ = new BeaconPad( "EntryPad", this, entity()->getSubEntity( i ) ); + entryPad_->changeEntity( "beacon_pad.mesh" ); + entryPad_->entity()->setMaterialName( "singleColor" ); + entryPad_->entity()->getSubEntity( 0 )->setCustomParameter( 0, Ogre::Vector4( 0.8, 0.0, 0.0, 0.2 ) ); + } + if ( entity()->getSubEntity( i )->getMaterialName() == "beacon/pad_mount_1" ){ + entity()->getSubEntity( i )->setMaterialName( "singleColor" ); + entity()->getSubEntity( i )->setCustomParameter( 0, Ogre::Vector4( 0.5, 0.5, 0.5, 1.0 ) ); + exitPad_ = new BeaconPad( "ExitPad", this, entity()->getSubEntity( i ) ); + exitPad_->changeEntity( "beacon_pad.mesh" ); + exitPad_->entity()->setMaterialName( "singleColor" ); + exitPad_->entity()->getSubEntity( 0 )->setCustomParameter( 0, Ogre::Vector4( 0.8, 0.0, 0.0, 0.2 ) ); + } + } + + +// std::vector < Ogre::Vector3 > verts; +// std::vector < Triangle > tris; +// readSubEntity( entity_, verts, tris ); + + + +} + +BeaconObject::~BeaconObject( ){ + if ( entryPad_ ) delete entryPad_; + if ( exitPad_ ) delete exitPad_; +} + +Ogre::Vector3 BeaconObject::entrancePosition() const { + return Ogre::Vector3::ZERO; +} + +Ogre::Vector3 BeaconObject::exitPosition() const { + return Ogre::Vector3::ZERO; +} + } // namespace OpenGate Modified: trunk/src/Station.h =================================================================== --- trunk/src/Station.h 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/Station.h 2008-05-14 21:33:27 UTC (rev 897) @@ -31,8 +31,11 @@ namespace OpenGate{ class Station; +class Pad; class StationPad; +class BeaconPad; class StationObject; +class BeaconObject; struct Triangle{ int a, b, c; @@ -52,14 +55,12 @@ protected: }; -/*! A station pad is a plain area where vessel dock or launch */ -class StationPad : public BaseObject{ +class Pad : public BaseObject { public: /*! Constructor, with a name, */ - StationPad( const std::string & name, StationObject * station, Ogre::SubEntity * padSubEntity, - bool docking = false ); + Pad( const std::string & name, SectorObject * parent, Ogre::SubEntity * padSubEntity ); /*! Destructor */ - virtual ~StationPad( ); + virtual ~Pad( ); /*! Return runtime type information */ virtual long rtti() const { return STATIONPAD_RTTI; } @@ -67,7 +68,7 @@ virtual std::string collisionClass() const { return "DockPad"; } /*! What happen on collision */ - void collide( BaseObject * object ); + virtual void collide( BaseObject * object ){} /*! Update the pad in each frame */ virtual bool update( Ogre::Real elapsedTime ){ return true; } @@ -80,16 +81,13 @@ /*! Radius of the pad */ Ogre::Real radius() const { return radius_; } - - bool isDocking( ) const { return docking_; } Ogre::SceneNode * padNode(){ return padNode_; } virtual Ogre::Entity * entity( ) { return padEntity_; } protected: - StationObject * station_; - bool docking_; + SectorObject * parent_; Ogre::SceneNode * padNode_; Ogre::ManualObject * padManualObject_; Ogre::MeshPtr padMesh_; @@ -99,6 +97,22 @@ Ogre::Vector3 direction_; Ogre::Real radius_; }; + +/*! A station pad is a plain area where vessel dock or launch */ +class StationPad : public Pad { +public: + /*! Constructor, with a name, */ + StationPad( const std::string & name, StationObject * station, Ogre::SubEntity * padSubEntity, + bool docking = false ); + /*! Destructor */ + virtual ~StationPad( ); + + /*! What to do on collision */ + void collide( BaseObject * object ); + +protected: + bool docking_; +}; //** derive from dockable so sector can handle set of dockables class StationObject : public SectorObject{ @@ -142,11 +156,6 @@ /*! Docking rings end position respectively outer position of the dockingtube*/ Ogre::Vector3 dockingRingEnd( ) const ; - /*! Return pointer to the active sector.*/ - Sector * sector() { return sector_; } - - Ogre::SceneNode * rotnode() { return mainNodeEntityRot_;} - protected: Station * station_; Ogre::SceneNode * ringNode_; @@ -159,9 +168,43 @@ StationPad * dockPad_; StationPad * launchPad_; //StationDockPad * dockPad_; +}; + +/*! A station pad is a plain area where vessel dock or launch */ +class BeaconPad : public Pad{ +public: + /*! Constructor, with a name, */ + BeaconPad( const std::string & name, BeaconObject * station, Ogre::SubEntity * padSubEntity ); + + /*! Destructor */ + virtual ~BeaconPad( ); + + /*! What happen on collision */ + void collide( BaseObject * object ); + + void changeEntity( const std::string & meshname ); + +protected: }; +class BeaconObject : public SectorObject { +public: + BeaconObject( Sector * sector ); + + virtual ~BeaconObject( ); + + /*! Return entrance position in world coordinates */ + Ogre::Vector3 entrancePosition() const; + + /*! Return exit position in world coordinates */ + Ogre::Vector3 exitPosition() const; + +protected: + BeaconPad * entryPad_; + BeaconPad * exitPad_; +}; + } // namespace OpenGate #endif //_OPENGATE_STATION__H Modified: trunk/src/UnDockedState.cpp =================================================================== --- trunk/src/UnDockedState.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/UnDockedState.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -771,7 +771,7 @@ } void UnDockedState::setTarget( SectorObject * target ) { - SectorObject * oldTarget = target_; + // SectorObject * oldTarget = target_; target_ = target; if ( target_ != NULL ){ Modified: trunk/src/Vessel.cpp =================================================================== --- trunk/src/Vessel.cpp 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/Vessel.cpp 2008-05-14 21:33:27 UTC (rev 897) @@ -25,28 +25,29 @@ #include <OgreMeshManager.h> namespace OpenGate{ - + Vessel::Vessel( ) : Moveable() { - rtti_ = VESSEL; - fixEquipment_ = false; + rtti_ = VESSEL; + fixEquipment_ = false; - amountModX_ = 0; + amountModX_ = 0; amountMissiles_ = 0; - - shieldSize_ = 0; - radarSize_ = 0; - engineSize_ = 0; - capacitorSize_ = 0; + + shieldSize_ = 0; + radarSize_ = 0; + engineSize_ = 0; + capacitorSize_ = 0; powerPlantSize_ = 0; - cargoSize_ = 0; - ecmSize_ = 0; - missileSize_ = 0; - powerPlant_ = NULL; - engine_ = NULL; - radar_ = NULL; - ecm_ = NULL; - shield_ = NULL; - capacitor_ = NULL; + cargoSize_ = 0; + ecmSize_ = 0; + missileSize_ = 0; + + powerPlant_ = NULL; + engine_ = NULL; + radar_ = NULL; + ecm_ = NULL; + shield_ = NULL; + capacitor_ = NULL; } std::vector < Ogre::Vector3 > findMountPoints( TiXmlHandle * hRoot, const std::string & key ){ @@ -60,7 +61,7 @@ return mountPoints; } -bool Vessel::readPropertiesFromXML( TiXmlHandle & hRoot ){ +void Vessel::readPropertiesFromXML( TiXmlHandle & hRoot ){ Moveable::readPropertiesFromXML( hRoot ); readXMLNode< int >( hRoot, "modx", this, &OpenGate::Vessel::setAmountModX, false ); @@ -262,7 +263,7 @@ } Ogre::Real Vessel::maxSpeed() const { - if ( engine_ ) return sqrt( engine_->maxThrust() / dragFactor() ); + if ( engine_ ) return std::sqrt( engine_->maxThrust() / dragFactor() ); return 0.0; } @@ -273,7 +274,7 @@ lifetime_ = 1; } -bool Missile::readPropertiesFromXML( TiXmlHandle & hRoot ){ +void Missile::readPropertiesFromXML( TiXmlHandle & hRoot ){ Moveable::readPropertiesFromXML( hRoot ); readXMLNode< int >( hRoot, "damage", this, &OpenGate::Missile::setDamage, false ); Modified: trunk/src/Vessel.h =================================================================== --- trunk/src/Vessel.h 2008-05-12 16:19:10 UTC (rev 896) +++ trunk/src/Vessel.h 2008-05-14 21:33:27 UTC (rev 897) @@ -67,94 +67,93 @@ /*! Desctructor */ virtual ~Vessel(){} - bool readPropertiesFromXML( TiXmlHandle & hRoot ); + virtual void readPropertiesFromXML( TiXmlHandle & hRoot ); inline void setFixEquipment( bool fix ) { fixEquipment_ = fix; } - inline bool fixEquipment( ) const { return fixEquipment_ ; } + inline bool fixEquipment( ) const { return fixEquipment_ ; } - inline void setPowerPlantSize( int size ){ powerPlantSize_ = size; } - inline int powerPlantSize( ) const { return powerPlantSize_; } - bool setPowerPlant( PowerPlant * item ); - inline PowerPlant * powerPlant( ){ return powerPlant_; } + inline void setPowerPlantSize( int size ){ powerPlantSize_ = size; } + inline int powerPlantSize( ) const { return powerPlantSize_; } + bool setPowerPlant( PowerPlant * item ); + inline PowerPlant * powerPlant( ){ return powerPlant_; } - inline void setEngineSize( int size ){ engineSize_ = size; } - inline int engineSize( ) const { return engineSize_; } - bool setEngine( Engine * item ); - inline Engine * engine( ){ return engine_; } + inline void setEngineSize( int size ){ engineSize_ = size; } + inline int engineSize( ) const { return engineSize_; } + bool setEngine( Engine * item ); + inline Engine * engine( ){ return engine_; } - inline void setRadarSize( int size ){ radarSize_ = size; } - inline int radarSize( ) const { return radarSize_; } - bool setRadar( Radar * item ); - inline Radar * radar( ){ return radar_; } + inline void setRadarSize( int size ){ radarSize_ = size; } + inline int radarSize( ) const { return radarSize_; } + bool setRadar( Radar * item ); + inline Radar * radar( ){ return radar_; } - inline void setEcmSize( int size ){ ecmSize_ = size; } - inline int ecmSize( ) const { return ecmSize_; } - bool setEcm( Ecm *... [truncated message content] |