mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
added keyboard mode switching for rave glove effects
This commit is contained in:
parent
1d5bf20b80
commit
9890cf72ce
6 changed files with 118 additions and 51 deletions
|
@ -551,6 +551,7 @@ void Application::sendVoxelServerAddScene() {
|
|||
}
|
||||
|
||||
void Application::keyPressEvent(QKeyEvent* event) {
|
||||
|
||||
if (activeWindow() == _window) {
|
||||
if (_chatEntryOn) {
|
||||
if (_chatEntry.keyPressEvent(event)) {
|
||||
|
@ -566,6 +567,11 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//this is for switching between modes for the leap rave glove test
|
||||
if (_simulateLeapHand->isChecked() || _testRaveGlove->isChecked()) {
|
||||
_myAvatar.getHand().setRaveGloveEffectsMode((QKeyEvent*)event);
|
||||
}
|
||||
|
||||
bool shifted = event->modifiers().testFlag(Qt::ShiftModifier);
|
||||
switch (event->key()) {
|
||||
|
@ -765,7 +771,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
case Qt::Key_6:
|
||||
case Qt::Key_7:
|
||||
case Qt::Key_8:
|
||||
_swatch.handleEvent(event->key(), _eyedropperMode->isChecked());
|
||||
_swatch.handleEvent(event->key(), _eyedropperMode->isChecked());
|
||||
break;
|
||||
default:
|
||||
event->ignore();
|
||||
|
@ -776,6 +782,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
|
||||
void Application::keyReleaseEvent(QKeyEvent* event) {
|
||||
if (activeWindow() == _window) {
|
||||
|
||||
if (_chatEntryOn) {
|
||||
_myAvatar.setKeyState(NO_KEY_DOWN);
|
||||
return;
|
||||
|
@ -2652,9 +2659,17 @@ void Application::displaySide(Camera& whichCamera) {
|
|||
float sphereRadius = 0.25f;
|
||||
glColor3f(1,0,0);
|
||||
glPushMatrix();
|
||||
glutSolidSphere(sphereRadius, 15, 15);
|
||||
glutSolidSphere(sphereRadius, 15, 15);
|
||||
glPopMatrix();
|
||||
|
||||
/*
|
||||
glPushMatrix();
|
||||
glColor3f(1, 0, 1);
|
||||
glTranslatef(0.0f, 0.0f, 5.0f);
|
||||
_particleSystem.render();
|
||||
glPopMatrix();
|
||||
*/
|
||||
|
||||
//draw a grid ground plane....
|
||||
if (_renderGroundPlaneOn->isChecked()) {
|
||||
renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude());
|
||||
|
@ -2715,13 +2730,25 @@ void Application::displaySide(Camera& whichCamera) {
|
|||
renderLookatIndicator(_lookatOtherPosition, whichCamera);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (TESTING_PARTICLE_SYSTEM) {
|
||||
if (_particleSystemInitialized) {
|
||||
_particleSystem.render();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
glPushMatrix();
|
||||
glColor3f(1, 0, 1);
|
||||
glTranslatef(0.0f, 0.0f, 5.0f);
|
||||
_particleSystem.render();
|
||||
glPopMatrix();
|
||||
*/
|
||||
|
||||
_particleSystem.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Render the world box
|
||||
if (!_lookingInMirror->isChecked() && _renderStatsOn->isChecked()) { render_world_box(); }
|
||||
|
||||
|
@ -3658,8 +3685,9 @@ void Application::updateParticleSystem(float deltaTime) {
|
|||
const float EMIT_RATE_IN_SECONDS = 10000.0;
|
||||
// create a stable test emitter and spit out a bunch of particles
|
||||
_coolDemoParticleEmitter = _particleSystem.addEmitter();
|
||||
|
||||
|
||||
if (_coolDemoParticleEmitter != -1) {
|
||||
|
||||
_particleSystem.setShowingEmitter(_coolDemoParticleEmitter, true);
|
||||
glm::vec3 particleEmitterPosition = glm::vec3(5.0f, 1.0f, 5.0f);
|
||||
|
||||
|
@ -3673,7 +3701,7 @@ void Application::updateParticleSystem(float deltaTime) {
|
|||
_particleSystemInitialized = true;
|
||||
} else {
|
||||
// update the particle system
|
||||
|
||||
|
||||
static bool emitting = true;
|
||||
static float t = 0.0f;
|
||||
t += deltaTime;
|
||||
|
|
|
@ -25,19 +25,19 @@ ParticleSystem::ParticleSystem() {
|
|||
|
||||
for (unsigned int emitterIndex = 0; emitterIndex < MAX_EMITTERS; emitterIndex++) {
|
||||
|
||||
Emitter e = _emitter[emitterIndex];
|
||||
Emitter * e = &_emitter[emitterIndex];
|
||||
|
||||
e.position = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
e.direction = glm::vec3(0.0f, 1.0f, 0.0f);
|
||||
e.visible = false;
|
||||
e.particleResolution = DEFAULT_PARTICLE_SPHERE_RESOLUTION;
|
||||
e.particleLifespan = DEFAULT_PARTICLE_LIFESPAN;
|
||||
e.showingBaseParticle = false;
|
||||
e.emitReserve = 0.0;
|
||||
e.thrust = 0.0f;
|
||||
e.rate = 0.0f;
|
||||
e.currentParticle = 0;
|
||||
e.particleRenderStyle = PARTICLE_RENDER_STYLE_SPHERE;
|
||||
e->position = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
e->direction = glm::vec3(0.0f, 1.0f, 0.0f);
|
||||
e->visible = false;
|
||||
e->particleResolution = DEFAULT_PARTICLE_SPHERE_RESOLUTION;
|
||||
e->particleLifespan = DEFAULT_PARTICLE_LIFESPAN;
|
||||
e->showingBaseParticle = false;
|
||||
e->emitReserve = 0.0;
|
||||
e->thrust = 0.0f;
|
||||
e->rate = 0.0f;
|
||||
e->currentParticle = 0;
|
||||
e->particleRenderStyle = PARTICLE_RENDER_STYLE_SPHERE;
|
||||
|
||||
for (int lifeStage = 0; lifeStage<NUM_PARTICLE_LIFE_STAGES; lifeStage++) {
|
||||
|
||||
|
@ -102,8 +102,9 @@ void ParticleSystem::simulate(float deltaTime) {
|
|||
}
|
||||
|
||||
// update particles
|
||||
|
||||
for (unsigned int p = 0; p < _numParticles; p++) {
|
||||
if (_particle[p].alive) {
|
||||
if (_particle[p].alive) {
|
||||
if (_particle[p].age > _emitter[_particle[p].emitterIndex].particleLifespan) {
|
||||
killParticle(p);
|
||||
} else {
|
||||
|
@ -319,12 +320,12 @@ void ParticleSystem::render() {
|
|||
}
|
||||
};
|
||||
|
||||
// render the particles
|
||||
// render the particles
|
||||
for (unsigned int p = 0; p < _numParticles; p++) {
|
||||
if (_particle[p].alive) {
|
||||
if (_emitter[_particle[p].emitterIndex].particleLifespan > 0.0) {
|
||||
renderParticle(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -363,8 +364,8 @@ void ParticleSystem::renderParticle(int p) {
|
|||
} else if (_emitter[_particle[p].emitterIndex].particleRenderStyle == PARTICLE_RENDER_STYLE_SPHERE) {
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(_particle[p].position.x, _particle[p].position.y, _particle[p].position.z);
|
||||
glutSolidSphere(_particle[p].radius, _emitter[_particle[p].emitterIndex].particleResolution, _emitter[_particle[p].emitterIndex].particleResolution);
|
||||
glTranslatef(_particle[p].position.x, _particle[p].position.y, _particle[p].position.z);
|
||||
glutSolidSphere(_particle[p].radius, _emitter[_particle[p].emitterIndex].particleResolution, _emitter[_particle[p].emitterIndex].particleResolution);
|
||||
glPopMatrix();
|
||||
|
||||
} else if (_emitter[_particle[p].emitterIndex].particleRenderStyle == PARTICLE_RENDER_STYLE_RIBBON) {
|
||||
|
|
|
@ -447,7 +447,7 @@ void Avatar::updateThrust(float deltaTime, Transmitter * transmitter) {
|
|||
}
|
||||
|
||||
void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||
|
||||
|
||||
glm::quat orientation = getOrientation();
|
||||
glm::vec3 front = orientation * IDENTITY_FRONT;
|
||||
glm::vec3 right = orientation * IDENTITY_RIGHT;
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
#include "Util.h"
|
||||
#include "renderer/ProgramObject.h"
|
||||
|
||||
const bool SHOW_LEAP_HAND = false;
|
||||
const int NUM_TEST_RAVE_GLOVE_MODES = 8;
|
||||
const float TEST_RAVE_GLOVE_MODE_DURATION = 7.0f;
|
||||
const bool SHOW_LEAP_HAND = false;
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -52,6 +50,7 @@ void Hand::init() {
|
|||
void Hand::reset() {
|
||||
}
|
||||
|
||||
|
||||
void Hand::simulate(float deltaTime, bool isMine) {
|
||||
if (_isRaveGloveActive) {
|
||||
updateFingerParticles(deltaTime);
|
||||
|
@ -86,6 +85,20 @@ void Hand::calculateGeometry() {
|
|||
}
|
||||
}
|
||||
|
||||
void Hand::setRaveGloveEffectsMode(QKeyEvent* event) {
|
||||
switch (event->key()) {
|
||||
case Qt::Key_0: setRaveGloveMode(RAVE_GLOVE_EFFECTS_MODE_0); break;
|
||||
case Qt::Key_1: setRaveGloveMode(RAVE_GLOVE_EFFECTS_MODE_1); break;
|
||||
case Qt::Key_2: setRaveGloveMode(RAVE_GLOVE_EFFECTS_MODE_2); break;
|
||||
case Qt::Key_3: setRaveGloveMode(RAVE_GLOVE_EFFECTS_MODE_3); break;
|
||||
case Qt::Key_4: setRaveGloveMode(RAVE_GLOVE_EFFECTS_MODE_4); break;
|
||||
case Qt::Key_5: setRaveGloveMode(RAVE_GLOVE_EFFECTS_MODE_5); break;
|
||||
case Qt::Key_6: setRaveGloveMode(RAVE_GLOVE_EFFECTS_MODE_6); break;
|
||||
case Qt::Key_7: setRaveGloveMode(RAVE_GLOVE_EFFECTS_MODE_7); break;
|
||||
case Qt::Key_8: setRaveGloveMode(RAVE_GLOVE_EFFECTS_MODE_8); break;
|
||||
case Qt::Key_9: setRaveGloveMode(RAVE_GLOVE_EFFECTS_MODE_9); break;
|
||||
};
|
||||
}
|
||||
|
||||
void Hand::render(bool lookingInMirror) {
|
||||
|
||||
|
@ -277,25 +290,14 @@ void Hand::updateFingerParticles(float deltaTime) {
|
|||
assert( _fingerParticleEmitter[f] != -1 );
|
||||
}
|
||||
|
||||
setRaveGloveMode(_testRaveGloveMode);
|
||||
setRaveGloveMode(RAVE_GLOVE_EFFECTS_MODE_2);
|
||||
_particleSystem.setUpDirection(glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
_particleSystemInitialized = true;
|
||||
} else {
|
||||
|
||||
_testRaveGloveClock += deltaTime;
|
||||
|
||||
// cycle through the rave glove test modes...
|
||||
if (_testRaveGloveClock > TEST_RAVE_GLOVE_MODE_DURATION) {
|
||||
_testRaveGloveClock = 0.0f;
|
||||
_testRaveGloveMode ++;
|
||||
|
||||
if (_testRaveGloveMode > NUM_TEST_RAVE_GLOVE_MODES) {
|
||||
_testRaveGloveMode = 0;
|
||||
}
|
||||
|
||||
setRaveGloveMode(_testRaveGloveMode);
|
||||
}
|
||||
|
||||
if (_testRaveGloveMode == 0) {
|
||||
if (_testRaveGloveMode == RAVE_GLOVE_EFFECTS_MODE_0) {
|
||||
ParticleSystem::ParticleAttributes attributes;
|
||||
float red = 0.5f + 0.5f * sinf(_testRaveGloveClock * 1.4f);
|
||||
float green = 0.5f + 0.5f * cosf(_testRaveGloveClock * 1.7f);
|
||||
|
@ -317,6 +319,8 @@ void Hand::updateFingerParticles(float deltaTime) {
|
|||
|
||||
void Hand::setRaveGloveMode(int mode) {
|
||||
|
||||
_testRaveGloveMode = mode;
|
||||
|
||||
_particleSystem.killAllParticles();
|
||||
|
||||
for ( int f = 0; f< NUM_FINGERS; f ++ ) {
|
||||
|
@ -326,7 +330,7 @@ void Hand::setRaveGloveMode(int mode) {
|
|||
//-----------------------------------------
|
||||
// throbbing color cycle
|
||||
//-----------------------------------------
|
||||
if (mode == 0) {
|
||||
if (mode == RAVE_GLOVE_EFFECTS_MODE_0) {
|
||||
_particleSystem.setParticleRenderStyle (_fingerParticleEmitter[f], PARTICLE_RENDER_STYLE_SPHERE );
|
||||
_particleSystem.setShowingEmitterBaseParticle(_fingerParticleEmitter[f], true );
|
||||
_particleSystem.setEmitterParticleLifespan (_fingerParticleEmitter[f], 0.0f );
|
||||
|
@ -354,7 +358,7 @@ void Hand::setRaveGloveMode(int mode) {
|
|||
//-----------------------------------------
|
||||
// trails
|
||||
//-----------------------------------------
|
||||
} else if (mode == 1) {
|
||||
} else if (mode == RAVE_GLOVE_EFFECTS_MODE_1) {
|
||||
_particleSystem.setParticleRenderStyle (_fingerParticleEmitter[f], PARTICLE_RENDER_STYLE_RIBBON );
|
||||
_particleSystem.setShowingEmitterBaseParticle(_fingerParticleEmitter[f], false );
|
||||
_particleSystem.setEmitterParticleLifespan (_fingerParticleEmitter[f], 1.0f );
|
||||
|
@ -388,7 +392,7 @@ void Hand::setRaveGloveMode(int mode) {
|
|||
//-----------------------------------------
|
||||
// Fire!
|
||||
//-----------------------------------------
|
||||
if (mode == 2) {
|
||||
if (mode == RAVE_GLOVE_EFFECTS_MODE_2) {
|
||||
|
||||
_particleSystem.setParticleRenderStyle (_fingerParticleEmitter[f], PARTICLE_RENDER_STYLE_SPHERE );
|
||||
_particleSystem.setShowingEmitterBaseParticle(_fingerParticleEmitter[f], false );
|
||||
|
@ -428,7 +432,7 @@ void Hand::setRaveGloveMode(int mode) {
|
|||
//-----------------------------------------
|
||||
// water
|
||||
//-----------------------------------------
|
||||
} else if (mode == 3) {
|
||||
} else if (mode == RAVE_GLOVE_EFFECTS_MODE_3) {
|
||||
|
||||
_particleSystem.setParticleRenderStyle (_fingerParticleEmitter[f], PARTICLE_RENDER_STYLE_SPHERE );
|
||||
_particleSystem.setShowingEmitterBaseParticle(_fingerParticleEmitter[f], true );
|
||||
|
@ -464,7 +468,7 @@ void Hand::setRaveGloveMode(int mode) {
|
|||
//-----------------------------------------
|
||||
// flashy
|
||||
//-----------------------------------------
|
||||
} else if (mode == 4) {
|
||||
} else if (mode == RAVE_GLOVE_EFFECTS_MODE_4) {
|
||||
|
||||
_particleSystem.setParticleRenderStyle (_fingerParticleEmitter[f], PARTICLE_RENDER_STYLE_SPHERE );
|
||||
_particleSystem.setShowingEmitterBaseParticle(_fingerParticleEmitter[f], true );
|
||||
|
@ -501,7 +505,7 @@ void Hand::setRaveGloveMode(int mode) {
|
|||
//-----------------------------------------
|
||||
// Bozo sparkler
|
||||
//-----------------------------------------
|
||||
} else if (mode == 5) {
|
||||
} else if (mode == RAVE_GLOVE_EFFECTS_MODE_5) {
|
||||
|
||||
_particleSystem.setParticleRenderStyle (_fingerParticleEmitter[f], PARTICLE_RENDER_STYLE_RIBBON );
|
||||
_particleSystem.setShowingEmitterBaseParticle(_fingerParticleEmitter[f], false );
|
||||
|
@ -538,7 +542,7 @@ void Hand::setRaveGloveMode(int mode) {
|
|||
//-----------------------------------------
|
||||
// long sparkler
|
||||
//-----------------------------------------
|
||||
} else if (mode == 6) {
|
||||
} else if (mode == RAVE_GLOVE_EFFECTS_MODE_6) {
|
||||
|
||||
_particleSystem.setParticleRenderStyle (_fingerParticleEmitter[f], PARTICLE_RENDER_STYLE_RIBBON );
|
||||
_particleSystem.setShowingEmitterBaseParticle(_fingerParticleEmitter[f], false );
|
||||
|
@ -575,7 +579,7 @@ void Hand::setRaveGloveMode(int mode) {
|
|||
//-----------------------------------------
|
||||
// bubble snake
|
||||
//-----------------------------------------
|
||||
} else if (mode == 7) {
|
||||
} else if (mode == RAVE_GLOVE_EFFECTS_MODE_7) {
|
||||
|
||||
_particleSystem.setParticleRenderStyle (_fingerParticleEmitter[f], PARTICLE_RENDER_STYLE_SPHERE );
|
||||
_particleSystem.setShowingEmitterBaseParticle(_fingerParticleEmitter[f], true );
|
||||
|
|
|
@ -8,6 +8,12 @@
|
|||
#ifndef hifi_Hand_h
|
||||
#define hifi_Hand_h
|
||||
|
||||
#include <QApplication>
|
||||
#include <QAction>
|
||||
#include <QSettings>
|
||||
#include <QTouchEvent>
|
||||
#include <QList>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <AvatarData.h>
|
||||
#include <HandData.h>
|
||||
|
@ -22,6 +28,22 @@
|
|||
class Avatar;
|
||||
class ProgramObject;
|
||||
|
||||
enum RaveGloveEffectsMode
|
||||
{
|
||||
RAVE_GLOVE_EFFECTS_MODE_NULL = -1,
|
||||
RAVE_GLOVE_EFFECTS_MODE_0,
|
||||
RAVE_GLOVE_EFFECTS_MODE_1,
|
||||
RAVE_GLOVE_EFFECTS_MODE_2,
|
||||
RAVE_GLOVE_EFFECTS_MODE_3,
|
||||
RAVE_GLOVE_EFFECTS_MODE_4,
|
||||
RAVE_GLOVE_EFFECTS_MODE_5,
|
||||
RAVE_GLOVE_EFFECTS_MODE_6,
|
||||
RAVE_GLOVE_EFFECTS_MODE_7,
|
||||
RAVE_GLOVE_EFFECTS_MODE_8,
|
||||
RAVE_GLOVE_EFFECTS_MODE_9,
|
||||
NUM_RAVE_GLOVE_EFFECTS_MODES
|
||||
};
|
||||
|
||||
class Hand : public HandData {
|
||||
public:
|
||||
Hand(Avatar* owningAvatar);
|
||||
|
@ -45,7 +67,7 @@ public:
|
|||
void updateFingerParticles(float deltaTime);
|
||||
void updateFingerParticleEmitters();
|
||||
void setRaveGloveActive(bool active) { _isRaveGloveActive = active; }
|
||||
|
||||
void setRaveGloveEffectsMode(QKeyEvent* event);
|
||||
|
||||
// getters
|
||||
const glm::vec3& getLeapBallPosition (int ball) const { return _leapBalls[ball].position;}
|
||||
|
|
|
@ -32,6 +32,18 @@ const float MAX_AUDIO_LOUDNESS = 1000.0; // close enough for mouth animation
|
|||
enum KeyState
|
||||
{
|
||||
NO_KEY_DOWN = 0,
|
||||
/*
|
||||
ONE_KEY_DOWN,
|
||||
TOW_KEY_DOWN,
|
||||
THREE_KEY_DOWN,
|
||||
FOUR_KEY_DOWN,
|
||||
FIVE_KEY_DOWN,
|
||||
SIX_KEY_DOWN,
|
||||
SEVEN_KEY_DOWN,
|
||||
EIGHT_KEY_DOWN,
|
||||
NINE_KEY_DOWN,
|
||||
ZERO_KEY_DOWN,
|
||||
*/
|
||||
INSERT_KEY_DOWN,
|
||||
DELETE_KEY_DOWN
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue