Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10035 in orxonox.OLD for branches/playability/src/world_entities


Ignore:
Timestamp:
Dec 9, 2006, 7:00:44 PM (18 years ago)
Author:
nicolasc
Message:

updated swarm_projectile, model included in data
TE2 tests

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

Legend:

Unmodified
Added
Removed
  • branches/playability/src/world_entities/projectiles/projectile.cc

    r10020 r10035  
    167167 *  @return normalized (new) direction vector
    168168*/
    169 Vector Projectile::newDirection(Vector curDirection, Vector estTargetDir, float angle)
    170 {
    171   float tmp = angleDeg ( curDirection, estTargetDir);
    172   if (tmp == 0) { return curDirection; }
    173 
    174   if( angle >  tmp ) { angle = tmp; }
    175 
    176   //Vector n = curDirection.cross(estTargetDir);
    177   //Vector d = n.cross(curDirection);
    178   Vector d = curDirection.cross(estTargetDir).cross(curDirection);
    179   d.normalize();
    180   if( angle == 90) { return d; }
    181 
    182   Vector newDir = curDirection + d *  curDirection.len() * tan (angle);
    183   newDir.normalize();
    184   return newDir;
    185 }
     169// Vector Projectile::newDirection(Vector curDirection, Vector estTargetDir, float angle)
     170// {
     171//   float tmp = angleDeg ( curDirection, estTargetDir);
     172//   if ( unlikely(tmp == 0) ) { return curDirection; }
     173//
     174//   if( fabsf(angle) >  fabsf(tmp) ) { angle = tmp; }
     175//
     176//   Vector d = curDirection.cross(estTargetDir).cross(curDirection);
     177//   d.normalize();
     178//   if( unlikely( angle == 90)) { return d; }
     179//
     180//   Vector newDir = curDirection + d *  curDirection.len() * tan (angle);
     181//   newDir.normalize();
     182//   return newDir;
     183// }
    186184
    187185
     
    192190void Projectile::tick (float dt)
    193191{
    194   float tti = 0;  //!< time to impact
    195   Vector estTargetDir = (this->target->getRelCoor() + this->target->getVelocity());
    196   this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * dt ) * this->velocity.len();
    197   Vector v = this->velocity * (dt);
    198   this->shiftCoor(v);
     192/*
     193  if (target != NULL){
     194    float tti = this->target->getRelCoor().len() / this->getVelocity().len();
     195    Vector estTargetDir = (this->target->getRelCoor() + this->target->getVelocity()) * tti;
     196    this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * dt ) * this->velocity.len();
     197    Vector v = this->velocity * (dt);
     198    this->shiftCoor(v);
     199  }*/
    199200
    200201  if (this->tickLifeCycle(dt))
  • branches/playability/src/world_entities/projectiles/projectile.h

    r9969 r10035  
    6262    inline float getElecDamage() { return this->elecDamage; };
    6363
     64    inline void setPhysDamage( float dmg) {this->physDamage = dmg; };
     65    inline void setElecDamage( float dmg) {this->elecDamage = dmg; };
     66
    6467  protected:
    6568    // energy
     
    8891    OrxSound::SoundBuffer  engineBuffer;
    8992
    90     virtual Vector newDirection(Vector curDirection, Vector estTargetDir, float angle);
     93//     virtual Vector newDirection(Vector curDirection, Vector estTargetDir, float angle);
    9194};
    9295
  • branches/playability/src/world_entities/projectiles/swarm_projectile.cc

    r10004 r10035  
    3737{
    3838
    39   this->loadModel("models/projectiles/orx-rocket.obj", 0.5);
     39/*  this->loadModel("models/projectiles/orx-rocket.obj", 0.5);*/
     40  this->loadModel("models/projectiles/swarm_projectile.obj");
    4041  this->loadExplosionSound("sound/explosions/explosion_4.wav");
    4142
     
    4546  this->lifeSpan = 2.0;
    4647  this->agility = 3.5;
    47   this->maxVelocity = 150;
     48  this->maxVelocity = 100;
    4849
    4950  this->emitter = new DotEmitter(100, 5, M_2_PI);
     
    141142}
    142143
     144
     145
     146/**
     147 *  this function gets called by tick to calculate the new flight direction
     148 *  @param curDirection direction vector
     149 *  @param estTargetDir target vector, pointing to where the target will be on hit
     150 *  @param angle = tick * turningSpeed
     151 *  @return (new) direction vector
     152*/
     153Vector SwarmProjectile::newDirection(Vector curDirection, Vector estTargetDir, float angle)
     154{
     155  printf("recalculating direction\n");
     156  float tmp = angleDeg ( curDirection, estTargetDir);
     157  if ( unlikely(tmp == 0) ) { return curDirection * maxVelocity / curDirection.len(); }
     158
     159  if( fabsf(angle) >  fabsf(tmp) ) { angle = tmp; }
     160
     161  Vector d = curDirection.cross(estTargetDir).cross(curDirection);
     162  d.normalize();
     163  if( unlikely( angle == 90)) { return d; } //avoid complication
     164
     165  Vector newDir = curDirection + d *  curDirection.len() * tan (angle);
     166  newDir.normalize();
     167  newDir *= curDirection.len();
     168  return newDir;
     169}
     170
     171
     172
     173
    143174/**
    144175 *  signal tick, time dependent things will be handled here
     
    147178void SwarmProjectile::tick (float time)
    148179{
    149 
     180/*
    150181  Vector targetFarFarAway = this->getAbsCoor() + Vector(100000, 0, 0);
    151182
     
    173204  velocity *= maxVelocity/velocity.len();
    174205  Vector v = this->velocity * (time);
    175   this->shiftCoor(v);
     206  this->shiftCoor(v);*/
     207
     208  if (target != NULL){
     209    float tti = this->target->getRelCoor().len() / this->getVelocity().len();
     210    Vector estTargetDir = (this->target->getRelCoor() + this->target->getVelocity()) * tti;
     211    this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * time );
     212  }
     213  else
     214    velocity *= maxVelocity / velocity.len(); // set speed to max
     215
     216  this->shiftCoor(velocity * time);
    176217
    177218  if(this->tickLifeCycle(time))
     
    208249  this->getAbsDir().matrix (matrix);
    209250  glMultMatrixf((float*)matrix);
    210   glScalef(2.0, 2.0, 2.0);
     251  //glScalef(2.0, 2.0, 2.0);
    211252  this->getModel()->draw();
    212253
  • branches/playability/src/world_entities/projectiles/swarm_projectile.h

    r10004 r10035  
    4545    Vector                            correctionVector;
    4646
     47    PNode*                            target;
     48
    4749    WorldEntity* hitEntity; // FIXME TEMPORARY
     50
     51    Vector newDirection(Vector curDirection, Vector estTargetDir, float angle);
    4852
    4953};
  • branches/playability/src/world_entities/test_entity2.cc

    r10005 r10035  
    8888
    8989  this->material->setDiffuseMap("maps/TE2.tga");
     90
    9091}
    9192
     
    126127
    127128
     129  glEnable(GL_BLEND);
     130  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     131  glShadeModel(GL_FLAT);
     132  glClearColor(0.0, 0.0, 0.0, 0.0);
     133
    128134  glEnable(GL_TEXTURE_2D);
    129135  this->material->select();
     
    186192  glEnd();
    187193
     194/*
    188195  glBegin(GL_QUADS);// -X
    189196    glTexCoord2f (0.0, 0.0);
     
    238245    glVertex3f( -0.5f, 0.5f, 0.0f );
    239246//     glNormal3f(0.0, 0.0, -1.0);
    240   glEnd();
     247  glEnd();*/
    241248
    242249  glPopMatrix();
Note: See TracChangeset for help on using the changeset viewer.