public void ApplyDNA(UMAData umaData, UMASkeleton skeleton, UMADnaBase activeDNA, float masterWeight = 1f) { if (_poseToApply == null) { if (Debug.isDebugBuild) { Debug.LogWarning(umaData.gameObject.name + " had an invalid or empty pose set in its BonePoseDNAConverters in its DNAConverterController"); } return; } _livePoseWeight = _startingPoseWeight; //dna weight superceeds startingWeight if it exists if (_modifyingDNA.UsedDNANames.Count > 0) { _livePoseWeight = _modifyingDNA.Evaluate(activeDNA); } _livePoseWeight = _livePoseWeight * masterWeight; _livePoseWeight = Mathf.Clamp(_livePoseWeight, 0f, 1f); _poseToApply.ApplyPose(skeleton, _livePoseWeight); }
public void SetValues() { if (expressionSet == null) { return; } if (skeleton == null) { return; } if (!initialized) { return; } float[] values = Values; MecanimJoint mecanimMask = MecanimJoint.None; if (!overrideMecanimNeck) { mecanimMask |= MecanimJoint.Neck; } if (!overrideMecanimHead) { mecanimMask |= MecanimJoint.Head; } if (!overrideMecanimJaw) { mecanimMask |= MecanimJoint.Jaw; } if (!overrideMecanimEyes) { mecanimMask |= MecanimJoint.Eye; } if (overrideMecanimJaw) { skeleton.Restore(jawHash); } for (int i = 0; i < values.Length; i++) { if ((MecanimAlternate[i] & mecanimMask) != MecanimJoint.None) { continue; } float weight = values[i]; UMABonePose pose = null; if (weight > 0) { pose = expressionSet.posePairs[i].primary; } else { weight = -weight; pose = expressionSet.posePairs[i].inverse; } if (pose == null) { continue; } //Debug.Log("SETTING VALUES: "+pose.name); pose.ApplyPose(skeleton, weight); } }
public void ApplyDNA(UMAData data, UMASkeleton skeleton) { UMADnaBase activeDNA = data.GetDna(this.dnaTypeHash); if (activeDNA == null) { Debug.LogError("Could not get DNA values for: " + this.name); return; } if (startingPose != null) { startingPose.ApplyPose(skeleton, 1f); } if (activeDNA.Count == dnaPoses.Length) { float[] dnaValues = activeDNA.Values; for (int i = 0; i < dnaValues.Length; i++) { float dnaValue = dnaValues[i]; if ((dnaValue > 0.5f) && (dnaPoses[i].poseOne != null)) { float poseWeight = (dnaValue - 0.5f) * 2f; dnaPoses[i].poseOne.ApplyPose(skeleton, poseWeight); } else if ((dnaValue < 0.5f) && (dnaPoses[i].poseZero != null)) { float poseWeight = (0.5f - dnaValue) * 2f; dnaPoses[i].poseOne.ApplyPose(skeleton, poseWeight); } } } else { Debug.LogWarning("DNA length mismatch, trying names. This is SLOW!"); string[] dnaNames = activeDNA.Names; for (int i = 0; i < dnaPoses.Length; i++) { if ((dnaPoses[i].dnaEntryName == null) || (dnaPoses[i].dnaEntryName.Length == 0)) { continue; } int dnaIndex = System.Array.IndexOf(dnaNames, dnaPoses[i].dnaEntryName); if (dnaIndex < 0) { continue; } float dnaValue = activeDNA.GetValue(dnaIndex); if ((dnaValue > 0.5f) && (dnaPoses[i].poseOne != null)) { float poseWeight = (dnaValue - 0.5f) * 2f; dnaPoses[i].poseOne.ApplyPose(skeleton, poseWeight); } else if ((dnaValue < 0.5f) && (dnaPoses[i].poseZero != null)) { float poseWeight = (0.5f - dnaValue) * 2f; dnaPoses[i].poseOne.ApplyPose(skeleton, poseWeight); } } } }