[Orxonox-commit 1369] r6087 - in code/branches/particles2/src: modules/weapons/projectiles orxonox orxonox/controllers orxonox/infos
scheusso at orxonox.net
scheusso at orxonox.net
Wed Nov 18 13:34:15 CET 2009
Author: scheusso
Date: 2009-11-18 13:34:14 +0100 (Wed, 18 Nov 2009)
New Revision: 6087
Modified:
code/branches/particles2/src/modules/weapons/projectiles/Rocket.cc
code/branches/particles2/src/modules/weapons/projectiles/Rocket.h
code/branches/particles2/src/orxonox/Scene.cc
code/branches/particles2/src/orxonox/controllers/AIController.cc
code/branches/particles2/src/orxonox/infos/PlayerInfo.cc
code/branches/particles2/src/orxonox/infos/PlayerInfo.h
Log:
changes in PlayerInfo and Rocket (and scene)
not yet working in network though
Modified: code/branches/particles2/src/modules/weapons/projectiles/Rocket.cc
===================================================================
--- code/branches/particles2/src/modules/weapons/projectiles/Rocket.cc 2009-11-18 12:32:42 UTC (rev 6086)
+++ code/branches/particles2/src/modules/weapons/projectiles/Rocket.cc 2009-11-18 12:34:14 UTC (rev 6087)
@@ -51,16 +51,17 @@
{
RegisterObject(Rocket);// - register the Rocket class to the core
- this->setCollisionType(WorldEntity::Kinematic);
- this->setVelocity(0,0,-100);
- this->model_ = new Model(this);
- this->model_->setMeshSource("rocket_test.mesh");
- this->attach(this->model_);
- this->lifetime_ = 100;
- this->bDestroy_ = false;
-
if (GameMode::isMaster())
{
+ this->setCollisionType(WorldEntity::Kinematic);
+ this->setVelocity(0,0,-100);
+ this->lifetime_ = 100;
+ this->bDestroy_ = false;
+
+ this->model_ = new Model(this);
+ this->model_->setMeshSource("rocket_test.mesh");
+ this->attach(this->model_);
+
this->enableCollisionCallback();
this->setCollisionResponse(false);
this->setCollisionType(Kinematic);
@@ -75,6 +76,7 @@
this->camPosition_ = new CameraPosition(this);
this->camPosition_->setPosition(0,10,40);
+ this->camPosition_->setSyncMode(0x0);
this->attach( this->camPosition_ );
this->addCameraPosition( this->camPosition_ );
}
@@ -87,11 +89,13 @@
{
if(this->isInitialized())
{
- this->collisionShape_->destroy();
- this->model_->destroy();
- if (GameMode::isMaster() && this->player_)
+ if (GameMode::isMaster() && this->player_.get())
+ {
+ this->model_->destroy();
+ this->collisionShape_->destroy();
this->player_->stopTemporaryControl();
+ }
this->camPosition_->destroy();
}
}
@@ -109,7 +113,6 @@
void Rocket::setOwner(Pawn* owner)
{
this->owner_ = owner;
-
this->originalControllableEntity_ = this->owner_->getPlayer()->getControllableEntity();
this->player_ = this->owner_->getPlayer();
this->owner_->getPlayer()->startTemporaryControl(this);
@@ -125,12 +128,15 @@
{
SUPER(Rocket, tick, dt);
- this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_);
- this->setVelocity( this->getOrientation()*WorldEntity::FRONT*this->getVelocity().length() );
- this->localAngularVelocity_ = 0;
-
- if( this->bDestroy_ )
- this->destroy();
+ if( GameMode::isMaster() )
+ {
+ this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_);
+ this->setVelocity( this->getOrientation()*WorldEntity::FRONT*this->getVelocity().length() );
+ this->localAngularVelocity_ = 0;
+
+ if( this->bDestroy_ )
+ this->destroy();
+ }
}
bool Rocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
@@ -179,6 +185,30 @@
if (GameMode::isMaster())
this->destroy();
}
+
+ void Rocket::fire(unsigned int firemode)
+ {
+ if (this->owner_)
+ {
+ {
+ ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
+ effect->setPosition(this->getPosition());
+ effect->setOrientation(this->getOrientation());
+ effect->setDestroyAfterLife(true);
+ effect->setSource("Orxonox/explosion3");
+ effect->setLifetime(2.0f);
+ }
+ {
+ ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
+ effect->setPosition(this->getPosition());
+ effect->setOrientation(this->getOrientation());
+ effect->setDestroyAfterLife(true);
+ effect->setSource("Orxonox/smoke4");
+ effect->setLifetime(3.0f);
+ }
+ this->destroy();
+ }
+ }
/**
@brief
Modified: code/branches/particles2/src/modules/weapons/projectiles/Rocket.h
===================================================================
--- code/branches/particles2/src/modules/weapons/projectiles/Rocket.h 2009-11-18 12:32:42 UTC (rev 6086)
+++ code/branches/particles2/src/modules/weapons/projectiles/Rocket.h 2009-11-18 12:34:14 UTC (rev 6087)
@@ -109,7 +109,7 @@
{ this->damage_ = damage; }
inline float getDamage() const
{ return this->damage_; }
- virtual void fire(unsigned int firemode) { this->destroy(); }
+ virtual void fire(unsigned int firemode);
private:
WeakPtr<Pawn> owner_;
@@ -121,7 +121,7 @@
Model* model_;
CameraPosition* camPosition_;
ConeCollisionShape* collisionShape_;
- PlayerInfo* player_;
+ WeakPtr<PlayerInfo> player_;
Timer destroyTimer_;
float lifetime_;
};
Modified: code/branches/particles2/src/orxonox/Scene.cc
===================================================================
--- code/branches/particles2/src/orxonox/Scene.cc 2009-11-18 12:32:42 UTC (rev 6086)
+++ code/branches/particles2/src/orxonox/Scene.cc 2009-11-18 12:34:14 UTC (rev 6087)
@@ -333,10 +333,8 @@
int index0, const btCollisionObject* colObj1, int partId1, int index1)
{
// get the WorldEntity pointers
- WorldEntity* object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());
- assert(orxonox_cast<WorldEntity*>(object0));
- WorldEntity* object1 = static_cast<WorldEntity*>(colObj1->getUserPointer());
- assert(orxonox_cast<WorldEntity*>(object1));
+ SmartPtr<WorldEntity> object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());
+ SmartPtr<WorldEntity> object1 = static_cast<WorldEntity*>(colObj1->getUserPointer());
// false means that bullet will assume we didn't modify the contact
bool modified = false;
Modified: code/branches/particles2/src/orxonox/controllers/AIController.cc
===================================================================
--- code/branches/particles2/src/orxonox/controllers/AIController.cc 2009-11-18 12:32:42 UTC (rev 6086)
+++ code/branches/particles2/src/orxonox/controllers/AIController.cc 2009-11-18 12:34:14 UTC (rev 6087)
@@ -108,7 +108,7 @@
this->moveToTargetPosition();
if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(Ogre::Math::PI / 20.0f))
- this->getControllableEntity()->fire(0);
+// this->getControllableEntity()->fire(0);
SUPER(AIController, tick, dt);
}
Modified: code/branches/particles2/src/orxonox/infos/PlayerInfo.cc
===================================================================
--- code/branches/particles2/src/orxonox/infos/PlayerInfo.cc 2009-11-18 12:32:42 UTC (rev 6086)
+++ code/branches/particles2/src/orxonox/infos/PlayerInfo.cc 2009-11-18 12:34:14 UTC (rev 6087)
@@ -49,7 +49,9 @@
this->bSetUnreadyAfterSpawn_ = true;
this->controller_ = 0;
this->controllableEntity_ = 0;
- this->controllableEntityID_ = CLIENTID_UNKNOWN;
+ this->controllableEntityID_ = OBJECTID_UNKNOWN;
+ this->temporaryControllableEntity_ = 0;
+ this->temporaryControllableEntityID_ = OBJECTID_UNKNOWN;
this->gtinfo_ = 0;
this->gtinfoID_ = OBJECTID_UNKNOWN;
@@ -79,6 +81,7 @@
{
registerVariable(this->name_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
registerVariable(this->controllableEntityID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
+ registerVariable(this->temporaryControllableEntityID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
registerVariable(this->bReadyToSpawn_, VariableDirection::ToServer);
registerVariable(this->gtinfoID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID));
}
@@ -165,17 +168,14 @@
void PlayerInfo::startTemporaryControl(ControllableEntity* entity)
{
- if (!entity || entity == this->controllableEntity_)
+ if (!entity)
return;
+
+ assert( this->temporaryControllableEntity_==0 );
-// if (this->controllableEntity_)
-// this->stopControl();
+ this->temporaryControllableEntity_ = entity;
+ this->temporaryControllableEntityID_ = entity->getObjectID();
- this->oldControllableEntity_ = this->controllableEntity_;
-
- this->controllableEntity_ = entity;
- this->controllableEntityID_ = entity->getObjectID();
-
entity->setPlayer(this);
this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);
@@ -200,34 +200,28 @@
this->controller_->setControllableEntity(0);
entity->removePlayer();
-
- if ( this->oldControllableEntity_ )
- {
- this->oldControllableEntity_->removePlayer();
- this->oldControllableEntity_ = 0;
- }
this->changedControllableEntity();
}
void PlayerInfo::stopTemporaryControl()
{
- ControllableEntity* entity = this->controllableEntity_;
+ ControllableEntity* entity = this->temporaryControllableEntity_;
if (!entity)
return;
- this->controllableEntity_ = this->oldControllableEntity_.get();
- this->controllableEntityID_ = this->controllableEntity_->getObjectID();
+ this->temporaryControllableEntity_ = 0;
+ this->temporaryControllableEntityID_ = OBJECTID_UNKNOWN;
- if (this->controller_)
+ if ( this->controllableEntity_ && this->controller_)
this->controller_->setControllableEntity(this->controllableEntity_);
entity->removePlayer();
this->changedControllableEntity();
}
-
+
void PlayerInfo::networkcallback_changedcontrollableentityID()
{
if (this->controllableEntityID_ != OBJECTID_UNKNOWN)
@@ -242,8 +236,25 @@
}
}
+ void PlayerInfo::networkcallback_changedtemporarycontrollableentityID()
+ {
+ CCOUT(0) << "changedtemporarycontrollableentityid" << endl;
+ if (this->temporaryControllableEntityID_ != OBJECTID_UNKNOWN)
+ {
+ Synchronisable* temp = Synchronisable::getSynchronisable(this->temporaryControllableEntityID_);
+ ControllableEntity* entity = orxonox_cast<ControllableEntity*>(temp);
+ this->startTemporaryControl(entity);
+ }
+ else
+ {
+ this->stopTemporaryControl();
+ }
+ }
+
+
void PlayerInfo::networkcallback_changedgtinfoID()
{
+ CCOUT(0) << "changedcontrollableentityid" << endl;
if (this->gtinfoID_ != OBJECTID_UNKNOWN)
{
this->gtinfo_ = orxonox_cast<GametypeInfo*>(Synchronisable::getSynchronisable(this->gtinfoID_));
Modified: code/branches/particles2/src/orxonox/infos/PlayerInfo.h
===================================================================
--- code/branches/particles2/src/orxonox/infos/PlayerInfo.h 2009-11-18 12:32:42 UTC (rev 6086)
+++ code/branches/particles2/src/orxonox/infos/PlayerInfo.h 2009-11-18 12:34:14 UTC (rev 6087)
@@ -91,14 +91,16 @@
private:
void networkcallback_changedcontrollableentityID();
+ void networkcallback_changedtemporarycontrollableentityID();
void networkcallback_changedgtinfoID();
void updateGametypeInfo();
bool bReadyToSpawn_;
Controller* controller_;
ControllableEntity* controllableEntity_;
- WeakPtr<ControllableEntity> oldControllableEntity_;
+ ControllableEntity* temporaryControllableEntity_;
unsigned int controllableEntityID_;
+ unsigned int temporaryControllableEntityID_;
const GametypeInfo* gtinfo_;
unsigned int gtinfoID_;
More information about the Orxonox-commit
mailing list