Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10095 in orxonox.OLD for branches/playability/src


Ignore:
Timestamp:
Dec 19, 2006, 11:18:22 AM (18 years ago)
Author:
marcscha
Message:

velocity fix

Location:
branches/playability/src/world_entities
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/world_entities/effects/trail.cc

    r10083 r10095  
    4343 *
    4444 */
    45 Trail::Trail (float maxLength, int sections, float radius)
     45Trail::Trail (float maxLength, int sections, float radius, PNode* parent)
    4646{
    4747  this->maxLength = maxLength;
     
    4949  this->sections  = sections;
    5050  this->radius    = radius;
     51  this->setParent( parent);
    5152
    5253  this->nodeList  = new Vector[sections];
     
    9697  for( int i = 1; i < sections; i++)
    9798  {
    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))));
    99100    //PRINTF(0)(" N%i (%f,%f,%f)",i,this->nodeList[i].x,this->nodeList[i].y,this->nodeList[i].z);
    100101  }
     
    277278    Q[3]  = now + Vector(0,-radone,0) ;
    278279
    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);
    281282
    282283    if( i == 1)
     
    284285        Q[1]  = later + Vector(0,radzero,0) ;
    285286        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);
    288289        }
    289290
     
    340341    Q[3]  = now + targ.cross(Vector(0,-radone,0)) ;
    341342
    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);
    344345
    345346    if( i == 1)
     
    347348        Q[1]  = later + targ.cross(Vector(0,radzero,0)) ;
    348349        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);
    351352        }
    352353
  • branches/playability/src/world_entities/effects/trail.h

    r10081 r10095  
    1616  ObjectListDeclaration(Trail);
    1717  public:
    18     Trail(float maxLength, int sections, float radius);
     18    Trail(float maxLength, int sections, float radius, PNode* parent);
    1919    Trail(const TiXmlElement* root = NULL);
    2020    virtual ~Trail();
  • branches/playability/src/world_entities/projectiles/mbolt.cc

    r10081 r10095  
    7777
    7878 
    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);
    8181  this->trail->setTexture( "maps/laser.png");
     82  this->trail->setAbsCoor(this->getAbsCoor() - Vector(1,0,0));
    8283}
    8384
     
    126127  this->emitter->setEmissionRate(10.0);
    127128  this->emitter->setEmissionVelocity(0);
    128   this->updateNode(0);
    129129}
    130130
     
    144144void MBolt::collidesWith(WorldEntity* entity, const Vector& location)
    145145{
    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)
    148148    return;
    149149
    150150  PRINTF(0)("MBolt collides\n");
    151151  dynamic_cast<SpaceShip*>(entity)->damage( this->getPhysDamage(), this->getElecDamage());
    152   entity->destroy(this);
    153   this->deactivate();
     152  //entity->destroy(this);
     153  //this->deactivate();
    154154}
    155155
  • branches/playability/src/world_entities/projectiles/swarm_projectile.cc

    r10087 r10095  
    5959  this->physDamage = 200;
    6060
    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);
    6363  this->trail->setTexture( "maps/laser.png");
    6464}
     
    240240  this->lastDir = this->curDir;
    241241  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  }
    242247}
    243248
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r10092 r10095  
    326326
    327327 
    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);
    330330  this->trail->setTexture( "maps/engine.png");
    331331
    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);
    334334  this->trailL->setTexture( "maps/engine.png");
    335335
    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);
    338338  this->trailR->setTexture( "maps/engine.png");
    339339}
     
    371371{
    372372  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   }*/
    378373  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  }
    379379  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true);
    380380  //this->attachCamera();
     
    385385{
    386386  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   }*/
    392387  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  }
    393393  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( false);
    394394  //this->detachCamera();
     
    492492  this->acceleration = this->travelSpeed * 2;
    493493
    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   */
    523494  this->movement(time);
    524495
     
    527498  this->cameraNode.setRelDirSoft(this->getAbsDir(), 30.0f);
    528499
     500 
     501  this->velocity  = (this->getAbsCoor() - this->oldPos) / time;
     502  this->oldPos    = this->getAbsCoor();
     503
    529504  this->trail->tick(time);
    530505  this->trailL->tick(time);
    531506  this->trailR->tick(time);
     507
    532508  //orient the spaceship in direction of the mouse
    533509  /*
     
    600576{
    601577  PRINTF(0)("spaceship destroy\n");
    602   /*
     578 
    603579  EmitterNode* node  = NULL;
    604580  DotEmitter* emitter = NULL;
     
    628604  node->setVelocity( this->getParent()->getVelocity());
    629605  node->setAbsCoor( this->getAbsCoor());
    630   node->start();*/
     606  node->start();
     607/*
    631608  PNode* node          = new PNode();
    632609  node->setAbsCoor(this->getAbsCoor());
    633610  Explosion* explosion = new Explosion();
    634611  explosion->explode( node, Vector(5,5,5));
    635 
     612*/
    636613  this->setAbsCoor(Vector(-10000,10000,10000));
    637614  this->hide();
    638615
    639616  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))
    643620      dynamic_cast<WorldEntity*>(*it)->toList( OM_DEAD);
    644   }*/
     621  }
    645622    PRINTF(0)("spaceship destroy == ship translated \n");
    646623}
     
    654631      dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_00);
    655632  }*/
    656   /*if( this->hasPlayer())
     633  if( this->hasPlayer())
     634  {
    657635    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  }
    658642  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  }
    660651
    661652}
     
    664655void SpaceShip::damage(float pDamage, float eDamage){
    665656  PRINTF(0)("ship hit for (%f,%f) \n",pDamage,eDamage);
    666   PRINTF(0)("SHIP HIT - SHIP HIT - SHIP HIT\n");
    667657
    668658  if( this->shieldActive) {
     
    800790  float pi = 3.14;
    801791 
     792  Vector tempVelocity;
    802793
    803794  switch(this->getPlaymode())
     
    807798      // these routines will change the travel movement into zero in a short amout of time, if the player
    808799      // doesn't press any buttons.
    809       if (this->velocity.x >= 0)
    810       {
    811         if (this->velocity.x > airCoeff*this->acceleration * dt)
    812           this->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;
    813804        else
    814           this->velocity.x = 0;
     805          tempVelocity.x = 0;
    815806      }
    816807      else
    817808      {
    818         if (this->velocity.x < -airCoeff*this->acceleration * dt)
    819           this->velocity.x += airCoeff* this->acceleration * dt;
     809        if (tempVelocity.x < -airCoeff*this->acceleration * dt)
     810          tempVelocity.x += airCoeff* this->acceleration * dt;
    820811        else
    821           this->velocity.x = 0;
    822       }
    823       if (this->velocity.z >= 0)
    824       {
    825         if (this->velocity.z > airCoeff*this->acceleration * dt)
    826           this->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;
    827818        else
    828           this->velocity.z = 0;
     819          tempVelocity.z = 0;
    829820      }
    830821      else
    831822      {
    832         if (this->velocity.z < -airCoeff*this->acceleration * dt)
    833           this->velocity.z += airCoeff* this->acceleration * dt;
     823        if (tempVelocity.z < -airCoeff*this->acceleration * dt)
     824          tempVelocity.z += airCoeff* this->acceleration * dt;
    834825        else
    835           this->velocity.z = 0;
     826          tempVelocity.z = 0;
    836827      }
    837828   
     
    851842        if(this->getRelCoor().x < this->travelDistancePlus.x)
    852843        {
    853           if (this->velocity.x < this->travelSpeed)
     844          if (tempVelocity.x < this->travelSpeed)
    854845          {
    855             this->velocity.x += (airCoeff + 1.0)*this->acceleration*dt;
     846            tempVelocity.x += (airCoeff + 1.0)*this->acceleration*dt;
    856847          }
    857848          else
    858849          {
    859             this->velocity.x = this->travelSpeed;
     850            tempVelocity.x = this->travelSpeed;
    860851          }
    861852        }
    862853        else
    863854        {
    864           this->velocity.x = 0.0f;
     855          tempVelocity.x = 0.0f;
    865856        }
    866857      }
     
    870861        if(this->getRelCoor().x > this->travelDistanceMinus.x)
    871862        {
    872           if (this->velocity.x > -this->travelSpeed)
     863          if (tempVelocity.x > -this->travelSpeed)
    873864          {
    874             this->velocity.x -= (airCoeff + 1.0)*this->acceleration*dt;
     865            tempVelocity.x -= (airCoeff + 1.0)*this->acceleration*dt;
    875866          }
    876867          else
    877868          {
    878             this->velocity.x = -this->travelSpeed;
     869            tempVelocity.x = -this->travelSpeed;
    879870          }
    880871        }
    881872        else
    882873        {
    883           this->velocity.x = 0.0f;
     874          tempVelocity.x = 0.0f;
    884875        }
    885876      }
     
    889880        if(this->getRelCoor().z > this->travelDistanceMinus.y)
    890881        {
    891           if (this->velocity.z > -this->travelSpeed)
     882          if (tempVelocity.z > -this->travelSpeed)
    892883          {
    893             this->velocity.z -= (airCoeff + 1.0)*this->acceleration*dt;
     884            tempVelocity.z -= (airCoeff + 1.0)*this->acceleration*dt;
    894885          }
    895886          else
    896887          {
    897             this->velocity.z = -this->travelSpeed;
     888            tempVelocity.z = -this->travelSpeed;
    898889          }
    899890        }
    900891        else
    901892        {
    902           this->velocity.z = 0.0f;
     893          tempVelocity.z = 0.0f;
    903894        }
    904895        this->setRelDirSoft(Quaternion(-pi/6, Vector(1,0,0)), 6);
     
    909900        if(this->getRelCoor().z < this->travelDistancePlus.y)
    910901        {
    911           if (this->velocity.z < this->travelSpeed)
     902          if (tempVelocity.z < this->travelSpeed)
    912903          {
    913             this->velocity.z += (airCoeff + 1.0)*this->acceleration*dt;
     904            tempVelocity.z += (airCoeff + 1.0)*this->acceleration*dt;
    914905          }
    915906          else
    916907          {
    917             this->velocity.z = this->travelSpeed;
     908            tempVelocity.z = this->travelSpeed;
    918909          }
    919910        }
    920911        else
    921912        {
    922           this->velocity.z = 0.0f;
     913          tempVelocity.z = 0.0f;
    923914        }
    924915        this->setRelDirSoft(Quaternion(pi/6, Vector(1,0,0)), 6);
     
    931922
    932923      this->travelNode->shiftCoor(Vector(this->cameraSpeed * dt, 0, 0));
    933       this->shiftCoor (this->velocity * dt);
     924      this->shiftCoor (tempVelocity * dt);
    934925
    935926    //normalisation of the vectors (vector sum must be <= travelspeed)
    936     float xzNorm = sqrt(pow(this->velocity.x, 2) + pow(this->velocity.z, 2));
     927    float xzNorm = sqrt(pow(tempVelocity.x, 2) + pow(tempVelocity.z, 2));
    937928    if (xzNorm > this->travelSpeed)
    938929    {
    939       this->velocity.x = this->velocity.x/xzNorm * this->travelSpeed;
    940       this->velocity.z = this->velocity.z/xzNorm * this->travelSpeed;
     930      tempVelocity.x = tempVelocity.x/xzNorm * this->travelSpeed;
     931      tempVelocity.z = tempVelocity.z/xzNorm * this->travelSpeed;
    941932    }
    942933
     
    945936   
    946937    //set new coordinates calculated through key- events.
    947     this->shiftCoor (this->velocity * dt);
     938    this->shiftCoor (tempVelocity * dt);
    948939    break;
    949940    }
     
    954945  }
    955946 
     947
     948/*
    956949  this->travelNode->shiftCoor(Vector(this->cameraSpeed * dt, 0, 0));
    957   this->shiftCoor (this->velocity * dt);
    958  
    959   float angle = this->velocity.z / travelSpeed * pi / 3;
     950  this->shiftCoor (tempVelocity * dt);
     951
     952  float angle = tempVelocity.z / travelSpeed * pi / 3;
    960953  if (angle > pi/4) angle = pi/4;
    961954  if (angle < -pi/4) angle = -pi/4;
    962955  this->setRelDirSoft(Quaternion(angle, Vector(1,0,0)), 5.0f);
     956*/
     957 
    963958}
    964959
  • branches/playability/src/world_entities/space_ships/space_ship.h

    r10081 r10095  
    5151    virtual void destroy(WorldEntity* killer);
    5252    virtual void respawn();
     53
     54    inline Vector getVelocity() { return this->velocity; };
    5355
    5456    virtual void collidesWith(WorldEntity* entity, const Vector& location);
  • branches/playability/src/world_entities/weapons/medium_blaster.cc

    r10064 r10095  
    9696  pj->setParent(PNode::getNullParent());
    9797
    98   pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*160);
     98  pj->setVelocity(this->getParent()->getVelocity() + this->getAbsDir().apply(Vector(1,0,0))*100);
    9999
    100100  pj->setAbsCoor(this->getEmissionPoint());
Note: See TracChangeset for help on using the changeset viewer.