Changeset 3932 in orxonox.OLD for orxonox/branches/particleEngine/src/lib/graphics/particles/particle_system.cc
- Timestamp:
- Apr 23, 2005, 12:42:09 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/particleEngine/src/lib/graphics/particles/particle_system.cc
r3931 r3932 20 20 #include "particle_emitter.h" 21 21 #include "particle_engine.h" 22 #include "compiler.h" 22 23 23 24 using namespace std; … … 36 37 37 38 this->particleType = type; 39 this->particles = NULL; 40 this->conserve = 1.0; 41 this->setLifeSpan(5.0); 42 43 ParticleEngine::getInstance()->addSystem(this); 38 44 } 39 45 … … 43 49 44 50 */ 45 ParticleSystem::~ParticleSystem 51 ParticleSystem::~ParticleSystem() 46 52 { 47 53 // delete what has to be deleted here 48 54 } 49 55 56 // setting properties 57 void ParticleSystem::setMaterial(Material* material) 58 { 59 60 } 61 62 void ParticleSystem::setLifeSpan(float lifeSpan, float randomLifeSpan) 63 { 64 65 } 66 67 void ParticleSystem::setRadius(float startRadius, float endRadius, float randomRadius) 68 { 69 70 } 71 72 void ParticleSystem::setConserve(float conserve) 73 { 74 this->conserve = conserve; 75 } 76 77 50 78 51 79 void ParticleSystem::tick(float dt) 52 80 { 81 Particle* tmpPart = particles; 82 while (likely(tmpPart != NULL)) 83 { 84 tmpPart->position = tmpPart->position + tmpPart->velocity; 85 86 // many more to come 87 88 tmpPart = tmpPart->next; 89 } 90 } 91 92 void ParticleSystem::draw(void) 93 { 94 Particle* tmpPart = particles; 95 if (likely(tmpPart != NULL)) 96 { 97 glBegin(GL_POINTS); 98 while (likely(tmpPart != NULL)) 99 { 100 // draw in DOT mode 101 glVertex3f(tmpPart->position.x, tmpPart->position.y, tmpPart->position.z); 102 103 104 tmpPart = tmpPart->next; 105 } 106 glEnd(); 107 } 108 } 109 110 111 void ParticleSystem::addParticle(Vector position, Vector velocity, unsigned int data) 112 { 113 // if it is the first Particle 114 if (unlikely(particles == NULL)) 115 { 116 this->particles = new Particle; 117 this->particles->next = NULL; 118 } 119 // filling the List from the beginning 120 else 121 { 122 Particle* tmpPart = new Particle; 123 tmpPart->next = this->particles; 124 this->particles = tmpPart; 125 } 53 126 127 particles->timeToLive = this->lifeSpan + (float)(random()/RAND_MAX)* this->randomLifeSpan; 128 particles->position = position; 129 particles->velocity = velocity; 130 // particle->rotation = ; //! \todo rotation is once again something to be done. 131 particles->mass = this->initialMass + (random()/RAND_MAX)* this->randomInitialMass; 132 particles->radius = this->startRadius + (random()/RAND_MAX)*this->randomRadius; 133 } 54 134 55 }
Note: See TracChangeset
for help on using the changeset viewer.