Changeset 3942 in orxonox.OLD for orxonox/branches/particleEngine/src/lib/graphics/particles/particle_system.cc
- Timestamp:
- Apr 23, 2005, 1:28:24 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/particleEngine/src/lib/graphics/particles/particle_system.cc
r3938 r3942 21 21 #include "particle_engine.h" 22 22 #include "compiler.h" 23 #include "material.h" 23 24 24 25 using namespace std; 25 26 26 27 27 /** … … 43 43 this->setLifeSpan(.1); 44 44 this->setInheritSpeed(0); 45 45 this->glID = NULL; 46 this->setRadius(1.0, 1.0, 0.0); 47 this->setType(PARTICLE_SPRITE, 1); 46 48 ParticleEngine::getInstance()->addSystem(this); 47 49 } … … 58 60 } 59 61 62 63 void ParticleSystem::setType(PARTICLE_TYPE particleType, int count) 64 { 65 this->particleType = particleType; 66 this->dialectCount = count; 67 if (glID != NULL) 68 delete glID; 69 70 glID = new GLuint[count]; 71 for (int i = 0; i< count; i++) 72 glID[i] = 0; 73 74 glID[0] = glGenLists(count); 75 76 material = new Material("transperencyMap"); 77 material->setDiffuseMap("pictures/radialTransparency.jpg"); 78 79 glNewList(glID[0], GL_COMPILE); 80 glBegin(GL_TRIANGLE_STRIP); 81 glTexCoord2f(1, 1); 82 glVertex3f(0.0, 1.0, 1.0); 83 glTexCoord2f(1, 0); 84 glVertex3f(0.0, 1.0, 0.0); 85 glTexCoord2f(0, 1); 86 glVertex3f(0.0, 0.0, 1.0); 87 glTexCoord2f(0, 0); 88 glVertex3f(0.0, 0.0, 0.0); 89 glEnd(); 90 glEndList(); 91 92 93 94 } 95 60 96 // setting properties 61 97 void ParticleSystem::setMaterial(Material* material) … … 63 99 this->material = material; 64 100 } 101 65 102 66 103 … … 90 127 } 91 128 92 void ParticleSystem::setRadius(float startRadius, float endRadius, float random Radius)129 void ParticleSystem::setRadius(float startRadius, float endRadius, float randomStartRadius, float randomEndRadius) 93 130 { 94 131 this->startRadius = startRadius; 95 132 this->endRadius = endRadius; 96 this->randomRadius = randomRadius; 133 this->randomStartRadius = randomStartRadius; 134 this->randomEndRadius = randomEndRadius; 97 135 } 98 136 … … 117 155 118 156 tickPart->position = tickPart->position + tickPart->velocity; 119 tickPart->radius + tickPart->radiusIt * dt; 157 tickPart->radius += tickPart->radiusIt * dt; 158 120 159 // many more to come 121 160 … … 153 192 void ParticleSystem::draw(void) 154 193 { 194 // material->select(); 195 196 197 glMatrixMode(GL_MODELVIEW); 198 155 199 Particle* drawPart = particles; 156 200 if (likely(drawPart != NULL)) … … 160 204 { 161 205 // draw in DOT mode 162 glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z); 206 glPushMatrix(); 207 glTranslatef(drawPart->position.x, drawPart->position.y, drawPart->position.z); 208 glScalef(drawPart->radius, drawPart->radius, drawPart->radius); 209 glCallList(*this->glID); 163 210 164 211 // glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z); 165 212 drawPart = drawPart->next; 213 glPopMatrix(); 166 214 } 167 215 glEnd(); … … 193 241 // particle->rotation = ; //! \todo rotation is once again something to be done. 194 242 particles->mass = this->initialMass + (random()/RAND_MAX -.5)* this->randomInitialMass; 195 particles->radius = this->startRadius + (random()/RAND_MAX-.5)*this->random Radius;243 particles->radius = this->startRadius + (random()/RAND_MAX-.5)*this->randomStartRadius; 196 244 197 particles->radiusIt = (this->endRadius + (random()/RAND_MAX-.5)*this->random Radius - particles->radius) / particles->timeToLive;245 particles->radiusIt = (this->endRadius + (random()/RAND_MAX-.5)*this->randomEndRadius - particles->radius) / particles->timeToLive; 198 246 199 247 ++this->count;
Note: See TracChangeset
for help on using the changeset viewer.