Changeset 6823 in orxonox.OLD for trunk/src/lib/particles/box_emitter.cc
- Timestamp:
- Jan 29, 2006, 2:20:46 AM (18 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/particles/box_emitter.cc
r6822 r6823 16 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS 17 17 18 #include " dot_emitter.h"18 #include "box_emitter.h" 19 19 20 20 #include "particle_system.h" … … 28 28 29 29 30 CREATE_FACTORY( DotEmitter, CL_DOT_EMITTER);30 CREATE_FACTORY(BoxEmitter, CL_BOX_EMITTER); 31 31 32 32 /** 33 33 * standard constructor 34 34 */ 35 DotEmitter::DotEmitter(const Vector& direction, float angle, float emissionRate, 36 float velocity) 37 : ParticleEmitter(direction, angle, emissionRate, velocity) 35 BoxEmitter::BoxEmitter(const Vector& size) 38 36 { 39 37 this->init(); 38 this->setSize(size); 40 39 } 41 40 42 41 /** 43 * constructs and loads a DotEmitter from a XML-element42 * constructs and loads a BoxEmitter from a XML-element 44 43 * @param root the XML-element to load from 45 44 */ 46 DotEmitter::DotEmitter(const TiXmlElement* root)47 : ParticleEmitter()45 BoxEmitter::BoxEmitter(const TiXmlElement* root) 46 : ParticleEmitter() 48 47 { 49 48 this->init(); 50 49 51 52 50 if (root != NULL) 51 this->loadParams(root); 53 52 } 54 53 … … 58 57 removes the EmitterSystem from the ParticleEngine 59 58 */ 60 DotEmitter::~DotEmitter ()59 BoxEmitter::~BoxEmitter () 61 60 { 62 61 this->setSystem(NULL); … … 66 65 @brief initializes default values of a ParitcleEmitter 67 66 */ 68 void DotEmitter::init()67 void BoxEmitter::init() 69 68 { 70 this->setClassID(CL_DOT_EMITTER, "DotEmitter"); 69 this->setClassID(CL_BOX_EMITTER, "BoxEmitter"); 70 this->setSize(1.0f,1.0f,1.0f); 71 71 } 72 72 73 void DotEmitter::emitParticles(unsigned int count) const 73 void BoxEmitter::loadParams(const TiXmlElement* root) 74 { 75 ParticleEmitter::loadParams(root); 76 77 LoadParam(root, "size", this, BoxEmitter, setSize) 78 .describe("The Size of the BoxEmitter: x, y, z") 79 .defaultValues(3, 1.0f,1.0f,1.0f); 80 } 81 82 void BoxEmitter::emitParticles(unsigned int count) const 74 83 { 75 84 Vector inheritVelocity = this->getVelocity() * this->inheritSpeed; … … 82 91 Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity; 83 92 93 Vector extension = Vector(((float)rand()/RAND_MAX -.5)*this->size.x, 94 ((float)rand()/RAND_MAX -.5) *this->size.y, 95 ((float)rand()/RAND_MAX -.5) * this->size.z); 96 97 84 98 // ROTATIONAL CALCULATION (this must not be done for all types of particles.) 85 99 randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2); … … 88 102 Quaternion moment = Quaternion(this->momentum + this->momentumRandom, randDir); 89 103 90 this->getSystem()->addParticle(this->getAbsCoor() , velocityV, orient, moment);104 this->getSystem()->addParticle(this->getAbsCoor() + extension, velocityV, orient, moment); 91 105 92 106 }
Note: See TracChangeset
for help on using the changeset viewer.