Changeset 9336
- Timestamp:
- Jul 29, 2012, 10:44:11 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2012merge/src/orxonox/controllers/FormationController.cc
r9272 r9336 282 282 Vector2 coord = get2DViewcoordinates(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target); 283 283 float distance = (target - this->getControllableEntity()->getPosition()).length(); 284 if(coord.x < 0.0001 && coord.y < 0.0001) 285 { 286 // if the ship reaches a direction very close to the direct one, set it to the direct one 287 Vector3 v_temp = this->getControllableEntity()->getPosition(); 288 Quaternion quat = v_temp.getRotationTo(target); 289 this->getControllableEntity()->rotate(quat); 290 } 284 float rotateX = clamp(coord.x * 10, -1.0f, 1.0f); 285 float rotateY = clamp(coord.y * 10, -1.0f, 1.0f); 291 286 292 287 if(this->state_ == FREE) … … 295 290 { 296 291 // Multiply with ROTATEFACTOR_FREE to make them a bit slower 297 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_FREE * coord.x * 2);298 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_FREE * coord.y * 2);292 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_FREE * rotateX); 293 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_FREE * rotateY); 299 294 } 300 295 … … 311 306 if (this->target_ || distance > 10) 312 307 { 313 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_MASTER * coord.x * 2);314 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_MASTER * coord.y * 2);308 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_MASTER * rotateX); 309 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_MASTER * rotateY); 315 310 } 316 311 … … 326 321 { 327 322 328 this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * coord.x * 2);329 this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * coord.y * 2);323 this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * rotateX); 324 this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * rotateY); 330 325 331 326 if (distance < 300)
Note: See TracChangeset
for help on using the changeset viewer.