mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 17:35:45 +02:00
cleanup
This commit is contained in:
parent
89f36a7eb7
commit
0aaeb4550a
3 changed files with 73 additions and 71 deletions
|
@ -51,7 +51,7 @@ ParticleSystem::ParticleSystem() {
|
|||
_particle[p].age = 0.0f;
|
||||
_particle[p].radius = 0.0f;
|
||||
_particle[p].emitterIndex = 0;
|
||||
_particle[p].previousParticle = -1;
|
||||
_particle[p].previousParticle = NULL_PARTICLE;
|
||||
_particle[p].position = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
_particle[p].velocity = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ int ParticleSystem::addEmitter() {
|
|||
return _numEmitters - 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return NULL_EMITTER;
|
||||
}
|
||||
|
||||
|
||||
|
@ -116,7 +116,7 @@ void ParticleSystem::createParticle(int e, float timeFraction) {
|
|||
_particle[p].position = _emitter[e].previousPosition + timeFraction * (_emitter[e].position - _emitter[e].previousPosition);
|
||||
_particle[p].radius = _emitter[e].particleAttributes[0].radius;
|
||||
_particle[p].color = _emitter[e].particleAttributes[0].color;
|
||||
_particle[p].previousParticle = -1;
|
||||
_particle[p].previousParticle = NULL_PARTICLE;
|
||||
|
||||
if (_particle[_emitter[e].currentParticle].alive) {
|
||||
if (_particle[_emitter[e].currentParticle].emitterIndex == e) {
|
||||
|
@ -137,11 +137,11 @@ void ParticleSystem::killParticle(int p) {
|
|||
assert(p < MAX_PARTICLES);
|
||||
|
||||
_particle[p].alive = false;
|
||||
_particle[p].previousParticle = -1;
|
||||
_particle[p].previousParticle = NULL_PARTICLE;
|
||||
_particle[p].position = _emitter[_particle[p].emitterIndex].position;
|
||||
_particle[p].velocity = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
_particle[p].age = 0.0f;
|
||||
_particle[p].emitterIndex = -1;
|
||||
_particle[p].emitterIndex = NULL_PARTICLE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -347,7 +347,7 @@ void ParticleSystem::updateParticle(int p, float deltaTime) {
|
|||
void ParticleSystem::killAllParticles() {
|
||||
|
||||
for (int e = 0; e < _numEmitters; e++) {
|
||||
_emitter[e].currentParticle = -1;
|
||||
_emitter[e].currentParticle = NULL_PARTICLE;
|
||||
_emitter[e].emitReserve = 0.0f;
|
||||
_emitter[e].previousPosition = _emitter[e].position;
|
||||
_emitter[e].rate = 0.0f;
|
||||
|
@ -428,32 +428,30 @@ void ParticleSystem::renderParticle(int p) {
|
|||
|
||||
} else if (_emitter[_particle[p].emitterIndex].particleRenderStyle == PARTICLE_RENDER_STYLE_RIBBON) {
|
||||
|
||||
if (_particle[p].previousParticle != -1) {
|
||||
if (_particle[p].previousParticle != NULL_PARTICLE) {
|
||||
if ((_particle[p].alive)
|
||||
&& (_particle[_particle[p].previousParticle].alive)
|
||||
&& (_particle[_particle[p].previousParticle].emitterIndex == _particle[p].emitterIndex)) {
|
||||
|
||||
int pp = _particle[p].previousParticle;
|
||||
|
||||
glm::vec3 v = _particle[p].position - _particle[pp].position;
|
||||
float distance = glm::length(v);
|
||||
glm::vec3 vectorFromPreviousParticle = _particle[p].position - _particle[_particle[p].previousParticle].position;
|
||||
float distance = glm::length(vectorFromPreviousParticle);
|
||||
|
||||
if (distance > 0.0f) {
|
||||
|
||||
v /= distance;
|
||||
vectorFromPreviousParticle /= distance;
|
||||
|
||||
glm::vec3 up = glm::normalize(glm::cross(v, _upDirection)) * _particle[p].radius;
|
||||
glm::vec3 right = glm::normalize(glm::cross(up, v )) * _particle[p].radius;
|
||||
glm::vec3 up = glm::normalize(glm::cross(vectorFromPreviousParticle, _upDirection)) * _particle[p].radius;
|
||||
glm::vec3 right = glm::normalize(glm::cross(up, vectorFromPreviousParticle )) * _particle[p].radius;
|
||||
|
||||
glm::vec3 p0Left = _particle[p ].position - right;
|
||||
glm::vec3 p0Right = _particle[p ].position + right;
|
||||
glm::vec3 p0Down = _particle[p ].position - up;
|
||||
glm::vec3 p0Up = _particle[p ].position + up;
|
||||
|
||||
glm::vec3 ppLeft = _particle[pp].position - right;
|
||||
glm::vec3 ppRight = _particle[pp].position + right;
|
||||
glm::vec3 ppDown = _particle[pp].position - up;
|
||||
glm::vec3 ppUp = _particle[pp].position + up;
|
||||
glm::vec3 ppLeft = _particle[_particle[p].previousParticle].position - right;
|
||||
glm::vec3 ppRight = _particle[_particle[p].previousParticle].position + right;
|
||||
glm::vec3 ppDown = _particle[_particle[p].previousParticle].position - up;
|
||||
glm::vec3 ppUp = _particle[_particle[p].previousParticle].position + up;
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
const int MAX_PARTICLES = 5000;
|
||||
const int NULL_EMITTER = -1;
|
||||
const int NULL_PARTICLE = -1;
|
||||
const int MAX_EMITTERS = 100;
|
||||
|
||||
enum ParticleRenderStyle
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "Util.h"
|
||||
#include "renderer/ProgramObject.h"
|
||||
|
||||
const bool SHOW_LEAP_HAND = true;
|
||||
const bool SHOW_LEAP_HAND = false;
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -22,18 +22,17 @@ Hand::Hand(Avatar* owningAvatar) :
|
|||
HandData((AvatarData*)owningAvatar),
|
||||
|
||||
_raveGloveClock(0.0f),
|
||||
_raveGloveMode(0),
|
||||
_raveGloveMode(RAVE_GLOVE_EFFECTS_MODE_0),
|
||||
_raveGloveInitialized(false),
|
||||
_isRaveGloveActive(false),
|
||||
_owningAvatar(owningAvatar),
|
||||
_renderAlpha(1.0),
|
||||
_lookingInMirror(false),
|
||||
_isRaveGloveActive(false),
|
||||
_ballColor(0.0, 0.0, 0.4)
|
||||
|
||||
{
|
||||
// initialize all finger particle emitters with an invalid id as default
|
||||
for (int f = 0; f< NUM_FINGERS; f ++ ) {
|
||||
_raveGloveEmitter[f] = -1;
|
||||
_raveGloveEmitter[f] = NULL_EMITTER;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +57,7 @@ void Hand::simulate(float deltaTime, bool isMine) {
|
|||
}
|
||||
|
||||
void Hand::calculateGeometry() {
|
||||
glm::vec3 offset(0.0, -0.2, -0.3); // place the hand in front of the face where we can see it
|
||||
glm::vec3 offset(0.2, -0.2, -0.3); // place the hand in front of the face where we can see it
|
||||
|
||||
Head& head = _owningAvatar->getHead();
|
||||
_basePosition = head.getPosition() + head.getOrientation() * offset;
|
||||
|
@ -256,7 +255,7 @@ void Hand::updateRaveGloveEmitters() {
|
|||
for (size_t f = 0; f < palm.getNumFingers(); ++f) {
|
||||
FingerData& finger = palm.getFingers()[f];
|
||||
if (finger.isActive()) {
|
||||
if (_raveGloveEmitter[0] != -1) {
|
||||
if (_raveGloveEmitter[0] != NULL_EMITTER) {
|
||||
|
||||
glm::vec3 fingerDirection = finger.getTipPosition() - finger.getRootPosition();
|
||||
float fingerLength = glm::length(fingerDirection);
|
||||
|
@ -269,6 +268,7 @@ void Hand::updateRaveGloveEmitters() {
|
|||
|
||||
assert(_raveGloveEmitter[fingerIndex] >=0 );
|
||||
assert(_raveGloveEmitter[fingerIndex] < NUM_FINGERS );
|
||||
|
||||
_raveGloveParticleSystem.setEmitterPosition (_raveGloveEmitter[fingerIndex], finger.getTipPosition());
|
||||
_raveGloveParticleSystem.setEmitterDirection(_raveGloveEmitter[fingerIndex], fingerDirection);
|
||||
fingerIndex ++;
|
||||
|
@ -289,7 +289,7 @@ void Hand::updateRaveGloveParticles(float deltaTime) {
|
|||
// start up the rave glove finger particles...
|
||||
for ( int f = 0; f< NUM_FINGERS; f ++ ) {
|
||||
_raveGloveEmitter[f] = _raveGloveParticleSystem.addEmitter();
|
||||
assert( _raveGloveEmitter[f] != -1 );
|
||||
assert( _raveGloveEmitter[f] != NULL_EMITTER );
|
||||
}
|
||||
|
||||
setRaveGloveMode(RAVE_GLOVE_EFFECTS_MODE_2);
|
||||
|
@ -299,13 +299,15 @@ void Hand::updateRaveGloveParticles(float deltaTime) {
|
|||
|
||||
_raveGloveClock += deltaTime;
|
||||
|
||||
// this rave glove effect oscillates though various colors and radii that are meant to show off some effects
|
||||
if (_raveGloveMode == RAVE_GLOVE_EFFECTS_MODE_0) {
|
||||
ParticleSystem::ParticleAttributes attributes;
|
||||
float red = 0.5f + 0.5f * sinf(_raveGloveClock * 1.4f);
|
||||
float green = 0.5f + 0.5f * cosf(_raveGloveClock * 1.7f);
|
||||
float blue = 0.5f + 0.5f * sinf(_raveGloveClock * 2.0f);
|
||||
float alpha = 1.0f;
|
||||
|
||||
attributes.color = glm::vec4(red, green, blue, 1.0f);
|
||||
attributes.color = glm::vec4(red, green, blue, alpha);
|
||||
attributes.radius = 0.01f + 0.005f * sinf(_raveGloveClock * 2.2f);
|
||||
attributes.modulationAmplitude = 0.0f;
|
||||
|
||||
|
|
Loading…
Reference in a new issue