mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 14:29:03 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into pointy
This commit is contained in:
commit
8de709a2c6
11 changed files with 276 additions and 135 deletions
|
@ -196,8 +196,9 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
_isTouchPressed(false),
|
_isTouchPressed(false),
|
||||||
_yawFromTouch(0.0f),
|
_yawFromTouch(0.0f),
|
||||||
_pitchFromTouch(0.0f),
|
_pitchFromTouch(0.0f),
|
||||||
_groundPlaneImpact(0.0f),
|
|
||||||
_mousePressed(false),
|
_mousePressed(false),
|
||||||
|
_isHoverVoxel(false),
|
||||||
|
_isHoverVoxelSounding(false),
|
||||||
_mouseVoxelScale(1.0f / 1024.0f),
|
_mouseVoxelScale(1.0f / 1024.0f),
|
||||||
_justEditedVoxel(false),
|
_justEditedVoxel(false),
|
||||||
_isLookingAtOtherAvatar(false),
|
_isLookingAtOtherAvatar(false),
|
||||||
|
@ -854,6 +855,11 @@ void Application::mouseMoveEvent(QMouseEvent* event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool MAKE_SOUND_ON_VOXEL_HOVER = false;
|
||||||
|
const bool MAKE_SOUND_ON_VOXEL_CLICK = true;
|
||||||
|
const float HOVER_VOXEL_FREQUENCY = 14080.f;
|
||||||
|
const float HOVER_VOXEL_DECAY = 0.999f;
|
||||||
|
|
||||||
void Application::mousePressEvent(QMouseEvent* event) {
|
void Application::mousePressEvent(QMouseEvent* event) {
|
||||||
if (activeWindow() == _window) {
|
if (activeWindow() == _window) {
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
|
@ -864,6 +870,14 @@ void Application::mousePressEvent(QMouseEvent* event) {
|
||||||
_mouseVoxelDragging = _mouseVoxel;
|
_mouseVoxelDragging = _mouseVoxel;
|
||||||
_mousePressed = true;
|
_mousePressed = true;
|
||||||
maybeEditVoxelUnderCursor();
|
maybeEditVoxelUnderCursor();
|
||||||
|
if (MAKE_SOUND_ON_VOXEL_CLICK && _isHoverVoxel && !_isHoverVoxelSounding) {
|
||||||
|
_hoverVoxelOriginalColor[0] = _hoverVoxel.red;
|
||||||
|
_hoverVoxelOriginalColor[1] = _hoverVoxel.green;
|
||||||
|
_hoverVoxelOriginalColor[2] = _hoverVoxel.blue;
|
||||||
|
_hoverVoxelOriginalColor[3] = 1;
|
||||||
|
_audio.startCollisionSound(1.0, HOVER_VOXEL_FREQUENCY * _hoverVoxel.s * TREE_SCALE, 0.0, HOVER_VOXEL_DECAY);
|
||||||
|
_isHoverVoxelSounding = true;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (event->button() == Qt::RightButton && checkedVoxelModeAction() != 0) {
|
} else if (event->button() == Qt::RightButton && checkedVoxelModeAction() != 0) {
|
||||||
deleteVoxelUnderCursor();
|
deleteVoxelUnderCursor();
|
||||||
|
@ -918,8 +932,10 @@ void Application::touchEndEvent(QTouchEvent* event) {
|
||||||
_isTouchPressed = false;
|
_isTouchPressed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool USE_MOUSEWHEEL = false;
|
||||||
void Application::wheelEvent(QWheelEvent* event) {
|
void Application::wheelEvent(QWheelEvent* event) {
|
||||||
if (activeWindow() == _window) {
|
// Wheel Events disabled for now because they are also activated by touch look pitch up/down.
|
||||||
|
if (USE_MOUSEWHEEL && (activeWindow() == _window)) {
|
||||||
if (checkedVoxelModeAction() == 0) {
|
if (checkedVoxelModeAction() == 0) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
return;
|
return;
|
||||||
|
@ -2085,6 +2101,7 @@ void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& which
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::update(float deltaTime) {
|
void Application::update(float deltaTime) {
|
||||||
|
|
||||||
// Use Transmitter Hand to move hand if connected, else use mouse
|
// Use Transmitter Hand to move hand if connected, else use mouse
|
||||||
if (_myTransmitter.isConnected()) {
|
if (_myTransmitter.isConnected()) {
|
||||||
const float HAND_FORCE_SCALING = 0.01f;
|
const float HAND_FORCE_SCALING = 0.01f;
|
||||||
|
@ -2117,11 +2134,46 @@ void Application::update(float deltaTime) {
|
||||||
// If the mouse is over another avatar's head...
|
// If the mouse is over another avatar's head...
|
||||||
glm::vec3 myLookAtFromMouse(eyePosition);
|
glm::vec3 myLookAtFromMouse(eyePosition);
|
||||||
_myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
|
_myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
|
||||||
|
} else if (_isHoverVoxel) {
|
||||||
|
// Look at the hovered voxel
|
||||||
|
glm::vec3 lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel);
|
||||||
|
_myAvatar.getHead().setLookAtPosition(lookAtSpot);
|
||||||
} else {
|
} else {
|
||||||
|
// Just look in direction of the mouse ray
|
||||||
glm::vec3 myLookAtFromMouse(mouseRayOrigin + mouseRayDirection);
|
glm::vec3 myLookAtFromMouse(mouseRayOrigin + mouseRayDirection);
|
||||||
_myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
|
_myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Find the voxel we are hovering over, and respond if clicked
|
||||||
|
float distance;
|
||||||
|
BoxFace face;
|
||||||
|
|
||||||
|
// If we have clicked on a voxel, update it's color
|
||||||
|
if (_isHoverVoxelSounding) {
|
||||||
|
VoxelNode* hoveredNode = _voxels.getVoxelAt(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s);
|
||||||
|
float bright = _audio.getCollisionSoundMagnitude();
|
||||||
|
nodeColor clickColor = { 255 * bright + _hoverVoxelOriginalColor[0] * (1.f - bright),
|
||||||
|
_hoverVoxelOriginalColor[1] * (1.f - bright),
|
||||||
|
_hoverVoxelOriginalColor[2] * (1.f - bright), 1 };
|
||||||
|
hoveredNode->setColor(clickColor);
|
||||||
|
if (bright < 0.01f) {
|
||||||
|
hoveredNode->setColor(_hoverVoxelOriginalColor);
|
||||||
|
_isHoverVoxelSounding = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Check for a new hover voxel
|
||||||
|
glm::vec4 oldVoxel(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s);
|
||||||
|
_isHoverVoxel = _voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _hoverVoxel, distance, face);
|
||||||
|
if (MAKE_SOUND_ON_VOXEL_HOVER && _isHoverVoxel && glm::vec4(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s) != oldVoxel) {
|
||||||
|
_hoverVoxelOriginalColor[0] = _hoverVoxel.red;
|
||||||
|
_hoverVoxelOriginalColor[1] = _hoverVoxel.green;
|
||||||
|
_hoverVoxelOriginalColor[2] = _hoverVoxel.blue;
|
||||||
|
_hoverVoxelOriginalColor[3] = 1;
|
||||||
|
_audio.startCollisionSound(1.0, HOVER_VOXEL_FREQUENCY * _hoverVoxel.s * TREE_SCALE, 0.0, HOVER_VOXEL_DECAY);
|
||||||
|
_isHoverVoxelSounding = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we are dragging on a voxel, add thrust according to the amount the mouse is dragging
|
// If we are dragging on a voxel, add thrust according to the amount the mouse is dragging
|
||||||
const float VOXEL_GRAB_THRUST = 0.0f;
|
const float VOXEL_GRAB_THRUST = 0.0f;
|
||||||
if (_mousePressed && (_mouseVoxel.s != 0)) {
|
if (_mousePressed && (_mouseVoxel.s != 0)) {
|
||||||
|
@ -2147,8 +2199,6 @@ void Application::update(float deltaTime) {
|
||||||
(fabs(_myAvatar.getVelocity().x) +
|
(fabs(_myAvatar.getVelocity().x) +
|
||||||
fabs(_myAvatar.getVelocity().y) +
|
fabs(_myAvatar.getVelocity().y) +
|
||||||
fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) {
|
fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) {
|
||||||
float distance;
|
|
||||||
BoxFace face;
|
|
||||||
if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) {
|
if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) {
|
||||||
if (distance < MAX_VOXEL_EDIT_DISTANCE) {
|
if (distance < MAX_VOXEL_EDIT_DISTANCE) {
|
||||||
// find the nearest voxel with the desired scale
|
// find the nearest voxel with the desired scale
|
||||||
|
@ -2335,20 +2385,18 @@ void Application::update(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::updateAvatar(float deltaTime) {
|
void Application::updateAvatar(float deltaTime) {
|
||||||
|
|
||||||
// When head is rotated via touch/mouse look, slowly turn body to follow
|
// rotate body yaw for yaw received from multitouch
|
||||||
const float BODY_FOLLOW_HEAD_RATE = 0.5f;
|
|
||||||
// update body yaw by body yaw delta
|
|
||||||
_myAvatar.setOrientation(_myAvatar.getOrientation()
|
_myAvatar.setOrientation(_myAvatar.getOrientation()
|
||||||
* glm::quat(glm::vec3(0, _yawFromTouch * deltaTime * BODY_FOLLOW_HEAD_RATE, 0) * deltaTime));
|
* glm::quat(glm::vec3(0, _yawFromTouch * deltaTime, 0)));
|
||||||
_yawFromTouch -= _yawFromTouch * deltaTime * BODY_FOLLOW_HEAD_RATE;
|
_yawFromTouch = 0.f;
|
||||||
|
|
||||||
// Update my avatar's state from gyros and/or webcam
|
// Update my avatar's state from gyros and/or webcam
|
||||||
_myAvatar.updateFromGyrosAndOrWebcam(_gyroLook->isChecked(),
|
_myAvatar.updateFromGyrosAndOrWebcam(_gyroLook->isChecked(),
|
||||||
glm::vec3(_headCameraPitchYawScale,
|
glm::vec3(_headCameraPitchYawScale,
|
||||||
_headCameraPitchYawScale,
|
_headCameraPitchYawScale,
|
||||||
_headCameraPitchYawScale),
|
_headCameraPitchYawScale),
|
||||||
_yawFromTouch,
|
0.f,
|
||||||
_pitchFromTouch);
|
_pitchFromTouch);
|
||||||
|
|
||||||
if (_serialHeadSensor.isActive()) {
|
if (_serialHeadSensor.isActive()) {
|
||||||
|
@ -2807,8 +2855,12 @@ void Application::displayOverlay() {
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
|
|
||||||
// Display a single screen-size quad to
|
// Display a single screen-size quad to create an alpha blended 'collision' flash
|
||||||
renderCollisionOverlay(_glWidget->width(), _glWidget->height(), _audio.getCollisionSoundMagnitude());
|
float collisionSoundMagnitude = _audio.getCollisionSoundMagnitude();
|
||||||
|
const float VISIBLE_COLLISION_SOUND_MAGNITUDE = 0.5f;
|
||||||
|
if (collisionSoundMagnitude > VISIBLE_COLLISION_SOUND_MAGNITUDE) {
|
||||||
|
renderCollisionOverlay(_glWidget->width(), _glWidget->height(), _audio.getCollisionSoundMagnitude());
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
_audio.render(_glWidget->width(), _glWidget->height());
|
_audio.render(_glWidget->width(), _glWidget->height());
|
||||||
|
|
|
@ -109,8 +109,6 @@ public slots:
|
||||||
|
|
||||||
void sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data);
|
void sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data);
|
||||||
|
|
||||||
void setGroundPlaneImpact(float groundPlaneImpact) { _groundPlaneImpact = groundPlaneImpact; }
|
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
@ -371,14 +369,16 @@ private:
|
||||||
float _yawFromTouch;
|
float _yawFromTouch;
|
||||||
float _pitchFromTouch;
|
float _pitchFromTouch;
|
||||||
|
|
||||||
float _groundPlaneImpact;
|
|
||||||
|
|
||||||
VoxelDetail _mouseVoxelDragging;
|
VoxelDetail _mouseVoxelDragging;
|
||||||
glm::vec3 _voxelThrust;
|
glm::vec3 _voxelThrust;
|
||||||
bool _mousePressed; // true if mouse has been pressed (clear when finished)
|
bool _mousePressed; // true if mouse has been pressed (clear when finished)
|
||||||
|
|
||||||
|
VoxelDetail _hoverVoxel; // Stuff about the voxel I am hovering or clicking
|
||||||
|
bool _isHoverVoxel;
|
||||||
|
bool _isHoverVoxelSounding;
|
||||||
|
nodeColor _hoverVoxelOriginalColor;
|
||||||
|
|
||||||
VoxelDetail _mouseVoxel; // details of the voxel under the mouse cursor
|
VoxelDetail _mouseVoxel; // details of the voxel to be edited
|
||||||
float _mouseVoxelScale; // the scale for adding/removing voxels
|
float _mouseVoxelScale; // the scale for adding/removing voxels
|
||||||
glm::vec3 _lastMouseVoxelPos; // the position of the last mouse voxel edit
|
glm::vec3 _lastMouseVoxelPos; // the position of the last mouse voxel edit
|
||||||
bool _justEditedVoxel; // set when we've just added/deleted/colored a voxel
|
bool _justEditedVoxel; // set when we've just added/deleted/colored a voxel
|
||||||
|
|
|
@ -27,6 +27,7 @@ ParticleSystem::ParticleSystem() {
|
||||||
for (unsigned int emitterIndex = 0; emitterIndex < MAX_EMITTERS; emitterIndex++) {
|
for (unsigned int emitterIndex = 0; emitterIndex < MAX_EMITTERS; emitterIndex++) {
|
||||||
|
|
||||||
Emitter * e = &_emitter[emitterIndex];
|
Emitter * e = &_emitter[emitterIndex];
|
||||||
|
e->active = false;
|
||||||
e->position = glm::vec3(0.0f, 0.0f, 0.0f);
|
e->position = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||||
e->previousPosition = glm::vec3(0.0f, 0.0f, 0.0f);
|
e->previousPosition = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||||
e->direction = glm::vec3(0.0f, 1.0f, 0.0f);
|
e->direction = glm::vec3(0.0f, 1.0f, 0.0f);
|
||||||
|
@ -72,25 +73,16 @@ void ParticleSystem::simulate(float deltaTime) {
|
||||||
|
|
||||||
_timer += deltaTime;
|
_timer += deltaTime;
|
||||||
|
|
||||||
// emit particles
|
// update emitters
|
||||||
for (int e = 0; e < _numEmitters; e++) {
|
for (int emitterIndex = 0; emitterIndex < _numEmitters; emitterIndex++) {
|
||||||
|
assert(emitterIndex <= MAX_EMITTERS);
|
||||||
|
|
||||||
assert(e >= 0);
|
if (_emitter[emitterIndex].active) {
|
||||||
assert(e <= MAX_EMITTERS);
|
updateEmitter(emitterIndex, deltaTime);
|
||||||
assert(_emitter[e].rate >= 0);
|
|
||||||
|
|
||||||
_emitter[e].emitReserve += _emitter[e].rate * deltaTime;
|
|
||||||
_emitter[e].numParticlesEmittedThisTime = (int)_emitter[e].emitReserve;
|
|
||||||
_emitter[e].emitReserve -= _emitter[e].numParticlesEmittedThisTime;
|
|
||||||
|
|
||||||
for (int p = 0; p < _emitter[e].numParticlesEmittedThisTime; p++) {
|
|
||||||
float timeFraction = (float)p / (float)_emitter[e].numParticlesEmittedThisTime;
|
|
||||||
createParticle(e, timeFraction);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update particles
|
|
||||||
|
|
||||||
|
// update particles
|
||||||
for (int p = 0; p < MAX_PARTICLES; p++) {
|
for (int p = 0; p < MAX_PARTICLES; p++) {
|
||||||
if (_particle[p].alive) {
|
if (_particle[p].alive) {
|
||||||
if (_particle[p].age > _emitter[_particle[p].emitterIndex].particleLifespan) {
|
if (_particle[p].age > _emitter[_particle[p].emitterIndex].particleLifespan) {
|
||||||
|
@ -102,6 +94,20 @@ void ParticleSystem::simulate(float deltaTime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ParticleSystem::updateEmitter(int emitterIndex, float deltaTime) {
|
||||||
|
|
||||||
|
_emitter[emitterIndex].emitReserve += _emitter[emitterIndex].rate * deltaTime;
|
||||||
|
_emitter[emitterIndex].numParticlesEmittedThisTime = (int)_emitter[emitterIndex].emitReserve;
|
||||||
|
_emitter[emitterIndex].emitReserve -= _emitter[emitterIndex].numParticlesEmittedThisTime;
|
||||||
|
|
||||||
|
for (int p = 0; p < _emitter[emitterIndex].numParticlesEmittedThisTime; p++) {
|
||||||
|
float timeFraction = (float)p / (float)_emitter[emitterIndex].numParticlesEmittedThisTime;
|
||||||
|
createParticle(emitterIndex, timeFraction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ParticleSystem::createParticle(int e, float timeFraction) {
|
void ParticleSystem::createParticle(int e, float timeFraction) {
|
||||||
|
|
||||||
for (unsigned int p = 0; p < MAX_PARTICLES; p++) {
|
for (unsigned int p = 0; p < MAX_PARTICLES; p++) {
|
||||||
|
@ -212,7 +218,6 @@ void ParticleSystem::setParticleAttributes(int emitterIndex, ParticleLifeStage l
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ParticleSystem::updateParticle(int p, float deltaTime) {
|
void ParticleSystem::updateParticle(int p, float deltaTime) {
|
||||||
|
|
||||||
Emitter myEmitter = _emitter[_particle[p].emitterIndex];
|
Emitter myEmitter = _emitter[_particle[p].emitterIndex];
|
||||||
|
@ -363,14 +368,16 @@ void ParticleSystem::killAllParticles() {
|
||||||
void ParticleSystem::render() {
|
void ParticleSystem::render() {
|
||||||
|
|
||||||
// render the emitters
|
// render the emitters
|
||||||
for (int e = 0; e < _numEmitters; e++) {
|
for (int e = 0; e < MAX_EMITTERS; e++) {
|
||||||
|
|
||||||
if (_emitter[e].showingBaseParticle) {
|
if (_emitter[e].active) {
|
||||||
glColor4f(_particle[0].color.r, _particle[0].color.g, _particle[0].color.b, _particle[0].color.a);
|
if (_emitter[e].showingBaseParticle) {
|
||||||
glPushMatrix();
|
glColor4f(_particle[0].color.r, _particle[0].color.g, _particle[0].color.b, _particle[0].color.a);
|
||||||
glTranslatef(_emitter[e].position.x, _emitter[e].position.y, _emitter[e].position.z);
|
glPushMatrix();
|
||||||
glutSolidSphere(_particle[0].radius, _emitter[e].particleResolution, _emitter[e].particleResolution);
|
glTranslatef(_emitter[e].position.x, _emitter[e].position.y, _emitter[e].position.z);
|
||||||
glPopMatrix();
|
glutSolidSphere(_particle[0].radius, _emitter[e].particleResolution, _emitter[e].particleResolution);
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_emitter[e].visible) {
|
if (_emitter[e].visible) {
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
|
|
||||||
#include <glm/gtc/quaternion.hpp>
|
#include <glm/gtc/quaternion.hpp>
|
||||||
|
|
||||||
const int MAX_PARTICLES = 5000;
|
|
||||||
const int NULL_EMITTER = -1;
|
const int NULL_EMITTER = -1;
|
||||||
const int NULL_PARTICLE = -1;
|
const int NULL_PARTICLE = -1;
|
||||||
const int MAX_EMITTERS = 100;
|
const int MAX_EMITTERS = 100;
|
||||||
|
const int MAX_PARTICLES = 5000;
|
||||||
|
|
||||||
enum ParticleRenderStyle
|
enum ParticleRenderStyle
|
||||||
{
|
{
|
||||||
|
@ -78,6 +78,7 @@ public:
|
||||||
void setParticleAttributes (int emitterIndex, ParticleAttributes attributes); // set attributes for whole life of particles
|
void setParticleAttributes (int emitterIndex, ParticleAttributes attributes); // set attributes for whole life of particles
|
||||||
void setParticleAttributes (int emitterIndex, ParticleLifeStage lifeStage, ParticleAttributes attributes); // set attributes for this life stage
|
void setParticleAttributes (int emitterIndex, ParticleLifeStage lifeStage, ParticleAttributes attributes); // set attributes for this life stage
|
||||||
void setEmitterPosition (int emitterIndex, glm::vec3 position );
|
void setEmitterPosition (int emitterIndex, glm::vec3 position );
|
||||||
|
void setEmitterActive (int emitterIndex, bool active ) {_emitter[emitterIndex].active = active; }
|
||||||
void setEmitterParticleResolution (int emitterIndex, int resolution ) {_emitter[emitterIndex].particleResolution = resolution; }
|
void setEmitterParticleResolution (int emitterIndex, int resolution ) {_emitter[emitterIndex].particleResolution = resolution; }
|
||||||
void setEmitterDirection (int emitterIndex, glm::vec3 direction ) {_emitter[emitterIndex].direction = direction; }
|
void setEmitterDirection (int emitterIndex, glm::vec3 direction ) {_emitter[emitterIndex].direction = direction; }
|
||||||
void setShowingEmitter (int emitterIndex, bool showing ) {_emitter[emitterIndex].visible = showing; }
|
void setShowingEmitter (int emitterIndex, bool showing ) {_emitter[emitterIndex].visible = showing; }
|
||||||
|
@ -101,6 +102,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Emitter {
|
struct Emitter {
|
||||||
|
bool active; // if false, the emitter is disabled - allows for easy switching on and off
|
||||||
glm::vec3 position; // the position of the emitter in world coordinates
|
glm::vec3 position; // the position of the emitter in world coordinates
|
||||||
glm::vec3 previousPosition; // the position of the emitter in the previous time step
|
glm::vec3 previousPosition; // the position of the emitter in the previous time step
|
||||||
glm::vec3 direction; // a normalized vector used as an axis for particle emission and other effects
|
glm::vec3 direction; // a normalized vector used as an axis for particle emission and other effects
|
||||||
|
@ -124,6 +126,7 @@ private:
|
||||||
float _timer;
|
float _timer;
|
||||||
|
|
||||||
// private methods
|
// private methods
|
||||||
|
void updateEmitter(int emitterIndex, float deltaTime);
|
||||||
void updateParticle(int index, float deltaTime);
|
void updateParticle(int index, float deltaTime);
|
||||||
void createParticle(int e, float timeFraction);
|
void createParticle(int e, float timeFraction);
|
||||||
void killParticle(int p);
|
void killParticle(int p);
|
||||||
|
|
|
@ -38,3 +38,7 @@ void applyDamping(float deltaTime, glm::vec3& velocity, float linearStrength, fl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void applyDampedSpring(float deltaTime, glm::vec3& velocity, glm::vec3& position, glm::vec3& targetPosition, float k, float damping) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -339,6 +339,7 @@ void renderCollisionOverlay(int width, int height, float magnitude) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderGroundPlaneGrid(float size, float impact) {
|
void renderGroundPlaneGrid(float size, float impact) {
|
||||||
|
float IMPACT_SOUND_MAGNITUDE_FOR_RECOLOR = 1.f;
|
||||||
glLineWidth(2.0);
|
glLineWidth(2.0);
|
||||||
glm::vec4 impactColor(1, 0, 0, 1);
|
glm::vec4 impactColor(1, 0, 0, 1);
|
||||||
glm::vec3 lineColor(0.4, 0.5, 0.3);
|
glm::vec3 lineColor(0.4, 0.5, 0.3);
|
||||||
|
@ -355,7 +356,12 @@ void renderGroundPlaneGrid(float size, float impact) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the floor, colored for recent impact
|
// Draw the floor, colored for recent impact
|
||||||
glm::vec4 floorColor = impact * impactColor + (1.f - impact) * surfaceColor;
|
glm::vec4 floorColor;
|
||||||
|
if (impact > IMPACT_SOUND_MAGNITUDE_FOR_RECOLOR) {
|
||||||
|
floorColor = impact * impactColor + (1.f - impact) * surfaceColor;
|
||||||
|
} else {
|
||||||
|
floorColor = surfaceColor;
|
||||||
|
}
|
||||||
glColor4fv(&floorColor.x);
|
glColor4fv(&floorColor.x);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glVertex3f(0, 0, 0);
|
glVertex3f(0, 0, 0);
|
||||||
|
|
|
@ -889,21 +889,15 @@ void Avatar::updateCollisionWithSphere(glm::vec3 position, float radius, float d
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::updateCollisionWithEnvironment(float deltaTime) {
|
void Avatar::updateCollisionWithEnvironment(float deltaTime) {
|
||||||
|
|
||||||
glm::vec3 up = getBodyUpDirection();
|
glm::vec3 up = getBodyUpDirection();
|
||||||
float radius = _height * 0.125f;
|
float radius = _height * 0.125f;
|
||||||
const float ENVIRONMENT_SURFACE_ELASTICITY = 1.0f;
|
const float ENVIRONMENT_SURFACE_ELASTICITY = 1.0f;
|
||||||
const float ENVIRONMENT_SURFACE_DAMPING = 0.01;
|
const float ENVIRONMENT_SURFACE_DAMPING = 0.01;
|
||||||
const float ENVIRONMENT_COLLISION_FREQUENCY = 0.05f;
|
const float ENVIRONMENT_COLLISION_FREQUENCY = 0.05f;
|
||||||
const float VISIBLE_GROUND_COLLISION_VELOCITY = 0.2f;
|
|
||||||
glm::vec3 penetration;
|
glm::vec3 penetration;
|
||||||
if (Application::getInstance()->getEnvironment()->findCapsulePenetration(
|
if (Application::getInstance()->getEnvironment()->findCapsulePenetration(
|
||||||
_position - up * (_pelvisFloatingHeight - radius),
|
_position - up * (_pelvisFloatingHeight - radius),
|
||||||
_position + up * (_height - _pelvisFloatingHeight - radius), radius, penetration)) {
|
_position + up * (_height - _pelvisFloatingHeight - radius), radius, penetration)) {
|
||||||
float velocityTowardCollision = glm::dot(_velocity, glm::normalize(penetration));
|
|
||||||
if (velocityTowardCollision > VISIBLE_GROUND_COLLISION_VELOCITY) {
|
|
||||||
Application::getInstance()->setGroundPlaneImpact(1.0f);
|
|
||||||
}
|
|
||||||
_lastCollisionPosition = _position;
|
_lastCollisionPosition = _position;
|
||||||
updateCollisionSound(penetration, deltaTime, ENVIRONMENT_COLLISION_FREQUENCY);
|
updateCollisionSound(penetration, deltaTime, ENVIRONMENT_COLLISION_FREQUENCY);
|
||||||
applyHardCollision(penetration, ENVIRONMENT_SURFACE_ELASTICITY, ENVIRONMENT_SURFACE_DAMPING);
|
applyHardCollision(penetration, ENVIRONMENT_SURFACE_ELASTICITY, ENVIRONMENT_SURFACE_DAMPING);
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "renderer/ProgramObject.h"
|
#include "renderer/ProgramObject.h"
|
||||||
|
|
||||||
const bool SHOW_LEAP_HAND = true;
|
const bool SHOW_LEAP_HAND = false;
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ void Hand::reset() {
|
||||||
|
|
||||||
|
|
||||||
void Hand::simulate(float deltaTime, bool isMine) {
|
void Hand::simulate(float deltaTime, bool isMine) {
|
||||||
|
|
||||||
if (_isRaveGloveActive) {
|
if (_isRaveGloveActive) {
|
||||||
updateRaveGloveParticles(deltaTime);
|
updateRaveGloveParticles(deltaTime);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +64,8 @@ void Hand::calculateGeometry() {
|
||||||
_basePosition = head.getPosition() + head.getOrientation() * offset;
|
_basePosition = head.getPosition() + head.getOrientation() * offset;
|
||||||
_baseOrientation = head.getOrientation();
|
_baseOrientation = head.getOrientation();
|
||||||
|
|
||||||
_leapBalls.clear();
|
// generate finger tip balls....
|
||||||
|
_leapFingerTipBalls.clear();
|
||||||
for (size_t i = 0; i < getNumPalms(); ++i) {
|
for (size_t i = 0; i < getNumPalms(); ++i) {
|
||||||
PalmData& palm = getPalms()[i];
|
PalmData& palm = getPalms()[i];
|
||||||
if (palm.isActive()) {
|
if (palm.isActive()) {
|
||||||
|
@ -71,8 +73,8 @@ void Hand::calculateGeometry() {
|
||||||
FingerData& finger = palm.getFingers()[f];
|
FingerData& finger = palm.getFingers()[f];
|
||||||
if (finger.isActive()) {
|
if (finger.isActive()) {
|
||||||
const float standardBallRadius = 0.01f;
|
const float standardBallRadius = 0.01f;
|
||||||
_leapBalls.resize(_leapBalls.size() + 1);
|
_leapFingerTipBalls.resize(_leapFingerTipBalls.size() + 1);
|
||||||
HandBall& ball = _leapBalls.back();
|
HandBall& ball = _leapFingerTipBalls.back();
|
||||||
ball.rotation = _baseOrientation;
|
ball.rotation = _baseOrientation;
|
||||||
ball.position = finger.getTipPosition();
|
ball.position = finger.getTipPosition();
|
||||||
ball.radius = standardBallRadius;
|
ball.radius = standardBallRadius;
|
||||||
|
@ -82,6 +84,27 @@ void Hand::calculateGeometry() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// generate finger rot balls....
|
||||||
|
_leapFingerRootBalls.clear();
|
||||||
|
for (size_t i = 0; i < getNumPalms(); ++i) {
|
||||||
|
PalmData& palm = getPalms()[i];
|
||||||
|
if (palm.isActive()) {
|
||||||
|
for (size_t f = 0; f < palm.getNumFingers(); ++f) {
|
||||||
|
FingerData& finger = palm.getFingers()[f];
|
||||||
|
if (finger.isActive()) {
|
||||||
|
const float standardBallRadius = 0.01f;
|
||||||
|
_leapFingerRootBalls.resize(_leapFingerRootBalls.size() + 1);
|
||||||
|
HandBall& ball = _leapFingerRootBalls.back();
|
||||||
|
ball.rotation = _baseOrientation;
|
||||||
|
ball.position = finger.getRootPosition();
|
||||||
|
ball.radius = standardBallRadius;
|
||||||
|
ball.touchForce = 0.0;
|
||||||
|
ball.isCollidable = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hand::setRaveGloveEffectsMode(QKeyEvent* event) {
|
void Hand::setRaveGloveEffectsMode(QKeyEvent* event) {
|
||||||
|
@ -120,8 +143,9 @@ void Hand::render(bool lookingInMirror) {
|
||||||
glEnable(GL_RESCALE_NORMAL);
|
glEnable(GL_RESCALE_NORMAL);
|
||||||
|
|
||||||
if ( SHOW_LEAP_HAND ) {
|
if ( SHOW_LEAP_HAND ) {
|
||||||
renderFingerTrails();
|
//renderLeapHands();
|
||||||
renderHandSpheres();
|
renderLeapFingerTrails();
|
||||||
|
renderLeapHandSpheres();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,18 +177,64 @@ void Hand::renderRaveGloveStage() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hand::renderHandSpheres() {
|
|
||||||
|
void Hand::renderLeapHands() {
|
||||||
|
for (size_t i = 0; i < getNumPalms(); ++i) {
|
||||||
|
PalmData& hand = getPalms()[i];
|
||||||
|
if (hand.isActive()) {
|
||||||
|
renderLeapHand(hand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Hand::renderLeapHand(PalmData& hand) {
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
const float palmThickness = 0.002f;
|
||||||
|
glColor4f(0.5f, 0.5f, 0.5f, 1.0);
|
||||||
|
glm::vec3 tip = hand.getPosition();
|
||||||
|
glm::vec3 root = hand.getPosition() + hand.getNormal() * palmThickness;
|
||||||
|
Avatar::renderJointConnectingCone(root, tip, 0.05, 0.03);
|
||||||
|
|
||||||
|
for (size_t f = 0; f < hand.getNumFingers(); ++f) {
|
||||||
|
FingerData& finger = hand.getFingers()[f];
|
||||||
|
if (finger.isActive()) {
|
||||||
|
glColor4f(_ballColor.r, _ballColor.g, _ballColor.b, 0.5);
|
||||||
|
glm::vec3 tip = finger.getTipPosition();
|
||||||
|
glm::vec3 root = finger.getRootPosition();
|
||||||
|
Avatar::renderJointConnectingCone(root, tip, 0.001, 0.003);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Hand::renderLeapHandSpheres() {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
// Draw the leap balls
|
// Draw the leap balls
|
||||||
for (size_t i = 0; i < _leapBalls.size(); i++) {
|
for (size_t i = 0; i < _leapFingerTipBalls.size(); i++) {
|
||||||
float alpha = 1.0f;
|
float alpha = 1.0f;
|
||||||
|
|
||||||
if (alpha > 0.0f) {
|
if (alpha > 0.0f) {
|
||||||
glColor4f(_ballColor.r, _ballColor.g, _ballColor.b, alpha);
|
glColor4f(_ballColor.r, _ballColor.g, _ballColor.b, alpha);
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(_leapBalls[i].position.x, _leapBalls[i].position.y, _leapBalls[i].position.z);
|
glTranslatef(_leapFingerTipBalls[i].position.x, _leapFingerTipBalls[i].position.y, _leapFingerTipBalls[i].position.z);
|
||||||
glutSolidSphere(_leapBalls[i].radius, 20.0f, 20.0f);
|
glutSolidSphere(_leapFingerTipBalls[i].radius, 20.0f, 20.0f);
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < _leapFingerRootBalls.size(); i++) {
|
||||||
|
float alpha = 1.0f;
|
||||||
|
|
||||||
|
if (alpha > 0.0f) {
|
||||||
|
glColor4f(0.3f, 0.4f, 0.6f, alpha);
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(_leapFingerRootBalls[i].position.x, _leapFingerRootBalls[i].position.y, _leapFingerRootBalls[i].position.z);
|
||||||
|
glutSolidSphere(_leapFingerRootBalls[i].radius, 20.0f, 20.0f);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,7 +270,7 @@ void Hand::renderHandSpheres() {
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hand::renderFingerTrails() {
|
void Hand::renderLeapFingerTrails() {
|
||||||
// Draw the finger root cones
|
// Draw the finger root cones
|
||||||
for (size_t i = 0; i < getNumPalms(); ++i) {
|
for (size_t i = 0; i < getNumPalms(); ++i) {
|
||||||
PalmData& palm = getPalms()[i];
|
PalmData& palm = getPalms()[i];
|
||||||
|
@ -229,6 +299,7 @@ void Hand::renderFingerTrails() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Hand::setLeapHands(const std::vector<glm::vec3>& handPositions,
|
void Hand::setLeapHands(const std::vector<glm::vec3>& handPositions,
|
||||||
const std::vector<glm::vec3>& handNormals) {
|
const std::vector<glm::vec3>& handNormals) {
|
||||||
for (size_t i = 0; i < getNumPalms(); ++i) {
|
for (size_t i = 0; i < getNumPalms(); ++i) {
|
||||||
|
@ -244,69 +315,28 @@ void Hand::setLeapHands(const std::vector<glm::vec3>& handPositions,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// call this right after the geometry of the leap hands are set
|
|
||||||
|
// call this soon after the geometry of the leap hands are set
|
||||||
void Hand::updateRaveGloveEmitters() {
|
void Hand::updateRaveGloveEmitters() {
|
||||||
|
|
||||||
bool debug = false;
|
for (size_t i = 0; i < NUM_FINGERS; i++) {
|
||||||
|
_raveGloveParticleSystem.setEmitterActive(_raveGloveEmitter[i], false);
|
||||||
|
}
|
||||||
|
|
||||||
if (_raveGloveInitialized) {
|
for (size_t i = 0; i < _leapFingerTipBalls.size(); i++) {
|
||||||
|
if (i < NUM_FINGERS) {
|
||||||
if(debug) printf( "\n" );
|
glm::vec3 fingerDirection = _leapFingerTipBalls[i].position - _leapFingerRootBalls[i].position;
|
||||||
if(debug) printf( "------------------------------------\n" );
|
float fingerLength = glm::length(fingerDirection);
|
||||||
if(debug) printf( "updating rave glove emitters:\n" );
|
|
||||||
if(debug) printf( "------------------------------------\n" );
|
|
||||||
|
|
||||||
int emitterIndex = 0;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < getNumPalms(); ++i) {
|
|
||||||
PalmData& palm = getPalms()[i];
|
|
||||||
|
|
||||||
if(debug) printf( "\n" );
|
if (fingerLength > 0.0f) {
|
||||||
if(debug) printf( "palm %d ", (int)i );
|
fingerDirection /= fingerLength;
|
||||||
|
|
||||||
if (palm.isActive()) {
|
|
||||||
|
|
||||||
if(debug) printf( "is active\n" );
|
|
||||||
|
|
||||||
for (size_t f = 0; f < palm.getNumFingers(); ++f) {
|
|
||||||
FingerData& finger = palm.getFingers()[f];
|
|
||||||
|
|
||||||
if(debug) printf( "emitterIndex %d: ", emitterIndex );
|
|
||||||
|
|
||||||
if (finger.isActive()) {
|
|
||||||
|
|
||||||
if ((emitterIndex >=0)
|
|
||||||
&& (emitterIndex < NUM_FINGERS)) {
|
|
||||||
|
|
||||||
assert(emitterIndex >=0 );
|
|
||||||
assert(emitterIndex < NUM_FINGERS );
|
|
||||||
|
|
||||||
if(debug) printf( "_raveGloveEmitter[%d] = %d\n", emitterIndex, _raveGloveEmitter[emitterIndex] );
|
|
||||||
|
|
||||||
glm::vec3 fingerDirection = finger.getTipPosition() - finger.getRootPosition();
|
|
||||||
float fingerLength = glm::length(fingerDirection);
|
|
||||||
|
|
||||||
if (fingerLength > 0.0f) {
|
|
||||||
fingerDirection /= fingerLength;
|
|
||||||
} else {
|
|
||||||
fingerDirection = IDENTITY_UP;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(_raveGloveEmitter[emitterIndex] >=0 );
|
|
||||||
assert(_raveGloveEmitter[emitterIndex] < NUM_FINGERS );
|
|
||||||
|
|
||||||
_raveGloveParticleSystem.setEmitterPosition (_raveGloveEmitter[emitterIndex], finger.getTipPosition());
|
|
||||||
_raveGloveParticleSystem.setEmitterDirection(_raveGloveEmitter[emitterIndex], fingerDirection);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(debug) printf( "BOGUS finger\n" );
|
|
||||||
}
|
|
||||||
|
|
||||||
emitterIndex ++;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if(debug) printf( "is NOT active\n" );
|
fingerDirection = IDENTITY_UP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_raveGloveParticleSystem.setEmitterActive (_raveGloveEmitter[i], true);
|
||||||
|
_raveGloveParticleSystem.setEmitterPosition (_raveGloveEmitter[i], _leapFingerTipBalls[i].position);
|
||||||
|
_raveGloveParticleSystem.setEmitterDirection(_raveGloveEmitter[i], fingerDirection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,16 +347,11 @@ void Hand::updateRaveGloveParticles(float deltaTime) {
|
||||||
|
|
||||||
if (!_raveGloveInitialized) {
|
if (!_raveGloveInitialized) {
|
||||||
|
|
||||||
//printf( "Initializing rave glove emitters:\n" );
|
|
||||||
//printf( "The indices of the emitters are:\n" );
|
|
||||||
|
|
||||||
// start up the rave glove finger particles...
|
// start up the rave glove finger particles...
|
||||||
for ( int f = 0; f< NUM_FINGERS; f ++ ) {
|
for ( int f = 0; f< NUM_FINGERS; f ++ ) {
|
||||||
_raveGloveEmitter[f] = _raveGloveParticleSystem.addEmitter();
|
_raveGloveEmitter[f] = _raveGloveParticleSystem.addEmitter();
|
||||||
assert( _raveGloveEmitter[f] >= 0 );
|
assert( _raveGloveEmitter[f] >= 0 );
|
||||||
assert( _raveGloveEmitter[f] != NULL_EMITTER );
|
assert( _raveGloveEmitter[f] != NULL_EMITTER );
|
||||||
|
|
||||||
//printf( "%d\n", _raveGloveEmitter[f] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setRaveGloveMode(RAVE_GLOVE_EFFECTS_MODE_FIRE);
|
setRaveGloveMode(RAVE_GLOVE_EFFECTS_MODE_FIRE);
|
||||||
|
@ -339,13 +364,13 @@ void Hand::updateRaveGloveParticles(float deltaTime) {
|
||||||
// this rave glove effect oscillates though various colors and radii that are meant to show off some effects
|
// this rave glove effect oscillates though various colors and radii that are meant to show off some effects
|
||||||
if (_raveGloveMode == RAVE_GLOVE_EFFECTS_MODE_THROBBING_COLOR) {
|
if (_raveGloveMode == RAVE_GLOVE_EFFECTS_MODE_THROBBING_COLOR) {
|
||||||
ParticleSystem::ParticleAttributes attributes;
|
ParticleSystem::ParticleAttributes attributes;
|
||||||
float red = 0.5f + 0.5f * sinf(_raveGloveClock * 1.4f);
|
float red = 0.5f + 0.5f * sinf(_raveGloveClock * 2.4f);
|
||||||
float green = 0.5f + 0.5f * cosf(_raveGloveClock * 1.7f);
|
float green = 0.5f + 0.5f * cosf(_raveGloveClock * 2.7f);
|
||||||
float blue = 0.5f + 0.5f * sinf(_raveGloveClock * 2.0f);
|
float blue = 0.5f + 0.5f * sinf(_raveGloveClock * 3.0f);
|
||||||
float alpha = 1.0f;
|
float alpha = 1.0f;
|
||||||
|
|
||||||
attributes.color = glm::vec4(red, green, blue, alpha);
|
attributes.color = glm::vec4(red, green, blue, alpha);
|
||||||
attributes.radius = 0.01f + 0.005f * sinf(_raveGloveClock * 2.2f);
|
attributes.radius = 0.01f + 0.003f * sinf(_raveGloveClock * 50.0f);
|
||||||
attributes.modulationAmplitude = 0.0f;
|
attributes.modulationAmplitude = 0.0f;
|
||||||
|
|
||||||
for ( int f = 0; f< NUM_FINGERS; f ++ ) {
|
for ( int f = 0; f< NUM_FINGERS; f ++ ) {
|
||||||
|
@ -360,6 +385,8 @@ void Hand::updateRaveGloveParticles(float deltaTime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Hand::setRaveGloveMode(int mode) {
|
void Hand::setRaveGloveMode(int mode) {
|
||||||
|
|
||||||
_raveGloveMode = mode;
|
_raveGloveMode = mode;
|
||||||
|
@ -376,7 +403,7 @@ void Hand::setRaveGloveMode(int mode) {
|
||||||
if (mode == RAVE_GLOVE_EFFECTS_MODE_THROBBING_COLOR) {
|
if (mode == RAVE_GLOVE_EFFECTS_MODE_THROBBING_COLOR) {
|
||||||
_raveGloveParticleSystem.setParticleRenderStyle (_raveGloveEmitter[f], PARTICLE_RENDER_STYLE_SPHERE );
|
_raveGloveParticleSystem.setParticleRenderStyle (_raveGloveEmitter[f], PARTICLE_RENDER_STYLE_SPHERE );
|
||||||
_raveGloveParticleSystem.setShowingEmitterBaseParticle(_raveGloveEmitter[f], true );
|
_raveGloveParticleSystem.setShowingEmitterBaseParticle(_raveGloveEmitter[f], true );
|
||||||
_raveGloveParticleSystem.setEmitterParticleLifespan (_raveGloveEmitter[f], 0.0f );
|
_raveGloveParticleSystem.setEmitterParticleLifespan (_raveGloveEmitter[f], 0.03f );
|
||||||
_raveGloveParticleSystem.setEmitterThrust (_raveGloveEmitter[f], 0.0f );
|
_raveGloveParticleSystem.setEmitterThrust (_raveGloveEmitter[f], 0.0f );
|
||||||
_raveGloveParticleSystem.setEmitterRate (_raveGloveEmitter[f], 30.0f );
|
_raveGloveParticleSystem.setEmitterRate (_raveGloveEmitter[f], 30.0f );
|
||||||
_raveGloveParticleSystem.setEmitterParticleResolution (_raveGloveEmitter[f], 20 );
|
_raveGloveParticleSystem.setEmitterParticleResolution (_raveGloveEmitter[f], 20 );
|
||||||
|
@ -650,7 +677,7 @@ void Hand::setRaveGloveMode(int mode) {
|
||||||
_raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_3, attributes);
|
_raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_3, attributes);
|
||||||
|
|
||||||
//-----------------------------------------
|
//-----------------------------------------
|
||||||
// throb
|
// long sparkler
|
||||||
//-----------------------------------------
|
//-----------------------------------------
|
||||||
} else if (mode == RAVE_GLOVE_EFFECTS_MODE_LONG_SPARKLER) {
|
} else if (mode == RAVE_GLOVE_EFFECTS_MODE_LONG_SPARKLER) {
|
||||||
|
|
||||||
|
@ -672,6 +699,30 @@ void Hand::setRaveGloveMode(int mode) {
|
||||||
_raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_1, attributes);
|
_raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_1, attributes);
|
||||||
_raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_2, attributes);
|
_raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_2, attributes);
|
||||||
_raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_3, attributes);
|
_raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_3, attributes);
|
||||||
|
|
||||||
|
//-----------------------------------------
|
||||||
|
// throb
|
||||||
|
//-----------------------------------------
|
||||||
|
} else if (mode == RAVE_GLOVE_EFFECTS_MODE_THROB) {
|
||||||
|
|
||||||
|
_raveGloveParticleSystem.setParticleRenderStyle (_raveGloveEmitter[f], PARTICLE_RENDER_STYLE_SPHERE );
|
||||||
|
_raveGloveParticleSystem.setShowingEmitterBaseParticle(_raveGloveEmitter[f], true );
|
||||||
|
_raveGloveParticleSystem.setEmitterParticleLifespan (_raveGloveEmitter[f], 0.03 );
|
||||||
|
_raveGloveParticleSystem.setEmitterThrust (_raveGloveEmitter[f], 0.0f );
|
||||||
|
_raveGloveParticleSystem.setEmitterRate (_raveGloveEmitter[f], 30.0 );
|
||||||
|
_raveGloveParticleSystem.setEmitterParticleResolution (_raveGloveEmitter[f], 20 );
|
||||||
|
|
||||||
|
_raveGloveParticleSystem.setParticleAttributesToDefault(&attributes);
|
||||||
|
|
||||||
|
attributes.radius = 0.01f;
|
||||||
|
attributes.color = glm::vec4( 0.1f, 0.2f, 0.4f, 0.5f);
|
||||||
|
attributes.modulationAmplitude = 0.5;
|
||||||
|
attributes.modulationRate = 3.0;
|
||||||
|
attributes.modulationStyle = COLOR_MODULATION_STYLE_LIGHTNESS_WAVE;
|
||||||
|
_raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_0, attributes);
|
||||||
|
_raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_1, attributes);
|
||||||
|
_raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_2, attributes);
|
||||||
|
_raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_3, attributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,9 @@ public:
|
||||||
void setRaveGloveEffectsMode(QKeyEvent* event);
|
void setRaveGloveEffectsMode(QKeyEvent* event);
|
||||||
|
|
||||||
// getters
|
// getters
|
||||||
const glm::vec3& getLeapBallPosition (int ball) const { return _leapBalls[ball].position;}
|
const glm::vec3& getLeapFingerTipBallPosition (int ball) const { return _leapFingerTipBalls [ball].position;}
|
||||||
bool isRaveGloveActive () const { return _isRaveGloveActive; }
|
const glm::vec3& getLeapFingerRootBallPosition(int ball) const { return _leapFingerRootBalls[ball].position;}
|
||||||
|
bool isRaveGloveActive() const { return _isRaveGloveActive; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// disallow copies of the Hand, copy of owning Avatar is disallowed too
|
// disallow copies of the Hand, copy of owning Avatar is disallowed too
|
||||||
|
@ -84,7 +85,8 @@ private:
|
||||||
float _renderAlpha;
|
float _renderAlpha;
|
||||||
bool _lookingInMirror;
|
bool _lookingInMirror;
|
||||||
glm::vec3 _ballColor;
|
glm::vec3 _ballColor;
|
||||||
std::vector<HandBall> _leapBalls;
|
std::vector<HandBall> _leapFingerTipBalls;
|
||||||
|
std::vector<HandBall> _leapFingerRootBalls;
|
||||||
|
|
||||||
// private methods
|
// private methods
|
||||||
void setLeapHands(const std::vector<glm::vec3>& handPositions,
|
void setLeapHands(const std::vector<glm::vec3>& handPositions,
|
||||||
|
@ -92,8 +94,10 @@ private:
|
||||||
|
|
||||||
void renderRaveGloveStage();
|
void renderRaveGloveStage();
|
||||||
void setRaveGloveMode(int mode);
|
void setRaveGloveMode(int mode);
|
||||||
void renderHandSpheres();
|
void renderLeapHandSpheres();
|
||||||
void renderFingerTrails();
|
void renderLeapHands();
|
||||||
|
void renderLeapHand(PalmData& hand);
|
||||||
|
void renderLeapFingerTrails();
|
||||||
void calculateGeometry();
|
void calculateGeometry();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
17
libraries/avatars/src/AvatarData.cpp
Executable file → Normal file
17
libraries/avatars/src/AvatarData.cpp
Executable file → Normal file
|
@ -130,6 +130,8 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
||||||
|
|
||||||
// leap hand data
|
// leap hand data
|
||||||
std::vector<glm::vec3> fingerVectors;
|
std::vector<glm::vec3> fingerVectors;
|
||||||
|
|
||||||
|
//printf("about to call _handData->encodeRemoteData(fingerVectors);\n");
|
||||||
_handData->encodeRemoteData(fingerVectors);
|
_handData->encodeRemoteData(fingerVectors);
|
||||||
|
|
||||||
if (fingerVectors.size() > 255)
|
if (fingerVectors.size() > 255)
|
||||||
|
@ -244,17 +246,32 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||||
// hand state, stored as a semi-nibble in the bitItems
|
// hand state, stored as a semi-nibble in the bitItems
|
||||||
_handState = getSemiNibbleAt(bitItems,HAND_STATE_START_BIT);
|
_handState = getSemiNibbleAt(bitItems,HAND_STATE_START_BIT);
|
||||||
|
|
||||||
|
//printf("about to call leap hand data code in AvatarData::parseData...\n");
|
||||||
|
|
||||||
// leap hand data
|
// leap hand data
|
||||||
if (sourceBuffer - startPosition < numBytes) {
|
if (sourceBuffer - startPosition < numBytes) {
|
||||||
|
|
||||||
|
//printf("got inside of 'if (sourceBuffer - startPosition < numBytes)'\n");
|
||||||
|
|
||||||
|
|
||||||
// check passed, bytes match
|
// check passed, bytes match
|
||||||
unsigned int numFingerVectors = *sourceBuffer++;
|
unsigned int numFingerVectors = *sourceBuffer++;
|
||||||
|
|
||||||
|
//printf("numFingerVectors = %d\n", numFingerVectors);
|
||||||
|
|
||||||
|
|
||||||
if (numFingerVectors > 0) {
|
if (numFingerVectors > 0) {
|
||||||
|
|
||||||
|
//printf("ok, we got fingers in AvatarData::parseData\n");
|
||||||
|
|
||||||
std::vector<glm::vec3> fingerVectors(numFingerVectors);
|
std::vector<glm::vec3> fingerVectors(numFingerVectors);
|
||||||
for (size_t i = 0; i < numFingerVectors; ++i) {
|
for (size_t i = 0; i < numFingerVectors; ++i) {
|
||||||
sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(fingerVectors[i].x), fingerVectorRadix);
|
sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(fingerVectors[i].x), fingerVectorRadix);
|
||||||
sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(fingerVectors[i].y), fingerVectorRadix);
|
sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(fingerVectors[i].y), fingerVectorRadix);
|
||||||
sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(fingerVectors[i].z), fingerVectorRadix);
|
sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(fingerVectors[i].z), fingerVectorRadix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf("about to call _handData->decodeRemoteData(fingerVectors);\n");
|
||||||
_handData->decodeRemoteData(fingerVectors);
|
_handData->decodeRemoteData(fingerVectors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
3
libraries/avatars/src/HandData.cpp
Executable file → Normal file
3
libraries/avatars/src/HandData.cpp
Executable file → Normal file
|
@ -51,7 +51,9 @@ _owningHandData(owningHandData)
|
||||||
|
|
||||||
void HandData::encodeRemoteData(std::vector<glm::vec3>& fingerVectors) {
|
void HandData::encodeRemoteData(std::vector<glm::vec3>& fingerVectors) {
|
||||||
fingerVectors.clear();
|
fingerVectors.clear();
|
||||||
|
|
||||||
for (size_t i = 0; i < getNumPalms(); ++i) {
|
for (size_t i = 0; i < getNumPalms(); ++i) {
|
||||||
|
|
||||||
PalmData& palm = getPalms()[i];
|
PalmData& palm = getPalms()[i];
|
||||||
if (!palm.isActive()) {
|
if (!palm.isActive()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -60,6 +62,7 @@ void HandData::encodeRemoteData(std::vector<glm::vec3>& fingerVectors) {
|
||||||
fingerVectors.push_back(palm.getRawNormal());
|
fingerVectors.push_back(palm.getRawNormal());
|
||||||
for (size_t f = 0; f < palm.getNumFingers(); ++f) {
|
for (size_t f = 0; f < palm.getNumFingers(); ++f) {
|
||||||
FingerData& finger = palm.getFingers()[f];
|
FingerData& finger = palm.getFingers()[f];
|
||||||
|
|
||||||
if (finger.isActive()) {
|
if (finger.isActive()) {
|
||||||
fingerVectors.push_back(finger.getTipRawPosition());
|
fingerVectors.push_back(finger.getTipRawPosition());
|
||||||
fingerVectors.push_back(finger.getRootRawPosition());
|
fingerVectors.push_back(finger.getRootRawPosition());
|
||||||
|
|
Loading…
Reference in a new issue