From 07544c7b433d82070202f1cf6ba1d079f670926e Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 27 May 2014 12:52:44 -0700 Subject: [PATCH 1/6] removal of unused getNeckRotation() --- interface/src/renderer/Model.cpp | 4 ---- interface/src/renderer/Model.h | 4 ---- 2 files changed, 8 deletions(-) diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 5337e845a1..0cc914b65c 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -613,10 +613,6 @@ bool Model::getNeckPosition(glm::vec3& neckPosition) const { return isActive() && getJointPosition(_geometry->getFBXGeometry().neckJointIndex, neckPosition); } -bool Model::getNeckRotation(glm::quat& neckRotation) const { - return isActive() && getJointRotation(_geometry->getFBXGeometry().neckJointIndex, neckRotation); -} - bool Model::getNeckParentRotation(glm::quat& neckParentRotation) const { if (!isActive()) { return false; diff --git a/interface/src/renderer/Model.h b/interface/src/renderer/Model.h index 5b1f6402d3..26e80dfd52 100644 --- a/interface/src/renderer/Model.h +++ b/interface/src/renderer/Model.h @@ -135,10 +135,6 @@ public: /// \return whether or not the neck was found bool getNeckPosition(glm::vec3& neckPosition) const; - /// Returns the rotation of the neck joint. - /// \return whether or not the neck was found - bool getNeckRotation(glm::quat& neckRotation) const; - /// Returns the rotation of the neck joint's parent. /// \return whether or not the neck was found bool getNeckParentRotation(glm::quat& neckRotation) const; From f7b8c4f0a082717560ad58b59cdf4d10033ad004 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 27 May 2014 14:50:17 -0700 Subject: [PATCH 2/6] remove unused Head::_gravity data memeber --- interface/src/avatar/Head.cpp | 1 - interface/src/avatar/Head.h | 2 -- interface/src/avatar/MyAvatar.cpp | 1 - 3 files changed, 4 deletions(-) diff --git a/interface/src/avatar/Head.cpp b/interface/src/avatar/Head.cpp index 2d0599b31f..ffb33b2619 100644 --- a/interface/src/avatar/Head.cpp +++ b/interface/src/avatar/Head.cpp @@ -31,7 +31,6 @@ Head::Head(Avatar* owningAvatar) : _rightEyePosition(0.0f, 0.0f, 0.0f), _eyePosition(0.0f, 0.0f, 0.0f), _scale(1.0f), - _gravity(0.0f, -1.0f, 0.0f), _lastLoudness(0.0f), _audioAttack(0.0f), _angularVelocity(0,0,0), diff --git a/interface/src/avatar/Head.h b/interface/src/avatar/Head.h index 8c58b73ebd..cd7abeb9de 100644 --- a/interface/src/avatar/Head.h +++ b/interface/src/avatar/Head.h @@ -45,7 +45,6 @@ public: void render(float alpha, Model::RenderMode mode); void setScale(float scale); void setPosition(glm::vec3 position) { _position = position; } - void setGravity(glm::vec3 gravity) { _gravity = gravity; } void setAverageLoudness(float averageLoudness) { _averageLoudness = averageLoudness; } void setReturnToCenter (bool returnHeadToCenter) { _returnHeadToCenter = returnHeadToCenter; } void setRenderLookatVectors(bool onOff) { _renderLookatVectors = onOff; } @@ -118,7 +117,6 @@ private: glm::vec3 _rightEyePosition; glm::vec3 _eyePosition; float _scale; - glm::vec3 _gravity; float _lastLoudness; float _audioAttack; glm::vec3 _angularVelocity; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index a598c55aaa..fecbcd7023 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -378,7 +378,6 @@ void MyAvatar::setLocalGravity(glm::vec3 gravity) { void MyAvatar::setGravity(const glm::vec3& gravity) { _gravity = gravity; - getHead()->setGravity(_gravity); // use the gravity to determine the new world up direction, if possible float gravityLength = glm::length(gravity); From 6efa417742b3d07aaee90c5e4f71cb383de6dbd2 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 27 May 2014 15:06:50 -0700 Subject: [PATCH 3/6] move hand/arm stuff from Model to SkeletonModel --- interface/src/avatar/Hand.cpp | 2 +- interface/src/avatar/SkeletonModel.cpp | 40 ++++++++++++++++++++++ interface/src/avatar/SkeletonModel.h | 46 ++++++++++++++++++++++++++ interface/src/renderer/Model.cpp | 40 ---------------------- interface/src/renderer/Model.h | 46 -------------------------- 5 files changed, 87 insertions(+), 87 deletions(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 5f168c4f45..3aff984893 100644 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -103,7 +103,7 @@ void Hand::collideAgainstOurself() { getLeftRightPalmIndices(leftPalmIndex, rightPalmIndex); float scaledPalmRadius = PALM_COLLISION_RADIUS * _owningAvatar->getScale(); - const Model& skeletonModel = _owningAvatar->getSkeletonModel(); + const SkeletonModel& skeletonModel = _owningAvatar->getSkeletonModel(); for (int i = 0; i < int(getNumPalms()); i++) { PalmData& palm = getPalms()[i]; if (!palm.isActive()) { diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 429ab1cf30..9fe52f81ce 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -347,4 +347,44 @@ void SkeletonModel::setHandPosition(int jointIndex, const glm::vec3& position, c setJointRotation(jointIndex, rotation, true, PALM_PRIORITY); } + +bool SkeletonModel::getLeftHandPosition(glm::vec3& position) const { + return getJointPosition(getLeftHandJointIndex(), position); +} + +bool SkeletonModel::getLeftHandRotation(glm::quat& rotation) const { + return getJointRotation(getLeftHandJointIndex(), rotation); +} + +bool SkeletonModel::getRightHandPosition(glm::vec3& position) const { + return getJointPosition(getRightHandJointIndex(), position); +} + +bool SkeletonModel::getRightHandRotation(glm::quat& rotation) const { + return getJointRotation(getRightHandJointIndex(), rotation); +} + +bool SkeletonModel::restoreLeftHandPosition(float percent, float priority) { + return restoreJointPosition(getLeftHandJointIndex(), percent, priority); +} + +bool SkeletonModel::getLeftShoulderPosition(glm::vec3& position) const { + return getJointPosition(getLastFreeJointIndex(getLeftHandJointIndex()), position); +} + +float SkeletonModel::getLeftArmLength() const { + return getLimbLength(getLeftHandJointIndex()); +} + +bool SkeletonModel::restoreRightHandPosition(float percent, float priority) { + return restoreJointPosition(getRightHandJointIndex(), percent, priority); +} + +bool SkeletonModel::getRightShoulderPosition(glm::vec3& position) const { + return getJointPosition(getLastFreeJointIndex(getRightHandJointIndex()), position); +} + +float SkeletonModel::getRightArmLength() const { + return getLimbLength(getRightHandJointIndex()); +} diff --git a/interface/src/avatar/SkeletonModel.h b/interface/src/avatar/SkeletonModel.h index 77e6ea33d4..6a46b3b88e 100644 --- a/interface/src/avatar/SkeletonModel.h +++ b/interface/src/avatar/SkeletonModel.h @@ -34,7 +34,53 @@ public: void getBodyShapes(QVector& shapes) const; void renderIKConstraints(); + + /// Returns the index of the left hand joint, or -1 if not found. + int getLeftHandJointIndex() const { return isActive() ? _geometry->getFBXGeometry().leftHandJointIndex : -1; } + + /// Returns the index of the right hand joint, or -1 if not found. + int getRightHandJointIndex() const { return isActive() ? _geometry->getFBXGeometry().rightHandJointIndex : -1; } + /// Retrieve the position of the left hand + /// \return true whether or not the position was found + bool getLeftHandPosition(glm::vec3& position) const; + + /// Retrieve the rotation of the left hand + /// \return true whether or not the rotation was found + bool getLeftHandRotation(glm::quat& rotation) const; + + /// Retrieve the position of the right hand + /// \return true whether or not the position was found + bool getRightHandPosition(glm::vec3& position) const; + + /// Retrieve the rotation of the right hand + /// \return true whether or not the rotation was found + bool getRightHandRotation(glm::quat& rotation) const; + + /// Restores some percentage of the default position of the left hand. + /// \param percent the percentage of the default position to restore + /// \return whether or not the left hand joint was found + bool restoreLeftHandPosition(float percent = 1.0f, float priority = 1.0f); + + /// Gets the position of the left shoulder. + /// \return whether or not the left shoulder joint was found + bool getLeftShoulderPosition(glm::vec3& position) const; + + /// Returns the extended length from the left hand to its last free ancestor. + float getLeftArmLength() const; + + /// Restores some percentage of the default position of the right hand. + /// \param percent the percentage of the default position to restore + /// \return whether or not the right hand joint was found + bool restoreRightHandPosition(float percent = 1.0f, float priority = 1.0f); + + /// Gets the position of the right shoulder. + /// \return whether or not the right shoulder joint was found + bool getRightShoulderPosition(glm::vec3& position) const; + + /// Returns the extended length from the right hand to its first free ancestor. + float getRightArmLength() const; + protected: void applyHandPosition(int jointIndex, const glm::vec3& position); diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index d14e7ce44f..192bacdce9 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -640,46 +640,6 @@ bool Model::getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePos return getJointPosition(geometry.leftEyeJointIndex, firstEyePosition) && getJointPosition(geometry.rightEyeJointIndex, secondEyePosition); } - -bool Model::getLeftHandPosition(glm::vec3& position) const { - return getJointPosition(getLeftHandJointIndex(), position); -} - -bool Model::getLeftHandRotation(glm::quat& rotation) const { - return getJointRotation(getLeftHandJointIndex(), rotation); -} - -bool Model::getRightHandPosition(glm::vec3& position) const { - return getJointPosition(getRightHandJointIndex(), position); -} - -bool Model::getRightHandRotation(glm::quat& rotation) const { - return getJointRotation(getRightHandJointIndex(), rotation); -} - -bool Model::restoreLeftHandPosition(float percent, float priority) { - return restoreJointPosition(getLeftHandJointIndex(), percent, priority); -} - -bool Model::getLeftShoulderPosition(glm::vec3& position) const { - return getJointPosition(getLastFreeJointIndex(getLeftHandJointIndex()), position); -} - -float Model::getLeftArmLength() const { - return getLimbLength(getLeftHandJointIndex()); -} - -bool Model::restoreRightHandPosition(float percent, float priority) { - return restoreJointPosition(getRightHandJointIndex(), percent, priority); -} - -bool Model::getRightShoulderPosition(glm::vec3& position) const { - return getJointPosition(getLastFreeJointIndex(getRightHandJointIndex()), position); -} - -float Model::getRightArmLength() const { - return getLimbLength(getRightHandJointIndex()); -} void Model::setURL(const QUrl& url, const QUrl& fallback, bool retainCurrent, bool delayLoad) { // don't recreate the geometry if it's the same URL diff --git a/interface/src/renderer/Model.h b/interface/src/renderer/Model.h index 5d224c48f8..763cbdb577 100644 --- a/interface/src/renderer/Model.h +++ b/interface/src/renderer/Model.h @@ -115,12 +115,6 @@ public: /// Sets the joint state at the specified index. void setJointState(int index, bool valid, const glm::quat& rotation = glm::quat(), float priority = 1.0f); - /// Returns the index of the left hand joint, or -1 if not found. - int getLeftHandJointIndex() const { return isActive() ? _geometry->getFBXGeometry().leftHandJointIndex : -1; } - - /// Returns the index of the right hand joint, or -1 if not found. - int getRightHandJointIndex() const { return isActive() ? _geometry->getFBXGeometry().rightHandJointIndex : -1; } - /// Returns the index of the parent of the indexed joint, or -1 if not found. int getParentJointIndex(int jointIndex) const; @@ -143,46 +137,6 @@ public: /// \return whether or not both eye meshes were found bool getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const; - /// Retrieve the position of the left hand - /// \return true whether or not the position was found - bool getLeftHandPosition(glm::vec3& position) const; - - /// Retrieve the rotation of the left hand - /// \return true whether or not the rotation was found - bool getLeftHandRotation(glm::quat& rotation) const; - - /// Retrieve the position of the right hand - /// \return true whether or not the position was found - bool getRightHandPosition(glm::vec3& position) const; - - /// Retrieve the rotation of the right hand - /// \return true whether or not the rotation was found - bool getRightHandRotation(glm::quat& rotation) const; - - /// Restores some percentage of the default position of the left hand. - /// \param percent the percentage of the default position to restore - /// \return whether or not the left hand joint was found - bool restoreLeftHandPosition(float percent = 1.0f, float priority = 1.0f); - - /// Gets the position of the left shoulder. - /// \return whether or not the left shoulder joint was found - bool getLeftShoulderPosition(glm::vec3& position) const; - - /// Returns the extended length from the left hand to its last free ancestor. - float getLeftArmLength() const; - - /// Restores some percentage of the default position of the right hand. - /// \param percent the percentage of the default position to restore - /// \return whether or not the right hand joint was found - bool restoreRightHandPosition(float percent = 1.0f, float priority = 1.0f); - - /// Gets the position of the right shoulder. - /// \return whether or not the right shoulder joint was found - bool getRightShoulderPosition(glm::vec3& position) const; - - /// Returns the extended length from the right hand to its first free ancestor. - float getRightArmLength() const; - bool getJointPosition(int jointIndex, glm::vec3& position) const; bool getJointRotation(int jointIndex, glm::quat& rotation, bool fromBind = false) const; From ae3b792a352d2e8755efcf8b3fad2d6c802b5b49 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 27 May 2014 15:28:41 -0700 Subject: [PATCH 4/6] move face/head code from Model into SkeletonModel --- interface/src/avatar/FaceModel.cpp | 9 +++++ interface/src/avatar/FaceModel.h | 4 +++ interface/src/avatar/SkeletonModel.cpp | 45 ++++++++++++++++++++++- interface/src/avatar/SkeletonModel.h | 22 ++++++++++-- interface/src/renderer/Model.cpp | 49 -------------------------- interface/src/renderer/Model.h | 20 ----------- 6 files changed, 76 insertions(+), 73 deletions(-) diff --git a/interface/src/avatar/FaceModel.cpp b/interface/src/avatar/FaceModel.cpp index 90e596bde5..eaa9875641 100644 --- a/interface/src/avatar/FaceModel.cpp +++ b/interface/src/avatar/FaceModel.cpp @@ -69,3 +69,12 @@ void FaceModel::maybeUpdateEyeRotation(const JointState& parentState, const FBXJ state.rotation = glm::angleAxis(glm::clamp(glm::angle(between), -MAX_ANGLE, MAX_ANGLE), glm::axis(between)) * joint.rotation; } + +bool FaceModel::getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const { + if (!isActive()) { + return false; + } + const FBXGeometry& geometry = _geometry->getFBXGeometry(); + return getJointPosition(geometry.leftEyeJointIndex, firstEyePosition) && + getJointPosition(geometry.rightEyeJointIndex, secondEyePosition); +} diff --git a/interface/src/avatar/FaceModel.h b/interface/src/avatar/FaceModel.h index 0b7fea8ec4..c3462f42ac 100644 --- a/interface/src/avatar/FaceModel.h +++ b/interface/src/avatar/FaceModel.h @@ -29,6 +29,10 @@ public: virtual void maybeUpdateNeckRotation(const JointState& parentState, const FBXJoint& joint, JointState& state); virtual void maybeUpdateEyeRotation(const JointState& parentState, const FBXJoint& joint, JointState& state); + /// Retrieve the positions of up to two eye meshes. + /// \return whether or not both eye meshes were found + bool getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const; + private: Head* _owningHead; diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 9fe52f81ce..9867f03f4c 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -198,10 +198,25 @@ void SkeletonModel::applyPalmData(int jointIndex, PalmData& palm) { } void SkeletonModel::updateJointState(int index) { + JointState& state = _jointStates[index]; + const FBXGeometry& geometry = _geometry->getFBXGeometry(); + const FBXJoint& joint = geometry.joints.at(index); + if (joint.parentIndex == -1) { + const JointState& parentState = _jointStates.at(joint.parentIndex); + if (index == geometry.leanJointIndex) { + maybeUpdateLeanRotation(parentState, joint, state); + + } else if (index == geometry.neckJointIndex) { + maybeUpdateNeckRotation(parentState, joint, state); + + } else if (index == geometry.leftEyeJointIndex || index == geometry.rightEyeJointIndex) { + maybeUpdateEyeRotation(parentState, joint, state); + } + } + Model::updateJointState(index); if (index == _geometry->getFBXGeometry().rootJointIndex) { - JointState& state = _jointStates[index]; state.transform[3][0] = 0.0f; state.transform[3][1] = 0.0f; state.transform[3][2] = 0.0f; @@ -388,3 +403,31 @@ float SkeletonModel::getRightArmLength() const { return getLimbLength(getRightHandJointIndex()); } +bool SkeletonModel::getHeadPosition(glm::vec3& headPosition) const { + return isActive() && getJointPosition(_geometry->getFBXGeometry().headJointIndex, headPosition); +} + +bool SkeletonModel::getNeckPosition(glm::vec3& neckPosition) const { + return isActive() && getJointPosition(_geometry->getFBXGeometry().neckJointIndex, neckPosition); +} + +bool SkeletonModel::getNeckParentRotation(glm::quat& neckParentRotation) const { + if (!isActive()) { + return false; + } + const FBXGeometry& geometry = _geometry->getFBXGeometry(); + if (geometry.neckJointIndex == -1) { + return false; + } + return getJointRotation(geometry.joints.at(geometry.neckJointIndex).parentIndex, neckParentRotation); +} + +bool SkeletonModel::getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const { + if (!isActive()) { + return false; + } + const FBXGeometry& geometry = _geometry->getFBXGeometry(); + return getJointPosition(geometry.leftEyeJointIndex, firstEyePosition) && + getJointPosition(geometry.rightEyeJointIndex, secondEyePosition); +} + diff --git a/interface/src/avatar/SkeletonModel.h b/interface/src/avatar/SkeletonModel.h index 6a46b3b88e..60e925b239 100644 --- a/interface/src/avatar/SkeletonModel.h +++ b/interface/src/avatar/SkeletonModel.h @@ -80,6 +80,22 @@ public: /// Returns the extended length from the right hand to its first free ancestor. float getRightArmLength() const; + + /// Returns the position of the head joint. + /// \return whether or not the head was found + bool getHeadPosition(glm::vec3& headPosition) const; + + /// Returns the position of the neck joint. + /// \return whether or not the neck was found + bool getNeckPosition(glm::vec3& neckPosition) const; + + /// Returns the rotation of the neck joint's parent. + /// \return whether or not the neck was found + bool getNeckParentRotation(glm::quat& neckRotation) const; + + /// Retrieve the positions of up to two eye meshes. + /// \return whether or not both eye meshes were found + bool getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const; protected: @@ -90,9 +106,9 @@ protected: /// Updates the state of the joint at the specified index. virtual void updateJointState(int index); - virtual void maybeUpdateLeanRotation(const JointState& parentState, const FBXJoint& joint, JointState& state); - virtual void maybeUpdateNeckRotation(const JointState& parentState, const FBXJoint& joint, JointState& state); - virtual void maybeUpdateEyeRotation(const JointState& parentState, const FBXJoint& joint, JointState& state); + void maybeUpdateLeanRotation(const JointState& parentState, const FBXJoint& joint, JointState& state); + void maybeUpdateNeckRotation(const JointState& parentState, const FBXJoint& joint, JointState& state); + void maybeUpdateEyeRotation(const JointState& parentState, const FBXJoint& joint, JointState& state); private: diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 192bacdce9..5a93dbcf25 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -613,34 +613,6 @@ int Model::getLastFreeJointIndex(int jointIndex) const { return (isActive() && jointIndex != -1) ? _geometry->getFBXGeometry().joints.at(jointIndex).freeLineage.last() : -1; } -bool Model::getHeadPosition(glm::vec3& headPosition) const { - return isActive() && getJointPosition(_geometry->getFBXGeometry().headJointIndex, headPosition); -} - -bool Model::getNeckPosition(glm::vec3& neckPosition) const { - return isActive() && getJointPosition(_geometry->getFBXGeometry().neckJointIndex, neckPosition); -} - -bool Model::getNeckParentRotation(glm::quat& neckParentRotation) const { - if (!isActive()) { - return false; - } - const FBXGeometry& geometry = _geometry->getFBXGeometry(); - if (geometry.neckJointIndex == -1) { - return false; - } - return getJointRotation(geometry.joints.at(geometry.neckJointIndex).parentIndex, neckParentRotation); -} - -bool Model::getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const { - if (!isActive()) { - return false; - } - const FBXGeometry& geometry = _geometry->getFBXGeometry(); - return getJointPosition(geometry.leftEyeJointIndex, firstEyePosition) && - getJointPosition(geometry.rightEyeJointIndex, secondEyePosition); -} - void Model::setURL(const QUrl& url, const QUrl& fallback, bool retainCurrent, bool delayLoad) { // don't recreate the geometry if it's the same URL if (_url == url) { @@ -1166,15 +1138,6 @@ void Model::updateJointState(int index) { state.combinedRotation = _rotation * combinedRotation; } else { const JointState& parentState = _jointStates.at(joint.parentIndex); - if (index == geometry.leanJointIndex) { - maybeUpdateLeanRotation(parentState, joint, state); - - } else if (index == geometry.neckJointIndex) { - maybeUpdateNeckRotation(parentState, joint, state); - - } else if (index == geometry.leftEyeJointIndex || index == geometry.rightEyeJointIndex) { - maybeUpdateEyeRotation(parentState, joint, state); - } glm::quat combinedRotation = joint.preRotation * state.rotation * joint.postRotation; state.transform = parentState.transform * glm::translate(state.translation) * joint.preTransform * glm::mat4_cast(combinedRotation) * joint.postTransform; @@ -1182,18 +1145,6 @@ void Model::updateJointState(int index) { } } -void Model::maybeUpdateLeanRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) { - // nothing by default -} - -void Model::maybeUpdateNeckRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) { - // nothing by default -} - -void Model::maybeUpdateEyeRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) { - // nothing by default -} - bool Model::setJointPosition(int jointIndex, const glm::vec3& translation, const glm::quat& rotation, bool useRotation, int lastFreeIndex, bool allIntermediatesFree, const glm::vec3& alignment, float priority) { if (jointIndex == -1 || _jointStates.isEmpty()) { diff --git a/interface/src/renderer/Model.h b/interface/src/renderer/Model.h index 763cbdb577..a4e45287dd 100644 --- a/interface/src/renderer/Model.h +++ b/interface/src/renderer/Model.h @@ -121,22 +121,6 @@ public: /// Returns the index of the last free ancestor of the indexed joint, or -1 if not found. int getLastFreeJointIndex(int jointIndex) const; - /// Returns the position of the head joint. - /// \return whether or not the head was found - bool getHeadPosition(glm::vec3& headPosition) const; - - /// Returns the position of the neck joint. - /// \return whether or not the neck was found - bool getNeckPosition(glm::vec3& neckPosition) const; - - /// Returns the rotation of the neck joint's parent. - /// \return whether or not the neck was found - bool getNeckParentRotation(glm::quat& neckRotation) const; - - /// Retrieve the positions of up to two eye meshes. - /// \return whether or not both eye meshes were found - bool getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const; - bool getJointPosition(int jointIndex, glm::vec3& position) const; bool getJointRotation(int jointIndex, glm::quat& rotation, bool fromBind = false) const; @@ -234,10 +218,6 @@ protected: /// Updates the state of the joint at the specified index. virtual void updateJointState(int index); - virtual void maybeUpdateLeanRotation(const JointState& parentState, const FBXJoint& joint, JointState& state); - virtual void maybeUpdateNeckRotation(const JointState& parentState, const FBXJoint& joint, JointState& state); - virtual void maybeUpdateEyeRotation(const JointState& parentState, const FBXJoint& joint, JointState& state); - bool setJointPosition(int jointIndex, const glm::vec3& translation, const glm::quat& rotation = glm::quat(), bool useRotation = false, int lastFreeIndex = -1, bool allIntermediatesFree = false, const glm::vec3& alignment = glm::vec3(0.0f, -1.0f, 0.0f), float priority = 1.0f); From 9f72d6ca3f6890734d37287f509c25ca053118ad Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 27 May 2014 15:53:20 -0700 Subject: [PATCH 5/6] fix bug -- negate logic around invalid joint index --- interface/src/avatar/SkeletonModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 9867f03f4c..7333bfc395 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -201,7 +201,7 @@ void SkeletonModel::updateJointState(int index) { JointState& state = _jointStates[index]; const FBXGeometry& geometry = _geometry->getFBXGeometry(); const FBXJoint& joint = geometry.joints.at(index); - if (joint.parentIndex == -1) { + if (joint.parentIndex != -1) { const JointState& parentState = _jointStates.at(joint.parentIndex); if (index == geometry.leanJointIndex) { maybeUpdateLeanRotation(parentState, joint, state); From d1a8c18d10621dd29df8f21cb7bf9bb9e860d776 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 27 May 2014 16:32:29 -0700 Subject: [PATCH 6/6] simplified hand index constants --- interface/src/devices/PrioVR.cpp | 8 ++++---- libraries/avatars/src/HandData.cpp | 4 ++-- libraries/avatars/src/HandData.h | 8 ++------ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/interface/src/devices/PrioVR.cpp b/interface/src/devices/PrioVR.cpp index deba4f82a5..3e19f1800e 100644 --- a/interface/src/devices/PrioVR.cpp +++ b/interface/src/devices/PrioVR.cpp @@ -63,7 +63,7 @@ static void setPalm(float deltaTime, int index) { if (!Application::getInstance()->getJoystickManager()->getJoystickStates().isEmpty()) { const JoystickState& state = Application::getInstance()->getJoystickManager()->getJoystickStates().at(0); if (state.axes.size() >= 4 && state.buttons.size() >= 4) { - if (index == SIXENSE_CONTROLLER_ID_LEFT_HAND) { + if (index == LEFT_HAND_INDEX) { palm->setControllerButtons(state.buttons.at(1) ? BUTTON_FWD : 0); palm->setTrigger(state.buttons.at(0) ? 1.0f : 0.0f); palm->setJoystick(state.axes.at(0), -state.axes.at(1)); @@ -82,7 +82,7 @@ static void setPalm(float deltaTime, int index) { Model* skeletonModel = &Application::getInstance()->getAvatar()->getSkeletonModel(); int jointIndex; glm::quat inverseRotation = glm::inverse(Application::getInstance()->getAvatar()->getOrientation()); - if (index == SIXENSE_CONTROLLER_ID_LEFT_HAND) { + if (index == LEFT_HAND_INDEX) { jointIndex = skeletonModel->getLeftHandJointIndex(); skeletonModel->getJointRotation(jointIndex, rotation, true); rotation = inverseRotation * rotation * glm::quat(glm::vec3(0.0f, PI_OVER_TWO, 0.0f)); @@ -180,8 +180,8 @@ void PrioVR::update(float deltaTime) { } // convert the joysticks into palm data - setPalm(deltaTime, SIXENSE_CONTROLLER_ID_LEFT_HAND); - setPalm(deltaTime, SIXENSE_CONTROLLER_ID_RIGHT_HAND); + setPalm(deltaTime, LEFT_HAND_INDEX); + setPalm(deltaTime, RIGHT_HAND_INDEX); #endif } diff --git a/libraries/avatars/src/HandData.cpp b/libraries/avatars/src/HandData.cpp index c0553a2b57..e6ef10ed3e 100644 --- a/libraries/avatars/src/HandData.cpp +++ b/libraries/avatars/src/HandData.cpp @@ -53,10 +53,10 @@ void HandData::getLeftRightPalmIndices(int& leftPalmIndex, int& rightPalmIndex) for (size_t i = 0; i < _palms.size(); i++) { const PalmData& palm = _palms[i]; if (palm.isActive()) { - if (palm.getSixenseID() == SIXENSE_CONTROLLER_ID_LEFT_HAND) { + if (palm.getSixenseID() == LEFT_HAND_INDEX) { leftPalmIndex = i; } - if (palm.getSixenseID() == SIXENSE_CONTROLLER_ID_RIGHT_HAND) { + if (palm.getSixenseID() == RIGHT_HAND_INDEX) { rightPalmIndex = i; } } diff --git a/libraries/avatars/src/HandData.h b/libraries/avatars/src/HandData.h index 7e8622f518..404d00b0f3 100755 --- a/libraries/avatars/src/HandData.h +++ b/libraries/avatars/src/HandData.h @@ -23,16 +23,12 @@ class AvatarData; class PalmData; +const int LEFT_HAND_INDEX = 0; +const int RIGHT_HAND_INDEX = 1; const int NUM_HANDS = 2; -const int NUM_FINGERS_PER_HAND = 5; -const int NUM_FINGERS = NUM_HANDS * NUM_FINGERS_PER_HAND; -const int LEAPID_INVALID = -1; const int SIXENSEID_INVALID = -1; -const int SIXENSE_CONTROLLER_ID_LEFT_HAND = 0; -const int SIXENSE_CONTROLLER_ID_RIGHT_HAND = 1; - class HandData { public: HandData(AvatarData* owningAvatar);