Changeset 10095 in orxonox.OLD for branches/playability
- Timestamp:
- Dec 19, 2006, 11:18:22 AM (18 years ago)
- Location:
- branches/playability/src/world_entities
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/world_entities/effects/trail.cc
r10083 r10095 43 43 * 44 44 */ 45 Trail::Trail (float maxLength, int sections, float radius )45 Trail::Trail (float maxLength, int sections, float radius, PNode* parent) 46 46 { 47 47 this->maxLength = maxLength; … … 49 49 this->sections = sections; 50 50 this->radius = radius; 51 this->setParent( parent); 51 52 52 53 this->nodeList = new Vector[sections]; … … 96 97 for( int i = 1; i < sections; i++) 97 98 { 98 this->nodeList[i] = (this->getAbsCoor() - (( Vector(1,0,0) * (i * this->maxLength / sections))));99 this->nodeList[i] = (this->getAbsCoor() - (((this->getParent()->getAbsDir().apply(Vector(1,1,1))).getNormalized() * (i * this->maxLength / sections)))); 99 100 //PRINTF(0)(" N%i (%f,%f,%f)",i,this->nodeList[i].x,this->nodeList[i].y,this->nodeList[i].z); 100 101 } … … 277 278 Q[3] = now + Vector(0,-radone,0) ; 278 279 279 glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x,Q[3].y,Q[3].z );280 glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x,Q[0].y,Q[0].z );280 glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x,Q[3].y,Q[3].z+0.0001f); 281 glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x,Q[0].y,Q[0].z+0.0001f); 281 282 282 283 if( i == 1) … … 284 285 Q[1] = later + Vector(0,radzero,0) ; 285 286 Q[2] = later + Vector(0,-radzero,0) ; 286 glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x,Q[2].y,Q[2].z );287 glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x,Q[1].y,Q[1].z );287 glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x,Q[2].y,Q[2].z+0.0001f); 288 glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x,Q[1].y,Q[1].z+0.0001f); 288 289 } 289 290 … … 340 341 Q[3] = now + targ.cross(Vector(0,-radone,0)) ; 341 342 342 glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x ,Q[0].y,Q[0].z);343 glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x ,Q[3].y,Q[3].z);343 glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x+0.0001f,Q[0].y,Q[0].z); 344 glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x+0.0001f,Q[3].y,Q[3].z); 344 345 345 346 if( i == 1) … … 347 348 Q[1] = later + targ.cross(Vector(0,radzero,0)) ; 348 349 Q[2] = later + targ.cross(Vector(0,-radzero,0)) ; 349 glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x ,Q[1].y,Q[1].z);350 glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x ,Q[2].y,Q[2].z);350 glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x+0.0001f,Q[1].y,Q[1].z); 351 glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x+0.0001f,Q[2].y,Q[2].z); 351 352 } 352 353 -
branches/playability/src/world_entities/effects/trail.h
r10081 r10095 16 16 ObjectListDeclaration(Trail); 17 17 public: 18 Trail(float maxLength, int sections, float radius );18 Trail(float maxLength, int sections, float radius, PNode* parent); 19 19 Trail(const TiXmlElement* root = NULL); 20 20 virtual ~Trail(); -
branches/playability/src/world_entities/projectiles/mbolt.cc
r10081 r10095 77 77 78 78 79 this->trail = new Trail(6, 1,.4);80 this->trail->setParent( this);79 this->trail = new Trail(6,4,.1, this); 80 //this->trail->setParent( this); 81 81 this->trail->setTexture( "maps/laser.png"); 82 this->trail->setAbsCoor(this->getAbsCoor() - Vector(1,0,0)); 82 83 } 83 84 … … 126 127 this->emitter->setEmissionRate(10.0); 127 128 this->emitter->setEmissionVelocity(0); 128 this->updateNode(0);129 129 } 130 130 … … 144 144 void MBolt::collidesWith(WorldEntity* entity, const Vector& location) 145 145 { 146 PRINTF( 0)("MBolt collides pretest\n");147 if( entity == NULL || dynamic_cast<SpaceShip*>(entity) == NULL)146 PRINTF(5)("MBolt collides pretest\n"); 147 if( entity == NULL) 148 148 return; 149 149 150 150 PRINTF(0)("MBolt collides\n"); 151 151 dynamic_cast<SpaceShip*>(entity)->damage( this->getPhysDamage(), this->getElecDamage()); 152 entity->destroy(this);153 this->deactivate();152 //entity->destroy(this); 153 //this->deactivate(); 154 154 } 155 155 -
branches/playability/src/world_entities/projectiles/swarm_projectile.cc
r10087 r10095 59 59 this->physDamage = 200; 60 60 61 this->trail = new Trail(2.5,4,.2 );62 this->trail->setParent( this);61 this->trail = new Trail(2.5,4,.2, this); 62 //this->trail->setParent( this); 63 63 this->trail->setTexture( "maps/laser.png"); 64 64 } … … 240 240 this->lastDir = this->curDir; 241 241 this->curDir = this->velocity; 242 if( (this->getAbsCoor() - this->target->getAbsCoor()).len() < 4) // FIXME Temp fake workaround for collision :) 243 { 244 dynamic_cast<WorldEntity*>(target)->destroy( this); 245 this->destroy( this); 246 } 242 247 } 243 248 -
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 -
branches/playability/src/world_entities/space_ships/space_ship.h
r10081 r10095 51 51 virtual void destroy(WorldEntity* killer); 52 52 virtual void respawn(); 53 54 inline Vector getVelocity() { return this->velocity; }; 53 55 54 56 virtual void collidesWith(WorldEntity* entity, const Vector& location); -
branches/playability/src/world_entities/weapons/medium_blaster.cc
r10064 r10095 96 96 pj->setParent(PNode::getNullParent()); 97 97 98 pj->setVelocity(this->get AbsDir().apply(Vector(1,0,0))*160);98 pj->setVelocity(this->getParent()->getVelocity() + this->getAbsDir().apply(Vector(1,0,0))*100); 99 99 100 100 pj->setAbsCoor(this->getEmissionPoint());
Note: See TracChangeset
for help on using the changeset viewer.