mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 00:10:52 +02:00
Removed obsolete HandControl class, files
This commit is contained in:
parent
44f92fb47c
commit
a84e97c54a
8 changed files with 114 additions and 155 deletions
|
@ -126,6 +126,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
_mouseVoxelScale(1.0f / 1024.0f),
|
_mouseVoxelScale(1.0f / 1024.0f),
|
||||||
_mouseVoxelScaleInitialized(false),
|
_mouseVoxelScaleInitialized(false),
|
||||||
_justEditedVoxel(false),
|
_justEditedVoxel(false),
|
||||||
|
_isHighlightVoxel(false),
|
||||||
_nudgeStarted(false),
|
_nudgeStarted(false),
|
||||||
_lookingAlongX(false),
|
_lookingAlongX(false),
|
||||||
_lookingAwayFromOrigin(true),
|
_lookingAwayFromOrigin(true),
|
||||||
|
@ -1765,8 +1766,6 @@ void Application::init() {
|
||||||
_voxelShader.init();
|
_voxelShader.init();
|
||||||
_pointShader.init();
|
_pointShader.init();
|
||||||
|
|
||||||
_handControl.setScreenDimensions(_glWidget->width(), _glWidget->height());
|
|
||||||
|
|
||||||
_headMouseX = _mouseX = _glWidget->width() / 2;
|
_headMouseX = _mouseX = _glWidget->width() / 2;
|
||||||
_headMouseY = _mouseY = _glWidget->height() / 2;
|
_headMouseY = _mouseY = _glWidget->height() / 2;
|
||||||
QCursor::setPos(_headMouseX, _headMouseY);
|
QCursor::setPos(_headMouseX, _headMouseY);
|
||||||
|
@ -1991,6 +1990,24 @@ void Application::renderFollowIndicator() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::renderHighlightVoxel(VoxelDetail voxel) {
|
||||||
|
glDisable(GL_LIGHTING);
|
||||||
|
glPushMatrix();
|
||||||
|
glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE);
|
||||||
|
//printf("Render: %.6f,%.6f,%.6f %.8f\n", voxel.x, voxel.y, voxel.z,
|
||||||
|
// voxel.s);
|
||||||
|
const float EDGE_EXPAND = 1.01f;
|
||||||
|
//glColor3ub(voxel.red + 128, voxel.green + 128, voxel.blue + 128);
|
||||||
|
glColor3ub(255, 0, 0);
|
||||||
|
|
||||||
|
glTranslatef(voxel.x + voxel.s * 0.5f,
|
||||||
|
voxel.y + voxel.s * 0.5f,
|
||||||
|
voxel.z + voxel.s * 0.5f);
|
||||||
|
glLineWidth(4.0f);
|
||||||
|
glutWireCube(_mouseVoxel.s * EDGE_EXPAND);
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) {
|
void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) {
|
||||||
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
||||||
PerformanceWarning warn(showWarnings, "Application::updateAvatars()");
|
PerformanceWarning warn(showWarnings, "Application::updateAvatars()");
|
||||||
|
@ -2236,11 +2253,6 @@ void Application::updateHandAndTouch(float deltaTime) {
|
||||||
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
||||||
PerformanceWarning warn(showWarnings, "Application::updateHandAndTouch()");
|
PerformanceWarning warn(showWarnings, "Application::updateHandAndTouch()");
|
||||||
|
|
||||||
// walking triggers the handControl to stop
|
|
||||||
if (_myAvatar.getMode() == AVATAR_MODE_WALKING) {
|
|
||||||
_handControl.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update from Touch
|
// Update from Touch
|
||||||
if (_isTouchPressed) {
|
if (_isTouchPressed) {
|
||||||
float TOUCH_YAW_SCALE = -0.25f;
|
float TOUCH_YAW_SCALE = -0.25f;
|
||||||
|
@ -3025,6 +3037,11 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
|
||||||
// restore default, white specular
|
// restore default, white specular
|
||||||
glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR);
|
glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR);
|
||||||
|
|
||||||
|
// Render the highlighted voxel
|
||||||
|
if (_isHighlightVoxel) {
|
||||||
|
renderHighlightVoxel(_highlightVoxel);
|
||||||
|
}
|
||||||
|
|
||||||
// indicate what we'll be adding/removing in mouse mode, if anything
|
// indicate what we'll be adding/removing in mouse mode, if anything
|
||||||
if (_mouseVoxel.s != 0 && whichCamera.getMode() != CAMERA_MODE_MIRROR) {
|
if (_mouseVoxel.s != 0 && whichCamera.getMode() != CAMERA_MODE_MIRROR) {
|
||||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
|
@ -3048,7 +3065,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
|
||||||
} else {
|
} else {
|
||||||
renderMouseVoxelGrid(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
|
renderMouseVoxelGrid(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode)) {
|
||||||
// use a contrasting color so that we can see what we're doing
|
// use a contrasting color so that we can see what we're doing
|
||||||
glColor3ub(_mouseVoxel.red + 128, _mouseVoxel.green + 128, _mouseVoxel.blue + 128);
|
glColor3ub(_mouseVoxel.red + 128, _mouseVoxel.green + 128, _mouseVoxel.blue + 128);
|
||||||
|
|
|
@ -47,7 +47,6 @@
|
||||||
#include "avatar/Avatar.h"
|
#include "avatar/Avatar.h"
|
||||||
#include "avatar/MyAvatar.h"
|
#include "avatar/MyAvatar.h"
|
||||||
#include "avatar/Profile.h"
|
#include "avatar/Profile.h"
|
||||||
#include "avatar/HandControl.h"
|
|
||||||
#include "devices/Faceshift.h"
|
#include "devices/Faceshift.h"
|
||||||
#include "devices/SerialInterface.h"
|
#include "devices/SerialInterface.h"
|
||||||
#include "devices/SixenseManager.h"
|
#include "devices/SixenseManager.h"
|
||||||
|
@ -188,6 +187,10 @@ public:
|
||||||
glm::vec2 getViewportDimensions() const{ return glm::vec2(_glWidget->width(),_glWidget->height()); }
|
glm::vec2 getViewportDimensions() const{ return glm::vec2(_glWidget->width(),_glWidget->height()); }
|
||||||
NodeToJurisdictionMap& getVoxelServerJurisdictions() { return _voxelServerJurisdictions; }
|
NodeToJurisdictionMap& getVoxelServerJurisdictions() { return _voxelServerJurisdictions; }
|
||||||
void pasteVoxelsToOctalCode(const unsigned char* octalCodeDestination);
|
void pasteVoxelsToOctalCode(const unsigned char* octalCodeDestination);
|
||||||
|
|
||||||
|
/// set a voxel which is to be rendered with a highlight
|
||||||
|
void setHighlightVoxel(const VoxelDetail& highlightVoxel) { _highlightVoxel = highlightVoxel; }
|
||||||
|
void setIsHighlightVoxel(bool isHighlightVoxel) { _isHighlightVoxel = isHighlightVoxel; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data);
|
void sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data);
|
||||||
|
@ -231,6 +234,7 @@ private slots:
|
||||||
void shrinkMirrorView();
|
void shrinkMirrorView();
|
||||||
void resetSensors();
|
void resetSensors();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resetCamerasOnResizeGL(Camera& camera, int width, int height);
|
void resetCamerasOnResizeGL(Camera& camera, int width, int height);
|
||||||
void updateProjectionMatrix();
|
void updateProjectionMatrix();
|
||||||
|
@ -272,9 +276,11 @@ private:
|
||||||
Avatar* findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection,
|
Avatar* findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection,
|
||||||
glm::vec3& eyePosition, QUuid &nodeUUID);
|
glm::vec3& eyePosition, QUuid &nodeUUID);
|
||||||
bool isLookingAtMyAvatar(Avatar* avatar);
|
bool isLookingAtMyAvatar(Avatar* avatar);
|
||||||
|
|
||||||
void renderLookatIndicator(glm::vec3 pointOfInterest);
|
void renderLookatIndicator(glm::vec3 pointOfInterest);
|
||||||
void renderFollowIndicator();
|
void renderFollowIndicator();
|
||||||
|
void renderHighlightVoxel(VoxelDetail voxel);
|
||||||
|
|
||||||
void updateAvatar(float deltaTime);
|
void updateAvatar(float deltaTime);
|
||||||
void updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection);
|
void updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection);
|
||||||
void queryVoxels();
|
void queryVoxels();
|
||||||
|
@ -371,8 +377,6 @@ private:
|
||||||
|
|
||||||
int _headMouseX, _headMouseY;
|
int _headMouseX, _headMouseY;
|
||||||
|
|
||||||
HandControl _handControl;
|
|
||||||
|
|
||||||
int _mouseX;
|
int _mouseX;
|
||||||
int _mouseY;
|
int _mouseY;
|
||||||
int _mouseDragStartedX;
|
int _mouseDragStartedX;
|
||||||
|
@ -405,6 +409,9 @@ private:
|
||||||
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
|
||||||
|
|
||||||
|
VoxelDetail _highlightVoxel;
|
||||||
|
bool _isHighlightVoxel;
|
||||||
|
|
||||||
VoxelDetail _nudgeVoxel; // details of the voxel to be nudged
|
VoxelDetail _nudgeVoxel; // details of the voxel to be nudged
|
||||||
bool _nudgeStarted;
|
bool _nudgeStarted;
|
||||||
bool _lookingAlongX;
|
bool _lookingAlongX;
|
||||||
|
|
|
@ -24,7 +24,7 @@ Hand::Hand(Avatar* owningAvatar) :
|
||||||
_raveGloveInitialized(false),
|
_raveGloveInitialized(false),
|
||||||
_owningAvatar(owningAvatar),
|
_owningAvatar(owningAvatar),
|
||||||
_renderAlpha(1.0),
|
_renderAlpha(1.0),
|
||||||
_ballColor(0.0, 0.0, 0.4)
|
_ballColor(0.0, 0.0, 0.4)
|
||||||
{
|
{
|
||||||
// initialize all finger particle emitters with an invalid id as default
|
// initialize all finger particle emitters with an invalid id as default
|
||||||
for (int f = 0; f< NUM_FINGERS; f ++ ) {
|
for (int f = 0; f< NUM_FINGERS; f ++ ) {
|
||||||
|
@ -67,25 +67,72 @@ void Hand::simulate(float deltaTime, bool isMine) {
|
||||||
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()) {
|
||||||
|
glm::vec3 palmPosition = palm.getPosition();
|
||||||
FingerData& finger = palm.getFingers()[0];
|
FingerData& finger = palm.getFingers()[0];
|
||||||
glm::vec3 newVoxelPosition = finger.getTipPosition();
|
glm::vec3 fingerTipPosition = finger.getTipPosition();
|
||||||
if (palm.getControllerButtons() & BUTTON_1) {
|
if (palm.getControllerButtons() & BUTTON_1) {
|
||||||
if (glm::length(newVoxelPosition - _lastFingerAddVoxel) > (FINGERTIP_VOXEL_SIZE / 2.f)) {
|
if (glm::length(fingerTipPosition - _lastFingerAddVoxel) > (FINGERTIP_VOXEL_SIZE / 2.f)) {
|
||||||
QColor paintColor = Menu::getInstance()->getActionForOption(MenuOption::VoxelPaintColor)->data().value<QColor>();
|
QColor paintColor = Menu::getInstance()->getActionForOption(MenuOption::VoxelPaintColor)->data().value<QColor>();
|
||||||
Application::getInstance()->makeVoxel(newVoxelPosition,
|
Application::getInstance()->makeVoxel(fingerTipPosition,
|
||||||
FINGERTIP_VOXEL_SIZE,
|
FINGERTIP_VOXEL_SIZE,
|
||||||
paintColor.red(),
|
paintColor.red(),
|
||||||
paintColor.green(),
|
paintColor.green(),
|
||||||
paintColor.blue(),
|
paintColor.blue(),
|
||||||
true);
|
true);
|
||||||
_lastFingerAddVoxel = newVoxelPosition;
|
_lastFingerAddVoxel = fingerTipPosition;
|
||||||
}
|
}
|
||||||
} else if (palm.getControllerButtons() & BUTTON_2) {
|
} else if (palm.getControllerButtons() & BUTTON_2) {
|
||||||
if (glm::length(newVoxelPosition - _lastFingerDeleteVoxel) > (FINGERTIP_VOXEL_SIZE / 2.f)) {
|
if (glm::length(fingerTipPosition - _lastFingerDeleteVoxel) > (FINGERTIP_VOXEL_SIZE / 2.f)) {
|
||||||
Application::getInstance()->removeVoxel(newVoxelPosition, FINGERTIP_VOXEL_SIZE);
|
Application::getInstance()->removeVoxel(fingerTipPosition, FINGERTIP_VOXEL_SIZE);
|
||||||
_lastFingerDeleteVoxel = newVoxelPosition;
|
_lastFingerDeleteVoxel = fingerTipPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Check if the finger is intersecting with a voxel in the client voxel tree
|
||||||
|
VoxelNode* fingerNode = Application::getInstance()->getVoxels()->getVoxelAt(fingerTipPosition.x / TREE_SCALE,
|
||||||
|
fingerTipPosition.y / TREE_SCALE,
|
||||||
|
fingerTipPosition.z / TREE_SCALE,
|
||||||
|
FINGERTIP_VOXEL_SIZE / TREE_SCALE);
|
||||||
|
if (fingerNode) {
|
||||||
|
finger.setIsTouchingVoxel(true);
|
||||||
|
glm::vec3 corner = fingerNode->getCorner();
|
||||||
|
glm::vec3 storedCorner = finger.getFingerVoxelPosition();
|
||||||
|
printf("corner: %.3f, %.3f, %.3f ", corner.x, corner.y, corner.z);
|
||||||
|
printf("stored corner: %.3f, %.3f, %.3f\n", storedCorner.x, storedCorner.y, storedCorner.z);
|
||||||
|
if (finger.getIsTouchingVoxel()) printf("Touching! %f.3", randFloat());
|
||||||
|
if (glm::length(fingerNode->getCorner() - finger.getFingerVoxelPosition()) > EPSILON) {
|
||||||
|
printf("diff = %.9f\n", glm::length(fingerNode->getCorner() - finger.getFingerVoxelPosition()));
|
||||||
|
finger.setFingerVoxelPosition(fingerNode->getCorner());
|
||||||
|
finger.setFingerVoxelScale(fingerNode->getScale());
|
||||||
|
printf("touching voxel scale, %0.4f\n", fingerNode->getScale() * TREE_SCALE);
|
||||||
|
printVector(glm::vec3(fingerNode->getCorner() * (float)TREE_SCALE));
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if ((currentFingerVoxel.x != _fingerVoxel.x) ||
|
||||||
|
(currentFingerVoxel.y != _fingerVoxel.y) ||
|
||||||
|
(currentFingerVoxel.z != _fingerVoxel.z) ||
|
||||||
|
(currentFingerVoxel.s != _fingerVoxel.s) ||
|
||||||
|
(currentFingerVoxel.red != _fingerVoxel.red) ||
|
||||||
|
(currentFingerVoxel.green != _fingerVoxel.green) ||
|
||||||
|
(currentFingerVoxel.blue != _fingerVoxel.blue)) {
|
||||||
|
memcpy(&_fingerVoxel, ¤tFingerVoxel, sizeof(VoxelDetail));
|
||||||
|
_fingerIsOnVoxel = true;
|
||||||
|
Application::getInstance()->setHighlightVoxel(currentFingerVoxel);
|
||||||
|
Application::getInstance()->setIsHighlightVoxel(true);
|
||||||
|
printf("Moved onto a voxel %.2f, %.2f, %.2f s %.2f\n",
|
||||||
|
currentFingerVoxel.x * TREE_SCALE,
|
||||||
|
currentFingerVoxel.y * TREE_SCALE,
|
||||||
|
currentFingerVoxel.z * TREE_SCALE,
|
||||||
|
currentFingerVoxel.s * TREE_SCALE);
|
||||||
|
// If desired, make a sound
|
||||||
|
Application::getInstance()->getAudio()->startCollisionSound(1.0, 7040 * currentFingerVoxel.s * TREE_SCALE, 0.0, 0.999f, false);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
} else if (finger.getIsTouchingVoxel()) {
|
||||||
|
// Just moved off a voxel, change back it's color
|
||||||
|
printf("Moved out of voxel!\n");
|
||||||
|
finger.setIsTouchingVoxel(false);
|
||||||
|
Application::getInstance()->setIsHighlightVoxel(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,6 +160,7 @@ void Hand::calculateGeometry() {
|
||||||
ball.radius = standardBallRadius;
|
ball.radius = standardBallRadius;
|
||||||
ball.touchForce = 0.0;
|
ball.touchForce = 0.0;
|
||||||
ball.isCollidable = true;
|
ball.isCollidable = true;
|
||||||
|
ball.isColliding = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,6 +182,7 @@ void Hand::calculateGeometry() {
|
||||||
ball.radius = standardBallRadius;
|
ball.radius = standardBallRadius;
|
||||||
ball.touchForce = 0.0;
|
ball.touchForce = 0.0;
|
||||||
ball.isCollidable = true;
|
ball.isCollidable = true;
|
||||||
|
ball.isColliding = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,7 +348,11 @@ void Hand::renderLeapHands() {
|
||||||
// Draw the leap balls
|
// Draw the leap balls
|
||||||
for (size_t i = 0; i < _leapFingerTipBalls.size(); i++) {
|
for (size_t i = 0; i < _leapFingerTipBalls.size(); i++) {
|
||||||
if (alpha > 0.0f) {
|
if (alpha > 0.0f) {
|
||||||
glColor4f(handColor.r, handColor.g, handColor.b, alpha);
|
if (_leapFingerTipBalls[i].isColliding) {
|
||||||
|
glColor4f(handColor.r, 0, 0, alpha);
|
||||||
|
} else {
|
||||||
|
glColor4f(handColor.r, handColor.g, handColor.b, alpha);
|
||||||
|
}
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(_leapFingerTipBalls[i].position.x, _leapFingerTipBalls[i].position.y, _leapFingerTipBalls[i].position.z);
|
glTranslatef(_leapFingerTipBalls[i].position.x, _leapFingerTipBalls[i].position.y, _leapFingerTipBalls[i].position.z);
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
glm::vec3 velocity; // the velocity of the ball
|
glm::vec3 velocity; // the velocity of the ball
|
||||||
float radius; // the radius of the ball
|
float radius; // the radius of the ball
|
||||||
bool isCollidable; // whether or not the ball responds to collisions
|
bool isCollidable; // whether or not the ball responds to collisions
|
||||||
|
bool isColliding; // ball is currently colliding
|
||||||
float touchForce; // a scalar determining the amount that the cursor (or hand) is penetrating the ball
|
float touchForce; // a scalar determining the amount that the cursor (or hand) is penetrating the ball
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
//
|
|
||||||
// HandControl.cpp
|
|
||||||
// interface
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "HandControl.h"
|
|
||||||
|
|
||||||
// this class takes mouse movements normalized within the screen
|
|
||||||
// dimensions and uses those to determine avatar hand movements, as well
|
|
||||||
// as states for ramping up and ramping down the amplitude of such movements.
|
|
||||||
//
|
|
||||||
// This class might expand to accommodate 3D input devices
|
|
||||||
//
|
|
||||||
|
|
||||||
HandControl::HandControl() {
|
|
||||||
|
|
||||||
_enabled = false;
|
|
||||||
_width = 0;
|
|
||||||
_height = 0;
|
|
||||||
_startX = 0;
|
|
||||||
_startY = 0;
|
|
||||||
_x = 0;
|
|
||||||
_y = 0;
|
|
||||||
_lastX = 0;
|
|
||||||
_lastY = 0;
|
|
||||||
_velocityX = 0;
|
|
||||||
_velocityY = 0;
|
|
||||||
_rampUpRate = 0.05;
|
|
||||||
_rampDownRate = 0.02;
|
|
||||||
_envelope = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandControl::setScreenDimensions(int width, int height) {
|
|
||||||
_width = width;
|
|
||||||
_height = height;
|
|
||||||
_startX = _width / 2;
|
|
||||||
_startY = _height / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandControl::update(int x, int y) {
|
|
||||||
_lastX = _x;
|
|
||||||
_lastY = _y;
|
|
||||||
_x = x;
|
|
||||||
_y = y;
|
|
||||||
_velocityX = _x - _lastX;
|
|
||||||
_velocityY = _y - _lastY;
|
|
||||||
|
|
||||||
// if the mouse is moving, ramp up the envelope to increase amplitude of hand movement...
|
|
||||||
if ((_velocityX != 0)
|
|
||||||
|| (_velocityY != 0)) {
|
|
||||||
_enabled = true;
|
|
||||||
if (_envelope < 1.0) {
|
|
||||||
_envelope += _rampUpRate;
|
|
||||||
if (_envelope >= 1.0) {
|
|
||||||
_envelope = 1.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if not enabled ramp down the envelope to decrease amplitude of hand movement...
|
|
||||||
if (! _enabled) {
|
|
||||||
if (_envelope > 0.0) {
|
|
||||||
_envelope -= _rampDownRate;
|
|
||||||
if (_envelope <= 0.0) {
|
|
||||||
_startX = _width / 2;
|
|
||||||
_startY = _height / 2;
|
|
||||||
_envelope = 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_leftRight = 0.0;
|
|
||||||
_downUp = 0.0;
|
|
||||||
_backFront = 0.0;
|
|
||||||
|
|
||||||
// if envelope is greater than zero, apply mouse movement to values to be output
|
|
||||||
if (_envelope > 0.0) {
|
|
||||||
_leftRight += ((_x - _startX) / (float)_width ) * _envelope;
|
|
||||||
_downUp += ((_y - _startY) / (float)_height) * _envelope;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 HandControl::getValues() {
|
|
||||||
return glm::vec3(_leftRight, _downUp, _backFront);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandControl::stop() {
|
|
||||||
_enabled = false;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
//
|
|
||||||
// HandControl.h
|
|
||||||
// interface
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef __interface__HandControl__
|
|
||||||
#define __interface__HandControl__
|
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
|
|
||||||
class HandControl {
|
|
||||||
public:
|
|
||||||
HandControl();
|
|
||||||
void setScreenDimensions(int width, int height);
|
|
||||||
void update( int x, int y );
|
|
||||||
glm::vec3 getValues();
|
|
||||||
void stop();
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool _enabled;
|
|
||||||
int _width;
|
|
||||||
int _height;
|
|
||||||
int _startX;
|
|
||||||
int _startY;
|
|
||||||
int _x;
|
|
||||||
int _y;
|
|
||||||
int _lastX;
|
|
||||||
int _lastY;
|
|
||||||
int _velocityX;
|
|
||||||
int _velocityY;
|
|
||||||
float _rampUpRate;
|
|
||||||
float _rampDownRate;
|
|
||||||
float _envelope;
|
|
||||||
float _leftRight;
|
|
||||||
float _downUp;
|
|
||||||
float _backFront;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -56,7 +56,10 @@ _isActive(false),
|
||||||
_leapID(LEAPID_INVALID),
|
_leapID(LEAPID_INVALID),
|
||||||
_numFramesWithoutData(0),
|
_numFramesWithoutData(0),
|
||||||
_owningPalmData(owningPalmData),
|
_owningPalmData(owningPalmData),
|
||||||
_owningHandData(owningHandData)
|
_owningHandData(owningHandData),
|
||||||
|
_isTouchingVoxel(false),
|
||||||
|
_fingerVoxelPosition(),
|
||||||
|
_fingerVoxelScale(0)
|
||||||
{
|
{
|
||||||
const int standardTrailLength = 10;
|
const int standardTrailLength = 10;
|
||||||
setTrailLength(standardTrailLength);
|
setTrailLength(standardTrailLength);
|
||||||
|
|
|
@ -119,6 +119,13 @@ public:
|
||||||
void incrementFramesWithoutData() { _numFramesWithoutData++; }
|
void incrementFramesWithoutData() { _numFramesWithoutData++; }
|
||||||
void resetFramesWithoutData() { _numFramesWithoutData = 0; }
|
void resetFramesWithoutData() { _numFramesWithoutData = 0; }
|
||||||
int getFramesWithoutData() const { return _numFramesWithoutData; }
|
int getFramesWithoutData() const { return _numFramesWithoutData; }
|
||||||
|
|
||||||
|
void setIsTouchingVoxel(bool isTouchingVoxel) { _isTouchingVoxel = isTouchingVoxel; }
|
||||||
|
bool getIsTouchingVoxel() { return _isTouchingVoxel; }
|
||||||
|
void setFingerVoxelPosition(const glm::vec3& fingerVoxelPosition) { _fingerVoxelPosition = fingerVoxelPosition; }
|
||||||
|
const glm::vec3& getFingerVoxelPosition() const { return _fingerVoxelPosition; }
|
||||||
|
void setFingerVoxelScale(float fingerVoxelScale) { _fingerVoxelScale = fingerVoxelScale; }
|
||||||
|
float getFingerVoxelScale() { return _fingerVoxelScale; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
glm::vec3 _tipRawPosition;
|
glm::vec3 _tipRawPosition;
|
||||||
|
@ -131,6 +138,10 @@ private:
|
||||||
int _tipTrailCurrentValidLength;
|
int _tipTrailCurrentValidLength;
|
||||||
PalmData* _owningPalmData;
|
PalmData* _owningPalmData;
|
||||||
HandData* _owningHandData;
|
HandData* _owningHandData;
|
||||||
|
|
||||||
|
bool _isTouchingVoxel;
|
||||||
|
glm::vec3 _fingerVoxelPosition;
|
||||||
|
float _fingerVoxelScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PalmData {
|
class PalmData {
|
||||||
|
|
Loading…
Reference in a new issue