Showing the changes to interface/src/ParticleSystem.cpp (1 of 5 files). Show all
Unified · Split
| @@ -22,9 +22,9 @@ ParticleSystem::ParticleSystem() { · 21 unmodified lines | |||
| 22 | _upDirection = glm::vec3(0.0f, 1.0f, 0.0f); // default | 22 | _upDirection = glm::vec3(0.0f, 1.0f, 0.0f); // default |
| 23 | 23 | ||
| 24 | for (unsigned int emitterIndex = 0; emitterIndex < MAX_EMITTERS; emitterIndex++) { | 24 | for (unsigned int emitterIndex = 0; emitterIndex < MAX_EMITTERS; emitterIndex++) { |
| 25 | _emitter[emitterIndex].position = glm::vec3(0.0f, 0.0f, 0.0f); | 25 | _emitter[emitterIndex].position = glm::vec3(0.0f, 0.0f, 0.0f); |
| 26 | _emitter[emitterIndex].rotation = glm::quat(); | 26 | _emitter[emitterIndex].direction = glm::vec3(0.0f, 1.0f, 0.0f); |
| 27 | _emitter[emitterIndex].visible = false; | 27 | _emitter[emitterIndex].visible = false; |
| 28 | _emitter[emitterIndex].baseParticle.alive = false; | 28 | _emitter[emitterIndex].baseParticle.alive = false; |
| 29 | _emitter[emitterIndex].baseParticle.age = 0.0f; | 29 | _emitter[emitterIndex].baseParticle.age = 0.0f; |
| 30 | _emitter[emitterIndex].baseParticle.lifespan = 0.0f; | 30 | _emitter[emitterIndex].baseParticle.lifespan = 0.0f; |
| @@ -90,10 +90,10 @@ void ParticleSystem::simulate(float deltaTime) { · 59 unmodified lines | |||
| 90 | } | 90 | } |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | void ParticleSystem::emitParticlesNow(int e, int num, glm::vec3 velocity, float lifespan) { | 93 | void ParticleSystem::emitParticlesNow(int e, int num, float thrust, float lifespan) { |
| 94 | 94 | ||
| 95 | for (unsigned int p = 0; p < num; p++) { | 95 | for (unsigned int p = 0; p < num; p++) { |
| 96 | createParticle(e, velocity, lifespan); | 96 | createParticle(e, _emitter[e].direction * thrust, lifespan); |
| 97 | } | 97 | } |
| 98 | } | 98 | } |
| 99 | 99 | ||
| @@ -212,9 +212,9 @@ void ParticleSystem::updateParticle(int p, float deltaTime) { · 112 unmodified lines | |||
| 212 | // apply tornado force | 212 | // apply tornado force |
| 213 | 213 | ||
| 214 | 214 | ||
| 215 | glm::vec3 emitterUp = myEmitter.rotation * IDENTITY_UP; | 215 | //glm::vec3 emitterUp = myEmitter.rotation * IDENTITY_UP; |
| 216 | 216 | ||
| 217 | glm::vec3 tornadoDirection = glm::cross(vectorToHome, emitterUp); | 217 | glm::vec3 tornadoDirection = glm::cross(vectorToHome, myEmitter.direction); |
| 218 | _particle[p].velocity += tornadoDirection * myEmitter.particleAttributes[lifeStage].tornadoForce * deltaTime; | 218 | _particle[p].velocity += tornadoDirection * myEmitter.particleAttributes[lifeStage].tornadoForce * deltaTime; |
| 219 | 219 | ||
| 220 | // apply air friction | 220 | // apply air friction |
| @@ -351,12 +351,19 @@ void ParticleSystem::renderParticle(int p) { · 130 unmodified lines | |||
| 351 | 351 | ||
| 352 | void ParticleSystem::renderEmitter(int e, float size) { | 352 | void ParticleSystem::renderEmitter(int e, float size) { |
| 353 | 353 | ||
| 354 | /* | ||
| 354 | glm::vec3 r = _emitter[e].rotation * IDENTITY_FRONT * size; | 355 | glm::vec3 r = _emitter[e].rotation * IDENTITY_FRONT * size; |
| 355 | glm::vec3 u = _emitter[e].rotation * IDENTITY_RIGHT * size; | 356 | glm::vec3 u = _emitter[e].rotation * IDENTITY_RIGHT * size; |
| 356 | glm::vec3 f = _emitter[e].rotation * IDENTITY_UP * size; | 357 | glm::vec3 f = _emitter[e].rotation * IDENTITY_UP * size; |
| 358 | */ | ||
| 357 | 359 | ||
| 360 | glm::vec3 f = _emitter[e].direction; | ||
| 361 | //glm::vec3 r = glm::vec3(_emitter[e].direction.y, _emitter[e].direction.z, _emitter[e].direction.x); | ||
| 362 | //glm::vec3 u = glm::vec3(_emitter[e].direction.z, _emitter[e].direction.x, _emitter[e].direction.y); | ||
| 363 | |||
| 358 | glLineWidth(2.0f); | 364 | glLineWidth(2.0f); |
| 359 | 365 | ||
| 366 | /* | ||
| 360 | glColor3f(0.8f, 0.4, 0.4); | 367 | glColor3f(0.8f, 0.4, 0.4); |
| 361 | glBegin(GL_LINES); | 368 | glBegin(GL_LINES); |
| 362 | glVertex3f(_emitter[e].position.x, _emitter[e].position.y, _emitter[e].position.z); | 369 | glVertex3f(_emitter[e].position.x, _emitter[e].position.y, _emitter[e].position.z); |
| @@ -368,7 +375,7 @@ void ParticleSystem::renderEmitter(int e, float size) { · 5 unmodified lines | |||
| 368 | glVertex3f(_emitter[e].position.x, _emitter[e].position.y, _emitter[e].position.z); | 375 | glVertex3f(_emitter[e].position.x, _emitter[e].position.y, _emitter[e].position.z); |
| 369 | glVertex3f(_emitter[e].position.x + u.x, _emitter[e].position.y + u.y, _emitter[e].position.z + u.z); | 376 | glVertex3f(_emitter[e].position.x + u.x, _emitter[e].position.y + u.y, _emitter[e].position.z + u.z); |
| 370 | glEnd(); | 377 | glEnd(); |
| 371 | 378 | */ | |
| 372 | glColor3f(0.4f, 0.4, 0.8); | 379 | glColor3f(0.4f, 0.4, 0.8); |
| 373 | glBegin(GL_LINES); | 380 | glBegin(GL_LINES); |
| 374 | glVertex3f(_emitter[e].position.x, _emitter[e].position.y, _emitter[e].position.z); | 381 | glVertex3f(_emitter[e].position.x, _emitter[e].position.y, _emitter[e].position.z); |