コード例 #1
0
    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);
    }
    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();
    }