mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 17:03:58 +02:00
clean up of particle system
This commit is contained in:
parent
4389389f17
commit
be5612711b
3 changed files with 15 additions and 27 deletions
|
@ -73,7 +73,7 @@ using namespace std;
|
|||
static char STAR_FILE[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt";
|
||||
static char STAR_CACHE_FILE[] = "cachedStars.txt";
|
||||
|
||||
static const bool TESTING_PARTICLE_SYSTEM = false;
|
||||
static const bool TESTING_PARTICLE_SYSTEM = true;
|
||||
|
||||
static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored
|
||||
|
||||
|
@ -3514,19 +3514,11 @@ void Application::updateParticleSystem(float deltaTime) {
|
|||
glm::vec4 color(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glm::vec3 velocity(0.0f, 0.1f, 0.0f);
|
||||
float lifespan = 100000.0f;
|
||||
|
||||
// determine a collision sphere
|
||||
glm::vec3 collisionSpherePosition = glm::vec3( 5.0f, 0.5f, 5.0f );
|
||||
float collisionSphereRadius = 0.5f;
|
||||
_particleSystem.setCollisionSphere(_coolDemoParticleEmitter, collisionSpherePosition, collisionSphereRadius);
|
||||
_particleSystem.emitParticlesNow(_coolDemoParticleEmitter, 1500, radius, color, velocity, lifespan);
|
||||
}
|
||||
|
||||
// signal that the particle system has been initialized
|
||||
_particleSystemInitialized = true;
|
||||
|
||||
// apply a preset color palette
|
||||
_particleSystem.setOrangeBlueColorPalette();
|
||||
} else {
|
||||
// update the particle system
|
||||
|
||||
|
@ -3547,6 +3539,7 @@ void Application::updateParticleSystem(float deltaTime) {
|
|||
ParticleSystem::ParticleAttributes attributes;
|
||||
|
||||
attributes.radius = 0.01f;
|
||||
attributes.color = glm::vec4( 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
attributes.gravity = 0.0f + 0.05f * sinf( t * 0.52f );
|
||||
attributes.airFriction = 2.5 + 2.0f * sinf( t * 0.32f );
|
||||
attributes.jitter = 0.05f + 0.05f * sinf( t * 0.42f );
|
||||
|
@ -3563,7 +3556,7 @@ void Application::updateParticleSystem(float deltaTime) {
|
|||
attributes.gravity = 0.0f;
|
||||
}
|
||||
|
||||
_particleSystem.setParticleAttributes(_coolDemoParticleEmitter, attributes);
|
||||
_particleSystem.setParticleAttributes(_coolDemoParticleEmitter, attributes);
|
||||
}
|
||||
|
||||
_particleSystem.setUpDirection(glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
|
|
|
@ -147,7 +147,7 @@ void ParticleSystem::killParticle(int p) {
|
|||
_numParticles --;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void ParticleSystem::setOrangeBlueColorPalette() {
|
||||
|
||||
for (unsigned int p = 0; p < _numParticles; p++) {
|
||||
|
@ -163,6 +163,7 @@ void ParticleSystem::setOrangeBlueColorPalette() {
|
|||
_particle[p].color = glm::vec4(red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void ParticleSystem::setParticleAttributes(int emitterIndex, ParticleAttributes attributes) {
|
||||
|
@ -201,13 +202,7 @@ void ParticleSystem::updateParticle(int p, float deltaTime) {
|
|||
int lifeStage = (int)( ageFraction * (NUM_PARTICLE_LIFE_STAGES-1) );
|
||||
|
||||
float lifeStageFraction = ageFraction * ( NUM_PARTICLE_LIFE_STAGES - 1 ) - lifeStage;
|
||||
|
||||
/*
|
||||
if ( p == 0 ) {
|
||||
printf( "lifespan = %f ageFraction = %f lifeStage = %d lifeStageFraction = %f\n", _particle[p].lifespan, ageFraction, lifeStage, lifeStageFraction );
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
_particle[p].radius
|
||||
= _emitter[_particle[p].emitterIndex].particleAttributes[lifeStage ].radius * (1.0f - lifeStageFraction)
|
||||
+ _emitter[_particle[p].emitterIndex].particleAttributes[lifeStage+1].radius * lifeStageFraction;
|
||||
|
@ -294,6 +289,7 @@ void ParticleSystem::updateParticle(int p, float deltaTime) {
|
|||
_particle[p].age += deltaTime;
|
||||
}
|
||||
|
||||
/*
|
||||
void ParticleSystem::setCollisionSphere(int e, glm::vec3 position, float radius) {
|
||||
|
||||
int lifeStage = 0;
|
||||
|
@ -302,6 +298,7 @@ void ParticleSystem::setCollisionSphere(int e, glm::vec3 position, float radius)
|
|||
_emitter[e].particleAttributes[lifeStage].collisionSpherePosition = position;
|
||||
_emitter[e].particleAttributes[lifeStage].collisionSphereRadius = radius;
|
||||
}
|
||||
*/
|
||||
|
||||
void ParticleSystem::setEmitterBaseParticle(int emitterIndex, bool showing ) {
|
||||
|
||||
|
|
|
@ -42,17 +42,15 @@ public:
|
|||
void emitParticlesNow(int emitterIndex, int numParticles, float radius, glm::vec4 color, glm::vec3 velocity, float lifespan);
|
||||
void simulate(float deltaTime);
|
||||
void render();
|
||||
|
||||
void setUpDirection(glm::vec3 upDirection) {_upDirection = upDirection;} // tell particle system which direction is up
|
||||
void setEmitterBaseParticle(int emitterIndex, bool showing );
|
||||
void setEmitterBaseParticle(int emitterIndex, bool showing, float radius, glm::vec4 color );
|
||||
|
||||
void setOrangeBlueColorPalette(); // apply a nice preset color palette to the particles
|
||||
void setUpDirection(glm::vec3 upDirection) {_upDirection = upDirection;} // tell particle system which direction is up
|
||||
void setParticleAttributes(int emitterIndex, ParticleAttributes attributes);
|
||||
void setParticleAttributes(int emitterIndex, int lifeStage, ParticleAttributes attributes);
|
||||
void setCollisionSphere (int emitterIndex, glm::vec3 position, float radius); // specify a sphere for the particles to collide with
|
||||
void setEmitterPosition (int emitterIndex, glm::vec3 position) { _emitter[emitterIndex].position = position; } // set position of emitter
|
||||
void setEmitterRotation (int emitterIndex, glm::quat rotation) { _emitter[emitterIndex].rotation = rotation; } // set rotation of emitter
|
||||
void setShowingEmitter (int emitterIndex, bool showing ) { _emitter[emitterIndex].visible = showing; } // set its visibiity
|
||||
void setParticleAttributes (int emitterIndex, ParticleAttributes attributes);
|
||||
void setParticleAttributes (int emitterIndex, int lifeStage, ParticleAttributes attributes);
|
||||
void setEmitterPosition (int emitterIndex, glm::vec3 position) { _emitter[emitterIndex].position = position; } // set position of emitter
|
||||
void setEmitterRotation (int emitterIndex, glm::quat rotation) { _emitter[emitterIndex].rotation = rotation; } // set rotation of emitter
|
||||
void setShowingEmitter (int emitterIndex, bool showing ) { _emitter[emitterIndex].visible = showing; } // set its visibiity
|
||||
|
||||
private:
|
||||
|
||||
|
|
Loading…
Reference in a new issue