/// <summary> /// Gets the position and scaled rotation of the transform in world space. /// </summary> /// <param name="stream">The AnimationStream that holds the animated values.</param> /// <param name="position">The position of the transform in world space.</param> /// <param name="rotation">The rotation of the transform in world space.</param> public void GetGlobalTR(AnimationStream stream, out Vector3 position, out Quaternion rotation) { if (m_InStream == 1) { m_StreamHandle.GetGlobalTR(stream, out position, out rotation); } else { m_SceneHandle.GetGlobalTR(stream, out position, out rotation); } }
public void ProcessAnimation(AnimationStream stream) { Vector3 rootPosition; Quaternion rootRotation; root.GetGlobalTR(stream, out rootPosition, out rootRotation); var rootTx = new AffineTransform(rootPosition, rootRotation); var mirroredTransforms = new NativeArray <AffineTransform> (mirroringTransforms.Length, Allocator.Temp); // 追加トランスフォームのミラーリング計算 if (mirror) { for (int i = 0; i < mirroringTransforms.Length; i++) { if (!mirroringTransforms[i].source.IsValid(stream)) { continue; } if (!mirroringTransforms[i].driven.IsValid(stream)) { continue; } Vector3 position; Quaternion rotation; mirroringTransforms[i].source.GetGlobalTR(stream, out position, out rotation); var drivenTx = new AffineTransform(position, rotation); drivenTx = rootTx.Inverse() * drivenTx; drivenTx = AnimationStreamMirrorExtensions.Mirrored(drivenTx); drivenTx = rootTx * drivenTx; mirroredTransforms[i] = drivenTx; } } // Humanoid ミラーリング if (stream.isHumanStream) { AnimationHumanStream humanStream = stream.AsHuman(); if (mirror) { humanStream.MirrorPose(); } humanStream.SolveIK(); } // 追加トランスフォームのミラーリング適用 if (mirror) { for (int i = 0; i < mirroringTransforms.Length; i++) { if (!mirroringTransforms[i].source.IsValid(stream)) { continue; } if (!mirroringTransforms[i].driven.IsValid(stream)) { continue; } mirroringTransforms[i].driven.SetGlobalTR(stream, mirroredTransforms[i].position, mirroredTransforms[i].rotation, false); } } // 追加トランスフォームのミラーリング拘束 if (mirror) { for (int i = 0; i < mirroringConstrants.Length; i++) { if (!mirroringConstrants[i].source.IsValid(stream)) { continue; } if (!mirroringConstrants[i].driven.IsValid(stream)) { continue; } Vector3 position; Quaternion rotation; mirroringConstrants[i].source.GetGlobalTR(stream, out position, out rotation); mirroringConstrants[i].driven.SetGlobalTR(stream, position, rotation, false); } } }
/// <summary> /// Gets the position and scaled rotation of the transform in world space. /// </summary> /// <param name="stream">The AnimationStream that holds the animated values.</param> /// <param name="position">The position of the transform in world space.</param> /// <param name="rotation">The rotation of the transform in world space.</param> public void GetGlobalTR(AnimationStream stream, out Vector3 position, out Quaternion rotation) => m_Handle.GetGlobalTR(stream, out position, out rotation);