public StagedSkinningTransform GetChainedTransform(ChannelOutputs outputs, StagedSkinningTransform parentTransform) { ScalingTransform scalingTransform = GetObjectCenteredScalingTransform(outputs); ScalingTransform chainedScalingTransform = scalingTransform.Chain(parentTransform.ScalingStage); DualQuaternion rotationTransform = GetObjectCenteredRotationTransform(outputs, parentTransform.ScalingStage); DualQuaternion chainedRotationTransform = rotationTransform.Chain(parentTransform.RotationStage); return(new StagedSkinningTransform(chainedScalingTransform, chainedRotationTransform)); }
private void UpdateEye(ChannelOutputs outputs, StagedSkinningTransform eyeParentTotalTransform, ChannelInputs inputs, Bone eyeBone, Vector3 targetPosition) { Vector3 targetPositionInRotationFreeEyeSpace = eyeParentTotalTransform.InverseTransform(targetPosition * 100) - eyeBone.CenterPoint.GetValue(outputs); var targetRotation = QuaternionExtensions.RotateBetween(Vector3.BackwardRH, targetPositionInRotationFreeEyeSpace); targetRotation = Quaternion.RotationAxis( targetRotation.Axis, TukeysBiweight(targetRotation.Angle, RotationAngleRejectionThreshold)); eyeBone.SetEffectiveRotation(inputs, outputs, targetRotation); }
public StagedSkinningTransform[] GetBoneTransforms(ChannelOutputs outputs) { while (outputs.Parent != null) { outputs = outputs.Parent; } StagedSkinningTransform[] boneTransforms = new StagedSkinningTransform[bones.Count]; for (int boneIdx = 0; boneIdx < bones.Count; ++boneIdx) { Bone bone = bones[boneIdx]; Bone parent = bone.Parent; StagedSkinningTransform parentTransform = parent != null ? boneTransforms[parent.Index] : StagedSkinningTransform.Identity; boneTransforms[boneIdx] = bone.GetChainedTransform(outputs, parentTransform); } return(boneTransforms); }
public static void PrependChildToParentBindPoseTransforms(RigidTransform[] childToParentBindPoseTransforms, StagedSkinningTransform[] boneTransforms) { for (int i = 0; i < boneTransforms.Length; ++i) { var childToParentBindPoseTransform = childToParentBindPoseTransforms[i]; /* * Technically, I should be using a DualQuaternion for the ChildToParentBindPoseTransform in order to get * smooth blending. But I don't currently have t chain a DualQuaternion with a StaggedSkinningTransform. * * Instead, I'll hack the ChildToParentBindPoseTransform into a ScalingTransform. Very few figures use * non-identity ChildToParentBindPoseTransforms so the difference with hardly ever matter. */ var childToParentBindPoseScalingTransform = new ScalingTransform( Matrix3x3.RotationQuaternion(childToParentBindPoseTransform.Rotation), childToParentBindPoseTransform.Translation); boneTransforms[i] = new StagedSkinningTransform( childToParentBindPoseScalingTransform.Chain(boneTransforms[i].ScalingStage), boneTransforms[i].RotationStage); } }
public StagedSkinningTransform GetChainedTransform(ChannelOutputs outputs) { StagedSkinningTransform parentTransform = Parent != null?Parent.GetChainedTransform(outputs) : StagedSkinningTransform.Identity; return(GetChainedTransform(outputs, parentTransform)); }
public void Add(float weight, StagedSkinningTransform t) { scalingStageBlender.Add(weight, t.ScalingStage); rotationStageBlender.Add(weight, t.RotationStage); }