Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6873 in orxonox.OLD


Ignore:
Timestamp:
Jan 30, 2006, 10:43:00 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: Emitter is emitting correctly

Location:
trunk/src
Files:
5 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r6630 r6873  
    6060                lib/particles/spark_particles.cc \
    6161                lib/particles/sprite_particles.cc \
     62                lib/particles/plane_emitter.cc \
    6263                \
    6364                subprojects/benchmark.cc
  • trunk/src/defs/class_id.h

    r6832 r6873  
    269269
    270270  // Particles
    271   CL_PARTICLE_EMITTER           =    0x00a01000,
    272   CL_PARTICLE_SYSTEM            =    0x00a02000,
     271  CL_PARTICLE_SYSTEM            =    0x00a01000,
    273272  CL_SPRITE_PARTICLES           =    0x00000a01,
    274273  CL_SPARK_PARTICLES            =    0x00000a02,
     
    276275  CL_DOT_PARTICLES              =    0x00000a04,
    277276  CL_MODEL_PARTICLES            =    0x00000a05,
    278   CL_DOT_EMITTER                =    0x00000a06,
    279   CL_BOX_EMITTER                =    0x00000a07,
    280   CL_SPHERE_EMITTER             =    0x00000a08,
    281   CL_MODEL_EMITTER              =    0x00000a09,
     277
     278  CL_PARTICLE_EMITTER           =    0x00a02000,
     279  CL_DOT_EMITTER                =    0x00000a21,
     280  CL_PLANE_EMITTER              =    0x00000a22,
     281  CL_BOX_EMITTER                =    0x00000a23,
     282  CL_SPHERE_EMITTER             =    0x00000a24,
     283  CL_MODEL_EMITTER              =    0x00000a25,
    282284
    283285
  • trunk/src/lib/coord/p_node.cc

    r6815 r6873  
    139139
    140140  LoadParam(root, "parent", this, PNode, setParent)
    141       .describe("the Name of the Parent of this PNode");
     141      .describe("the Name of the Parent to set for this PNode");
    142142
    143143  LoadParam(root, "parent-mode", this, PNode, setParentMode)
     
    355355 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
    356356 */
    357 void PNode::setRelDir (float x, float y, float z)
    358 {
    359   this->setRelDir(Quaternion(Vector(x,y,z), Vector(0,1,0)));
     357void PNode::setRelDir (float angle, float x, float y, float z)
     358{
     359  this->setRelDir(Quaternion(angle, Vector(x,y,z)));
    360360}
    361361
     
    386386 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
    387387 */
    388 void PNode::setRelDirSoft(float x, float y, float z, float bias)
    389 {
    390   this->setRelDirSoft(Quaternion(Vector(x,y,z), Vector(0,1,0)), bias);
     388void PNode::setRelDirSoft(float angle, float x, float y, float z, float bias)
     389{
     390  this->setRelDirSoft(Quaternion(angle, Vector(x,y,z)), bias);
    391391}
    392392
     
    421421 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
    422422 */
    423 void PNode::setAbsDir (float x, float y, float z)
    424 {
    425   this->setAbsDir(Quaternion(Vector(x,y,z), Vector(0,1,0)));
     423void PNode::setAbsDir (float angle, float x, float y, float z)
     424{
     425  this->setAbsDir(Quaternion(angle, Vector(x,y,z)));
    426426}
    427427
     
    456456 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
    457457 */
    458 void PNode::setAbsDirSoft (float x, float y, float z, float bias)
    459 {
    460   this->setAbsDirSoft(Quaternion(Vector(x,y,z), Vector(0,1,0)), bias);
     458void PNode::setAbsDirSoft (float angle, float x, float y, float z, float bias)
     459{
     460  this->setAbsDirSoft(Quaternion(angle, Vector(x,y,z)), bias);
    461461}
    462462
     
    13191319       fabs( rotz - absDirection.v.z ) > __OFFSET_ROT )
    13201320    return true;
    1321  
     1321
    13221322  return false;
    13231323}
  • trunk/src/lib/coord/p_node.h

    r6815 r6873  
    115115  // ROTATION //
    116116  void setRelDir (const Quaternion& relDir);
    117   void setRelDir (float x, float y, float z);
     117  void setRelDir (float angle, float x, float y, float z);
    118118  void setRelDirSoft(const Quaternion& relDirSoft, float bias = 1.0);
    119   void setRelDirSoft(float x, float y, float z, float bias = 1.0);
     119  void setRelDirSoft(float angle, float x, float y, float z, float bias = 1.0);
    120120  /** @returns the relative Direction */
    121121  inline const Quaternion& getRelDir () const { return this->prevRelDirection; };
     
    125125  inline Vector getRelDirV() const { return this->prevRelDirection.apply(Vector(0,1,0)); };
    126126  void setAbsDir (const Quaternion& absDir);
    127   void setAbsDir (float x, float y, float z);
     127  void setAbsDir (float angle, float x, float y, float z);
    128128  void setAbsDirSoft(const Quaternion& absDirSoft, float bias = 1.0);
    129   void setAbsDirSoft(float x, float y, float z, float bias = 1.0);
     129  void setAbsDirSoft(float angle, float x, float y, float z, float bias = 1.0);
    130130  void shiftDir (const Quaternion& shift);
    131131  /** @returns the absolute Direction */
  • trunk/src/lib/particles/Makefile.am

    r6823 r6873  
    88                        dot_emitter.cc \
    99                        box_emitter.cc \
     10                        plane_emitter.cc \
    1011                        \
    1112                        particle_system.cc \
     
    2223                        dot_emitter.h \
    2324                        box_emitter.h \
     25                        plane_emitter.h \
    2426                        \
    2527                        particle_system.h \
  • trunk/src/lib/particles/plane_emitter.cc

    r6870 r6873  
    1616#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
    1717
    18 #include "box_emitter.h"
     18#include "plane_emitter.h"
    1919
    2020#include "particle_system.h"
     
    2828
    2929
    30 CREATE_FACTORY(BoxEmitter, CL_BOX_EMITTER);
     30CREATE_FACTORY(PlaneEmitter, CL_PLANE_EMITTER);
    3131
    3232/**
    3333 *  standard constructor
    3434*/
    35 BoxEmitter::BoxEmitter(const Vector& size, float emissionRate, float velocity, float angle)
     35PlaneEmitter::PlaneEmitter(const Vector2D& size, float emissionRate, float velocity, float angle)
    3636    :  ParticleEmitter(emissionRate, velocity, angle)
    3737{
     
    4141
    4242/**
    43  *  constructs and loads a BoxEmitter from a XML-element
     43 *  constructs and loads a PlaneEmitter from a XML-element
    4444 * @param root the XML-element to load from
    4545*/
    46 BoxEmitter::BoxEmitter(const TiXmlElement* root)
     46PlaneEmitter::PlaneEmitter(const TiXmlElement* root)
    4747    : ParticleEmitter()
    4848{
     
    5858   removes the EmitterSystem from the ParticleEngine
    5959*/
    60 BoxEmitter::~BoxEmitter ()
     60PlaneEmitter::~PlaneEmitter ()
    6161{
    6262  this->setSystem(NULL);
     
    6666  @brief initializes default values of a ParitcleEmitter
    6767*/
    68 void BoxEmitter::init()
     68void PlaneEmitter::init()
    6969{
    70   this->setClassID(CL_BOX_EMITTER, "BoxEmitter");
    71   this->setSize(1.0f,1.0f,1.0f);
     70  this->setClassID(CL_PLANE_EMITTER, "PlaneEmitter");
     71  this->setSize(1.0f, 1.0f);
    7272}
    7373
    74 void BoxEmitter::loadParams(const TiXmlElement* root)
     74void PlaneEmitter::loadParams(const TiXmlElement* root)
    7575{
    7676  ParticleEmitter::loadParams(root);
    7777
    78   LoadParam(root, "size", this, BoxEmitter, setSize)
    79   .describe("The Size of the BoxEmitter: x, y, z")
    80   .defaultValues(3, 1.0f,1.0f,1.0f);
     78  LoadParam(root, "size", this, PlaneEmitter, setSize)
     79  .describe("The Size of the PlaneEmitter: x, y")
     80  .defaultValues(2, 1.0f,1.0f);
    8181}
    8282
    83 void BoxEmitter::setSize(float x, float y, float z)
     83void PlaneEmitter::setSize(float x, float y)
    8484{
    85   this->size = Vector (x,y,z);
     85  this->size = Vector2D(x, y);
    8686}
    8787
    8888
    89 void BoxEmitter::emitParticles(unsigned int count) const
     89void PlaneEmitter::emitParticles(unsigned int count) const
    9090{
    9191  Vector inheritVelocity = this->getVelocity() * this->inheritSpeed;
    9292
    9393  Vector xDir = this->getAbsDirX() * this->size.x;
    94   Vector yDir = this->getAbsDirY() * this->size.y;
    95   Vector zDir = this->getAbsDirZ() * this->size.z;
     94  Vector yDir = this->getAbsDirZ() * this->size.y;
     95  Vector zDir = this->getAbsDirY();
    9696
    9797  for (unsigned int i = 0; i < count; i++)
     
    9999    Vector randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2);
    100100    randDir.normalize();
    101     randDir = (Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->getAbsDirX());
     101    randDir = (Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(zDir);
    102102    Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity;
    103103
    104     Vector box = this->getAbsCoor() +
     104    Vector plane = this->getAbsCoor() +
    105105        xDir * ((float)rand()/RAND_MAX -.5) +
    106         yDir * ((float)rand()/RAND_MAX -.5) +
    107         zDir * ((float)rand()/RAND_MAX -.5);
     106        yDir * ((float)rand()/RAND_MAX -.5);
    108107
    109108    // ROTATIONAL CALCULATION (this must not be done for all types of particles.)
     
    113112    Quaternion moment = Quaternion(this->momentum + this->momentumRandom, randDir);
    114113
    115     this->getSystem()->addParticle(box, velocityV, orient, moment);
     114    this->getSystem()->addParticle(plane, velocityV, orient, moment);
    116115
    117116  }
  • trunk/src/lib/particles/plane_emitter.h

    r6870 r6873  
    11/*!
    2  * @file box_emitter.h
    3  *  Definition of a BoxEmitter
     2 * @file plane_emitter.h
     3 * Definition of a PlaneEmitter
    44 */
    55
    6 #ifndef _BOX_EMITTER_H
    7 #define _BOX_EMITTER_H
     6#ifndef _PLANE_EMITTER_H
     7#define _PLANE_EMITTER_H
    88
    99#include "particle_emitter.h"
    1010
    11 #define BOX_EMITTER_DEFAULT_SIZE Vector(1.0f, 1.0f, 1.0f)
     11#include "vector2D.h"
    1212
    13 //! A class to handle a Box Emitter.
     13#define PLANE_EMITTER_DEFAULT_SIZE Vector2D(1.0f, 1.0f)
     14
     15//! A class to handle a Plane Emitter.
    1416/**
    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
     17 * A Plane Emitter is a special kind of emitter, that has the (underlying) PNode
     18 * at its center, and from there on is a Plane in the Direction of the PNode
     19 * out around size in the corresponding directions in x and z
    1820 */
    19 class BoxEmitter : public ParticleEmitter
     21class PlaneEmitter : public ParticleEmitter
    2022{
    2123  friend class ParticleSystem;
    2224public:
    23   BoxEmitter(const Vector& size = BOX_EMITTER_DEFAULT_SIZE,
     25  PlaneEmitter(const Vector2D& size = PLANE_EMITTER_DEFAULT_SIZE,
    2426             float emissionRate = PARTICLE_EMITTER_DEFAULT_EMISSION_RATE,
    2527             float velocity = PARTICLE_EMITTER_DEFAULT_VELOCITY,
    2628             float angle = PARTICLE_EMITTER_DEFAULT_SPREAD);
    27   BoxEmitter(const TiXmlElement* root);
    28   virtual ~BoxEmitter();
     29  PlaneEmitter(const TiXmlElement* root);
     30  virtual ~PlaneEmitter();
    2931
    3032  virtual void loadParams(const TiXmlElement* root);
    3133
    32   void setSize(float x, float y, float z);
    33   void setSize(const Vector& size) { this->setSize(size.x, size.y, size.z); };
     34  void setSize(float x, float y);
     35  void setSize(const Vector2D& size) { this->setSize(size.x, size.y); };
    3436
    3537protected:
     
    4042
    4143private:
    42   Vector      size;
     44  Vector2D      size;
    4345};
    4446
    45 #endif /* _BOX_EMITTER_H */
     47#endif /* _PLANE_EMITTER_H */
Note: See TracChangeset for help on using the changeset viewer.