[Orxonox-commit 1394] r6112 - in code/branches/presentation2/src/orxonox: controllers weaponsystem worldentities worldentities/pawns
scheusso at orxonox.net
scheusso at orxonox.net
Sat Nov 21 00:57:07 CET 2009
Author: scheusso
Date: 2009-11-21 00:57:06 +0100 (Sat, 21 Nov 2009)
New Revision: 6112
Modified:
code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc
code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc
code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.cc
code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.h
code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.cc
Log:
first attempts to have synchronised fire direction and target
however client cannot select targets yet (probably because of classtreemask hack)
Modified: code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc 2009-11-20 23:33:37 UTC (rev 6111)
+++ code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc 2009-11-20 23:57:06 UTC (rev 6112)
@@ -80,7 +80,7 @@
void NewHumanController::tick(float dt)
{
- if( !this->controllableEntity_->isInMouseLook() )
+ if( this->controllableEntity_ && !this->controllableEntity_->isInMouseLook() )
{
this->crossHairOverlay_->setPosition(Vector2(static_cast<float>(this->currentYaw_)/2*-1+.5-overlaySize_/2, static_cast<float>(this->currentPitch_)/2*-1+.5-overlaySize_/2));
this->crossHairOverlay_->show();
@@ -184,8 +184,6 @@
pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * 1200 );
pawn->setTarget( 0 );
}
-
- //return mouseRay.getOrigin() + mouseRay.getDirection() * 1200;
//return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getWorldOrientation() * Vector3::NEGATIVE_UNIT_Z * 2000);
Modified: code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc
===================================================================
--- code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc 2009-11-20 23:33:37 UTC (rev 6111)
+++ code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc 2009-11-20 23:57:06 UTC (rev 6112)
@@ -210,7 +210,6 @@
else
muzzleDirection = pawn->getAimPosition() - this->muzzlePosition_;
// COUT(0) << "muzzleDirection " << muzzleDirection << endl;
- //this->muzzleOrientation_ = this->weapon_->getWorldOrientation();
this->muzzleOrientation_ = (this->weapon_->getWorldOrientation() * WorldEntity::FRONT).getRotationTo(muzzleDirection) * this->weapon_->getWorldOrientation();
}
else
Modified: code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.cc
===================================================================
--- code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.cc 2009-11-20 23:33:37 UTC (rev 6111)
+++ code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.cc 2009-11-20 23:57:06 UTC (rev 6112)
@@ -49,6 +49,7 @@
CreateFactory(ControllableEntity);
registerMemberNetworkFunction( ControllableEntity, fire );
+ registerMemberNetworkFunction( ControllableEntity, setTargetInternal );
ControllableEntity::ControllableEntity(BaseObject* creator) : MobileEntity(creator)
{
@@ -232,6 +233,27 @@
callMemberNetworkFunction(ControllableEntity, fire, this->getObjectID(), 0, firemode);
}
}
+
+ void ControllableEntity::setTarget( WorldEntity* target )
+ {
+ this->target_ = target;
+ if ( !GameMode::isMaster() )
+ {
+ if ( target != 0 )
+ {
+ callMemberNetworkFunction(ControllableEntity, setTargetInternal, this->getObjectID(), 0, target->getObjectID() );
+ }
+ else
+ {
+ callMemberNetworkFunction(ControllableEntity, setTargetInternal, this->getObjectID(), 0, OBJECTID_UNKNOWN );
+ }
+ }
+ }
+
+ void ControllableEntity::setTargetInternal( uint32_t targetID )
+ {
+ this->setTarget( orxonox_cast<WorldEntity*>(Synchronisable::getSynchronisable(targetID)) );
+ }
void ControllableEntity::setPlayer(PlayerInfo* player)
{
Modified: code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.h
===================================================================
--- code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.h 2009-11-20 23:33:37 UTC (rev 6111)
+++ code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.h 2009-11-20 23:57:06 UTC (rev 6112)
@@ -145,10 +145,10 @@
inline void setController(Controller* val)
{ this->controller_ = val; }
- virtual void setTarget( WorldEntity* target )
- { this->target_ = target; }
+ virtual void setTarget( WorldEntity* target );
virtual WorldEntity* getTarget()
{ return this->target_.get(); }
+ void setTargetInternal( uint32_t targetID );
protected:
virtual void setPlayer(PlayerInfo* player); // don't call this directly, use friend class PlayerInfo instead
Modified: code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.cc 2009-11-20 23:33:37 UTC (rev 6111)
+++ code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.cc 2009-11-20 23:57:06 UTC (rev 6112)
@@ -118,6 +118,7 @@
registerVariable(this->health_, VariableDirection::ToClient);
registerVariable(this->initialHealth_, VariableDirection::ToClient);
registerVariable(this->bReload_, VariableDirection::ToServer);
+ registerVariable(this->aimPosition_, Bidirectionality::ServerMaster, 0, true);
}
void Pawn::tick(float dt)
More information about the Orxonox-commit
mailing list