- Timestamp:
- Dec 15, 2008, 12:53:05 AM (17 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2371 r2459 29 29 #include "OrxonoxStableHeaders.h" 30 30 #include "Spectator.h" 31 32 #include <OgreBillboardSet.h> 31 33 32 34 #include "core/CoreIncludes.h" … … 50 52 51 53 this->speed_ = 100; 52 this->rotation Speed_ = 3;54 this->rotationGain_ = 3; 53 55 54 56 this->yaw_ = 0; 55 57 this->pitch_ = 0; 56 58 this->roll_ = 0; 59 this->localVelocity_ = Vector3::ZERO; 57 60 this->setHudTemplate("spectatorhud"); 58 61 this->hudmode_ = 0; … … 63 66 this->greetingFlare_->setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 1.0, 0.8), Vector3(0, 20, 0), 1); 64 67 if (this->greetingFlare_->getBillboardSet()) 65 this-> getNode()->attachObject(this->greetingFlare_->getBillboardSet());68 this->attachOgreObject(this->greetingFlare_->getBillboardSet()); 66 69 this->greetingFlare_->setVisible(false); 67 70 this->bGreetingFlareVisible_ = false; … … 78 81 { 79 82 if (this->greetingFlare_->getBillboardSet()) 80 this-> getNode()->detachObject(this->greetingFlare_->getBillboardSet());83 this->detachOgreObject(this->greetingFlare_->getBillboardSet()); 81 84 delete this->greetingFlare_; 82 85 } … … 108 111 if (this->isLocallyControlled()) 109 112 { 110 Vector3 velocity = this->getVelocity(); 111 velocity.normalise(); 112 this->setVelocity(velocity * this->speed_); 113 114 this->yaw(Radian(this->yaw_ * this->rotationSpeed_)); 115 this->pitch(Radian(this->pitch_ * this->rotationSpeed_)); 116 this->roll(Radian(this->roll_ * this->rotationSpeed_)); 113 float localSpeedSquared = this->localVelocity_.squaredLength(); 114 float localSpeed; 115 if (localSpeedSquared > 1.0) 116 localSpeed = this->speed_ / sqrtf(localSpeedSquared); 117 else 118 localSpeed = this->speed_; 119 120 this->localVelocity_.x *= localSpeed; 121 this->localVelocity_.y *= localSpeed; 122 this->localVelocity_.z *= localSpeed; 123 this->setVelocity(this->getOrientation() * this->localVelocity_); 124 this->localVelocity_.x = 0; 125 this->localVelocity_.y = 0; 126 this->localVelocity_.z = 0; 127 128 this->yaw (Radian(this->yaw_ * this->rotationGain_)); 129 this->pitch(Radian(this->pitch_ * this->rotationGain_)); 130 this->roll (Radian(this->roll_ * this->rotationGain_)); 117 131 118 132 this->yaw_ = this->pitch_ = this->roll_ = 0; … … 120 134 121 135 SUPER(Spectator, tick, dt); 122 123 if (this->isLocallyControlled())124 {125 this->setVelocity(Vector3::ZERO);126 }127 136 } 128 137 … … 143 152 void Spectator::moveFrontBack(const Vector2& value) 144 153 { 145 this-> setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::FRONT);154 this->localVelocity_.z -= value.x; 146 155 } 147 156 148 157 void Spectator::moveRightLeft(const Vector2& value) 149 158 { 150 this-> setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::RIGHT);159 this->localVelocity_.x += value.x; 151 160 } 152 161 153 162 void Spectator::moveUpDown(const Vector2& value) 154 163 { 155 this-> setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::UP);164 this->localVelocity_.y += value.x; 156 165 } 157 166 158 167 void Spectator::rotateYaw(const Vector2& value) 159 168 { 160 this->yaw_ = value.y;169 this->yaw_ += value.y; 161 170 } 162 171 163 172 void Spectator::rotatePitch(const Vector2& value) 164 173 { 165 this->pitch_ = value.y;174 this->pitch_ += value.y; 166 175 } 167 176 168 177 void Spectator::rotateRoll(const Vector2& value) 169 178 { 170 this->roll_ = value.y;179 this->roll_ += value.y; 171 180 } 172 181
Note: See TracChangeset
for help on using the changeset viewer.