- Timestamp:
- Jun 3, 2012, 4:33:13 PM (12 years ago)
- Location:
- code/branches/presentation2012merge
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2012merge
- Property svn:ignore
-
old new 1 .project 1 2 build 2 3 codeblocks 4 dependencies 3 5 vs 4 dependencies
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
code/branches/presentation2012merge/src/orxonox/controllers/FormationController.cc
r9265 r9269 280 280 } 281 281 282 Vector2 coord = get2DView direction(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);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 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 } 285 291 286 292 if(this->state_ == FREE) … … 289 295 { 290 296 // Multiply with ROTATEFACTOR_FREE to make them a bit slower 291 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_FREE * sgn(coord.x) * coord.x*coord.x);292 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_FREE * sgn(coord.y) * coord.y*coord.y);293 } 294 295 if (this->target_ && distance < 200 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength())297 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_FREE * coord.x * 2); 298 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_FREE * coord.y * 2); 299 } 300 301 if (this->target_ && distance < 200 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength()) 296 302 { 297 303 this->getControllableEntity()->moveFrontBack(-0.05f); // They don't brake with full power to give the player a chance … … 305 311 if (this->target_ || distance > 10) 306 312 { 307 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_MASTER * sgn(coord.x) * coord.x*coord.x);308 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_MASTER * sgn(coord.y) * coord.y*coord.y);313 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_MASTER * coord.x * 2); 314 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_MASTER * coord.y * 2); 309 315 } 310 316 … … 318 324 319 325 if(this->state_ == SLAVE) 320 321 322 this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * sgn(coord.x) * coord.x*coord.x);323 this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * sgn(coord.y) * coord.y*coord.y);324 325 326 327 328 329 copyTargetOrientation();330 331 332 {//linear speed reduction333 334 335 336 337 338 339 340 326 { 327 328 this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * coord.x * 2); 329 this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * coord.y * 2); 330 331 if (distance < 300) 332 { 333 if (bHasTargetOrientation_) 334 { 335 copyTargetOrientation(); 336 } 337 if (distance < 100) 338 { //linear speed reduction 339 this->getControllableEntity()->moveFrontBack(distance/100.0f*0.4f*SPEED_MASTER); 340 341 } else this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER); 342 343 } else { 344 this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER + distance/300.0f); 345 } 346 } 341 347 342 348 if (distance < 10)
Note: See TracChangeset
for help on using the changeset viewer.