[Orxonox-commit 2360] r7075 - in code/branches/presentation3/src/orxonox: controllers worldentities/pawns
landauf at orxonox.net
landauf at orxonox.net
Wed Jun 2 00:27:03 CEST 2010
Author: landauf
Date: 2010-06-02 00:27:03 +0200 (Wed, 02 Jun 2010)
New Revision: 7075
Modified:
code/branches/presentation3/src/orxonox/controllers/NewHumanController.cc
code/branches/presentation3/src/orxonox/worldentities/pawns/FpsPlayer.cc
code/branches/presentation3/src/orxonox/worldentities/pawns/FpsPlayer.h
code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.cc
code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.h
Log:
removed some tabs and adjusted formatting in some fps related files
Modified: code/branches/presentation3/src/orxonox/controllers/NewHumanController.cc
===================================================================
--- code/branches/presentation3/src/orxonox/controllers/NewHumanController.cc 2010-06-01 22:06:38 UTC (rev 7074)
+++ code/branches/presentation3/src/orxonox/controllers/NewHumanController.cc 2010-06-01 22:27:03 UTC (rev 7075)
@@ -215,11 +215,12 @@
if (!controlPaused_ )
{
if (this->getControllableEntity() && (this->getControllableEntity()->isExactlyA(ClassByString("SpaceShip")) || this->getControllableEntity()->isExactlyA(ClassByString("Rocket"))))
- {this->showOverlays();}
-
- if (this->getControllableEntity() && this->getControllableEntity()->isExactlyA(ClassByString("FpsPlayer")))\
- {this->showOverlays();
- this->hideArrows();}
+ this->showOverlays();
+ else if (this->getControllableEntity() && this->getControllableEntity()->isExactlyA(ClassByString("FpsPlayer")))
+ {
+ this->showOverlays();
+ this->hideArrows();
+ }
this->crossHairOverlay_->setPosition(Vector2(static_cast<float>(this->currentYaw_)/2*-1+.5f-overlaySize_/2, static_cast<float>(this->currentPitch_)/2*-1+.5f-overlaySize_/2));
@@ -377,11 +378,11 @@
{
// Try to cast the user pointer
WorldEntity* wePtr = dynamic_cast<WorldEntity*>(Ogre::any_cast<OrxonoxClass*>(itr->movable->getUserAny()));
-
+
// make sure we don't shoot ourselves
if( wePtr==myWe )
continue;
-
+
if (wePtr)
{
// go through all parents of object and look whether they are sightable or not
@@ -591,9 +592,9 @@
this->arrowsOverlay4_->hide();
}
}
-
-
+
+
}
Modified: code/branches/presentation3/src/orxonox/worldentities/pawns/FpsPlayer.cc
===================================================================
--- code/branches/presentation3/src/orxonox/worldentities/pawns/FpsPlayer.cc 2010-06-01 22:06:38 UTC (rev 7074)
+++ code/branches/presentation3/src/orxonox/worldentities/pawns/FpsPlayer.cc 2010-06-01 22:27:03 UTC (rev 7075)
@@ -59,7 +59,7 @@
RegisterObject(FpsPlayer);
this->speed_ = 200;
this->localVelocity_ = Vector3::ZERO;
-/*
+/*
* this->primaryThrust_ = 100;
* this->auxilaryThrust_ = 30;
* this->rotationThrust_ = 10;
@@ -69,7 +69,7 @@
* this->bBoost_ = false;
* this->bPermanentBoost_ = false;
* this->steering_ = Vector3::ZERO;
-*/
+*/
this->bInvertYAxis_ = false;
@@ -85,25 +85,25 @@
this->setConfigValues();
this->registerVariables();
- //this->weaponNode = this->cameraPositionRootNode_;
- this->weaponNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode();
- this->attachNode(this->weaponNode_);
+ //this->weaponNode = this->cameraPositionRootNode_;
+ this->weaponNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode();
+ this->attachNode(this->weaponNode_);
}
FpsPlayer::~FpsPlayer()
{
- if (this->isInitialized() && this->mesh_.getEntity())
+ if (this->isInitialized() && this->mesh_.getEntity())
this->detachOgreObject(this->mesh_.getEntity());
}
void FpsPlayer::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(FpsPlayer, XMLPort, xmlelement, mode);
-
+
XMLPortParamVariable(FpsPlayer, "primaryThrust", primaryThrust_, xmlelement, mode);
XMLPortParamVariable(FpsPlayer, "auxilaryThrust", auxilaryThrust_, xmlelement, mode);
XMLPortParamVariable(FpsPlayer, "rotationThrust", rotationThrust_, xmlelement, mode);
- XMLPortParam(FpsPlayer, "weapon", setMeshSource, getMeshSource, xmlelement, mode);
+ XMLPortParam(FpsPlayer, "weapon", setMeshSource, getMeshSource, xmlelement, mode);
}
void FpsPlayer::registerVariables()
@@ -111,11 +111,11 @@
registerVariable(this->primaryThrust_, VariableDirection::ToClient);
registerVariable(this->auxilaryThrust_, VariableDirection::ToClient);
registerVariable(this->rotationThrust_, VariableDirection::ToClient);
- registerVariable(this->weaponMashName_);
+ registerVariable(this->weaponMashName_, VariableDirection::ToClient);
}
-
-
+
+
void FpsPlayer::setConfigValues()
{
SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = targetting down).");
@@ -138,10 +138,10 @@
if (this->hasLocalController())
{
this->setOrientation(savedOrientation_);
-
- thisTickBoost_=false;
-
- float localSpeedSquared = this->localVelocity_.squaredLength();
+
+ this->thisTickBoost_ = false;
+
+ float localSpeedSquared = this->localVelocity_.squaredLength();
float localSpeed;
if (localSpeedSquared > 1.0)
localSpeed = this->speed_ / sqrtf(localSpeedSquared);
@@ -150,9 +150,11 @@
this->localVelocity_.x *= localSpeed;
this->localVelocity_.z *= localSpeed;
- Vector3 temp = this->getOrientation() * this->localVelocity_;
- if(localVelocity_.y==jumpValue_) this->setVelocity(Vector3(temp.x, temp.y + this->getVelocity().y, temp.z));
- else this->setVelocity(Vector3(temp.x, this->getVelocity().y, temp.z));
+ Vector3 temp = this->getOrientation() * this->localVelocity_;
+ if (localVelocity_.y == jumpValue_)
+ this->setVelocity(Vector3(temp.x, temp.y + this->getVelocity().y, temp.z));
+ else
+ this->setVelocity(Vector3(temp.x, this->getVelocity().y, temp.z));
this->localVelocity_.x = 0;
this->localVelocity_.y = 0;
this->localVelocity_.z = 0;
@@ -160,40 +162,38 @@
if (!this->isInMouseLook())
{
this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed()), WorldEntity::Parent);
-
- Radian pitch=this->cameraPositionRootNode_->getOrientation().getPitch();
- if( pitch<Radian(1.5707) && pitch>Radian(-1.5707) ) {
- this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
- }
- else if(pitch<Radian(-1.5707)){
- if(this->pitch_>0.0) {
- this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
- }
- else if(pitch<Radian(-1.571)){
- this->cameraPositionRootNode_->pitch(-pitch+Radian(-1.570796));
- }
- }
- else if(pitch>Radian(1.5707)){
- if(this->pitch_<0.0) {
- this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
- }
- else if(pitch>Radian(1.571)){
- this->cameraPositionRootNode_->pitch(-pitch+Radian(1.570796));
- }
- }
- this->weaponNode_->setOrientation(this->cameraPositionRootNode_->getOrientation());
-
- }
+ Radian pitch = this->cameraPositionRootNode_->getOrientation().getPitch();
+ if (pitch < Radian(1.5707) && pitch > Radian(-1.5707))
+ {
+ this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
+ }
+ else if (pitch < Radian(-1.5707))
+ {
+ if (this->pitch_ > 0.0)
+ this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
+ else if (pitch < Radian(-1.571))
+ this->cameraPositionRootNode_->pitch(-pitch + Radian(-1.570796));
+ }
+ else if (pitch > Radian(1.5707))
+ {
+ if (this->pitch_ < 0.0)
+ this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
+ else if (pitch > Radian(1.571))
+ this->cameraPositionRootNode_->pitch(-pitch + Radian(1.570796));
+ }
+ this->weaponNode_->setOrientation(this->cameraPositionRootNode_->getOrientation());
+ }
+
this->yaw_ = this->pitch_ = this->roll_ = 0;
-
- this->setAngularVelocity(0.0, 0.0, 0.0);
- savedOrientation_=this->getOrientation();
+
+ this->setAngularVelocity(0.0, 0.0, 0.0);
+ this->savedOrientation_ = this->getOrientation();
}
SUPER(FpsPlayer, tick, dt);
}
-
+
void FpsPlayer::changedMesh()
{
if (GameMode::showsGraphics())
@@ -221,7 +221,7 @@
{
ControllableEntity::startLocalHumanControl();
}
-
+
void FpsPlayer::moveFrontBack(const Vector2& value)
{
this->localVelocity_.z -= value.x;
@@ -262,36 +262,40 @@
void FpsPlayer::fire()
{
}
-
- void FpsPlayer::boost() //acctually jump
+
+ void FpsPlayer::boost() //acctually jump
{
- if(isFloor_) {
- if(!thisTickBoost_) this->localVelocity_.y = jumpValue_;
- //this->physicalBody_->applyCentralImpulse(btVector3(0, jumpvalue, 0));
- thisTickBoost_=true;
- isFloor_=false;
- }
+ if (this->isFloor_)
+ {
+ if (!this->thisTickBoost_)
+ this->localVelocity_.y = jumpValue_;
+ //this->physicalBody_->applyCentralImpulse(btVector3(0, jumpvalue, 0));
+ this->thisTickBoost_ = true;
+ this->isFloor_ = false;
+ }
}
bool FpsPlayer::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
{
- if(contactPoint.m_normalWorldOnB.y() > 0.6) isFloor_=true;
- else isFloor_=false;
-
- return false;
+ if (contactPoint.m_normalWorldOnB.y() > 0.6)
+ this->isFloor_ = true;
+ else
+ this->isFloor_ = false;
+
+ return false;
}
-
+
void FpsPlayer::addedWeaponPack(WeaponPack* wPack)
{
for (size_t i = 0; i < wPack->getNumWeapons(); ++i)
- {
- Weapon* weapon = wPack->getWeapon(i);
- if (weapon->getWeaponSlot())
- {
- weapon->getWeaponSlot()->removeWeapon();
- weapon->detachFromParent();
- weapon->attachToNode(this->weaponNode_);
- }
- }
+ {
+ Weapon* weapon = wPack->getWeapon(i);
+ if (weapon->getWeaponSlot())
+ {
+ weapon->getWeaponSlot()->removeWeapon();
+ weapon->detachFromParent();
+ weapon->attachToNode(this->weaponNode_);
+ }
+ }
}
}
Modified: code/branches/presentation3/src/orxonox/worldentities/pawns/FpsPlayer.h
===================================================================
--- code/branches/presentation3/src/orxonox/worldentities/pawns/FpsPlayer.h 2010-06-01 22:06:38 UTC (rev 7074)
+++ code/branches/presentation3/src/orxonox/worldentities/pawns/FpsPlayer.h 2010-06-01 22:27:03 UTC (rev 7075)
@@ -57,21 +57,21 @@
virtual void rotateYaw(const Vector2& value);
virtual void rotatePitch(const Vector2& value);
virtual void rotateRoll(const Vector2& value);
-
-
+
+
inline void setMeshSource(const std::string& meshname)
{ this->meshSrc_ = meshname; this->changedMesh(); }
inline const std::string& getMeshSource() const
{ return this->meshSrc_; }
-
- void boost(); //acctually jump
+ void boost(); //acctually jump
+
virtual void fire();
-
- bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
- virtual void addedWeaponPack(WeaponPack* wPack);
-
+ bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
+
+ virtual void addedWeaponPack(WeaponPack* wPack);
+
protected:
virtual void setPlayer(PlayerInfo* player);
virtual void startLocalHumanControl();
@@ -83,7 +83,7 @@
float primaryThrust_;
float auxilaryThrust_;
float rotationThrust_;
- std::string weaponMashName_;
+ std::string weaponMashName_;
btVector3 localLinearAcceleration_;
btVector3 localAngularAcceleration_;
@@ -91,18 +91,18 @@
virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const;
float speed_;
- void changedMesh();
- Mesh mesh_;
- std::string meshSrc_;
+ void changedMesh();
+ Mesh mesh_;
+ std::string meshSrc_;
float yaw_;
float pitch_;
float roll_;
Vector3 localVelocity_;
- bool isFloor_;
- bool thisTickBoost_;
- Quaternion savedOrientation_;
- Ogre::SceneNode* weaponNode_;
- };
+ bool isFloor_;
+ bool thisTickBoost_;
+ Quaternion savedOrientation_;
+ Ogre::SceneNode* weaponNode_;
+ };
}
#endif /* _FpsPlayer_H__ */
Modified: code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.cc 2010-06-01 22:06:38 UTC (rev 7074)
+++ code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.cc 2010-06-01 22:27:03 UTC (rev 7075)
@@ -52,7 +52,7 @@
{
CreateFactory(Pawn);
- Pawn::Pawn(BaseObject* creator)
+ Pawn::Pawn(BaseObject* creator)
: ControllableEntity(creator)
, RadarViewable(creator, static_cast<WorldEntity*>(this))
{
@@ -362,21 +362,21 @@
void Pawn::addWeaponPack(WeaponPack * wPack)
{
if (this->weaponSystem_)
- {
+ {
this->weaponSystem_->addWeaponPack(wPack);
- this->addedWeaponPack(wPack);
- }
+ this->addedWeaponPack(wPack);
+ }
}
void Pawn::addWeaponPackXML(WeaponPack * wPack)
{
if (this->weaponSystem_)
- {
+ {
if (!this->weaponSystem_->addWeaponPack(wPack))
wPack->destroy();
- else
+ else
this->addedWeaponPack(wPack);
- }
+ }
}
WeaponPack * Pawn::getWeaponPack(unsigned int index) const
Modified: code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.h 2010-06-01 22:06:38 UTC (rev 7074)
+++ code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.h 2010-06-01 22:27:03 UTC (rev 7075)
@@ -76,7 +76,7 @@
{ this->shieldHealth_ = shieldHealth; }
inline float getShieldHealth()
{ return this->shieldHealth_; }
-
+
inline void setShieldAbsorption(float shieldAbsorption)
{ this->shieldAbsorption_ = shieldAbsorption; }
inline float getShieldAbsorption()
@@ -100,9 +100,9 @@
void addWeaponPack(WeaponPack * wPack);
void addWeaponPackXML(WeaponPack * wPack);
WeaponPack * getWeaponPack(unsigned int index) const;
-
- virtual void addedWeaponPack(WeaponPack* wPack) {}
+ virtual void addedWeaponPack(WeaponPack* wPack) {}
+
inline const WorldEntity* getWorldEntity() const
{ return const_cast<Pawn*>(this); }
@@ -127,7 +127,7 @@
{ this->aimPosition_ = position; }
Vector3 getAimPosition()
{ return this->aimPosition_; }
-
+
virtual const Vector3& getCarrierPosition(void)
{ return this->getWorldPosition(); };
More information about the Orxonox-commit
mailing list