History

Remove arm stretching, add sixense calibration

Andrew Meadows committed 12 years ago

Commit a045a871 parent 0a69b1b9 files · +243 −97Browse files

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

Unified · Split

interface/src/avatar/SkeletonModel.cpp+1−41
@@ -123,6 +123,7 @@ void SkeletonModel::applyPalmData(int jointIndex, const QVector<int>& fingerJoin · 122 unmodified lines
123 return;123 return;
124 }124 }
125 const FBXGeometry& geometry = _geometry->getFBXGeometry();125 const FBXGeometry& geometry = _geometry->getFBXGeometry();
126 setJointPosition(jointIndex, palm.getPosition());
126 float sign = (jointIndex == geometry.rightHandJointIndex) ? 1.0f : -1.0f;127 float sign = (jointIndex == geometry.rightHandJointIndex) ? 1.0f : -1.0f;
127 glm::quat palmRotation;128 glm::quat palmRotation;
128 getJointRotation(jointIndex, palmRotation, true);129 getJointRotation(jointIndex, palmRotation, true);
@@ -154,7 +155,6 @@ void SkeletonModel::applyPalmData(int jointIndex, const QVector<int>& fingerJoin · 25 unmodified lines
154 155
155 // no point in continuing if there are no fingers156 // no point in continuing if there are no fingers
156 if (palm.getNumFingers() == 0 || fingerJointIndices.isEmpty()) {157 if (palm.getNumFingers() == 0 || fingerJointIndices.isEmpty()) {
157 stretchArm(jointIndex, palm.getPosition());
158 return;158 return;
159 }159 }
160 160
@@ -172,8 +172,6 @@ void SkeletonModel::applyPalmData(int jointIndex, const QVector<int>& fingerJoin · 11 unmodified lines
172 172
173 setJointRotation(fingerJointIndex, rotationBetween(palmRotation * jointVector, fingerVector) * palmRotation, true);173 setJointRotation(fingerJointIndex, rotationBetween(palmRotation * jointVector, fingerVector) * palmRotation, true);
174 }174 }
175
176 stretchArm(jointIndex, palm.getPosition());
177}175}
178 176
179void SkeletonModel::updateJointState(int index) {177void SkeletonModel::updateJointState(int index) {
@@ -200,41 +198,3 @@ void SkeletonModel::maybeUpdateLeanRotation(const JointState& parentState, const · 20 unmodified lines
200 glm::normalize(inverse * axes[0])) * joint.rotation;198 glm::normalize(inverse * axes[0])) * joint.rotation;
201}199}
202 200
203void SkeletonModel::stretchArm(int jointIndex, const glm::vec3& position) {
204 // find out where the hand is pointing
205 glm::quat handRotation;
206 getJointRotation(jointIndex, handRotation, true);
207 const FBXGeometry& geometry = _geometry->getFBXGeometry();
208 glm::vec3 forwardVector(jointIndex == geometry.rightHandJointIndex ? -1.0f : 1.0f, 0.0f, 0.0f);
209 glm::vec3 handVector = handRotation * forwardVector;
210
211 // align elbow with hand
212 const FBXJoint& joint = geometry.joints.at(jointIndex);
213 if (joint.parentIndex == -1) {
214 return;
215 }
216 glm::quat elbowRotation;
217 getJointRotation(joint.parentIndex, elbowRotation, true);
218 applyRotationDelta(joint.parentIndex, rotationBetween(elbowRotation * forwardVector, handVector), false);
219
220 // set position according to normal length
221 float scale = extractUniformScale(_scale);
222 glm::vec3 handPosition = position - _translation;
223 glm::vec3 elbowPosition = handPosition - handVector * joint.distanceToParent * scale;
224
225 // set shoulder orientation to point to elbow
226 const FBXJoint& parentJoint = geometry.joints.at(joint.parentIndex);
227 if (parentJoint.parentIndex == -1) {
228 return;
229 }
230 glm::quat shoulderRotation;
231 getJointRotation(parentJoint.parentIndex, shoulderRotation, true);
232 applyRotationDelta(parentJoint.parentIndex, rotationBetween(shoulderRotation * forwardVector,
233 elbowPosition - extractTranslation(_jointStates.at(parentJoint.parentIndex).transform)), false);
234
235 // update the shoulder state
236 updateJointState(parentJoint.parentIndex);
237
238 // adjust the elbow's local translation
239 setJointTranslation(joint.parentIndex, elbowPosition);
240}

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