Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6826 in orxonox.OLD


Ignore:
Timestamp:
Jan 29, 2006, 1:35:43 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: ok, the Cube Emitter works

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/particles/box_emitter.cc

    r6825 r6826  
    8181}
    8282
     83void BoxEmitter::setSize(float x, float y, float z)
     84{
     85  this->size = Vector (x,y,z);
     86}
     87
     88
    8389void BoxEmitter::emitParticles(unsigned int count) const
    8490{
    8591  Vector inheritVelocity = this->getVelocity() * this->inheritSpeed;
     92
     93  Vector xDir = this->getAbsDirX() * this->size.x;
     94  Vector yDir = this->getAbsDirY() * this->size.y;
     95  Vector zDir = this->getAbsDirZ() * this->size.z;
    8696
    8797  for (unsigned int i = 0; i < count; i++)
     
    92102    Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity;
    93103
    94     Vector extension = Vector(((float)rand()/RAND_MAX -.5)*this->size.x,
    95                               ((float)rand()/RAND_MAX -.5) *this->size.y,
    96                               ((float)rand()/RAND_MAX -.5) * this->size.z);
    97 
     104    Vector box = this->getAbsCoor() +
     105        xDir * ((float)rand()/RAND_MAX -.5) +
     106        yDir * ((float)rand()/RAND_MAX -.5) +
     107        zDir * ((float)rand()/RAND_MAX -.5);
    98108
    99109    // ROTATIONAL CALCULATION (this must not be done for all types of particles.)
     
    103113    Quaternion moment = Quaternion(this->momentum + this->momentumRandom, randDir);
    104114
    105     this->getSystem()->addParticle(this->getAbsCoor() + extension, velocityV, orient, moment);
     115    this->getSystem()->addParticle(box, velocityV, orient, moment);
    106116
    107117  }
  • trunk/src/lib/particles/box_emitter.h

    r6825 r6826  
    1111#define BOX_EMITTER_DEFAULT_SIZE Vector(1.0f, 1.0f, 1.0f)
    1212
    13 //! A class to handle an Emitter.
     13//! A class to handle a Box Emitter.
     14/**
     15 * A Box Emitter is a special kind of emitter, that has the (underlying) PNode
     16 * at its center, and from there on is a Box in the Direction of the PNode
     17 * out around size in the corresponding directions
     18 */
    1419class BoxEmitter : public ParticleEmitter
    1520{
  • trunk/src/world_entities/projectiles/hyperblast.cc

    r6825 r6826  
    2323#include "class_list.h"
    2424
    25 #include "dot_emitter.h"
    26 #include "sprite_particles.h"
     25#include "box_emitter.h"
    2726#include "spark_particles.h"
    2827
     
    4746  this->size = 4.0;
    4847
    49   this->emitter = new DotEmitter(100, 5, M_2_PI);
     48  this->emitter = new BoxEmitter(Vector(400, 2, 2), 100, 5, M_2_PI);
     49  this->emitter->setRelCoor(200,0,0);
    5050  this->emitter->setParent(this);
    5151  this->emitter->setSpread(M_PI, M_PI);
     
    141141  glPushMatrix();
    142142
    143   float matrix[4][4];
    144   glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
    145   this->getAbsDir().matrix (matrix);
    146   glMultMatrixf((float*)matrix);
    147   glScalef(2.0, this->size, this->size);
    148   this->getModel()->draw();
     143  glTranslatef (this->getAbsCoor ().x,
     144                this->getAbsCoor ().y,
     145                this->getAbsCoor ().z);
     146  Vector tmpRot = this->getAbsDir().getSpacialAxis();
     147  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     148
     149//  glScalef(2.0, this->size, this->size);
     150//  this->getModel()->draw();
    149151
    150152  glPopMatrix();
Note: See TracChangeset for help on using the changeset viewer.