Showing the changes to interface/src/avatar/SkeletonModel.cpp (1 of 6 files). Show all
Unified · Split
| @@ -198,10 +198,25 @@ void SkeletonModel::applyPalmData(int jointIndex, PalmData& palm) { · 197 unmodified lines | ||
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | void SkeletonModel::updateJointState(int index) { |
| 201 | + JointState& state = _jointStates[index]; | |
| 202 | + const FBXGeometry& geometry = _geometry->getFBXGeometry(); | |
| 203 | + const FBXJoint& joint = geometry.joints.at(index); | |
| 204 | + if (joint.parentIndex == -1) { | |
| 205 | + const JointState& parentState = _jointStates.at(joint.parentIndex); | |
| 206 | + if (index == geometry.leanJointIndex) { | |
| 207 | + maybeUpdateLeanRotation(parentState, joint, state); | |
| 208 | + | |
| 209 | + } else if (index == geometry.neckJointIndex) { | |
| 210 | + maybeUpdateNeckRotation(parentState, joint, state); | |
| 211 | + | |
| 212 | + } else if (index == geometry.leftEyeJointIndex || index == geometry.rightEyeJointIndex) { | |
| 213 | + maybeUpdateEyeRotation(parentState, joint, state); | |
| 214 | + } | |
| 215 | + } | |
| 216 | + | |
| 201 | 217 | Model::updateJointState(index); |
| 202 | 218 | |
| 203 | 219 | if (index == _geometry->getFBXGeometry().rootJointIndex) { |
| 204 | − JointState& state = _jointStates[index]; | |
| 205 | 220 | state.transform[3][0] = 0.0f; |
| 206 | 221 | state.transform[3][1] = 0.0f; |
| 207 | 222 | state.transform[3][2] = 0.0f; |
| @@ -388,3 +403,31 @@ float SkeletonModel::getRightArmLength() const { · 180 unmodified lines | ||
| 388 | 403 | return getLimbLength(getRightHandJointIndex()); |
| 389 | 404 | } |
| 390 | 405 | |
| 406 | +bool SkeletonModel::getHeadPosition(glm::vec3& headPosition) const { | |
| 407 | + return isActive() && getJointPosition(_geometry->getFBXGeometry().headJointIndex, headPosition); | |
| 408 | +} | |
| 409 | + | |
| 410 | +bool SkeletonModel::getNeckPosition(glm::vec3& neckPosition) const { | |
| 411 | + return isActive() && getJointPosition(_geometry->getFBXGeometry().neckJointIndex, neckPosition); | |
| 412 | +} | |
| 413 | + | |
| 414 | +bool SkeletonModel::getNeckParentRotation(glm::quat& neckParentRotation) const { | |
| 415 | + if (!isActive()) { | |
| 416 | + return false; | |
| 417 | + } | |
| 418 | + const FBXGeometry& geometry = _geometry->getFBXGeometry(); | |
| 419 | + if (geometry.neckJointIndex == -1) { | |
| 420 | + return false; | |
| 421 | + } | |
| 422 | + return getJointRotation(geometry.joints.at(geometry.neckJointIndex).parentIndex, neckParentRotation); | |
| 423 | +} | |
| 424 | + | |
| 425 | +bool SkeletonModel::getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const { | |
| 426 | + if (!isActive()) { | |
| 427 | + return false; | |
| 428 | + } | |
| 429 | + const FBXGeometry& geometry = _geometry->getFBXGeometry(); | |
| 430 | + return getJointPosition(geometry.leftEyeJointIndex, firstEyePosition) && | |
| 431 | + getJointPosition(geometry.rightEyeJointIndex, secondEyePosition); | |
| 432 | +} | |
| 433 | + | |