Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10107 in orxonox.OLD


Ignore:
Timestamp:
Dec 19, 2006, 10:03:19 PM (17 years ago)
Author:
marcscha
Message:

many additions, several fixes

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

Legend:

Unmodified
Added
Removed
  • branches/playability/src/world_entities/Makefile.am

    r10101 r10107  
    1111                                                extendable.cc           power_ups/power_up.cc           power_ups/param_power_up.cc \
    1212                                power_ups/weapon_power_up.cc                            spawning_point.cc                                               effects/explosion.cc            effects/billboard.cc \
    13                                 effects/trail.cc                                elements/glgui_energywidget.cc glgui_energywidget.cc
     13                                effects/trail.cc                                elements/glgui_energywidget.cc elements/glgui_energywidgetvertical.cc
    1414
    1515
     
    1919                                                power_ups/power_up.h            power_ups/param_power_up.h              power_ups/weapon_power_up.h \
    2020                                                spawning_point.h                                                effects/explosion.h             effects/billboard.h             effects/trail.h \
    21                                                                                 elements/glgui_energywidget.h glgui_energywidget.h
     21                                                                                elements/glgui_energywidget.h elements/glgui_energywidgetvertical.h
    2222
    2323
  • branches/playability/src/world_entities/effects/trail.cc

    r10104 r10107  
    174174  //glMatrixMode(GL_MODELVIEW);
    175175  //glLoadIdentity();
    176 
    177   glEnable( GL_BLEND);
     176  /*
     177  glEnable(GL_BLEND);
    178178  glBlendFunc(GL_SRC_ALPHA,GL_ONE);
    179   glDisable( GL_ALPHA_TEST);
     179  glDisable( GL_ALPHA_TEST);*/
    180180
    181181  glTranslatef(-this->getAbsCoor().x,-this->getAbsCoor().y,-this->getAbsCoor().z);
     
    183183  this->material->select();
    184184
    185   float alphaStep = (trailAlphaMax - trailAlphaMin)/this->sections;
     185  //float alphaStep = 1.0 / this->sections;
    186186
    187187  glBegin(GL_TRIANGLE_STRIP);
     
    190190  for( int i = 1; i < this->sections-1; i++)
    191191  {
    192     radone  = this->radius * (1.0-i*fact);
    193     radzero  = this->radius * (1.0-(i+1)*fact);
     192    radone  = this->radius * (1.0-i*fact + 0.2 * (float)rand()/(float)RAND_MAX);
     193    radzero  = this->radius * (1.0-(i+1)*fact + 0.2 * (float)rand()/(float)RAND_MAX);
    194194
    195195    now   =  this->nodeList[i];
     
    204204    Q[3]  = now + Vector(0,-radone,0) ;
    205205   
    206     glTexCoord2f(0.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[0].x,Q[0].y,Q[0].z);
    207         glTexCoord2f(1.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[3].x,Q[3].y,Q[3].z);
     206    glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x,Q[0].y,Q[0].z);
     207        glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x,Q[3].y,Q[3].z);
    208208
    209209    if( i == this->sections - 1)
     
    212212      Q[1]  = later + Vector(0,radzero,0) ;
    213213      Q[2]  = later + Vector(0,-radzero,0) ;
    214       glTexCoord2f(0.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[1].x,Q[1].y,Q[1].z);
    215       glTexCoord2f(1.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[2].x,Q[2].y,Q[2].z);
     214      glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x,Q[1].y,Q[1].z);
     215      glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x,Q[2].y,Q[2].z);
    216216    }
    217217
     
    222222  for( int i = this->sections-1; i > 0; i--)
    223223  {
    224     radone  = this->radius * (1.0-i*fact);
    225     radzero  = this->radius * (1.0-(i-1)*fact);
     224    radone  = this->radius * (1.0-i*fact + 0.2 * (float)rand()/(float)RAND_MAX);
     225    radzero  = this->radius * (1.0-(i-1)*fact + 0.2 * (float)rand()/(float)RAND_MAX);
    226226
    227227    now   =  this->nodeList[i];
     
    236236    Q[3]  = now + Vector(0,-radone,0) ;
    237237
    238         glTexCoord2f(1.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[3].x,Q[3].y,Q[3].z+0.01f);
    239         glTexCoord2f(0.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[0].x,Q[0].y,Q[0].z+0.01f);
     238        glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x,Q[3].y,Q[3].z+0.01f);
     239        glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x,Q[0].y,Q[0].z+0.01f);
    240240
    241241    if( i == 1)
     
    243243        Q[1]  = later + Vector(0,radzero,0) ;
    244244        Q[2]  = later + Vector(0,-radzero,0) ;
    245                 glTexCoord2f(1.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[2].x,Q[2].y,Q[2].z+0.01f);
    246                 glTexCoord2f(0.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[1].x,Q[1].y,Q[1].z+0.01f);
     245
     246                glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x,Q[2].y,Q[2].z+0.01f);
     247                glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x,Q[1].y,Q[1].z+0.01f);
    247248        }
    248249
     
    254255  for( int i = 1; i < this->sections-1; i++)
    255256  {
    256     radone  = this->radius * (1.0-i*fact);
    257     radzero  = this->radius * (1.0-(i+1)*fact);
     257    radone  = this->radius * (1.0-i*fact + 0.2 * (float)rand()/(float)RAND_MAX);
     258    radzero  = this->radius * (1.0-(i+1)*fact + 0.2 * (float)rand()/(float)RAND_MAX);
    258259
    259260    now   =  this->nodeList[i];
     
    268269    Q[3]  = now + targ.cross(Vector(0,-radone,0)) ;
    269270   
    270         glTexCoord2f(0.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[0].x,Q[0].y,Q[0].z);
    271         glTexCoord2f(1.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[3].x,Q[3].y,Q[3].z);
     271        glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x,Q[0].y,Q[0].z);
     272        glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x,Q[3].y,Q[3].z);
    272273
    273274    if( i == this->sections-1)
     
    275276      Q[1]  = later + targ.cross(Vector(0,radzero,0)) ;
    276277      Q[2]  = later + targ.cross(Vector(0,-radzero,0)) ;
    277       glTexCoord2f(0.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[1].x,Q[1].y,Q[1].z);
    278       glTexCoord2f(1.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[2].x,Q[2].y,Q[2].z);
     278      glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x,Q[1].y,Q[1].z);
     279      glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x,Q[2].y,Q[2].z);
    279280    }
    280281
     
    285286  for( int i = this->sections-1; i > 0; i--)
    286287  {
    287     radone  = this->radius * (1.0-i*fact);
    288     radzero  = this->radius * (1.0-(i-1)*fact);
     288    radone  = this->radius * (1.0-i*fact + 0.2 * (float)rand()/(float)RAND_MAX);
     289    radzero  = this->radius * (1.0-(i-1)*fact + 0.2 * (float)rand()/(float)RAND_MAX);
    289290
    290291    now   =  this->nodeList[i];
     
    299300    Q[3]  = now + targ.cross(Vector(0,-radone,0)) ;
    300301
    301         glTexCoord2f(0.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[0].x+0.01f,Q[0].y,Q[0].z);
    302         glTexCoord2f(1.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[3].x+0.01f,Q[3].y,Q[3].z);
     302        glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x+0.01f,Q[0].y,Q[0].z);
     303        glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x+0.01f,Q[3].y,Q[3].z);
    303304
    304305    if( i == 1)
     
    306307        Q[1]  = later + targ.cross(Vector(0,radzero,0)) ;
    307308        Q[2]  = later + targ.cross(Vector(0,-radzero,0)) ;
    308                 glTexCoord2f(0.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[1].x+0.01f,Q[1].y,Q[1].z);
    309                 glTexCoord2f(1.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[2].x+0.01f,Q[2].y,Q[2].z);
     309
     310                glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x+0.01f,Q[1].y,Q[1].z);
     311                glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x+0.01f,Q[2].y,Q[2].z);
    310312        }
    311313
     
    316318  glPopMatrix();
    317319  glPopAttrib();
    318 /*
    319   //glTranslatef(this->getAbsCoor().x, this->getAbsCoor().y, this->getAbsCoor().z);
    320   //glTranslatef(0,0,0);
    321 
    322   const PNode* camera = State::getCameraNode();  //!< @todo MUST be different
    323   Vector cameraPos = camera->getAbsCoor();
    324   Vector cameraTargetPos = State::getCameraTargetNode()->getAbsCoor();
    325   Vector view = cameraTargetPos - cameraPos;
    326   Vector up = Vector(0, 1, 0);
    327   up = camera->getAbsDir().apply(up);
    328   Vector h = up.cross(view);
    329   Vector v = h.cross(view);
    330   h.normalize();
    331   v.normalize();
    332 
    333   v *= sizeX;
    334   h *= sizeY;
    335 
    336 //v += this->getAbsCoor();
    337     //PRINTF(0)("sizeX: %f sizeY: %f\n", sizeX, sizeY);
    338   glBegin(GL_QUADS);
    339   glTexCoord2f(0.0f, 0.0f);
    340   glVertex3f(this->getAbsCoor().x - h.x - v.x,
    341              this->getAbsCoor().y - h.y - v.y,
    342              this->getAbsCoor().z - h.z - v.z);
    343   glTexCoord2f(1.0f, 0.0f);
    344   glVertex3f( this->getAbsCoor().x + h.x - v.x,
    345               this->getAbsCoor().y + h.y - v.y,
    346               this->getAbsCoor().z + h.z - v.z);
    347   glTexCoord2f(1.0f, 1.0f);
    348   glVertex3f(this->getAbsCoor().x + h.x + v.x,
    349              this->getAbsCoor().y + h.y + v.y,
    350              this->getAbsCoor().z + h.z + v.z);
    351   glTexCoord2f(0.0f, 1.0f);
    352   glVertex3f(this->getAbsCoor().x - h.x + v.x,
    353              this->getAbsCoor().y - h.y + v.y,
    354              this->getAbsCoor().z - h.z + v.z);
    355   glEnd();
    356 
    357 
    358   glPopMatrix();
    359 
    360   glPopAttrib();*/
    361 }
     320}
  • branches/playability/src/world_entities/particles/emitter_node.cc

    r10098 r10107  
    2121
    2222#include "util/loading/load_param.h"
     23#include "util/loading/factory.h"
    2324#include "debug.h"
    2425
    2526ObjectListDefinition(EmitterNode);
     27//CREATE_FAST_FACTORY(EmitterNode);
    2628
    2729/**
     
    3234  this->registerObject(this, EmitterNode::_objectList);
    3335
     36  this->toList(OM_DEAD_TICK);
     37
    3438  this->system = NULL;
    3539  this->emitter = NULL;
    3640  this->lifeCycle = 0.0;
    3741  this->lifeSpan = lifetime;
     42
     43  this->setParent( PNode::getNullParent());
    3844}
    3945
     
    6470{
    6571  this->started  = true;
     72
     73  this->emitter->start();
     74  this->emitter->setSystem( this->system);
     75
    6676  return this->started;
    6777}
     
    6979void EmitterNode::tick(float dt)
    7080{
     81
    7182  if( !this->started)
    7283    return;
    7384
    7485  this->lifeCycle += dt/this->lifeSpan;
    75   if  (this->lifeCycle >= 1)
     86
     87  if( this->lifeCycle >= 1.0f)
    7688  {
    7789    this->removeNode();
    78     this->hide();
    79     this->system->removeEmitter(this->emitter);
    8090    this->emitter->stop();
    8191    this->emitter->setSystem(NULL);
    8292    this->started = false;
     93
     94    this->destroy( NULL );
    8395  }
    84   PRINTF(0)("Coordinate Update EmitterNode: (%f,%f,%f) -> (%f,%f,%f)\n",this->getAbsCoor().x,this->getAbsCoor().y,this->getAbsCoor().z,this->velocity.x,this->velocity.y,this->velocity.z);
    85   this->setAbsCoor(this->getAbsCoor() + (this->velocity * dt));
     96  this->shiftCoor(this->velocity * dt);
    8697}
  • branches/playability/src/world_entities/particles/emitter_node.h

    r10098 r10107  
    11/*!
    2  * @file particle_emitter.h
     2 * @file emitter_node.h
    33  *  Definition of a EmitterNode
    44  *  An emitter node is a node that takes an emitter and a particle system and keeps them alive for a given amount of time.
     
    3232  inline void setVelocity(Vector velocity) { this->velocity = velocity;};
    3333
    34   inline void setupParticle(DotEmitter* emitter, ParticleSystem* system) { this->emitter = emitter; this->system = system; this->system->setLifeSpan(this->lifeSpan);} ;
     34  inline void setupParticle(DotEmitter* emitter, ParticleSystem* system) { this->emitter = emitter; this->emitter->setParent( this); this->system = system;} ;
    3535  void setLifetime( float lifeTime) { this->lifeSpan  = lifeTime;};
    3636
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r10099 r10107  
    585585void SpaceShip::destroy( WorldEntity* killer )
    586586{
    587   PRINTF(0)("spaceship destroy\n");
     587  PRINTF(5)("spaceship destroy\n");
    588588 
    589589  EmitterNode* node  = NULL;
     
    591591  SpriteParticles*  explosionParticles  = NULL;
    592592
    593   explosionParticles = new SpriteParticles(100);
    594   explosionParticles->setName("MBoltExplosionParticles");
    595   explosionParticles->setLifeSpan(.5, .3);
     593  explosionParticles = new SpriteParticles(200);
     594  explosionParticles->setName("SpaceShipExplosionParticles");
     595  explosionParticles->setLifeSpan(.2, .3);
    596596  explosionParticles->setRadius(0.0, 10.0);
    597597  explosionParticles->setRadius(.5, 6.0);
     
    600600  explosionParticles->setColor(0.1,  1,1,0,.9);
    601601  explosionParticles->setColor(0.5, .8,.4,0,.5);
    602   explosionParticles->setColor(1.0, .2,.2,.2,.0);
    603 
    604  
    605   emitter = new DotEmitter( 200, 200, M_2_PI);
    606   emitter->setSpread( 0, M_2_PI);
    607   emitter->setEmissionRate( 400.0);
     602  explosionParticles->setColor(1.0, .2,.2,.2,.5);
     603
     604 
     605  emitter = new DotEmitter( 2000, 70, 360);
     606  //emitter->setSpread( 0, M_2_PI);
     607  emitter->setEmissionRate( 200.0);
    608608  //emitter->setEmissionVelocity( 200.0);
    609   emitter->setSystem( explosionParticles);
    610   emitter->setAbsCoor( this->getAbsCoor());
    611 
    612   node  = new EmitterNode( 1);
     609  //emitter->setSystem( explosionParticles);
     610  //emitter->setAbsCoor( this->getAbsCoor());
     611
     612  node  = new EmitterNode( .1f);
    613613  node->setupParticle( emitter, explosionParticles);
    614   node->setVelocity( this->getParent()->getVelocity());
     614  node->setAbsDir( this->getAbsDir());
     615  node->setVelocity( this->getVelocity() * .9f);
    615616  node->setAbsCoor( this->getAbsCoor());
    616   node->start();
     617  if( !node->start())
     618    PRINTF(0)("Explosion node not correctly started!");
     619
    617620/*
    618621  PNode* node          = new PNode();
     
    621624  explosion->explode( node, Vector(5,5,5));
    622625*/
    623   this->setAbsCoor(Vector(-10000,10000,10000));
    624   //this->hide();
    625 
    626   this->toList( OM_DEAD);
    627   PRINTF(0)("spaceship destroy == ship translated \n");
     626
     627  if( this->hasPlayer())
     628  {
     629        this->setAbsCoor(Vector(-10000,10000,10000));
     630        this->hide();
     631  }
     632  else
     633  {
     634    this->setAbsCoor( this->getAbsCoor() + Vector(150,0,0) + Vector(1,0,0) * VECTOR_RAND(50).dot(Vector(1,0,0)));
     635  }
     636
    628637}
    629638
    630639void SpaceShip::respawn( )
    631640{
    632   //this->unhide();
     641  this->unhide();
    633642  /*for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++)
    634643  {
  • branches/playability/src/world_entities/weapons/swarm_launcher.cc

    r10104 r10107  
    145145void SwarmLauncher::fire()
    146146{
     147  bool fired  = false;
     148
    147149  Projectile* pj = NULL;
    148150  for( ObjectList<Playable>::const_iterator eIterator = Playable::objectList().begin(); eIterator !=Playable::objectList().end(); eIterator++)
     
    153155      if (pj == NULL)
    154156        return;
    155 
     157     
     158      fired = true;
    156159      pj->setVelocity(this->getVelocity()+(this->getAbsDir().apply(Vector(1,0,0))*115.0 + VECTOR_RAND(10)));
    157160
     
    164167    }
    165168  }
     169  if( !fired)
     170    this->increaseEnergy( this->getProjectile()->getMinEnergy());
    166171}
  • branches/playability/src/world_entities/world_entity.h

    r10102 r10107  
    148148  void increaseHealthMax(float increaseHealth);
    149149  OrxGui::GLGuiWidget* getHealthWidget();
    150   bool hasHealthWidget() const { return this->healthWidget; };
     150  bool hasHealthWidget() const { return this->healthWidget != NULL; };
    151151
    152152  virtual void varChangeHandler( std::list<int> & id );
Note: See TracChangeset for help on using the changeset viewer.