Changeset 10095 in orxonox.OLD for branches/playability/src/world_entities/space_ships/space_ship.cc
- Timestamp:
- Dec 19, 2006, 11:18:22 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/world_entities/space_ships/space_ship.cc
r10092 r10095 326 326 327 327 328 this->trail = new Trail( 15, 10, .2);329 this->trail->setParent( this);328 this->trail = new Trail( 3, 3, .2, this); 329 //this->trail->setParent( this); 330 330 this->trail->setTexture( "maps/engine.png"); 331 331 332 this->trailL = new Trail( 15, 10, .2);333 this->trailL->setParent( this);332 this->trailL = new Trail( 3, 3, .2, this); 333 //this->trailL->setParent( this); 334 334 this->trailL->setTexture( "maps/engine.png"); 335 335 336 this->trailR = new Trail( 15, 10, .2);337 this->trailR->setParent( this);336 this->trailR = new Trail( 3, 3, .2, this); 337 //this->trailR->setParent( this); 338 338 this->trailR->setTexture( "maps/engine.png"); 339 339 } … … 371 371 { 372 372 this->secWeaponMan.showCrosshair(); 373 /*for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++)374 {375 if( likely( dynamic_cast<WorldEntity*>(*it) != NULL))376 dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_01);377 }*/378 373 this->toList( OM_GROUP_01 ); 374 for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++) 375 { 376 if( likely( dynamic_cast<Weapon*>(*it) != NULL)) 377 dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_00_PROJ); 378 } 379 379 //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true); 380 380 //this->attachCamera(); … … 385 385 { 386 386 this->secWeaponMan.hideCrosshair(); 387 /*for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++)388 {389 if( likely(dynamic_cast<WorldEntity*>(*it) != NULL))390 dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_00);391 }*/392 387 this->toList( OM_GROUP_00); 388 for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++) 389 { 390 if( likely( dynamic_cast<Weapon*>(*it) != NULL)) 391 dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_01_PROJ); 392 } 393 393 //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( false); 394 394 //this->detachCamera(); … … 492 492 this->acceleration = this->travelSpeed * 2; 493 493 494 /*495 if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == SharedNetworkData::getInstance()->getHostID() )496 {497 if (xMouse > controlVelocityX) xMouse = controlVelocityX;498 else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX;499 if (yMouse > controlVelocityY) yMouse = controlVelocityY;500 else if (yMouse < -controlVelocityY) yMouse = -controlVelocityY;501 502 pitchDir = (Quaternion(xMouse*mouseSensitivity*0.5, Vector(1,0,0)));503 504 mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity*yInvert, Vector(0,0,1))*pitchDir);505 xMouse = yMouse = 0;506 }507 */508 509 // spaceship controlled movement fire(bool bF){ this->bFire = bF;}510 //if (this->getOwner() == this->getHostID())511 512 //is->calculateVelocity(time);513 514 515 //vector move = velocity*time;516 517 /*518 //orient the velocity in the direction of the spaceship.519 travelSpeed = velocity.len();520 velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity;521 velocity = (velocity.getNormalized())*travelSpeed;522 */523 494 this->movement(time); 524 495 … … 527 498 this->cameraNode.setRelDirSoft(this->getAbsDir(), 30.0f); 528 499 500 501 this->velocity = (this->getAbsCoor() - this->oldPos) / time; 502 this->oldPos = this->getAbsCoor(); 503 529 504 this->trail->tick(time); 530 505 this->trailL->tick(time); 531 506 this->trailR->tick(time); 507 532 508 //orient the spaceship in direction of the mouse 533 509 /* … … 600 576 { 601 577 PRINTF(0)("spaceship destroy\n"); 602 /*578 603 579 EmitterNode* node = NULL; 604 580 DotEmitter* emitter = NULL; … … 628 604 node->setVelocity( this->getParent()->getVelocity()); 629 605 node->setAbsCoor( this->getAbsCoor()); 630 node->start();*/ 606 node->start(); 607 /* 631 608 PNode* node = new PNode(); 632 609 node->setAbsCoor(this->getAbsCoor()); 633 610 Explosion* explosion = new Explosion(); 634 611 explosion->explode( node, Vector(5,5,5)); 635 612 */ 636 613 this->setAbsCoor(Vector(-10000,10000,10000)); 637 614 this->hide(); 638 615 639 616 this->toList( OM_DEAD); 640 /*for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++)641 { 642 if( dynamic_cast<WorldEntity*>(*it) != NULL)617 for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++) 618 { 619 if( likely( dynamic_cast<Weapon*>(*it) != NULL)) 643 620 dynamic_cast<WorldEntity*>(*it)->toList( OM_DEAD); 644 } */621 } 645 622 PRINTF(0)("spaceship destroy == ship translated \n"); 646 623 } … … 654 631 dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_00); 655 632 }*/ 656 /*if( this->hasPlayer()) 633 if( this->hasPlayer()) 634 { 657 635 this->toList( OM_GROUP_01); 636 for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++) 637 { 638 if( likely( dynamic_cast<Weapon*>(*it) != NULL)) 639 dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_00_PROJ); 640 } 641 } 658 642 else 659 this->toList( OM_GROUP_00);*/ 643 { 644 this->toList( OM_GROUP_00); 645 for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++) 646 { 647 if( likely( dynamic_cast<Weapon*>(*it) != NULL)) 648 dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_01_PROJ); 649 } 650 } 660 651 661 652 } … … 664 655 void SpaceShip::damage(float pDamage, float eDamage){ 665 656 PRINTF(0)("ship hit for (%f,%f) \n",pDamage,eDamage); 666 PRINTF(0)("SHIP HIT - SHIP HIT - SHIP HIT\n");667 657 668 658 if( this->shieldActive) { … … 800 790 float pi = 3.14; 801 791 792 Vector tempVelocity; 802 793 803 794 switch(this->getPlaymode()) … … 807 798 // these routines will change the travel movement into zero in a short amout of time, if the player 808 799 // doesn't press any buttons. 809 if (t his->velocity.x >= 0)810 { 811 if (t his->velocity.x > airCoeff*this->acceleration * dt)812 t his->velocity.x -= airCoeff* this->acceleration * dt;800 if (tempVelocity.x >= 0) 801 { 802 if (tempVelocity.x > airCoeff*this->acceleration * dt) 803 tempVelocity.x -= airCoeff* this->acceleration * dt; 813 804 else 814 t his->velocity.x = 0;805 tempVelocity.x = 0; 815 806 } 816 807 else 817 808 { 818 if (t his->velocity.x < -airCoeff*this->acceleration * dt)819 t his->velocity.x += airCoeff* this->acceleration * dt;809 if (tempVelocity.x < -airCoeff*this->acceleration * dt) 810 tempVelocity.x += airCoeff* this->acceleration * dt; 820 811 else 821 t his->velocity.x = 0;822 } 823 if (t his->velocity.z >= 0)824 { 825 if (t his->velocity.z > airCoeff*this->acceleration * dt)826 t his->velocity.z -= airCoeff* this->acceleration * dt;812 tempVelocity.x = 0; 813 } 814 if (tempVelocity.z >= 0) 815 { 816 if (tempVelocity.z > airCoeff*this->acceleration * dt) 817 tempVelocity.z -= airCoeff* this->acceleration * dt; 827 818 else 828 t his->velocity.z = 0;819 tempVelocity.z = 0; 829 820 } 830 821 else 831 822 { 832 if (t his->velocity.z < -airCoeff*this->acceleration * dt)833 t his->velocity.z += airCoeff* this->acceleration * dt;823 if (tempVelocity.z < -airCoeff*this->acceleration * dt) 824 tempVelocity.z += airCoeff* this->acceleration * dt; 834 825 else 835 t his->velocity.z = 0;826 tempVelocity.z = 0; 836 827 } 837 828 … … 851 842 if(this->getRelCoor().x < this->travelDistancePlus.x) 852 843 { 853 if (t his->velocity.x < this->travelSpeed)844 if (tempVelocity.x < this->travelSpeed) 854 845 { 855 t his->velocity.x += (airCoeff + 1.0)*this->acceleration*dt;846 tempVelocity.x += (airCoeff + 1.0)*this->acceleration*dt; 856 847 } 857 848 else 858 849 { 859 t his->velocity.x = this->travelSpeed;850 tempVelocity.x = this->travelSpeed; 860 851 } 861 852 } 862 853 else 863 854 { 864 t his->velocity.x = 0.0f;855 tempVelocity.x = 0.0f; 865 856 } 866 857 } … … 870 861 if(this->getRelCoor().x > this->travelDistanceMinus.x) 871 862 { 872 if (t his->velocity.x > -this->travelSpeed)863 if (tempVelocity.x > -this->travelSpeed) 873 864 { 874 t his->velocity.x -= (airCoeff + 1.0)*this->acceleration*dt;865 tempVelocity.x -= (airCoeff + 1.0)*this->acceleration*dt; 875 866 } 876 867 else 877 868 { 878 t his->velocity.x = -this->travelSpeed;869 tempVelocity.x = -this->travelSpeed; 879 870 } 880 871 } 881 872 else 882 873 { 883 t his->velocity.x = 0.0f;874 tempVelocity.x = 0.0f; 884 875 } 885 876 } … … 889 880 if(this->getRelCoor().z > this->travelDistanceMinus.y) 890 881 { 891 if (t his->velocity.z > -this->travelSpeed)882 if (tempVelocity.z > -this->travelSpeed) 892 883 { 893 t his->velocity.z -= (airCoeff + 1.0)*this->acceleration*dt;884 tempVelocity.z -= (airCoeff + 1.0)*this->acceleration*dt; 894 885 } 895 886 else 896 887 { 897 t his->velocity.z = -this->travelSpeed;888 tempVelocity.z = -this->travelSpeed; 898 889 } 899 890 } 900 891 else 901 892 { 902 t his->velocity.z = 0.0f;893 tempVelocity.z = 0.0f; 903 894 } 904 895 this->setRelDirSoft(Quaternion(-pi/6, Vector(1,0,0)), 6); … … 909 900 if(this->getRelCoor().z < this->travelDistancePlus.y) 910 901 { 911 if (t his->velocity.z < this->travelSpeed)902 if (tempVelocity.z < this->travelSpeed) 912 903 { 913 t his->velocity.z += (airCoeff + 1.0)*this->acceleration*dt;904 tempVelocity.z += (airCoeff + 1.0)*this->acceleration*dt; 914 905 } 915 906 else 916 907 { 917 t his->velocity.z = this->travelSpeed;908 tempVelocity.z = this->travelSpeed; 918 909 } 919 910 } 920 911 else 921 912 { 922 t his->velocity.z = 0.0f;913 tempVelocity.z = 0.0f; 923 914 } 924 915 this->setRelDirSoft(Quaternion(pi/6, Vector(1,0,0)), 6); … … 931 922 932 923 this->travelNode->shiftCoor(Vector(this->cameraSpeed * dt, 0, 0)); 933 this->shiftCoor (t his->velocity * dt);924 this->shiftCoor (tempVelocity * dt); 934 925 935 926 //normalisation of the vectors (vector sum must be <= travelspeed) 936 float xzNorm = sqrt(pow(t his->velocity.x, 2) + pow(this->velocity.z, 2));927 float xzNorm = sqrt(pow(tempVelocity.x, 2) + pow(tempVelocity.z, 2)); 937 928 if (xzNorm > this->travelSpeed) 938 929 { 939 t his->velocity.x = this->velocity.x/xzNorm * this->travelSpeed;940 t his->velocity.z = this->velocity.z/xzNorm * this->travelSpeed;930 tempVelocity.x = tempVelocity.x/xzNorm * this->travelSpeed; 931 tempVelocity.z = tempVelocity.z/xzNorm * this->travelSpeed; 941 932 } 942 933 … … 945 936 946 937 //set new coordinates calculated through key- events. 947 this->shiftCoor (t his->velocity * dt);938 this->shiftCoor (tempVelocity * dt); 948 939 break; 949 940 } … … 954 945 } 955 946 947 948 /* 956 949 this->travelNode->shiftCoor(Vector(this->cameraSpeed * dt, 0, 0)); 957 this->shiftCoor (t his->velocity * dt);958 959 float angle = t his->velocity.z / travelSpeed * pi / 3;950 this->shiftCoor (tempVelocity * dt); 951 952 float angle = tempVelocity.z / travelSpeed * pi / 3; 960 953 if (angle > pi/4) angle = pi/4; 961 954 if (angle < -pi/4) angle = -pi/4; 962 955 this->setRelDirSoft(Quaternion(angle, Vector(1,0,0)), 5.0f); 956 */ 957 963 958 } 964 959
Note: See TracChangeset
for help on using the changeset viewer.