Showing the changes to interface/src/avatar/SkeletonModel.cpp (1 of 2 files). Show all
Unified · Split
| @@ -36,9 +36,30 @@ SkeletonModel::~SkeletonModel() { · 35 unmodified lines | |||
| 36 | _ragdoll = NULL; | 36 | _ragdoll = NULL; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | const float MODEL_SCALE = 0.0006f; | ||
| 40 | |||
| 39 | void SkeletonModel::setJointStates(QVector<JointState> states) { | 41 | void SkeletonModel::setJointStates(QVector<JointState> states) { |
| 40 | Model::setJointStates(states); | 42 | Model::setJointStates(states); |
| 41 | 43 | ||
| 44 | // Determine the default eye position for avatar scale = 1.0 | ||
| 45 | int headJointIndex = _geometry->getFBXGeometry().headJointIndex; | ||
| 46 | if (0 <= headJointIndex && headJointIndex < _jointStates.size()) { | ||
| 47 | |||
| 48 | glm::vec3 leftEyePosition, rightEyePosition; | ||
| 49 | getEyeModelPositions(leftEyePosition, rightEyePosition); | ||
| 50 | glm::vec3 midEyePosition = (leftEyePosition + rightEyePosition) / 2.f; | ||
| 51 | |||
| 52 | int rootJointIndex = _geometry->getFBXGeometry().rootJointIndex; | ||
| 53 | glm::vec3 rootModelPosition; | ||
| 54 | getJointPosition(rootJointIndex, rootModelPosition); | ||
| 55 | |||
| 56 | _defaultEyeModelPosition = midEyePosition - rootModelPosition; | ||
| 57 | _defaultEyeModelPosition.z = -_defaultEyeModelPosition.z; | ||
| 58 | |||
| 59 | // Skeleton may have already been scaled so unscale it | ||
| 60 | _defaultEyeModelPosition = MODEL_SCALE * _defaultEyeModelPosition / _scale; | ||
| 61 | } | ||
| 62 | |||
| 42 | // the SkeletonModel override of updateJointState() will clear the translation part | 63 | // the SkeletonModel override of updateJointState() will clear the translation part |
| 43 | // of its root joint and we need that done before we try to build shapes hence we | 64 | // of its root joint and we need that done before we try to build shapes hence we |
| 44 | // recompute all joint transforms at this time. | 65 | // recompute all joint transforms at this time. |
| @@ -59,7 +80,6 @@ void SkeletonModel::simulate(float deltaTime, bool fullUpdate) { · 14 unmodified lines | |||
| 59 | setTranslation(_owningAvatar->getPosition()); | 80 | setTranslation(_owningAvatar->getPosition()); |
| 60 | static const glm::quat refOrientation = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f)); | 81 | static const glm::quat refOrientation = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f)); |
| 61 | setRotation(_owningAvatar->getOrientation() * refOrientation); | 82 | setRotation(_owningAvatar->getOrientation() * refOrientation); |
| 62 | const float MODEL_SCALE = 0.0006f; | ||
| 63 | setScale(glm::vec3(1.0f, 1.0f, 1.0f) * _owningAvatar->getScale() * MODEL_SCALE); | 83 | setScale(glm::vec3(1.0f, 1.0f, 1.0f) * _owningAvatar->getScale() * MODEL_SCALE); |
| 64 | setBlendshapeCoefficients(_owningAvatar->getHead()->getBlendshapeCoefficients()); | 84 | setBlendshapeCoefficients(_owningAvatar->getHead()->getBlendshapeCoefficients()); |
| 65 | 85 | ||
| @@ -507,6 +527,10 @@ bool SkeletonModel::getEyePositions(glm::vec3& firstEyePosition, glm::vec3& seco · 441 unmodified lines | |||
| 507 | return false; | 527 | return false; |
| 508 | } | 528 | } |
| 509 | 529 | ||
| 530 | glm::vec3 SkeletonModel::getDefaultEyeModelPosition() const { | ||
| 531 | return _owningAvatar->getScale() * _defaultEyeModelPosition; | ||
| 532 | } | ||
| 533 | |||
| 510 | void SkeletonModel::renderRagdoll() { | 534 | void SkeletonModel::renderRagdoll() { |
| 511 | if (!_ragdoll) { | 535 | if (!_ragdoll) { |
| 512 | return; | 536 | return; |
| @@ -666,20 +690,6 @@ void SkeletonModel::buildShapes() { · 153 unmodified lines | |||
| 666 | // This method moves the shapes to their default positions in Model frame. | 690 | // This method moves the shapes to their default positions in Model frame. |
| 667 | computeBoundingShape(geometry); | 691 | computeBoundingShape(geometry); |
| 668 | 692 | ||
| 669 | int headJointIndex = _geometry->getFBXGeometry().headJointIndex; | ||
| 670 | if (0 <= headJointIndex && headJointIndex < _jointStates.size()) { | ||
| 671 | glm::vec3 leftEyePosition, rightEyePosition; | ||
| 672 | getEyeModelPositions(leftEyePosition, rightEyePosition); | ||
| 673 | glm::vec3 midEyePosition = (leftEyePosition + rightEyePosition) / 2.f; | ||
| 674 | |||
| 675 | int rootJointIndex = _geometry->getFBXGeometry().rootJointIndex; | ||
| 676 | glm::vec3 rootModelPosition; | ||
| 677 | getJointPosition(rootJointIndex, rootModelPosition); | ||
| 678 | |||
| 679 | _defaultEyeModelPosition = midEyePosition - rootModelPosition; | ||
| 680 | _defaultEyeModelPosition.z = -_defaultEyeModelPosition.z; | ||
| 681 | } | ||
| 682 | |||
| 683 | // While the shapes are in their default position we disable collisions between | 693 | // While the shapes are in their default position we disable collisions between |
| 684 | // joints that are currently colliding. | 694 | // joints that are currently colliding. |
| 685 | disableCurrentSelfCollisions(); | 695 | disableCurrentSelfCollisions(); |