Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10286 in orxonox.OLD for branches


Ignore:
Timestamp:
Jan 17, 2007, 9:23:49 PM (18 years ago)
Author:
nicolasc
Message:

code cleanup, rebuilt spikeball

Location:
branches/playability/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/story_entities/game_world_data.cc

    r9869 r10286  
    232232  State::setPlayer(this->localPlayer);
    233233
    234   Playable* playable;
     234//   Playable* playable;
    235235  if (!Playable::objectList().empty())
    236236  {
  • branches/playability/src/world_entities/projectiles/spike.h

    r10196 r10286  
    4848
    4949    WorldEntity* hitEntity; // FIXME TEMPORARY
     50
     51    Vector                            velocity;
    5052};
    5153
  • branches/playability/src/world_entities/projectiles/spike_ball.cc

    r10281 r10286  
    5555  this->emitter->setEmissionVelocity(50.0);
    5656
    57 //   this->speed = 150;
    58 /*
    59   this->angle = 0;
    60   this->rotationSpeed = 130;*/
    6157  this->setRotationSpeed(130);
    6258
     
    7066
    7167  this->launcher = new Vector [this->getFragments()];
    72 
    73 //   this->fastFactory = tFastFactory<Spike>::getFastFactory(CL_SPIKE, "Spike");
    74 
    75 /*
    76   this->weaponMan = new WeaponManager(dynamic_cast<WorldEntity*>(this));
    77   this->weaponMan->setParentEntity(this);
    78   this->weaponMan->setSlotCount(1);
    79   this->weaponMan->setSlotPosition(0, Vector(0, 0, 0));
    80   this->weaponMan->setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    81 
    82   Weapon* cannon = new SpikeLauncher();
    83   cannon->setName( "SpikeLauncher");
    84   this->weaponMan->addWeapon(cannon, 0, 0);
    85   this->weaponMan->changeWeaponConfig(0);
    86 
    87   this->weaponMan->getWeapon(0)->increaseEnergy(50);*/
    8868}
    8969
     
    172152  this->hitEntity = entity;
    173153  dynamic_cast<SpaceShip*>(entity)->damage(this->getDamage(),0);
    174 //   this->deactivate();
    175154}
    176155
     
    178157void SpikeBall::blow()
    179158{
     159  updateFireDir();
     160
    180161  Spike* pj = NULL;
    181 /*  printf( "KA-" );*/
    182162  for ( int i = 0; i < this->getFragments(); i++)
    183163  {
    184164    pj  = new Spike();
    185165    assert( pj );
    186 /*    printf(" %i", i);*/
    187166    pj->setParent(PNode::getNullParent());
    188167
     
    191170    pj->setParent(PNode::getNullParent());
    192171    pj->setAbsCoor(this->getAbsCoor() + this->launcher[i] * this->size);
    193     Quaternion q;
    194     pj->setAbsDir(q.lookAt(Vector(), this->launcher[i], VECTOR_RAND(1)));
     172//     Quaternion q;
     173    pj->setAbsDir(Quaternion(this->launcher[i], 0));
    195174
    196175    pj->toList(this->getOMListNumber());
    197176
    198 /*
    199     pj->setAbsCoor(this->getAbsCoor() + VECTOR_RAND(3));
    200     pj->setAbsDir(this->getAbsDir());*/
    201177    pj->activate();
    202178  }
    203 /*  printf( "BOOM\n" );*/
    204179}
    205180
     
    219194  ca = cos (this->getAngle());
    220195  sa = sin (this->getAngle());
    221 // final version below... easier to to cheat with the one above.
    222196
    223197  m[0][0] = nx * nx * (1 - ca) + ca;
     
    233207  float x, y, z;
    234208  for (int i = 0; i < this->getFragments(); i++){
    235 //     printf("%i ", i);
    236209    x = m[0][0] * this->launcher[i].x + m[0][1] * this->launcher[i].y + m[0][2] * this->launcher[i].z;
    237210    y = m[1][0] * this->launcher[i].x + m[1][1] * this->launcher[i].y + m[1][2] * this->launcher[i].z;
     
    240213    this->launcher[i] = Vector (x, y, z);
    241214  }
    242 //   printf("\n");
    243215
    244216  for( int i = 0; i < 3 ; i++)
     
    254226void SpikeBall::tick (float dt)
    255227{
    256   //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
    257   Vector v = this->getVelocity() * dt;
     228  Vector v = this->velocity * dt;
    258229  this->shiftCoor(v);
    259 
    260 //   if(this->lifeCycle > .9){
    261 // /*    printf("time to blow:  ");*/
    262 // //     this->weaponMan->fire();
    263 // /*    this->blow();*/
    264 //   }
    265230
    266231  if (this->tickLifeCycle(dt)){
     
    270235
    271236  this->updateAngle( dt );
    272 //   angle += rotationSpeed * dt;
    273237}
    274238
     
    289253{
    290254  glPushAttrib(GL_ENABLE_BIT);
    291   //glDisable(GL_LIGHTING);
    292 
    293255  glMatrixMode(GL_MODELVIEW);
    294256  glPushMatrix();
     
    305267
    306268  glPopMatrix();
    307 
    308269  glPopAttrib();
    309270}
  • branches/playability/src/world_entities/projectiles/spike_ball.h

    r10271 r10286  
    1010#include "spike.h"
    1111#include "effects/billboard.h"
    12 
    13 // #include "../weapons/spike_launcher.h"
    1412
    1513
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r10284 r10286  
    204204
    205205  curWeaponPrimary    = 3;
    206   curWeaponSecondary  = 1;
     206  curWeaponSecondary  = 0;
    207207
    208208  Playable::weaponConfigChanged();
     
    295295  this->weaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    296296
    297   this->weaponMan.setSlotPosition(2, Vector(-1.5, 0, -.5));
     297  this->weaponMan.setSlotPosition(2, Vector(1.0, 0, -1.5));
    298298  this->weaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
    299299
    300   this->weaponMan.setSlotPosition(3, Vector(-1.5, 0, .5));
     300  this->weaponMan.setSlotPosition(3, Vector(1.0, 0, 1.5));
    301301  this->weaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
    302302
  • branches/playability/src/world_entities/weapons/heavy_blaster.cc

    r10281 r10286  
    235235
    236236  glPushMatrix();
    237   glTranslatef (this->objComp[1][0]->getAbsCoor().x, this->objComp[1][0]->getAbsCoor().y, this->objComp[1][0]->getAbsCoor().z);
    238   static_cast<StaticModel*>(this->getModel())->draw(2);
    239   glPopMatrix();
    240 
    241   glPushMatrix();
    242   glTranslatef (this->objComp[2][0]->getAbsCoor().x, this->objComp[2][0]->getAbsCoor().y, this->objComp[2][0]->getAbsCoor().z);
    243   static_cast<StaticModel*>(this->getModel())->draw(0);
    244   glPopMatrix();
    245 
    246   glPushMatrix();
    247   glTranslatef (this->objComp[0][1]->getAbsCoor().x, this->objComp[0][1]->getAbsCoor().y, this->objComp[0][1]->getAbsCoor().z);
     237    glTranslatef (this->objComp[1][0]->getAbsCoor().x, this->objComp[1][0]->getAbsCoor().y, this->objComp[1][0]->getAbsCoor().z);
     238    static_cast<StaticModel*>(this->getModel())->draw(2);
     239  glPopMatrix();
     240
     241  glPushMatrix();
     242    glTranslatef (this->objComp[2][0]->getAbsCoor().x, this->objComp[2][0]->getAbsCoor().y, this->objComp[2][0]->getAbsCoor().z);
     243    static_cast<StaticModel*>(this->getModel())->draw(0);
     244  glPopMatrix();
     245
     246  glPushMatrix();
     247    glTranslatef (this->objComp[0][1]->getAbsCoor().x, this->objComp[0][1]->getAbsCoor().y, this->objComp[0][1]->getAbsCoor().z);
    248248    static_cast<StaticModel*>(this->getModel())->draw(4);
    249249  glPopMatrix();
    250250
    251251  glPushMatrix();
    252   glTranslatef (this->objComp[1][1]->getAbsCoor().x, this->objComp[1][1]->getAbsCoor().y, this->objComp[1][1]->getAbsCoor().z);
    253   static_cast<StaticModel*>(this->getModel())->draw(5);
    254   glPopMatrix();
    255 
    256   glPushMatrix();
    257   glTranslatef (this->objComp[2][1]->getAbsCoor().x, this->objComp[2][1]->getAbsCoor().y, this->objComp[2][1]->getAbsCoor().z);
    258   static_cast<StaticModel*>(this->getModel())->draw(3);
    259   glPopMatrix();
    260 
    261   glPopMatrix();
    262 }
     252    glTranslatef (this->objComp[1][1]->getAbsCoor().x, this->objComp[1][1]->getAbsCoor().y, this->objComp[1][1]->getAbsCoor().z);
     253    static_cast<StaticModel*>(this->getModel())->draw(5);
     254  glPopMatrix();
     255
     256  glPushMatrix();
     257    glTranslatef (this->objComp[2][1]->getAbsCoor().x, this->objComp[2][1]->getAbsCoor().y, this->objComp[2][1]->getAbsCoor().z);
     258    static_cast<StaticModel*>(this->getModel())->draw(3);
     259  glPopMatrix();
     260
     261  glPopMatrix();
     262}
  • branches/playability/src/world_entities/weapons/medium_blaster.cc

    r10132 r10286  
    3737{
    3838      // model will be deleted from WorldEntity-destructor
     39  for (int i = 0; i < this->getBarrels(); i++)
     40  {
     41   delete [] this->shootAnim[i];
     42//    delete [] this->objComp[i];
     43  }
     44  delete [] this->shootAnim;
     45//   delete [] this->objComp;
    3946}
    4047
     
    5057//  this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN);
    5158
    52   this->loadModel("models/guns/plasmadriver_#.obj", 1.0);
     59  this->loadModel("models/guns/blaster.obj", .33);
    5360 
    5461
     
    7178  this->prepareProjectiles(100);
    7279
     80
     81  this->setBarrels(1);
     82  this->setSegs(2);
     83  this->activeBarrel = 0;
     84
     85  this->objComp = new PNode**[this->getBarrels()];
     86//   this->emissionPoint = new PNode*[this->getBarrels()];
     87  this->shootAnim = new Animation3D**[this->getBarrels()];
     88  for (int i = 0; i < this->getBarrels(); i++)
     89  {
     90    this->objComp[i] = new PNode* [this->getSegs()];
     91//     this->emissionPoint[i] = new PNode;
     92//     this->emissionPoint[i]->setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
     93//     this->emissionPoint[i]->setName("EmissionPoint");
     94//     this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     95    this->shootAnim[i] = new Animation3D* [this->getSegs()];
     96    for(int j = 0; j < this->getSegs(); j++)
     97    {
     98      this->objComp[i][j] = new PNode;
     99      this->shootAnim[i][j] = new Animation3D(this->objComp[i][j]);
     100      this->shootAnim[i][j]->setInfinity(ANIM_INF_CONSTANT);
     101    }
     102  }
     103
     104  for (int i = 0; i < this->getBarrels(); i++){
     105    this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.04, ANIM_LINEAR, ANIM_NULL);
     106    this->shootAnim[i][0]->addKeyFrame(Vector(-0.333, 0.0, 0.0), Quaternion(), 0.15, ANIM_LINEAR, ANIM_NULL);
     107    this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL);
     108
     109    this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.04, ANIM_LINEAR, ANIM_NULL);
     110    this->shootAnim[i][1]->addKeyFrame(Vector(.166, 0.0, 0.0), Quaternion(), 0.15, ANIM_LINEAR, ANIM_NULL);
     111    this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL);
     112  }
     113
    73114  Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this);
    74115  Animation3D* animation3 = this->getAnimation(WS_DEACTIVATING, this);
     
    77118  animation3->setInfinity(ANIM_INF_CONSTANT);
    78119
    79   this->setEmissionPoint(3.8, 1.2, 0);
     120
     121  this->setEmissionPoint(1.3, 0, 0);
    80122
    81123  animation2->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
     
    103145  pj->setAbsDir(this->getAbsDir());
    104146  pj->activate();
     147
     148  for (int i = 0; i < this->getSegs(); i++)
     149    this->shootAnim[this->activeBarrel][i]->replay();
    105150}
    106151
     
    121166void MediumBlaster::draw() const
    122167{
     168  glMatrixMode(GL_MODELVIEW);
     169  glPushMatrix();
     170  glTranslatef (this->getAbsCoor ().x,
     171                this->getAbsCoor ().y,
     172                this->getAbsCoor ().z);
     173
     174  static_cast<StaticModel*>(this->getModel())->draw(2);
     175
     176  glPushMatrix();
     177    glTranslatef (this->objComp[0][0]->getAbsCoor().x, this->objComp[0][0]->getAbsCoor().y, this->objComp[0][0]->getAbsCoor().z);
     178    static_cast<StaticModel*>(this->getModel())->draw(1);
     179  glPopMatrix();
     180
     181  glPushMatrix();
     182  glTranslatef (this->objComp[0][1]->getAbsCoor().x, this->objComp[0][1]->getAbsCoor().y, this->objComp[0][1]->getAbsCoor().z);
     183  static_cast<StaticModel*>(this->getModel())->draw(0);
     184  glPopMatrix();
     185
     186  glPopMatrix();
     187
     188  glPopMatrix();
    123189}
  • branches/playability/src/world_entities/weapons/medium_blaster.h

    r9998 r10286  
    2828    virtual void draw() const;
    2929
     30  private:
     31    PNode*** objComp;
     32    Animation3D*** shootAnim;
     33
     34    int activeBarrel;
     35
    3036};
    3137
Note: See TracChangeset for help on using the changeset viewer.