Changeset 2448
- Timestamp:
- Dec 14, 2008, 8:13:56 PM (16 years ago)
- Location:
- code/branches/physics_merge/src/orxonox/objects
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics_merge/src/orxonox/objects/Scene.cc
r2446 r2448 80 80 // No physics yet, XMLPort will do that. 81 81 const int defaultMaxWorldSize = 100000; 82 this->negativeWorldRange_ = Vector3 (-defaultMaxWorldSize, -defaultMaxWorldSize, -defaultMaxWorldSize);83 this->positiveWorldRange_ = Vector3 ( defaultMaxWorldSize, defaultMaxWorldSize, defaultMaxWorldSize);84 this->gravity_ = Vector3 (0, 0, 0);82 this->negativeWorldRange_ = Vector3::UNIT_SCALE * -defaultMaxWorldSize; 83 this->positiveWorldRange_ = Vector3::UNIT_SCALE * defaultMaxWorldSize; 84 this->gravity_ = Vector3::ZERO; 85 85 this->physicalWorld_ = 0; 86 86 this->solver_ = 0; -
code/branches/physics_merge/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2442 r2448 52 52 53 53 this->speed_ = 100; 54 this->rotation Speed_ = 3;54 this->rotationGain_ = 3; 55 55 56 56 this->yaw_ = 0; 57 57 this->pitch_ = 0; 58 58 this->roll_ = 0; 59 this->localVelocity_ = Vector3::ZERO; 59 60 this->setHudTemplate("spectatorhud"); 60 61 this->hudmode_ = 0; … … 110 111 if (this->isLocallyControlled()) 111 112 { 112 Vector3 velocity = this->getVelocity(); 113 velocity.normalise(); 114 this->setVelocity(this->getOrientation() * velocity * this->speed_); 115 116 this->yaw(Radian(this->yaw_ * this->rotationSpeed_)); 117 this->pitch(Radian(this->pitch_ * this->rotationSpeed_)); 118 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_)); 119 131 120 132 this->yaw_ = this->pitch_ = this->roll_ = 0; … … 122 134 123 135 SUPER(Spectator, tick, dt); 124 125 if (this->isLocallyControlled())126 {127 this->setVelocity(Vector3::ZERO);128 }129 136 } 130 137 … … 145 152 void Spectator::moveFrontBack(const Vector2& value) 146 153 { 147 this-> setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::FRONT);154 this->localVelocity_.z -= value.x; 148 155 } 149 156 150 157 void Spectator::moveRightLeft(const Vector2& value) 151 158 { 152 this-> setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::RIGHT);159 this->localVelocity_.x += value.x; 153 160 } 154 161 155 162 void Spectator::moveUpDown(const Vector2& value) 156 163 { 157 this-> setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::UP);164 this->localVelocity_.y += value.x; 158 165 } 159 166 160 167 void Spectator::rotateYaw(const Vector2& value) 161 168 { 162 this->yaw_ = value.y;169 this->yaw_ += value.y; 163 170 } 164 171 165 172 void Spectator::rotatePitch(const Vector2& value) 166 173 { 167 this->pitch_ = value.y;174 this->pitch_ += value.y; 168 175 } 169 176 170 177 void Spectator::rotateRoll(const Vector2& value) 171 178 { 172 this->roll_ = value.y;179 this->roll_ += value.y; 173 180 } 174 181 -
code/branches/physics_merge/src/orxonox/objects/worldentities/pawns/Spectator.h
r2087 r2448 69 69 70 70 float speed_; 71 float rotation Speed_;71 float rotationGain_; 72 72 73 73 float yaw_; 74 74 float pitch_; 75 75 float roll_; 76 77 Vector3 localVelocity_; 76 78 77 79 int hudmode_;
Note: See TracChangeset
for help on using the changeset viewer.