History

Fix avatar head, eye and torso twist.

* 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.

Anthony J. Thibault committed 11 years ago

Commit c2934bd1 parent 6c68dbe8 files · +108 −123Browse files

Showing the changes to interface/src/avatar/SkeletonModel.cpp (1 of 8 files). Show all

Unified · Split

interface/src/avatar/SkeletonModel.cpp+18−39
@@ -118,6 +118,24 @@ void SkeletonModel::updateClusterMatrices() { · 117 unmodified lines
118118 void SkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
119119 _rig->computeMotionAnimationState(deltaTime, _owningAvatar->getPosition(), _owningAvatar->getVelocity(), _owningAvatar->getOrientation());
120120 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+ }
121139 }
122140
123141 void SkeletonModel::simulate(float deltaTime, bool fullUpdate) {
@@ -259,51 +277,12 @@ void SkeletonModel::updateJointState(int index) { · 135 unmodified lines
259277 const FBXGeometry& geometry = _geometry->getFBXGeometry();
260278 glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
261279
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−
276280 _rig->updateJointState(index, parentTransform);
277281
278282 if (index == _geometry->getFBXGeometry().rootJointIndex) {
279283 _rig->clearJointTransformTranslation(index);
280284 }
281285 }
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−
307286 void SkeletonModel::renderJointConstraints(gpu::Batch& batch, int jointIndex) {
308287 if (jointIndex == -1 || jointIndex >= _rig->getJointStateCount()) {
309288 return;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t