* Updated SkeletionModel::updateRig to explicitly pass a set of HeadParameters to the rig to do procedural animation. * Moved torso lean procedural animation from SkeletonModel into Rig. * Moved eye tracking procedural animation from HeadModel into Rig. * Moved neck procedural animation from HeadModel into Rig.
Showing the changes to interface/src/avatar/SkeletonModel.cpp (1 of 8 files). Show all
Unified · Split
| @@ -118,6 +118,24 @@ void SkeletonModel::updateClusterMatrices() { · 117 unmodified lines | ||
| 118 | 118 | void SkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) { |
| 119 | 119 | _rig->computeMotionAnimationState(deltaTime, _owningAvatar->getPosition(), _owningAvatar->getVelocity(), _owningAvatar->getOrientation()); |
| 120 | 120 | Model::updateRig(deltaTime, parentTransform); |
| 121 | + if (_owningAvatar->isMyAvatar()) { | |
| 122 | + const FBXGeometry& geometry = _geometry->getFBXGeometry(); | |
| 123 | + | |
| 124 | + Rig::HeadParameters params; | |
| 125 | + params.leanSideways = _owningAvatar->getHead()->getFinalLeanSideways(); | |
| 126 | + params.leanForward = _owningAvatar->getHead()->getFinalLeanSideways(); | |
| 127 | + params.torsoTwist = _owningAvatar->getHead()->getTorsoTwist(); | |
| 128 | + params.localHeadOrientation = _owningAvatar->getHead()->getFinalOrientationInLocalFrame(); | |
| 129 | + params.worldHeadOrientation = _owningAvatar->getHead()->getFinalOrientationInWorldFrame(); | |
| 130 | + params.eyeLookAt = _owningAvatar->getHead()->getCorrectedLookAtPosition(); | |
| 131 | + params.eyeSaccade = _owningAvatar->getHead()->getSaccade(); | |
| 132 | + params.leanJointIndex = geometry.leanJointIndex; | |
| 133 | + params.neckJointIndex = geometry.neckJointIndex; | |
| 134 | + params.leftEyeJointIndex = geometry.leftEyeJointIndex; | |
| 135 | + params.rightEyeJointIndex = geometry.rightEyeJointIndex; | |
| 136 | + | |
| 137 | + _rig->updateFromHeadParameters(params); | |
| 138 | + } | |
| 121 | 139 | } |
| 122 | 140 | |
| 123 | 141 | void SkeletonModel::simulate(float deltaTime, bool fullUpdate) { |
| @@ -259,51 +277,12 @@ void SkeletonModel::updateJointState(int index) { · 135 unmodified lines | ||
| 259 | 277 | const FBXGeometry& geometry = _geometry->getFBXGeometry(); |
| 260 | 278 | glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset) * geometry.offset; |
| 261 | 279 | |
| 262 | − const JointState joint = _rig->getJointState(index); | |
| 263 | − if (joint.getParentIndex() >= 0 && joint.getParentIndex() < _rig->getJointStateCount()) { | |
| 264 | − const JointState parentState = _rig->getJointState(joint.getParentIndex()); | |
| 265 | − if (index == geometry.leanJointIndex) { | |
| 266 | − maybeUpdateLeanRotation(parentState, index); | |
| 267 | − | |
| 268 | − } else if (index == geometry.neckJointIndex) { | |
| 269 | − maybeUpdateNeckRotation(parentState, joint.getFBXJoint(), index); | |
| 270 | − | |
| 271 | − } else if (index == geometry.leftEyeJointIndex || index == geometry.rightEyeJointIndex) { | |
| 272 | − maybeUpdateEyeRotation(parentState, joint.getFBXJoint(), index); | |
| 273 | − } | |
| 274 | − } | |
| 275 | − | |
| 276 | 280 | _rig->updateJointState(index, parentTransform); |
| 277 | 281 | |
| 278 | 282 | if (index == _geometry->getFBXGeometry().rootJointIndex) { |
| 279 | 283 | _rig->clearJointTransformTranslation(index); |
| 280 | 284 | } |
| 281 | 285 | } |
| 282 | − | |
| 283 | −void SkeletonModel::maybeUpdateLeanRotation(const JointState& parentState, int index) { | |
| 284 | − if (!_owningAvatar->isMyAvatar()) { | |
| 285 | − return; | |
| 286 | − } | |
| 287 | − // get the rotation axes in joint space and use them to adjust the rotation | |
| 288 | − glm::vec3 xAxis(1.0f, 0.0f, 0.0f); | |
| 289 | − glm::vec3 yAxis(0.0f, 1.0f, 0.0f); | |
| 290 | − glm::vec3 zAxis(0.0f, 0.0f, 1.0f); | |
| 291 | − glm::quat inverse = glm::inverse(parentState.getRotation() * _rig->getJointDefaultRotationInParentFrame(index)); | |
| 292 | − _rig->setJointRotationInConstrainedFrame(index, | |
| 293 | − glm::angleAxis(- RADIANS_PER_DEGREE * _owningAvatar->getHead()->getFinalLeanSideways(), inverse * zAxis) | |
| 294 | − * glm::angleAxis(- RADIANS_PER_DEGREE * _owningAvatar->getHead()->getFinalLeanForward(), inverse * xAxis) | |
| 295 | − * glm::angleAxis(RADIANS_PER_DEGREE * _owningAvatar->getHead()->getTorsoTwist(), inverse * yAxis) | |
| 296 | − * _rig->getJointState(index).getFBXJoint().rotation, LEAN_PRIORITY); | |
| 297 | −} | |
| 298 | − | |
| 299 | −void SkeletonModel::maybeUpdateNeckRotation(const JointState& parentState, const FBXJoint& joint, int index) { | |
| 300 | − _owningAvatar->getHead()->getFaceModel().maybeUpdateNeckRotation(parentState, joint, index); | |
| 301 | −} | |
| 302 | − | |
| 303 | −void SkeletonModel::maybeUpdateEyeRotation(const JointState& parentState, const FBXJoint& joint, int index) { | |
| 304 | − _owningAvatar->getHead()->getFaceModel().maybeUpdateEyeRotation(this, parentState, joint, index); | |
| 305 | −} | |
| 306 | − | |
| 307 | 286 | void SkeletonModel::renderJointConstraints(gpu::Batch& batch, int jointIndex) { |
| 308 | 287 | if (jointIndex == -1 || jointIndex >= _rig->getJointStateCount()) { |
| 309 | 288 | return; |