nearly have the arms legs and back working with out the ik node

This commit is contained in:
amantley 2019-01-21 17:41:08 -08:00
parent 6680ca53ad
commit 8d88c627b0
6 changed files with 1773 additions and 1762 deletions

View file

@ -112,7 +112,7 @@
},
"children": [
{
"id": "rightArmPoleVector",
"id": "rightHandPoleVector",
"type": "poleVectorConstraint",
"data": {
"enabled": false,
@ -125,7 +125,7 @@
},
"children": [
{
"id": "rightArmIK",
"id": "rightHandIK",
"type": "twoBoneIK",
"data": {
"alpha": 1.0,
@ -135,53 +135,42 @@
"midJointName": "RightForeArm",
"tipJointName": "RightHand",
"midHingeAxis": [ 0, 0, -1 ],
"alphaVar": "rightArmIKAlpha",
"enabledVar": "rightArmIKEnabled",
"endEffectorRotationVarVar": "rightArmIKRotationVar",
"endEffectorPositionVarVar": "rightArmIKPositionVar"
"alphaVar": "rightHandIKAlpha",
"enabledVar": "rightHandIKEnabled",
"endEffectorRotationVarVar": "rightHandIKRotationVar",
"endEffectorPositionVarVar": "rightHandIKPositionVar"
},
"children": [
{
"id": "ikOverlay",
"type": "overlay",
"id": "leftHandPoleVector",
"type": "poleVectorConstraint",
"data": {
"enabled": false,
"referenceVector": [ 0, 0, 1 ],
"baseJointName": "LeftArm",
"midJointName": "LeftForeArm",
"tipJointName": "LeftHand",
"enabledVar": "leftHandPoleVectorEnabled",
"poleVectorVar": "leftHandPoleVector"
},
"children": [
{
"id": "leftHandIK",
"type": "twoBoneIK",
"data": {
"alpha": 1.0,
"alphaVar": "ikOverlayAlpha",
"boneSet": "fullBody"
"enabled": false,
"interpDuration": 15,
"baseJointName": "LeftArm",
"midJointName": "LeftForeArm",
"tipJointName": "LeftHand",
"midHingeAxis": [ 0, 0, 1 ],
"alphaVar": "leftHandIKAlpha",
"enabledVar": "leftHandIKEnabled",
"endEffectorRotationVarVar": "leftHandIKRotationVar",
"endEffectorPositionVarVar": "leftHandIKPositionVar"
},
"children": [
{
"id": "ik",
"type": "inverseKinematics",
"data": {
"solutionSource": "relaxToUnderPoses",
"solutionSourceVar": "solutionSource",
"targets": [
{
"jointName": "Hips",
"positionVar": "hipsPosition",
"rotationVar": "hipsRotation",
"typeVar": "hipsType",
"weightVar": "hipsWeight",
"weight": 1.0,
"flexCoefficients": [ 1 ]
},
{
"jointName": "LeftHand",
"positionVar": "leftHandPosition",
"rotationVar": "leftHandRotation",
"typeVar": "leftHandType",
"weightVar": "leftHandWeight",
"weight": 1.0,
"flexCoefficients": [ 1, 0.5, 0.5, 0.2, 0.01, 0.005, 0.001, 0.0, 0.0 ],
"poleVectorEnabledVar": "leftHandPoleVectorEnabled",
"poleReferenceVectorVar": "leftHandPoleReferenceVector",
"poleVectorVar": "leftHandPoleVector"
}
]
},
"children": []
},
{
"id": "defaultPoseOverlay",
"type": "overlay",
@ -2183,6 +2172,8 @@
]
}
]
}
]
},
{
"id": "userAnimA",

View file

@ -4679,7 +4679,6 @@ void setupCpuMonitorThread() {
void Application::idle() {
PerformanceTimer perfTimer("idle");
qCDebug(interfaceapp) << "idle called";
// Update the deadlock watchdog
updateHeartbeat();

View file

@ -973,8 +973,8 @@ const AnimPoseVec& AnimInverseKinematics::overlay(const AnimVariantMap& animVars
::blend(1, &prevHipsAbsPose, &absPose, alpha, &absPose);
}
_relativePoses[_hipsIndex] = parentAbsPose.inverse() * absPose;
_relativePoses[_hipsIndex].scale() = glm::vec3(1.0f);
//_relativePoses[_hipsIndex] = parentAbsPose.inverse() * absPose;
//_relativePoses[_hipsIndex].scale() = glm::vec3(1.0f);
}
// if there is an active jointChainInfo for the hips store the post shifted hips into it.
@ -1041,7 +1041,10 @@ const AnimPoseVec& AnimInverseKinematics::overlay(const AnimVariantMap& animVars
preconditionRelativePosesToAvoidLimbLock(context, targets);
solve(context, targets, dt, jointChainInfoVec);
//qCDebug(animation) << "hips before ccd" << _relativePoses[_hipsIndex];
//solve(context, targets, dt, jointChainInfoVec);
//qCDebug(animation) << "hips after ccd" << _relativePoses[_hipsIndex];
}
}

View file

@ -49,6 +49,22 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
AnimPoseVec underPoses = _children[0]->evaluate(animVars, context, dt, triggersOut);
_poses = underPoses;
// now we override the hips relative pose based on the hips target that has been set.
////////////////////////////////////////////////////
if (_poses.size() > 0) {
AnimPose hipsUnderPose = _skeleton->getAbsolutePose(_hipsIndex, _poses);
glm::quat hipsTargetRotation = animVars.lookupRigToGeometry("hipsRotation", hipsUnderPose.rot());
glm::vec3 hipsTargetTranslation = animVars.lookupRigToGeometry("hipsPosition", hipsUnderPose.trans());
AnimPose absHipsTargetPose(hipsTargetRotation, hipsTargetTranslation);
int hipsParentIndex = _skeleton->getParentIndex(_hipsIndex);
AnimPose hipsParentAbsPose = _skeleton->getAbsolutePose(hipsParentIndex, _poses);
_poses[_hipsIndex] = hipsParentAbsPose.inverse() * absHipsTargetPose;
_poses[_hipsIndex].scale() = glm::vec3(1.0f);
}
//////////////////////////////////////////////////////////////////////////////////
// check to see if we actually need absolute poses.
AnimPoseVec absolutePoses;
absolutePoses.resize(_poses.size());
@ -65,7 +81,7 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
AnimPose origSpine1 = _skeleton->getAbsolutePose(_skeleton->nameToJointIndex("Spine1"),_poses);
//origSpine2PoseRel = origSpine1.inverse() * origSpine2;
//qCDebug(animation) << "origSpine2Pose: " << origSpine2Pose.rot();
qCDebug(animation) << "original relative spine2 " << origSpine2PoseAbs;
//qCDebug(animation) << "original relative spine2 " << origSpine2PoseAbs;
}
@ -116,8 +132,8 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
targetSpine2 = AnimPose(rotation3, afterSolveSpine2.trans());
finalSpine2 = afterSolveSpine1.inverse() * targetSpine2;
qCDebug(animation) << "relative spine2 after solve" << afterSolveSpine2Rel;
qCDebug(animation) << "relative spine2 orig" << originalSpine2Relative;
//qCDebug(animation) << "relative spine2 after solve" << afterSolveSpine2Rel;
//qCDebug(animation) << "relative spine2 orig" << originalSpine2Relative;
AnimPose latestSpine2Relative(originalSpine2Relative.rot(), afterSolveSpine2Rel.trans());
//jointChain.setRelativePoseAtJointIndex(jointIndex2, finalSpine2);
jointChain.outputRelativePoses(_poses);
@ -146,7 +162,7 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
glm::quat rotation2 = animVars.lookupRigToGeometry("spine2Rotation", absPose2.rot());
glm::vec3 translation2 = animVars.lookupRigToGeometry("spine2Position", absPose2.trans());
float weight2 = animVars.lookup("spine2Weight", "2.0");
qCDebug(animation) << "rig to geometry" << rotation2;
// qCDebug(animation) << "rig to geometry" << rotation2;
//target2.setPose(rotation2, translation2);
target2.setPose(targetSpine2.rot(), targetSpine2.trans());

View file

@ -79,6 +79,7 @@ const AnimPoseVec& AnimTwoBoneIK::evaluate(const AnimVariantMap& animVars, const
// determine if we should interpolate
bool enabled = animVars.lookup(_enabledVar, _enabled);
// qCDebug(animation) << "two bone var " << _enabledVar;
if (enabled != _enabled) {
AnimChain poseChain;
poseChain.buildFromRelativePoses(_skeleton, _poses, _tipJointIndex);
@ -91,7 +92,7 @@ const AnimPoseVec& AnimTwoBoneIK::evaluate(const AnimVariantMap& animVars, const
_enabled = enabled;
// don't build chains or do IK if we are disabled & not interping.
if (_interpType == InterpType::None){// && !enabled) {
if (_interpType == InterpType::None && !enabled) {
_poses = underPoses;
return _poses;
}
@ -122,6 +123,7 @@ const AnimPoseVec& AnimTwoBoneIK::evaluate(const AnimVariantMap& animVars, const
// First look in the triggers then look in the animVars, so we can follow output joints underneath us in the anim graph
AnimPose targetPose(tipPose);
if (triggersOut.hasKey(endEffectorRotationVar)) {
qCDebug(animation) << " end effector variable " << endEffectorRotationVar << " is " << triggersOut.lookupRigToGeometry(endEffectorRotationVar, tipPose.rot());
targetPose.rot() = triggersOut.lookupRigToGeometry(endEffectorRotationVar, tipPose.rot());
} else if (animVars.hasKey(endEffectorRotationVar)) {
targetPose.rot() = animVars.lookupRigToGeometry(endEffectorRotationVar, tipPose.rot());

View file

@ -1541,7 +1541,7 @@ void Rig::updateHands2(bool leftHandEnabled, bool rightHandEnabled, bool headEna
int handJointIndex = _animSkeleton->nameToJointIndex("LeftHand");
int elbowJointIndex = _animSkeleton->nameToJointIndex("LeftForeArm");
int shoulderJointIndex = _animSkeleton->nameToJointIndex("LeftArm");
int oppositeArmJointIndex = _animSkeleton->nameToJointIndex("LeftArm");
int oppositeArmJointIndex = _animSkeleton->nameToJointIndex("RightArm");
glm::vec3 poleVector;
bool usePoleVector = calculateElbowPoleVector(handJointIndex, elbowJointIndex, shoulderJointIndex, oppositeArmJointIndex, poleVector);
glm::vec3 sensorPoleVector = transformVectorFast(rigToSensorMatrix, poleVector);
@ -1580,7 +1580,7 @@ void Rig::updateHands2(bool leftHandEnabled, bool rightHandEnabled, bool headEna
int handJointIndex = _animSkeleton->nameToJointIndex("RightHand");
int elbowJointIndex = _animSkeleton->nameToJointIndex("RightForeArm");
int shoulderJointIndex = _animSkeleton->nameToJointIndex("RightArm");
int oppositeArmJointIndex = _animSkeleton->nameToJointIndex("RightArm");
int oppositeArmJointIndex = _animSkeleton->nameToJointIndex("LeftArm");
glm::vec3 poleVector;
bool usePoleVector = calculateElbowPoleVector(handJointIndex, elbowJointIndex, shoulderJointIndex, oppositeArmJointIndex, poleVector);
glm::vec3 sensorPoleVector = transformVectorFast(rigToSensorMatrix, poleVector);
@ -1856,10 +1856,10 @@ void Rig::updateFromControllerParameters(const ControllerParameters& params, flo
updateHead(_headEnabled, hipsEnabled, params.primaryControllerPoses[PrimaryControllerType_Head]);
updateHands(leftHandEnabled, rightHandEnabled, hipsEnabled, hipsEstimated, leftArmEnabled, rightArmEnabled, _headEnabled, dt,
params.primaryControllerPoses[PrimaryControllerType_LeftHand], params.primaryControllerPoses[PrimaryControllerType_RightHand],
params.hipsShapeInfo, params.spineShapeInfo, params.spine1ShapeInfo, params.spine2ShapeInfo,
params.rigToSensorMatrix, sensorToRigMatrix);
//updateHands(leftHandEnabled, rightHandEnabled, hipsEnabled, hipsEstimated, leftArmEnabled, rightArmEnabled, _headEnabled, dt,
// params.primaryControllerPoses[PrimaryControllerType_LeftHand], params.primaryControllerPoses[PrimaryControllerType_RightHand],
// params.hipsShapeInfo, params.spineShapeInfo, params.spine1ShapeInfo, params.spine2ShapeInfo,
// params.rigToSensorMatrix, sensorToRigMatrix);
updateHands2(leftHandEnabled, rightHandEnabled, _headEnabled,
params.primaryControllerPoses[PrimaryControllerType_LeftHand], params.primaryControllerPoses[PrimaryControllerType_RightHand],
@ -1940,7 +1940,7 @@ void Rig::updateFromControllerParameters(const ControllerParameters& params, flo
std::shared_ptr<AnimInverseKinematics> ikNode = getAnimInverseKinematicsNode();
for (int i = 0; i < (int)NumSecondaryControllerTypes; i++) {
int index = indexOfJoint(secondaryControllerJointNames[i]);
if (index >= 0) {
if ((index >= 0) && (ikNode)) {
if (params.secondaryControllerFlags[i] & (uint8_t)ControllerFlags::Enabled) {
ikNode->setSecondaryTargetInRigFrame(index, params.secondaryControllerPoses[i]);
} else {