Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10252 in orxonox.OLD


Ignore:
Timestamp:
Jan 17, 2007, 1:41:51 PM (17 years ago)
Author:
nicolasc
Message:

bump

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

Legend:

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

    r10235 r10252  
    182182}
    183183
    184 void ProjectileWeapon::fire()
     184void ProjectileWeapon::blow()
    185185{
    186186}
  • branches/playability/src/world_entities/projectiles/projectile_weapon.h

    r10235 r10252  
    8282    inline float getAngle () { return this->angle; };
    8383
     84    inline void updateAngle ( float dt ) { this->angle += this->rotationSpeed * dt; };
     85
     86    inline void setFragments( int frag ) { this->fragments = frag; };
     87    inline int getFragments () { return this->fragments; };
     88
     89//     virtual void blow ();
     90
    8491  protected:
    8592    // energy
     
    100107    Vector                  rotationAxis;           //!< rotation axis
    101108
     109    int                     fragments;                //!< Number of fragements created by the blow
     110
    102111    Vector                  velocity;                 //!< velocity of the projectile_weapon.
    103112
    104113    PNode*                  target;                   //!< A target for guided Weapons.
    105114
    106     virtual void            fire();
     115    virtual void            blow();
    107116
    108117//     FastFactory             ff;
  • branches/playability/src/world_entities/projectiles/spike_ball.cc

    r10235 r10252  
    3131#include "space_ships/space_ship.h"
    3232
    33 // #include "weapons/weapon.h"
    34 // #include "../weapons/weapon_manager.h"
    3533
    3634#include "class_id_DEPRECATED.h"
     
    6563  this->halo->setSize(2, 2);
    6664  this->halo->setTexture("hbolt_halo.png");
     65
     66  this->setFragments(26);
     67
     68  this->size = 4;
     69//   this->fastFactory = tFastFactory<Spike>::getFastFactory(CL_SPIKE, "Spike");
     70
    6771/*
    6872  this->weaponMan = new WeaponManager(dynamic_cast<WorldEntity*>(this));
     
    118122  this->setDamage(5);
    119123  this->setHealth(0);
    120   this->rotationVector = VECTOR_RAND(1);
     124  this->setRotationAxis(VECTOR_RAND(1));
     125  this->setAngle();
     126
     127  this->launcher[0] = Vector(1.0, 0.0, 0.0);
     128  this->launcher[1] = Vector(0.0, 1.0, 0.0);
     129  this->launcher[2] = Vector(0.0, 0.0, 1.0);
     130
     131  this->launcher[3] = Vector(1.0, 1.0, 0.0);
     132  this->launcher[4] = Vector(0.0, 1.0, 1.0);
     133  this->launcher[5] = Vector(1.0, 0.0, 1.0);
     134  this->launcher[6] = Vector(1.0, -1.0, 0.0);
     135  this->launcher[7] = Vector(0.0, 1.0, -1.0);
     136  this->launcher[8] = Vector(-1.0, 0.0, 1.0);
     137
     138  this->launcher[9] = Vector(-1.0, 1.0, 1.0);
     139  this->launcher[10] = Vector(1.0, 1.0, 1.0);
     140  this->launcher[11] = Vector(1.0, -1.0, 1.0);
     141  this->launcher[12] = Vector(-1.0, -1.0, 1.0);
     142
     143  int tmp = this->getFragments() / 2;
     144  for (int i = 0; i < tmp; i++)
     145  {
     146    this->launcher[i].normalize();
     147    this->launcher[tmp + i] =  this->launcher[i] * (-1);
     148  }
    121149}
    122150
     
    143171//   this->deactivate();
    144172}
     173
     174
     175void SpikeBall::blow()
     176{
     177  Spike* pj = NULL;
     178
     179  for ( int i = 0; i < this->getFragments(); i++)
     180  {
     181    pj  = new Spike();
     182    if (pj == NULL)
     183      return;
     184
     185    pj->setParent(PNode::getNullParent());
     186
     187    pj->setVelocity(this->launcher[i].getNormalized() * 250.0);
     188
     189    pj->setParent(PNode::getNullParent());
     190    pj->setAbsCoor(this->getAbsCoor() + this->launcher[i] * this->size);
     191    Quaternion q;
     192    pj->setAbsDir(q.lookAt(Vector(), this->launcher[i], VECTOR_RAND(1)));
    145193/*
    146 void SpikeBall::blow()
    147 {
    148   const float* v = this->getModel()->getVertexArray();
    149   Projectile* pj = NULL;
    150 
    151   for (unsigned int i = 0; i < this->getModel()->getVertexCount(); i++)
    152   {
    153 
    154 //     v = this->getModel()->getModelInfo
    155 
    156       pj  = this->getProjectile();
    157       if (pj == NULL)
    158         return;
    159 
    160       if (v[i].x * v[i].x + v[i].y * v[i].y + v[i].z * v[i].z > 4)
    161       {
    162         pj->setParent(PNode::getNullParent());
    163         pj->setAbsCoor(this->getAbsCoor() + v);
    164         pj->setAbsDir(v->getNormalized() * this->speed);
    165         pj->activate();
    166       }
    167   }
    168 }*/
     194    pj->setAbsCoor(this->getAbsCoor() + VECTOR_RAND(3));
     195    pj->setAbsDir(this->getAbsDir());*/
     196    pj->activate();
     197  }
     198}
     199
     200
     201void SpikeBall::updateFireDir(){
     202
     203  float** m = new float* [3];
     204  for( int i = 0; i < 3 ; i++)
     205    m[i] = new float;
     206
     207  float nx, ny, nz, ca, sa;
     208
     209  nx = this->getRotationAxis().x;
     210  ny = this->getRotationAxis().y;
     211  nz = this->getRotationAxis().z;
     212
     213  ca = cos (this->getAngle());
     214  sa = sin (this->getAngle());
     215// final version below... easier to to cheat with the one above.
     216
     217  m[0][0] = nx * nx * (1 - ca) + ca;
     218  m[0][1] = nx * ny * (1 - ca) + nz * sa;
     219  m[0][2] = nx * nz * (1 - ca) - ny * sa;
     220  m[1][0] = nx * nz * (1 - ca) - nz * sa;
     221  m[1][1] = ny * ny * (1 - ca) + ca;
     222  m[1][2] = ny * nz * (1 - ca) + nx * sa;
     223  m[2][0] = nx * nz * (1 - ca) + ny * sa;
     224  m[2][1] = ny * nz * (1 - ca) - nx * sa;
     225  m[2][2] = nz * nz * (1 - ca) + ca;
     226
     227  float x, y, z;
     228  for (int i = 0; i < this->getFragments(); i++){
     229//     printf("%i ", i);
     230    x = m[0][0] * this->launcher[i].x + m[0][1] * this->launcher[i].y + m[0][2] * this->launcher[i].z;
     231    y = m[1][0] * this->launcher[i].x + m[1][1] * this->launcher[i].y + m[1][2] * this->launcher[i].z;
     232    z = m[2][0] * this->launcher[i].x + m[2][1] * this->launcher[i].y + m[2][2] * this->launcher[i].z;
     233
     234    this->launcher[i] = Vector (x, y, z);
     235  }
     236//   printf("\n");
     237
     238  for( int i = 0; i < 3 ; i++)
     239    delete m[i];
     240  delete m;
     241}
    169242
    170243
     
    180253
    181254  if(this->lifeCycle > .9){
    182     printf("called by spikeball  ");
    183     this->weaponMan->fire();
     255//     printf("called by spikeball  ");
     256//     this->weaponMan->fire();
     257//     this->blow();
    184258  }
    185259
     
    187261      this->deactivate();
    188262
    189   angle += rotationSpeed * dt;
     263  this->updateAngle( dt );
     264//   angle += rotationSpeed * dt;
    190265}
    191266
  • branches/playability/src/world_entities/projectiles/spike_ball.h

    r10235 r10252  
    11/*!
    2  * @file lbolt.h
    3  * @brief light blaster lbolt
     2 * @file spike_ball.h
     3 * @brief Noxonian SpikeBall Projectile; 2 stage weapon, splits into spikes
    44*/
    55
     
    88
    99#include "projectile_weapon.h"
     10#include "spike.h"
    1011#include "effects/billboard.h"
    1112
     
    1920class SpriteParticles;
    2021class ParticleEmitter;
    21 class FastFactory;
    2222class FastFactory;
    2323
     
    4141    virtual void draw () const;
    4242
    43     inline Vector getRotationVector() { return this->rotationVector; }
    44     inline float getAngle() { return this->angle; }
    45 
    46 //     virtual void blow();
     43//     inline Vector getRotationVector() { return this->rotationVector; }
     44//     inline float getAngle() { return this->angle; }
    4745
    4846  private:
     
    6361    WorldEntity* hitEntity; // FIXME TEMPORARY
    6462
    65     WeaponManager*                   weaponMan;
     63//     WeaponManager*                   weaponMan;
     64
     65    void updateFireDir();
     66    virtual void blow();
     67
     68//     int           spikes;
     69    Vector*       launcher;
     70    float         size;
     71
    6672};
    6773
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r10237 r10252  
    166166  wpLeft2->setName( "MediumBlaster");
    167167  //wpLeft2->setParent( this);
    168  
     168
    169169  Weapon* wpRight3 = new HeavyBlaster (1);
    170170  wpRight3->setName( "HeavyBlaster");
     
    177177  cannon->setName( "SwarmLauncher");
    178178
    179 //   Weapon* spike = new SpikeThrower();
    180 //   spike->setName( "SpikeThrower" );
     179  Weapon* spike = new SpikeThrower();
     180  spike->setName( "SpikeThrower" );
    181181
    182182  Weapon* spike2 = new SpikeLauncher();
     
    202202
    203203  this->secWeaponMan.addWeapon( cannon, 0, 0);
    204 /*  this->secWeaponMan.addWeapon( spike, 1, 1);*/
     204  this->secWeaponMan.addWeapon( spike, 1, 1);
    205205  this->secWeaponMan.addWeapon( spike2, 2, 2);
    206206
    207  
     207
    208208  this->weaponMan.changeWeaponConfig(3);
    209209  this->secWeaponMan.changeWeaponConfig(2);
     
    226226  shieldCur         = 20;
    227227  shieldMax         = 100;
    228   shieldTH          = .2* shieldMax;   // shield power must be 20% before shield kicks in again
     228  shieldTH          = .2 * shieldMax;   // shield power must be 20% before shield kicks in again
    229229
    230230  this->setHealth( 20);
  • branches/playability/src/world_entities/weapons/spike_thrower.cc

    r10224 r10252  
    2020#include "world_entities/projectiles/projectile.h"
    2121#include "world_entities/projectiles/spike_ball.h"
     22#include "world_entities/projectiles/spike.h"
    2223
    2324#include "model.h"
     
    9697
    9798  this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET | WTYPE_DIRECTIONAL | WTYPE_LIGHT);
    98   this->setProjectileTypeC("SpikeBall");
     99  this->setProjectileTypeC("Spike");
    99100
    100101//   this->loadModel("models/guns/turret1.obj", 1.0);
  • branches/playability/src/world_entities/weapons/weapon.cc

    r10230 r10252  
    586586bool Weapon::fireW()
    587587{
    588   printf("fireW Weapon\n");
     588//   printf("fireW Weapon\n");
    589589  //if (likely(this->currentState != WS_INACTIVE))
    590590  if (this->minCharge <= this->energy)
  • branches/playability/src/world_entities/weapons/weapon_manager.cc

    r10224 r10252  
    431431void WeaponManager::fire()
    432432{
    433   printf("firing WM: ");
     433//   printf("firing WM: ");
    434434  Weapon* firingWeapon;
    435435  for(int i = 0; i < this->slotCount; i++)
    436436  {
    437     printf("%i ", i);
     437//     printf("%i ", i);
    438438          firingWeapon = this->currentSlotConfig[i].currentWeapon;
    439439      if( firingWeapon != NULL && firingWeapon->getCurrentState() == WS_SHOOTING) continue;
    440440          if( firingWeapon != NULL) firingWeapon->requestAction(WA_SHOOT);
    441441  }
    442   printf("\n");
     442//   printf("\n");
    443443  /*
    444444        this->crosshair->setRotationSpeed(500);
Note: See TracChangeset for help on using the changeset viewer.