public MotionState(MotionData.Frame frame, bool mirrored) { Index = frame.Index; Timestamp = frame.Timestamp; Mirrored = mirrored; Root = frame.GetRootTransformation(mirrored); RootMotion = frame.GetRootMotion(mirrored); BoneTransformations = frame.GetBoneTransformations(mirrored); BoneVelocities = frame.GetBoneVelocities(mirrored); Trajectory = frame.GetTrajectory(mirrored); HeightMap = frame.GetHeightMap(mirrored); DepthMap = frame.GetDepthMap(mirrored); PastBoneTransformations = new List <Matrix4x4[]>(6); PastBoneVelocities = new List <Vector3[]>(6); for (int i = 0; i < 6; i++) { MotionData.Frame previous = frame.Data.GetFrame(Mathf.Clamp(frame.Timestamp - 1f + (float)i / 6f, 0f, frame.Data.GetTotalTime())); PastBoneTransformations.Add(previous.GetBoneTransformations(mirrored)); PastBoneVelocities.Add(previous.GetBoneVelocities(mirrored)); } FutureBoneTransformations = new List <Matrix4x4[]>(5); FutureBoneVelocities = new List <Vector3[]>(5); for (int i = 1; i <= 5; i++) { MotionData.Frame future = frame.Data.GetFrame(Mathf.Clamp(frame.Timestamp + (float)i / 5f, 0f, frame.Data.GetTotalTime())); FutureBoneTransformations.Add(future.GetBoneTransformations(mirrored)); FutureBoneVelocities.Add(future.GetBoneVelocities(mirrored)); } }
public float[] GetFeature(MotionData.Frame frame) { int dim = 6 * frame.Data.Source.Bones.Length; float[] feature = new float[dim]; int pivot = 0; Matrix4x4 root = frame.GetRootTransformation(false); for (int i = 0; i < frame.Data.Source.Bones.Length; i++) { feature[pivot + i] = frame.GetBoneTransformation(i, false).GetRelativeTransformationTo(root).GetPosition().x; } pivot += frame.Data.Source.Bones.Length; for (int i = 0; i < frame.Data.Source.Bones.Length; i++) { feature[pivot + i] = frame.GetBoneTransformation(i, false).GetRelativeTransformationTo(root).GetPosition().x; } pivot += frame.Data.Source.Bones.Length; for (int i = 0; i < frame.Data.Source.Bones.Length; i++) { feature[pivot + i] = frame.GetBoneTransformation(i, false).GetRelativeTransformationTo(root).GetPosition().x; } pivot += frame.Data.Source.Bones.Length; for (int i = 0; i < frame.Data.Source.Bones.Length; i++) { feature[pivot + i] = frame.GetBoneVelocity(i, false).GetRelativeDirectionTo(root).x; } pivot += frame.Data.Source.Bones.Length; for (int i = 0; i < frame.Data.Source.Bones.Length; i++) { feature[pivot + i] = frame.GetBoneVelocity(i, false).GetRelativeDirectionTo(root).y; } pivot += frame.Data.Source.Bones.Length; for (int i = 0; i < frame.Data.Source.Bones.Length; i++) { feature[pivot + i] = frame.GetBoneVelocity(i, false).GetRelativeDirectionTo(root).z; } pivot += frame.Data.Source.Bones.Length; return(feature); }