- Timestamp:
- Dec 10, 2008, 1:38:17 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/orxonox/objects/worldentities/pawns/SpaceShip.cc
r2314 r2374 40 40 namespace orxonox 41 41 { 42 const float orientationGain = 100; 42 43 CreateFactory(SpaceShip); 43 44 … … 84 85 if (this->physicalBody_) 85 86 { 86 this->physicalBody_->setDamping(0.8, 0.9); 87 this->physicalBody_->setActivationState(DISABLE_DEACTIVATION); 87 this->physicalBody_->setDamping(0.7, 0.3); 88 88 } 89 89 } … … 106 106 void SpaceShip::tick(float dt) 107 107 { 108 if (this->isLocallyControlled())109 {110 // #####################################111 // ############# STEERING ##############112 // #####################################113 114 //Vector3 velocity = this->getVelocity();115 //if (velocity.x > this->maxSecondarySpeed_)116 // velocity.x = this->maxSecondarySpeed_;117 //if (velocity.x < -this->maxSecondarySpeed_)118 // velocity.x = -this->maxSecondarySpeed_;119 //if (velocity.y > this->maxSecondarySpeed_)120 // velocity.y = this->maxSecondarySpeed_;121 //if (velocity.y < -this->maxSecondarySpeed_)122 // velocity.y = -this->maxSecondarySpeed_;123 //if (velocity.z > this->maxSecondarySpeed_)124 // velocity.z = this->maxSecondarySpeed_;125 //if (velocity.z < -this->maxSpeed_)126 // velocity.z = -this->maxSpeed_;127 128 // normalize velocity and acceleration129 //for (size_t dimension = 0; dimension < 3; ++dimension)130 //{131 // if (this->acceleration_[dimension] == 0)132 // {133 // if (velocity[dimension] > 0)134 // {135 // velocity[dimension] -= (this->translationDamping_ * dt);136 // if (velocity[dimension] < 0)137 // velocity[dimension] = 0;138 // }139 // else if (velocity[dimension] < 0)140 // {141 // velocity[dimension] += (this->translationDamping_ * dt);142 // if (velocity[dimension] > 0)143 // velocity[dimension] = 0;144 // }145 // }146 //}147 148 //this->setVelocity(velocity);149 }150 151 152 108 SUPER(SpaceShip, tick, dt); 153 154 155 //if (this->isLocallyControlled())156 //{157 // this->yaw(this->yawRotation_ * dt);158 // if (this->bInvertYAxis_)159 // this->pitch(Degree(-this->pitchRotation_ * dt));160 // else161 // this->pitch(Degree( this->pitchRotation_ * dt));162 // this->roll(this->rollRotation_ * dt);163 164 // this->acceleration_.x = 0;165 // this->acceleration_.y = 0;166 // this->acceleration_.z = 0;167 168 // this->yawRotation_ = this->zeroDegree_;169 // this->pitchRotation_ = this->zeroDegree_;170 // this->rollRotation_ = this->zeroDegree_;171 //}172 109 } 173 110 … … 176 113 assert(this->physicalBody_); 177 114 this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * btVector3(0.0f, 0.0f, -getMass() * value.x * 100)); 178 // this->acceleration_.z = -this->translationAcceleration_ * value.x;179 115 } 180 116 … … 182 118 { 183 119 this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * btVector3(getMass() * value.x * 100, 0.0f, 0.0f)); 184 // this->acceleration_.x = this->translationAcceleration_ * value.x;185 120 } 186 121 … … 188 123 { 189 124 this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * btVector3(0.0f, getMass() * value.x * 100, 0.0f)); 190 // this->acceleration_.y = this->translationAcceleration_ * value.x;191 125 } 192 126 193 127 void SpaceShip::rotateYaw(const Vector2& value) 194 128 { 195 this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * btVector3(0.0f, getMass() * value.x * 10000, 0.0f)); 196 //Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_; 197 //if (temp > this->maxRotation_) 198 // temp = this->maxRotation_; 199 //if (temp < -this->maxRotation_) 200 // temp = -this->maxRotation_; 201 //this->yawRotation_ = Degree(temp); 129 this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * btVector3(0.0f, 1 / this->physicalBody_->getInvInertiaDiagLocal().y() * value.y * orientationGain, 0.0f)); 202 130 } 203 131 204 132 void SpaceShip::rotatePitch(const Vector2& value) 205 133 { 206 this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * btVector3(getMass() * value.x * 10000, 0.0f, 0.0f)); 207 //Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_; 208 //if (temp > this->maxRotation_) 209 // temp = this->maxRotation_; 210 //if (temp < -this->maxRotation_) 211 // temp = -this->maxRotation_; 212 //this->pitchRotation_ = Degree(temp); 134 this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * btVector3(1 / this->physicalBody_->getInvInertiaDiagLocal().x() * value.y * orientationGain, 0.0f, 0.0f)); 213 135 } 214 136 215 137 void SpaceShip::rotateRoll(const Vector2& value) 216 138 { 217 this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * btVector3(0.0f, 0.0f, -getMass() * value.x * 10000)); 218 //Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_; 219 //if (temp > this->maxRotation_) 220 // temp = this->maxRotation_; 221 //if (temp < -this->maxRotation_) 222 // temp = -this->maxRotation_; 223 //this->rollRotation_ = Degree(temp); 139 this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * btVector3(0.0f, 0.0f, -1 / this->physicalBody_->getInvInertiaDiagLocal().z() * value.y * orientationGain)); 224 140 } 225 141
Note: See TracChangeset
for help on using the changeset viewer.