Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10064 in orxonox.OLD


Ignore:
Timestamp:
Dec 13, 2006, 3:19:40 PM (17 years ago)
Author:
marcscha
Message:

weapon, collision, particles

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

Legend:

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

    r10042 r10064  
    2424
    2525#include "particles/dot_emitter.h"
     26#include "particles/box_emitter.h"
    2627#include "particles/sprite_particles.h"
     28
     29#include "space_ships/space_ship.h"
    2730
    2831#include <cassert>
     
    3336
    3437#include "class_id_DEPRECATED.h"
     38ObjectListDefinition(MBolt);
    3539CREATE_FAST_FACTORY_STATIC(MBolt);
    3640
     
    4044MBolt::MBolt () : Projectile()
    4145{
    42 
     46  this->registerObject(this, MBolt::_objectList);
    4347  this->loadModel("models/projectiles/mbolt.obj",0.25);
    4448  //this->loadModel("models/projectiles/laser.obj");
     
    4953  this->angle     = 0;
    5054
    51   this->emitter = new DotEmitter(40, 0, M_2_PI);
     55
     56  //this->emitter = new DotEmitter(1000, 0, 0);
     57  this->emitter = new BoxEmitter(Vector(8,1,1)*dynamic_cast<StaticModel*>(this->getModel())->getScaleFactor(), 1000, 0, 0);
    5258  this->emitter->setParent(this);
    53   this->emitter->setSpread(M_PI, M_PI);
    54   this->emitter->setEmissionRate(300.0);
    55   this->emitter->setEmissionVelocity(50.0);
     59  this->emitter->setSpread(M_PI,M_PI);
     60  this->emitter->setInheritSpeed(this->velocity.len());
     61  this->emitter->setEmissionRate(500.0);
     62  this->emitter->setEmissionVelocity(this->velocity.len());
    5663
    5764  this->mat = new Material("mBolt");
     
    5966  this->mat->setBlendFunc(GL_SRC_ALPHA,GL_ONE);
    6067  this->mat->setDiffuse(1,1,1);
    61   this->mat->setDiffuseMap("laser.png");
     68  this->mat->setDiffuseMap("laser_add.png");
    6269  this->mat->setDiffuseMap("laser.png",1);
     70
    6371  dynamic_cast<StaticModel*>(this->getModel())->addMaterial(this->mat);
    6472  dynamic_cast<StaticModel*>(this->getModel())->finalize();
     
    99107    MBolt::trailParticles->setName("BoomerangProjectileTrailParticles");
    100108    MBolt::trailParticles->setMaterialTexture("maps/radial-trans-noise.png");
    101     MBolt::trailParticles->setLifeSpan(1, 0);
    102     MBolt::trailParticles->setRadius(0.0, 1);
    103     MBolt::trailParticles->setRadius(1.0, 1);
     109    MBolt::trailParticles->setLifeSpan(0.3, 0);
     110    MBolt::trailParticles->setRadius(0.0, .8);
     111    MBolt::trailParticles->setRadius(1.0, .2);
    104112    MBolt::trailParticles->setColor(0.0, 1,0,0,.9);
    105113    MBolt::trailParticles->setColor(0.2, .8,.2,0,.9);
    106     MBolt::trailParticles->setColor(0.5, .8,.4,0,.8);
    107     MBolt::trailParticles->setColor(1.0, .8,.8,0,.7);
     114    MBolt::trailParticles->setColor(0.5, .8,.4,.4,.8);
     115    MBolt::trailParticles->setColor(1.0, .8,.8,.8,.7);
    108116  }
    109117  if (unlikely(MBolt::explosionParticles == NULL))
     
    125133  this->emitter->setSystem(MBolt::trailParticles);
    126134
     135  this->emitter->setSpread(0);
     136  this->emitter->setEmissionRate(80.0);
     137  this->emitter->setEmissionVelocity(0);
    127138  this->updateNode(0);
    128   this->emitter->setSpread(0);
    129   this->emitter->setEmissionRate(20.0);
    130   this->emitter->setEmissionVelocity(this->velocity.len());
    131139}
    132140
     
    152160    this->destroy( entity );
    153161  this->hitEntity = entity;
     162  dynamic_cast<SpaceShip*>(entity)->damage(this->getDamage(),0);
    154163}
    155164
  • branches/playability/src/world_entities/projectiles/mbolt.h

    r10042 r10064  
    1818class MBolt : public Projectile
    1919{
    20   //ObjectListDeclaration(MBolt);
     20  ObjectListDeclaration(MBolt);
    2121  public:
    2222    MBolt ();
     
    4141
    4242    float                             angle;
    43     static const float                rotationSpeed = 540;
     43    static const float                rotationSpeed = 1080;
    4444
    4545    ParticleEmitter*                  emitter;
  • branches/playability/src/world_entities/projectiles/swarm_projectile.cc

    r10039 r10064  
    2323#include "particles/dot_emitter.h"
    2424#include "particles/sprite_particles.h"
     25#include "space_ships/space_ship.h"
    2526
    2627#include "debug.h"
     
    4445  this->setMinEnergy(1);
    4546  this->setHealthMax(10);
    46   this->lifeSpan = 2.0;
     47  this->lifeSpan = 4.0;
    4748  this->agility = 3.5;
    4849  this->maxVelocity = 100;
     
    6465SwarmProjectile::~SwarmProjectile ()
    6566{
    66   // delete this->emitter;
     67
    6768
    6869  /* this is normaly done by World.cc by deleting the ParticleEngine */
     
    7980    SwarmProjectile::explosionParticles = NULL;
    8081  }
    81 
     82   delete this->emitter;
    8283}
    8384
     
    9697    SwarmProjectile::trailParticles->setLifeSpan(1.0, .3);
    9798    SwarmProjectile::trailParticles->setRadius(0.0, .5);
    98     SwarmProjectile::trailParticles->setRadius(0.2, 4.0);
    99     SwarmProjectile::trailParticles->setRadius(.5, 1.5);
    100     SwarmProjectile::trailParticles->setRadius(1.0, 1.5);
     99    SwarmProjectile::trailParticles->setRadius(0.2, 2.0);
     100    SwarmProjectile::trailParticles->setRadius(.5, 1.0);
     101    SwarmProjectile::trailParticles->setRadius(1.0, 0.6);
    101102    SwarmProjectile::trailParticles->setColor(0.0, 1,0,0,.7);
    102103    SwarmProjectile::trailParticles->setColor(0.2, .8,.8,0,.5);
     
    145146    this->destroy( entity );
    146147  this->hitEntity = entity;
     148  dynamic_cast<SpaceShip*>(entity)->damage(this->getDamage(),0);
    147149}
    148150
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r10043 r10064  
    8484{
    8585  this->setPlayer(NULL);
     86  delete this->emitter;
    8687}
    8788
     
    135136  //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
    136137  this->registerObject(this, SpaceShip::_objectList);
    137 
     138  this->toList(OM_GROUP_00);
    138139  PRINTF(4)("SPACESHIP INIT\n");
    139140
     
    207208  electronicTH      = .7 * electronicMax; // 30% of eDamage can be handled by the ship
    208209
    209   /*
    210   this->addWeapon(wpLeft, 1, 0);
    211   this->addWeapon(wpRight,1 ,1);
    212   //this->addWeapon(cannon, 0, 6);
    213 
    214   this->getWeaponManager().changeWeaponConfig(1);
    215   */
    216210
    217211  this->loadModel("models/ships/mantawing.obj");
     
    220214  bForward = bBackward = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false;
    221215 
    222   /*
    223   xMouse = yMouse = 0;
    224   yInvert = 1;
    225   mouseSensitivity = 0.001;
    226   airViscosity = 0.9;
    227   controlVelocityX = 25;
    228   controlVelocityY = 150;
    229   shipInertia = 1.5;
    230   */
    231   //  cycle = 0.0;
    232216
    233217  this->setHealthMax(shieldMax);
     
    237221
    238222  // camera - issue
    239   //this->cameraNode = State::getCameraNode();
    240223  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    241224  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
    242225
    243   /*
    244   this->velocity = this->getAbsDirX()*travelSpeed;
    245   this->mouseDir = this->getAbsDir();
    246   this->pitchDir = this->getAbsDir();
    247   */
    248 
    249 
    250   //   GLGuiButton* button = new GLGuiPushButton();
    251   //    button->show();
    252   //    button->setLabel("orxonox");
    253   //    button->setBindNode(this);
    254   //     GLGuiBar* bar = new GLGuiBar();
    255   //     bar->show();
    256   //     bar->setValue(7.0);
    257   //     bar->setMaximum(10);
    258   //     bar->setSize2D( 20, 100);
    259   //     bar->setAbsCoor2D( 10, 200);
     226
    260227
    261228  //add events to the eventlist
     
    276243  this->weaponMan.setSlotCount(6);
    277244
    278   this->weaponMan.setSlotPosition(0, Vector(-2.6, .1, -3.0));
     245  this->weaponMan.setSlotPosition(0, Vector(-2.6, 0, -3.0));
    279246  this->weaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    280247
    281   this->weaponMan.setSlotPosition(1, Vector(-2.6, .1, 3.0));
     248  this->weaponMan.setSlotPosition(1, Vector(-2.6, 0, 3.0));
    282249  this->weaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    283250
    284   this->weaponMan.setSlotPosition(2, Vector(-1.5, .5, -.5));
     251  this->weaponMan.setSlotPosition(2, Vector(-1.5, 0, -.5));
    285252  this->weaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
    286253
    287   this->weaponMan.setSlotPosition(3, Vector(-1.5, .5, .5));
     254  this->weaponMan.setSlotPosition(3, Vector(-1.5, 0, .5));
    288255  this->weaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
    289256
    290   this->weaponMan.setSlotPosition(4, Vector(-1.5, -.5, .5));
     257  this->weaponMan.setSlotPosition(4, Vector(-1.5, 0, .5));
    291258  this->weaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
    292259
    293   this->weaponMan.setSlotPosition(5, Vector(-1.5, -.5, -.5));
     260  this->weaponMan.setSlotPosition(5, Vector(-1.5, 0, -.5));
    294261  this->weaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    295262
     
    314281  this->secWeaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    315282
    316   //
    317   //   this->getWeaponManager().setSlotPosition(8, Vector(-2.5, -0.3, -2.0));
    318   //   this->getWeaponManager().setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0)));
    319   //
    320   //   this->getWeaponManager().setSlotPosition(9, Vector(-2.5, -0.3, 2.0));
    321   //   this->getWeaponManager().setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:
    322283
    323284  this->weaponMan.getFixedTarget()->setParent(this);
     
    335296  this->burstEmitter->setRelCoor(-1, .5, 0);
    336297  this->burstEmitter->setName("SpaceShip_Burst_emitter");
     298  this->burstEmitter->setEmissionRate(200);
    337299
    338300  this->burstSystem = new SpriteParticles(1000);
     
    340302  this->burstSystem->setName("SpaceShip_Burst_System");
    341303  ((SpriteParticles*)this->burstSystem)->setMaterialTexture("maps/radial-trans-noise.png");
    342   this->burstSystem->setLifeSpan(1.0, .3);
     304  this->burstSystem->setLifeSpan(0.4, .3);
    343305  this->burstSystem->setRadius(0.0, 1.0);
    344306  this->burstSystem->setRadius(0.05, 1.0);
    345   this->burstSystem->setRadius(.5, .8);
     307  this->burstSystem->setRadius(.5, .6);
    346308  this->burstSystem->setRadius(1.0, 0);
    347309  this->burstSystem->setColor(0.0, .7,.7,1,.7);
     
    350312  this->burstSystem->setColor(1.0, .8,.8,.8,.0);
    351313
    352   /*
    353   registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mousedir", PERMISSION_OWNER ) );
    354   registerVar( new SynchronizeableBool( &bUp, &bUp, "bUp", PERMISSION_OWNER ) );
    355   registerVar( new SynchronizeableBool( &bDown, &bDown, "bDown", PERMISSION_OWNER ) );
    356   registerVar( new SynchronizeableBool( &bLeft, &bLeft, "bLeft", PERMISSION_OWNER ) );
    357   registerVar( new SynchronizeableBool( &bRight, &bRight, "bRight", PERMISSION_OWNER ) );
    358   registerVar( new SynchronizeableBool( &bAscend, &bAscend, "bAscend", PERMISSION_OWNER ) );
    359   registerVar( new SynchronizeableBool( &bDescend, &bDescend, "bDescend", PERMISSION_OWNER ) );
    360   registerVar( new SynchronizeableBool( &bRollL, &bRollL, "bRollL", PERMISSION_OWNER ) );
    361   registerVar( new SynchronizeableBool( &bRollR, &bRollR, "bRollR", PERMISSION_OWNER ) );
    362   */
     314  this->emitter = NULL;
    363315
    364316  registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
     
    369321  registerVar( new SynchronizeableFloat( &rotation, &rotation, "rotation", PERMISSION_OWNER ) );
    370322  registerVar( new SynchronizeableBool( &bFire, &bFire, "bSecFire", PERMISSION_OWNER));
    371 
    372323  registerVar( new SynchronizeableVector( &velocity, &velocity, "velocity", PERMISSION_MASTER_SERVER ) );
    373324
     
    404355}
    405356
    406 /*
    407 void SpaceShip::setTravelHeight(float travelHeight)
    408 {
    409   if (this->toTravelHeight == NULL)
    410     this->toTravelHeight = new float;
    411   *this->toTravelHeight = travelHeight;
    412 }
    413 */
    414 
    415 /*
    416 void SpaceShip::setTravelDistance(const Vector2D& distance)
    417 {
    418   this->travelDistance = distance;
    419 }
    420 
    421 void SpaceShip::setTravelDistance(float x, float y)
    422 {
    423   this->setTravelDistance(Vector2D(x, y));
    424 }
    425 */
    426 
    427 
    428 
    429357void SpaceShip::reset()
    430358{
     
    441369{
    442370  this->secWeaponMan.showCrosshair();
     371  this->toList( OM_GROUP_01 );
    443372  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true);
    444373  //this->attachCamera();
     
    449378{
    450379  this->secWeaponMan.hideCrosshair();
     380  this->toList(OM_GROUP_00);
    451381  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( false);
    452382  //this->detachCamera();
     
    466396*/
    467397void SpaceShip::leftWorld ()
    468 {}
     398{/*
     399  this->emitter->stop();
     400  delete this->emitter;
     401  delete this->explosionParticles; */
     402}
    469403
    470404WorldEntity* ref = NULL;
     
    603537
    604538}
    605 
    606 /*
    607 void SpaceShip::calculateVelocity (float time)
    608 {
    609   Vector accel(0.0, 0.0, 0.0);
    610   /* calculate the direction in which the craft is heading  */
    611   /*
    612   if( this->bUp )
    613   {
    614     accel += (this->getAbsDirX())*acceleration;
    615 
    616   }
    617 
    618   if( this->bDown )
    619   {
    620     accel -= (this->getAbsDirX())*0.5*acceleration;
    621 
    622   }
    623 
    624   if( this->bLeft)
    625   {
    626     this->shiftDir(Quaternion(time, Vector(0,1,0)));
    627   }
    628   if( this->bRight)
    629   {
    630     this->shiftDir(Quaternion(-time, Vector(0,1,0)));
    631   }
    632 
    633 
    634   if( this->bRollL)
    635   {
    636     mouseDir *= Quaternion(-time*2, Vector(1,0,0));
    637   }
    638   if( this->bRollR)
    639   {
    640     mouseDir *= Quaternion(time*2, Vector(1,0,0));
    641 
    642   }
    643   if (this->bAscend )
    644   {
    645     this->shiftDir(Quaternion(time, Vector(0,0,1)));
    646   }
    647   if (this->bDescend )
    648   {
    649     this->shiftDir(Quaternion(-time, Vector(0,0,1)));
    650   }
    651 
    652   velocity += accel*time*10;
    653 
    654 }
    655 */
    656539
    657540/**
     
    689572{
    690573  PRINTF(0)("spaceship destroy\n");
     574
     575  this->explosionParticles = new SpriteParticles(1000);
     576  this->explosionParticles->setName("MBoltExplosionParticles");
     577  this->explosionParticles->setLifeSpan(.5, .3);
     578  this->explosionParticles->setRadius(0.0, 10.0);
     579  this->explosionParticles->setRadius(.5, 6.0);
     580  this->explosionParticles->setRadius(1.0, 3.0);
     581  this->explosionParticles->setColor(0.0, 1,1,0,.9);
     582  this->explosionParticles->setColor(0.5, .8,.8,0,.5);
     583  this->explosionParticles->setColor(1.0, .8,.8,.7,.0);
     584
     585  this->emitter = new DotEmitter(100000, 0, 0);
     586  this->emitter->setParent(this);
     587  this->emitter->setSpread(M_PI,M_PI);
     588  this->emitter->setEmissionRate(50.0);
     589  this->emitter->setEmissionVelocity(50.0);
     590
     591  this->emitter->setSystem(this->explosionParticles);
     592
     593  this->emitter->setSpread(50);
     594  this->emitter->setEmissionRate(50.0);
     595  this->emitter->setEmissionVelocity(50.0);
     596  this->updateNode(0);
     597
     598  this->toList(OM_DEAD);
    691599}
    692600
    693601void SpaceShip::respawn( )
    694602{
    695   toList( OM_PLAYERS );
     603  toList( OM_GROUP_00 );
    696604}
    697605
    698606
    699607void SpaceShip::damage(float pDamage, float eDamage){
    700 if( this->shieldActive) {
     608  PRINTF(0)("ship hit");
     609  printf("Shit hit");
     610  if( this->shieldActive) {
    701611    if( this->shieldCur > pDamage) {
    702612      this->shieldCur = this->shieldCur - pDamage;
     
    717627  }
    718628  if( this->armorCur <= 0) { /* FIXME implement shipcrash*/ }
     629    this->destroy(this);
    719630}
    720631
  • branches/playability/src/world_entities/space_ships/space_ship.h

    r10043 r10064  
    176176    ParticleEmitter*      burstEmitter;
    177177    ParticleSystem*       burstSystem;
     178
     179   
     180    SpriteParticles*           explosionParticles;
     181    ParticleEmitter*           emitter;
    178182};
    179183
  • branches/playability/src/world_entities/weapons/medium_blaster.cc

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