public void ToParentDirection() { var a = new SrtTransform(new Vector3F(1, 2, 7), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, -5, 6)); var v = new Vector3F(7, 9, -12); var result1 = a.ToParentDirection(v); var result2 = a.Rotation.ToRotationMatrix33() * v; Assert.IsTrue(Vector3F.AreNumericallyEqual(result1, result2)); }
private void LimitBoneTransform() { // This method is called by the JacobianTransposeIKSolver after each internal iteration. // The job of this method is to apply bone limits; for example, the elbow should not // bend backwards, etc. // To apply a limit, get the bone transform or bone pose from skeleton pose, check if // is in the allowed range. If it is outside the allowed range, rotate it back to the // nearest allowed rotation. // Here, for example, we only make sure that the palm of the hand is always parallel // to the ground plane - as if the character wants to grab a horizontal bar or as // if it wants to place the hand on horizontal plane. SrtTransform bonePoseAbsolute = _meshNode.SkeletonPose.GetBonePoseAbsolute(15); Vector3F palmAxis = bonePoseAbsolute.ToParentDirection(-Vector3F.UnitY); bonePoseAbsolute.Rotation = QuaternionF.CreateRotation(palmAxis, Vector3F.UnitY) * bonePoseAbsolute.Rotation; _meshNode.SkeletonPose.SetBonePoseAbsolute(15, bonePoseAbsolute); }
private void LimitBoneTransform(int boneIndex) { // This method is called by the CcdIKSolver in each internal iteration after a bone // was modified. // The job of this method is to apply bone limits; for example, the elbow should not // bend backwards, etc. // To apply a limit, get the bone transform or bone pose from skeleton pose, check if // is in the allowed range. If it is outside the allowed range, rotate it back to the // nearest allowed rotation. // The parameter of this method is the boneIndex of the bone that was modified. // We can only apply the limit of this bone - or we can simply limit all bones // all the time and ignore the parameter. // Here, for example, we only make sure that the palm of the hand is always parallel // to the ground plane - as if the character wants to grab a horizontal bar or as // if it wants to place the hand on horizontal plane. SrtTransform bonePoseAbsolute = _meshNode.SkeletonPose.GetBonePoseAbsolute(15); Vector3 palmAxis = bonePoseAbsolute.ToParentDirection(-Vector3.UnitY); bonePoseAbsolute.Rotation = Quaternion.CreateFromRotationMatrix(palmAxis, Vector3.UnitY) * bonePoseAbsolute.Rotation; _meshNode.SkeletonPose.SetBonePoseAbsolute(15, bonePoseAbsolute); }
public void ToParentDirection() { var a = new SrtTransform(new Vector3F(1, 2, 7), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, -5, 6)); var v = new Vector3F(7, 9, -12); var result1 = a.ToParentDirection(v); var result2 = a.Rotation.ToRotationMatrix33() * v; Assert.IsTrue(Vector3F.AreNumericallyEqual(result1, result2)); }