コード例 #1
0
    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 void Draw()
    {
        if (Data == null)
        {
            return;
        }

        MotionData.Frame frame = GetCurrentFrame();

        if (ShowMotion)
        {
            for (int i = 0; i < 6; i++)
            {
                MotionData.Frame previous = Data.GetFrame(Mathf.Clamp(frame.Timestamp - 1f + (float)i / 6f, 0f, Data.GetTotalTime()));
                Actor.DrawSimple(Color.Lerp(UltiDraw.Blue, UltiDraw.Cyan, 1f - (float)(i + 1) / 6f).Transparent(0.75f), previous.GetBoneTransformations(ShowMirrored));
            }
            for (int i = 1; i <= 5; i++)
            {
                MotionData.Frame future = Data.GetFrame(Mathf.Clamp(frame.Timestamp + (float)i / 5f, 0f, Data.GetTotalTime()));
                Actor.DrawSimple(Color.Lerp(UltiDraw.Red, UltiDraw.Orange, (float)(i + 1) / 5f).Transparent(0.75f), future.GetBoneTransformations(ShowMirrored));
            }
        }

        if (ShowVelocities)
        {
            UltiDraw.Begin();
            for (int i = 0; i < Actor.Bones.Length; i++)
            {
                UltiDraw.DrawArrow(
                    Actor.Bones[i].Transform.position,
                    Actor.Bones[i].Transform.position + frame.GetBoneVelocity(i, ShowMirrored),
                    0.75f,
                    0.0075f,
                    0.05f,
                    UltiDraw.Purple.Transparent(0.5f)
                    );
            }
            UltiDraw.End();
        }

        if (ShowTrajectory)
        {
            frame.GetTrajectory(ShowMirrored).Draw();
        }

        frame.GetHeightMap(ShowMirrored).Draw();

        frame.GetDepthMap(ShowMirrored).Draw();
    }