Changeset 3935 in orxonox.OLD for orxonox/branches
- Timestamp:
- Apr 23, 2005, 3:30:45 AM (20 years ago)
- Location:
- orxonox/branches/particleEngine/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/particleEngine/src/lib/graphics/particles/particle_emitter.cc
r3934 r3935 19 19 20 20 #include "particle_system.h" 21 #include "particle_engine.h" 21 22 22 23 using namespace std; … … 33 34 this->setSpread(angle); 34 35 this->setEmissionRate(emissionRate); 35 this-> velocity = velocity;36 this->setVelocity(velocity); 36 37 37 38 this->saveTime = 0.0; 39 40 ParticleEngine::getInstance()->addEmitter(this); 38 41 } 39 42 … … 45 48 */ 46 49 ParticleEmitter::~ParticleEmitter () 47 {} 50 { 51 ParticleEngine::getInstance()->removeEmitter(this); 52 53 } 48 54 49 55 … … 85 91 */ 86 92 void ParticleEmitter::setSpread(float angle, float randomAngle) 87 { }88 89 90 93 { 94 this->angle = angle; 95 this->randomAngle = randomAngle; 96 } 91 97 92 98 /** … … 98 104 you may want to use the animation class 99 105 */ 100 void ParticleEmitter::setVelocity(float velocity, float random) 101 {} 106 void ParticleEmitter::setVelocity(float velocity, float randomVelocity) 107 { 108 this->velocity = velocity; 109 this->randomVelocity = randomVelocity; 110 } 102 111 103 112 /** … … 116 125 this->saveTime /= this->emissionRate; 117 126 127 118 128 for (int i = 0; i <= count; i++) 119 129 // emmits from EMITTER_DOT, 120 130 { 121 Vector randDir = Quaternion(Vector(random()-RAND_MAX/2, random()-RAND_MAX/2, random()-RAND_MAX/2), angle).apply(this->direction); 131 Vector randDir = Vector(random()-RAND_MAX/2, random()-RAND_MAX/2, random()-RAND_MAX/2); 132 randDir.normalize(); 133 randDir = Quaternion(angle + randomAngle *((float)random()/RAND_MAX -.5), randDir).apply(this->direction); 122 134 randDir.normalize(); 123 135 system->addParticle(this->getAbsCoor(), randDir* velocity); -
orxonox/branches/particleEngine/src/lib/graphics/particles/particle_emitter.h
r3932 r3935 22 22 23 23 public: 24 ParticleEmitter(const Vector& direction, float angle = 20.0, float emissionRate = 1.0,24 ParticleEmitter(const Vector& direction, float angle = .5, float emissionRate = 1.0, 25 25 float velocity = 1.0); 26 26 virtual ~ParticleEmitter(void); … … 34 34 void setEmissionRate(float emissionRate); 35 35 void setSpread(float angle, float randomAngle = 0.0); 36 void setVelocity(float velocity, float random = 0.0);36 void setVelocity(float velocity, float randomVelocity = 0.0); 37 37 38 38 private: 39 39 Vector direction; //!< emition direction 40 40 float angle; //!< max angle from the direction of the emitter 41 float angleRandom; //!< random emission angle (angle +- angleRandom is the emitted angle. 42 float emissionRate; //!< amount of particles per seconds emitted by emiter 43 float velocity; //!< the contant speed a particle gets if been emitted 41 float randomAngle; //!< random emission angle (angle +- angleRandom is the emitted angle. 42 float emissionRate; //!< amount of particles per seconds emitted by emitter. 43 float velocity; //!< the initial speed of a Particles. 44 float randomVelocity; //!< the random variation from the initial Speed. 44 45 45 46 float saveTime; //!< The time that was missing by the last Tick (otherwise there would be no emission when framefate is too big). -
orxonox/branches/particleEngine/src/lib/graphics/particles/particle_engine.cc
r3932 r3935 33 33 34 34 this->systemList = new tList<ParticleSystem>; 35 35 this->emitterList = new tList<ParticleEmitter>; 36 36 this->connectionList = new tList<ParticleConnection>; 37 37 } … … 70 70 } 71 71 72 void ParticleEngine::addEmitter(ParticleEmitter* emitter) 73 { 74 this->emitterList->add(emitter); 75 } 72 76 73 77 /** … … 83 87 84 88 this->connectionList->add(tmpCon); 89 } 90 91 92 bool ParticleEngine::removeSystem(ParticleSystem* system) 93 { 94 this->systemList->remove(system); 95 96 } 97 98 bool ParticleEngine::removeEmitter(ParticleEmitter* emitter) 99 { 100 this->emitterList->remove(emitter); 85 101 } 86 102 -
orxonox/branches/particleEngine/src/lib/graphics/particles/particle_system.cc
r3934 r3935 40 40 this->particleType = type; 41 41 this->particles = NULL; 42 this-> conserve = 1.0;42 this->setConserve(.8); 43 43 this->setLifeSpan(.1); 44 44 … … 54 54 { 55 55 // delete what has to be deleted here 56 ParticleEngine::getInstance()->removeSystem(this); 56 57 } 57 58 … … 59 60 void ParticleSystem::setMaterial(Material* material) 60 61 { 61 62 this->material = material; 62 63 } 63 64 … … 70 71 void ParticleSystem::setRadius(float startRadius, float endRadius, float randomRadius) 71 72 { 72 73 this->startRadius = startRadius; 74 this->endRadius = endRadius; 75 this->randomRadius = randomRadius; 73 76 } 74 77 75 78 void ParticleSystem::setConserve(float conserve) 76 79 { 77 this->conserve = conserve; 80 if (conserve > 1.0) 81 this->conserve = 1.0; 82 else if (conserve < 0.0) 83 this->conserve = 0.0; 84 else 85 this->conserve = conserve; 78 86 } 79 87 … … 86 94 while (likely(tickPart != NULL)) 87 95 { 88 96 89 97 tickPart->position = tickPart->position + tickPart->velocity; 90 98 // many more to come … … 94 102 95 103 96 104 if (this->conserve < 1.0) 105 tickPart->velocity = tickPart->velocity * this->conserve; 97 106 // find out if we have to delete tickPart 98 107 if ((tickPart->timeToLive -= dt) <= 0) … … 113 122 } 114 123 --this->count; 115 printf("deleted particle: count %d\n", count);116 124 } 117 125 else … … 128 136 if (likely(drawPart != NULL)) 129 137 { 130 glBegin(GL_ TRIANGLES);138 glBegin(GL_POINTS); 131 139 while (likely(drawPart != NULL)) 132 140 { -
orxonox/branches/particleEngine/src/story_entities/world.cc
r3934 r3935 377 377 this->glmis->step(); 378 378 379 testEmitter = new ParticleEmitter(Vector( 1,0,0), 0.0, 124.0, .1);379 testEmitter = new ParticleEmitter(Vector(-1,0,0), .1, 12400.0, 1); 380 380 testEmitter->setParent(localPlayer); 381 testEmitter->setSpread(.5, .1); 381 382 testSystem = new ParticleSystem(100000); 383 testSystem->setLifeSpan(3); 384 testSystem->setConserve(.8); 382 385 383 386 ParticleEngine::getInstance()->addConnection(testEmitter, testSystem);
Note: See TracChangeset
for help on using the changeset viewer.