mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 23:09:52 +02:00
further cleaning, broke the arms
This commit is contained in:
parent
f8bfef6dbd
commit
ffd3a24bf2
4 changed files with 29 additions and 69 deletions
|
@ -192,8 +192,6 @@
|
||||||
"tipRotationVar": "headRotation",
|
"tipRotationVar": "headRotation",
|
||||||
"alphaVar": "splineIKAlpha",
|
"alphaVar": "splineIKAlpha",
|
||||||
"enabledVar": "splineIKEnabled",
|
"enabledVar": "splineIKEnabled",
|
||||||
"endEffectorRotationVarVar": "splineIKRotationVar",
|
|
||||||
"endEffectorPositionVarVar": "splineIKPositionVar",
|
|
||||||
"tipTargetFlexCoefficients": "1.0, 1.0, 1.0, 1.0, 1.0",
|
"tipTargetFlexCoefficients": "1.0, 1.0, 1.0, 1.0, 1.0",
|
||||||
"midTargetFlexCoefficients": "1.0, 1.0, 1.0"
|
"midTargetFlexCoefficients": "1.0, 1.0, 1.0"
|
||||||
},
|
},
|
||||||
|
|
|
@ -594,16 +594,14 @@ static AnimNode::Pointer loadSplineIKNode(const QJsonObject& jsonObj, const QStr
|
||||||
READ_STRING(tipRotationVar, jsonObj, id, jsonUrl, nullptr);
|
READ_STRING(tipRotationVar, jsonObj, id, jsonUrl, nullptr);
|
||||||
READ_STRING(alphaVar, jsonObj, id, jsonUrl, nullptr);
|
READ_STRING(alphaVar, jsonObj, id, jsonUrl, nullptr);
|
||||||
READ_STRING(enabledVar, jsonObj, id, jsonUrl, nullptr);
|
READ_STRING(enabledVar, jsonObj, id, jsonUrl, nullptr);
|
||||||
READ_STRING(endEffectorRotationVarVar, jsonObj, id, jsonUrl, nullptr);
|
|
||||||
READ_STRING(endEffectorPositionVarVar, jsonObj, id, jsonUrl, nullptr);
|
|
||||||
READ_STRING(tipTargetFlexCoefficients, jsonObj, id, jsonUrl, nullptr);
|
READ_STRING(tipTargetFlexCoefficients, jsonObj, id, jsonUrl, nullptr);
|
||||||
READ_STRING(midTargetFlexCoefficients, jsonObj, id, jsonUrl, nullptr);
|
READ_STRING(midTargetFlexCoefficients, jsonObj, id, jsonUrl, nullptr);
|
||||||
|
|
||||||
auto node = std::make_shared<AnimSplineIK>(id, alpha, enabled, interpDuration,
|
auto node = std::make_shared<AnimSplineIK>(id, alpha, enabled, interpDuration,
|
||||||
baseJointName, midJointName, tipJointName,
|
baseJointName, midJointName, tipJointName,
|
||||||
alphaVar, enabledVar, endEffectorRotationVarVar, endEffectorPositionVarVar,
|
|
||||||
basePositionVar, baseRotationVar, midPositionVar, midRotationVar,
|
basePositionVar, baseRotationVar, midPositionVar, midRotationVar,
|
||||||
tipPositionVar, tipRotationVar, tipTargetFlexCoefficients, midTargetFlexCoefficients);
|
tipPositionVar, tipRotationVar, alphaVar, enabledVar,
|
||||||
|
tipTargetFlexCoefficients, midTargetFlexCoefficients);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,14 @@ AnimSplineIK::AnimSplineIK(const QString& id, float alpha, bool enabled, float i
|
||||||
const QString& baseJointName,
|
const QString& baseJointName,
|
||||||
const QString& midJointName,
|
const QString& midJointName,
|
||||||
const QString& tipJointName,
|
const QString& tipJointName,
|
||||||
const QString& alphaVar, const QString& enabledVar,
|
|
||||||
const QString& endEffectorRotationVarVar, const QString& endEffectorPositionVarVar,
|
|
||||||
const QString& basePositionVar,
|
const QString& basePositionVar,
|
||||||
const QString& baseRotationVar,
|
const QString& baseRotationVar,
|
||||||
const QString& midPositionVar,
|
const QString& midPositionVar,
|
||||||
const QString& midRotationVar,
|
const QString& midRotationVar,
|
||||||
const QString& tipPositionVar,
|
const QString& tipPositionVar,
|
||||||
const QString& tipRotationVar,
|
const QString& tipRotationVar,
|
||||||
|
const QString& alphaVar,
|
||||||
|
const QString& enabledVar,
|
||||||
const QString& tipTargetFlexCoefficients,
|
const QString& tipTargetFlexCoefficients,
|
||||||
const QString& midTargetFlexCoefficients) :
|
const QString& midTargetFlexCoefficients) :
|
||||||
AnimNode(AnimNode::Type::SplineIK, id),
|
AnimNode(AnimNode::Type::SplineIK, id),
|
||||||
|
@ -38,18 +38,14 @@ AnimSplineIK::AnimSplineIK(const QString& id, float alpha, bool enabled, float i
|
||||||
_baseJointName(baseJointName),
|
_baseJointName(baseJointName),
|
||||||
_midJointName(midJointName),
|
_midJointName(midJointName),
|
||||||
_tipJointName(tipJointName),
|
_tipJointName(tipJointName),
|
||||||
_alphaVar(alphaVar),
|
|
||||||
_enabledVar(enabledVar),
|
|
||||||
_endEffectorRotationVarVar(endEffectorRotationVarVar),
|
|
||||||
_endEffectorPositionVarVar(endEffectorPositionVarVar),
|
|
||||||
_prevEndEffectorRotationVar(),
|
|
||||||
_prevEndEffectorPositionVar(),
|
|
||||||
_basePositionVar(basePositionVar),
|
_basePositionVar(basePositionVar),
|
||||||
_baseRotationVar(baseRotationVar),
|
_baseRotationVar(baseRotationVar),
|
||||||
_midPositionVar(midPositionVar),
|
_midPositionVar(midPositionVar),
|
||||||
_midRotationVar(midRotationVar),
|
_midRotationVar(midRotationVar),
|
||||||
_tipPositionVar(tipPositionVar),
|
_tipPositionVar(tipPositionVar),
|
||||||
_tipRotationVar(tipRotationVar)
|
_tipRotationVar(tipRotationVar),
|
||||||
|
_alphaVar(alphaVar),
|
||||||
|
_enabledVar(enabledVar)
|
||||||
{
|
{
|
||||||
|
|
||||||
QStringList tipTargetFlexCoefficientsValues = tipTargetFlexCoefficients.split(',', QString::SkipEmptyParts);
|
QStringList tipTargetFlexCoefficientsValues = tipTargetFlexCoefficients.split(',', QString::SkipEmptyParts);
|
||||||
|
@ -101,7 +97,7 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
|
||||||
return _poses;
|
return _poses;
|
||||||
}
|
}
|
||||||
|
|
||||||
// guard against size changes
|
// guard against size change
|
||||||
if (underPoses.size() != _poses.size()) {
|
if (underPoses.size() != _poses.size()) {
|
||||||
_poses = underPoses;
|
_poses = underPoses;
|
||||||
}
|
}
|
||||||
|
@ -130,17 +126,14 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
|
||||||
AnimChain underChain;
|
AnimChain underChain;
|
||||||
underChain.buildFromRelativePoses(_skeleton, underPoses, _tipJointIndex);
|
underChain.buildFromRelativePoses(_skeleton, underPoses, _tipJointIndex);
|
||||||
|
|
||||||
glm::quat baseTargetRotation;
|
AnimPose baseTargetAbsolutePose;
|
||||||
glm::vec3 baseTargetTranslation;
|
|
||||||
|
|
||||||
// now we override the hips with the hips target pose.
|
// now we override the hips with the hips target pose.
|
||||||
// if there is a baseJoint ik target in animvars then use that
|
// if there is a baseJoint ik target in animvars then use that
|
||||||
// otherwise use the underpose
|
// otherwise use the underpose
|
||||||
if (_poses.size() > 0) {
|
if (_poses.size() > 0) {
|
||||||
AnimPose baseJointUnderPose = _skeleton->getAbsolutePose(_baseJointIndex, _poses);
|
AnimPose baseJointUnderPose = _skeleton->getAbsolutePose(_baseJointIndex, _poses);
|
||||||
baseTargetRotation = animVars.lookupRigToGeometry(_baseRotationVar, baseJointUnderPose.rot());
|
baseTargetAbsolutePose.rot() = animVars.lookupRigToGeometry(_baseRotationVar, baseJointUnderPose.rot());
|
||||||
baseTargetTranslation = animVars.lookupRigToGeometry(_basePositionVar, baseJointUnderPose.trans());
|
baseTargetAbsolutePose.trans() = animVars.lookupRigToGeometry(_basePositionVar, baseJointUnderPose.trans());
|
||||||
AnimPose absBaseTargetPose(baseTargetRotation, baseTargetTranslation);
|
|
||||||
|
|
||||||
int baseParentIndex = _skeleton->getParentIndex(_baseJointIndex);
|
int baseParentIndex = _skeleton->getParentIndex(_baseJointIndex);
|
||||||
AnimPose baseParentAbsPose(Quaternions::IDENTITY,glm::vec3());
|
AnimPose baseParentAbsPose(Quaternions::IDENTITY,glm::vec3());
|
||||||
|
@ -148,7 +141,7 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
|
||||||
baseParentAbsPose = _skeleton->getAbsolutePose(baseParentIndex, _poses);
|
baseParentAbsPose = _skeleton->getAbsolutePose(baseParentIndex, _poses);
|
||||||
}
|
}
|
||||||
|
|
||||||
_poses[_baseJointIndex] = baseParentAbsPose.inverse() * absBaseTargetPose;
|
_poses[_baseJointIndex] = baseParentAbsPose.inverse() * baseTargetAbsolutePose;
|
||||||
_poses[_baseJointIndex].scale() = glm::vec3(1.0f);
|
_poses[_baseJointIndex].scale() = glm::vec3(1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,26 +186,22 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimChain midJointChain;
|
AnimChain midJointChain;
|
||||||
AnimPose beforeSolveChestNeck;
|
int childOfMiddleJointIndex = -1;
|
||||||
int startJoint;
|
AnimPose childOfMiddleJointAbsolutePoseAfterBaseTipSpline;
|
||||||
AnimPose correctJoint;
|
|
||||||
if (_poses.size() > 0) {
|
if (_poses.size() > 0) {
|
||||||
|
|
||||||
AnimPoseVec absolutePoses2;
|
childOfMiddleJointIndex = _tipJointIndex;
|
||||||
absolutePoses2.resize(_poses.size());
|
|
||||||
computeAbsolutePoses(absolutePoses2);
|
|
||||||
|
|
||||||
// start at the tip
|
// start at the tip
|
||||||
for (startJoint = _tipJointIndex; _skeleton->getParentIndex(startJoint) != _midJointIndex; startJoint = _skeleton->getParentIndex(startJoint)) {
|
while (_skeleton->getParentIndex(childOfMiddleJointIndex) != _midJointIndex) {
|
||||||
// find the child of the midJoint
|
childOfMiddleJointIndex = _skeleton->getParentIndex(childOfMiddleJointIndex);
|
||||||
}
|
}
|
||||||
correctJoint = _skeleton->getAbsolutePose(startJoint, _poses);
|
childOfMiddleJointAbsolutePoseAfterBaseTipSpline = _skeleton->getAbsolutePose(childOfMiddleJointIndex, _poses);
|
||||||
|
|
||||||
// fix this to deal with no neck AA
|
|
||||||
beforeSolveChestNeck = _skeleton->getAbsolutePose(_skeleton->nameToJointIndex("Neck"), _poses);
|
|
||||||
|
|
||||||
|
AnimPoseVec absolutePosesAfterBaseTipSpline;
|
||||||
|
absolutePosesAfterBaseTipSpline.resize(_poses.size());
|
||||||
|
computeAbsolutePoses(absolutePosesAfterBaseTipSpline);
|
||||||
midJointChain.buildFromRelativePoses(_skeleton, _poses, midTarget.getIndex());
|
midJointChain.buildFromRelativePoses(_skeleton, _poses, midTarget.getIndex());
|
||||||
solveTargetWithSpline(context, midTarget, absolutePoses2, false, midJointChain);
|
solveTargetWithSpline(context, midTarget, absolutePosesAfterBaseTipSpline, false, midJointChain);
|
||||||
midJointChain.outputRelativePoses(_poses);
|
midJointChain.outputRelativePoses(_poses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,17 +209,8 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
|
||||||
int tipParent = _skeleton->getParentIndex(_tipJointIndex);
|
int tipParent = _skeleton->getParentIndex(_tipJointIndex);
|
||||||
int midTargetParent = _skeleton->getParentIndex(_midJointIndex);
|
int midTargetParent = _skeleton->getParentIndex(_midJointIndex);
|
||||||
if ((midTargetParent != -1) && (tipParent != -1) && (_poses.size() > 0)) {
|
if ((midTargetParent != -1) && (tipParent != -1) && (_poses.size() > 0)) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AnimPose midTargetPose(midTarget.getRotation(), midTarget.getTranslation());
|
AnimPose midTargetPose(midTarget.getRotation(), midTarget.getTranslation());
|
||||||
//AnimPose neckAbsolute = _skeleton->getAbsolutePose(tipParent, _poses);
|
_poses[childOfMiddleJointIndex] = midTargetPose.inverse() * childOfMiddleJointAbsolutePoseAfterBaseTipSpline;
|
||||||
//_poses[tipParent] = midTargetPose.inverse() * beforeSolveChestNeck;
|
|
||||||
_poses[startJoint] = midTargetPose.inverse() * correctJoint;
|
|
||||||
|
|
||||||
//AnimPose tipTargetPose(tipTarget.getRotation(),tipTarget.getTranslation());
|
|
||||||
//AnimPose tipRelativePose = _skeleton->getAbsolutePose(tipParent,_poses).inverse() * tipTargetPose;
|
|
||||||
//_poses[_tipJointIndex] = tipRelativePose;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute chain
|
// compute chain
|
||||||
|
@ -290,7 +270,7 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
|
||||||
DebugDraw::getInstance().addMyAvatarMarker(name2, glmExtractRotation(avatarTargetMat2), extractTranslation(avatarTargetMat2), WHITE);
|
DebugDraw::getInstance().addMyAvatarMarker(name2, glmExtractRotation(avatarTargetMat2), extractTranslation(avatarTargetMat2), WHITE);
|
||||||
|
|
||||||
|
|
||||||
glm::mat4 geomTargetMat3 = createMatFromQuatAndPos(baseTargetRotation,baseTargetTranslation);
|
glm::mat4 geomTargetMat3 = createMatFromQuatAndPos(baseTargetAbsolutePose.rot(), baseTargetAbsolutePose.trans());
|
||||||
glm::mat4 avatarTargetMat3 = rigToAvatarMat * context.getGeometryToRigMatrix() * geomTargetMat3;
|
glm::mat4 avatarTargetMat3 = rigToAvatarMat * context.getGeometryToRigMatrix() * geomTargetMat3;
|
||||||
QString name3 = QString("ikTargetSplineBase");
|
QString name3 = QString("ikTargetSplineBase");
|
||||||
DebugDraw::getInstance().addMyAvatarMarker(name3, glmExtractRotation(avatarTargetMat3), extractTranslation(avatarTargetMat3), WHITE);
|
DebugDraw::getInstance().addMyAvatarMarker(name3, glmExtractRotation(avatarTargetMat3), extractTranslation(avatarTargetMat3), WHITE);
|
||||||
|
@ -369,12 +349,7 @@ void AnimSplineIK::solveTargetWithSpline(const AnimContext& context, const IKTar
|
||||||
|
|
||||||
// build spline from tip to base
|
// build spline from tip to base
|
||||||
AnimPose tipPose = AnimPose(glm::vec3(1.0f), target.getRotation(), target.getTranslation());
|
AnimPose tipPose = AnimPose(glm::vec3(1.0f), target.getRotation(), target.getTranslation());
|
||||||
AnimPose basePose;
|
AnimPose basePose = absolutePoses[baseIndex];
|
||||||
//if (target.getIndex() == _tipJointIndex) {
|
|
||||||
// basePose = absolutePoses[tipBaseIndex];
|
|
||||||
//} else {
|
|
||||||
basePose = absolutePoses[baseIndex];
|
|
||||||
//}
|
|
||||||
|
|
||||||
CubicHermiteSplineFunctorWithArcLength spline;
|
CubicHermiteSplineFunctorWithArcLength spline;
|
||||||
if (target.getIndex() == _tipJointIndex) {
|
if (target.getIndex() == _tipJointIndex) {
|
||||||
|
@ -382,7 +357,6 @@ void AnimSplineIK::solveTargetWithSpline(const AnimContext& context, const IKTar
|
||||||
const float HIPS_GAIN = 0.5f;
|
const float HIPS_GAIN = 0.5f;
|
||||||
const float HEAD_GAIN = 1.0f;
|
const float HEAD_GAIN = 1.0f;
|
||||||
spline = computeSplineFromTipAndBase(tipPose, basePose, HIPS_GAIN, HEAD_GAIN);
|
spline = computeSplineFromTipAndBase(tipPose, basePose, HIPS_GAIN, HEAD_GAIN);
|
||||||
// spline = computeSplineFromTipAndBase(tipPose, basePose);
|
|
||||||
} else {
|
} else {
|
||||||
spline = computeSplineFromTipAndBase(tipPose, basePose);
|
spline = computeSplineFromTipAndBase(tipPose, basePose);
|
||||||
}
|
}
|
||||||
|
@ -406,7 +380,7 @@ void AnimSplineIK::solveTargetWithSpline(const AnimContext& context, const IKTar
|
||||||
float t = spline.arcLengthInverse(splineJointInfo.ratio * totalArcLength);
|
float t = spline.arcLengthInverse(splineJointInfo.ratio * totalArcLength);
|
||||||
glm::vec3 trans = spline(t);
|
glm::vec3 trans = spline(t);
|
||||||
|
|
||||||
// for head splines, preform most twist toward the tip by using ease in function. t^2
|
// for base->tip splines, preform most twist toward the tip by using ease in function. t^2
|
||||||
float rotT = t;
|
float rotT = t;
|
||||||
if (target.getIndex() == _tipJointIndex) {
|
if (target.getIndex() == _tipJointIndex) {
|
||||||
rotT = t * t;
|
rotT = t * t;
|
||||||
|
@ -454,9 +428,6 @@ void AnimSplineIK::solveTargetWithSpline(const AnimContext& context, const IKTar
|
||||||
if (!chainInfoOut.setRelativePoseAtJointIndex(splineJointInfo.jointIndex, relPose)) {
|
if (!chainInfoOut.setRelativePoseAtJointIndex(splineJointInfo.jointIndex, relPose)) {
|
||||||
qCDebug(animation) << "we didn't find the joint index for the spline!!!!";
|
qCDebug(animation) << "we didn't find the joint index for the spline!!!!";
|
||||||
}
|
}
|
||||||
if (splineJointInfo.jointIndex == _skeleton->nameToJointIndex("Neck")) {
|
|
||||||
qCDebug(animation) << "neck is " << relPose;
|
|
||||||
}
|
|
||||||
|
|
||||||
parentAbsPose = flexedAbsPose;
|
parentAbsPose = flexedAbsPose;
|
||||||
}
|
}
|
||||||
|
@ -518,7 +489,6 @@ void AnimSplineIK::computeAndCacheSplineJointInfosForIKTarget(const AnimContext&
|
||||||
int index = target.getIndex();
|
int index = target.getIndex();
|
||||||
int endIndex;
|
int endIndex;
|
||||||
if (target.getIndex() == _tipJointIndex) {
|
if (target.getIndex() == _tipJointIndex) {
|
||||||
//endIndex = _skeleton->getParentIndex(_secondaryTargetIndex);
|
|
||||||
endIndex = _skeleton->getParentIndex(_baseJointIndex);
|
endIndex = _skeleton->getParentIndex(_baseJointIndex);
|
||||||
} else {
|
} else {
|
||||||
endIndex = _skeleton->getParentIndex(_baseJointIndex);
|
endIndex = _skeleton->getParentIndex(_baseJointIndex);
|
||||||
|
|
|
@ -20,13 +20,12 @@ class AnimSplineIK : public AnimNode {
|
||||||
public:
|
public:
|
||||||
AnimSplineIK(const QString& id, float alpha, bool enabled, float interpDuration,
|
AnimSplineIK(const QString& id, float alpha, bool enabled, float interpDuration,
|
||||||
const QString& baseJointName, const QString& midJointName, const QString& tipJointName,
|
const QString& baseJointName, const QString& midJointName, const QString& tipJointName,
|
||||||
const QString& alphaVar, const QString& enabledVar,
|
|
||||||
const QString& endEffectorRotationVarVar, const QString& endEffectorPositionVarVar,
|
|
||||||
const QString& basePositionVar, const QString& baseRotationVar,
|
const QString& basePositionVar, const QString& baseRotationVar,
|
||||||
const QString& midPositionVar, const QString& midRotationVar,
|
const QString& midPositionVar, const QString& midRotationVar,
|
||||||
const QString& tipPositionVar, const QString& tipRotationVar,
|
const QString& tipPositionVar, const QString& tipRotationVar,
|
||||||
const QString& primaryFlexCoefficients,
|
const QString& alphaVar, const QString& enabledVar,
|
||||||
const QString& secondaryFlexCoefficients);
|
const QString& tipTargetFlexCoefficients,
|
||||||
|
const QString& midTargetFlexCoefficients);
|
||||||
|
|
||||||
virtual ~AnimSplineIK() override;
|
virtual ~AnimSplineIK() override;
|
||||||
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, AnimVariantMap& triggersOut) override;
|
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, AnimVariantMap& triggersOut) override;
|
||||||
|
@ -79,11 +78,6 @@ protected:
|
||||||
|
|
||||||
QString _alphaVar; // float - (0, 1) 0 means underPoses only, 1 means IK only.
|
QString _alphaVar; // float - (0, 1) 0 means underPoses only, 1 means IK only.
|
||||||
QString _enabledVar; // bool
|
QString _enabledVar; // bool
|
||||||
QString _endEffectorRotationVarVar; // string
|
|
||||||
QString _endEffectorPositionVarVar; // string
|
|
||||||
|
|
||||||
QString _prevEndEffectorRotationVar;
|
|
||||||
QString _prevEndEffectorPositionVar;
|
|
||||||
|
|
||||||
bool _previousEnableDebugIKTargets { false };
|
bool _previousEnableDebugIKTargets { false };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue