Fixed support for calling setJointMumblers with joint name. Walk.js runs smooth now!

This commit is contained in:
Thijs Wenker 2015-10-15 15:35:35 +02:00
parent 8111432088
commit c99573ea64
4 changed files with 27 additions and 8 deletions

View file

@ -82,7 +82,7 @@ Avatar = function() {
// only need to zero right leg IK chain and hips // only need to zero right leg IK chain and hips
if (IKChain === "RightLeg" || joint === "Hips" ) { if (IKChain === "RightLeg" || joint === "Hips" ) {
MyAvatar.setJointRotation(MyAvatar.jointNames.indexOf(joint), Quat.fromPitchYawRollDegrees(0, 0, 0)); MyAvatar.setJointRotation(joint, Quat.fromPitchYawRollDegrees(0, 0, 0));
} }
} }
this.calibration.hipsToFeet = MyAvatar.getJointPosition("Hips").y - MyAvatar.getJointPosition("RightToeBase").y; this.calibration.hipsToFeet = MyAvatar.getJointPosition("Hips").y - MyAvatar.getJointPosition("RightToeBase").y;
@ -112,16 +112,16 @@ Avatar = function() {
this.poseFingers = function() { this.poseFingers = function() {
for (knuckle in walkAssets.animationReference.leftHand) { for (knuckle in walkAssets.animationReference.leftHand) {
if (walkAssets.animationReference.leftHand[knuckle].IKChain === "LeftHandThumb") { if (walkAssets.animationReference.leftHand[knuckle].IKChain === "LeftHandThumb") {
MyAvatar.setJointRotation(MyAvatar.jointNames.indexOf(knuckle), Quat.fromPitchYawRollDegrees(0, 0, -4)); MyAvatar.setJointRotation(knuckle, Quat.fromPitchYawRollDegrees(0, 0, -4));
} else { } else {
MyAvatar.setJointRotation(MyAvatar.jointNames.indexOf(knuckle), Quat.fromPitchYawRollDegrees(16, 0, 5)); MyAvatar.setJointRotation(knuckle, Quat.fromPitchYawRollDegrees(16, 0, 5));
} }
} }
for (knuckle in walkAssets.animationReference.rightHand) { for (knuckle in walkAssets.animationReference.rightHand) {
if (walkAssets.animationReference.rightHand[knuckle].IKChain === "RightHandThumb") { if (walkAssets.animationReference.rightHand[knuckle].IKChain === "RightHandThumb") {
MyAvatar.setJointRotation(MyAvatar.jointNames.indexOf(knuckle), Quat.fromPitchYawRollDegrees(0, 0, 4)); MyAvatar.setJointRotation(knuckle, Quat.fromPitchYawRollDegrees(0, 0, 4));
} else { } else {
MyAvatar.setJointRotation(MyAvatar.jointNames.indexOf(knuckle), Quat.fromPitchYawRollDegrees(16, 0, -5)); MyAvatar.setJointRotation(knuckle, Quat.fromPitchYawRollDegrees(16, 0, -5));
} }
} }
}; };

View file

@ -449,6 +449,6 @@ function renderMotion() {
} }
// apply rotations // apply rotations
MyAvatar.setJointRotation(MyAvatar.jointNames.indexOf(jointName), Quat.fromVec3Degrees(jointRotations)); MyAvatar.setJointRotation(jointName, Quat.fromVec3Degrees(jointRotations));
} }
} }

View file

@ -1032,13 +1032,30 @@ glm::vec3 AvatarData::getJointTranslation(const QString& name) const {
void AvatarData::setJointData(const QString& name, const glm::quat& rotation, const glm::vec3& translation) { void AvatarData::setJointData(const QString& name, const glm::quat& rotation, const glm::vec3& translation) {
if (QThread::currentThread() != thread()) { if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "setJointData", Q_ARG(const QString&, name), QMetaObject::invokeMethod(this, "setJointData", Q_ARG(const QString&, name), Q_ARG(const glm::quat&, rotation),
Q_ARG(const glm::quat&, rotation)); Q_ARG(const glm::vec3&, translation));
return; return;
} }
setJointData(getJointIndex(name), rotation, translation); setJointData(getJointIndex(name), rotation, translation);
} }
void AvatarData::setJointRotation(const QString& name, const glm::quat& rotation) {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "setJointRotation", Q_ARG(const QString&, name), Q_ARG(const glm::quat&, rotation));
return;
}
setJointRotation(getJointIndex(name), rotation);
}
void AvatarData::setJointTranslation(const QString& name, const glm::vec3& translation) {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "setJointTranslation", Q_ARG(const QString&, name),
Q_ARG(const glm::vec3&, translation));
return;
}
setJointTranslation(getJointIndex(name), translation);
}
void AvatarData::setJointRotation(int index, const glm::quat& rotation) { void AvatarData::setJointRotation(int index, const glm::quat& rotation) {
if (index == -1) { if (index == -1) {
return; return;

View file

@ -251,6 +251,8 @@ public:
Q_INVOKABLE virtual glm::vec3 getJointTranslation(int index) const; Q_INVOKABLE virtual glm::vec3 getJointTranslation(int index) const;
Q_INVOKABLE void setJointData(const QString& name, const glm::quat& rotation, const glm::vec3& translation); Q_INVOKABLE void setJointData(const QString& name, const glm::quat& rotation, const glm::vec3& translation);
Q_INVOKABLE void setJointRotation(const QString& name, const glm::quat& rotation);
Q_INVOKABLE void setJointTranslation(const QString& name, const glm::vec3& translation);
Q_INVOKABLE void clearJointData(const QString& name); Q_INVOKABLE void clearJointData(const QString& name);
Q_INVOKABLE bool isJointDataValid(const QString& name) const; Q_INVOKABLE bool isJointDataValid(const QString& name) const;
Q_INVOKABLE glm::quat getJointRotation(const QString& name) const; Q_INVOKABLE glm::quat getJointRotation(const QString& name) const;