示例#1
0
    public void Draw()
    {
        if (ShowMotion)
        {
            for (int i = 0; i < GetState().PastBoneTransformations.Count; i++)
            {
                GetActor().DrawSimple(Color.Lerp(UltiDraw.Blue, UltiDraw.Cyan, 1f - (float)(i + 1) / 6f).Transparent(0.75f), GetState().PastBoneTransformations[i]);
            }
            for (int i = 0; i < GetState().FutureBoneTransformations.Count; i++)
            {
                GetActor().DrawSimple(Color.Lerp(UltiDraw.Red, UltiDraw.Orange, (float)i / 5f).Transparent(0.75f), GetState().FutureBoneTransformations[i]);
            }
        }

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

        if (ShowTrajectory)
        {
            GetState().Trajectory.Draw();
        }

        if (ShowHeightMap)
        {
            GetState().HeightMap.Draw();
        }

        if (ShowDepthMap)
        {
            GetState().DepthMap.Draw();
        }

        UltiDraw.Begin();
        UltiDraw.DrawGUIRectangle(Vector2.one / 2f, Vector2.one, UltiDraw.Mustard);
        UltiDraw.End();
        if (ShowDepthImage)
        {
            UltiDraw.Begin();
            Vector2 size = new Vector2(0.5f, 0.5f * Screen.width / Screen.height);
            for (int x = 0; x < GetState().DepthMap.GetResolution(); x++)
            {
                for (int y = 0; y < GetState().DepthMap.GetResolution(); y++)
                {
                    float distance  = Vector3.Distance(GetState().DepthMap.Points[GetState().DepthMap.GridToArray(x, y)], GetState().DepthMap.Pivot.GetPosition());
                    float intensity = 1f - distance / GetState().DepthMap.GetDistance();
                    UltiDraw.DrawGUIRectangle(Vector2.one / 2f - size / 2f + new Vector2((float)x * size.x, (float)y * size.y) / (GetState().DepthMap.GetResolution() - 1), size / (GetState().DepthMap.GetResolution() - 1), Color.Lerp(Color.black, Color.white, intensity));
                }
            }
            UltiDraw.End();
        }
    }
示例#2
0
    void OnRenderObject()
    {
        Tensor t = NN.GetTensor(ID);

        if (t == null)
        {
            return;
        }

        T = Tensor.PointwiseAbsolute(t, T);
        //float minimum = float.MaxValue;
        //float maximum = float.MinValue;

        if (Operator == OPERATOR.AbsSum)
        {
            if (Axis == AXIS.X)
            {
                Values = new float[T.GetRows()];
                for (int i = 0; i < T.GetRows(); i++)
                {
                    Values[i] = T.RowSum(i);
                    Minimum   = Mathf.Min(Minimum, Values[i]);
                    Maximum   = Mathf.Max(Maximum, Values[i]);
                }
            }
            if (Axis == AXIS.Y)
            {
                Values = new float[T.GetCols()];
                for (int i = 0; i < T.GetCols(); i++)
                {
                    Values[i] = T.ColSum(i);
                    Minimum   = Mathf.Min(Minimum, Values[i]);
                    Maximum   = Mathf.Max(Maximum, Values[i]);
                }
            }
        }

        UltiDraw.Begin();
        UltiDraw.DrawGUIRectangle(
            new Vector2(Rect.X, Rect.Y),
            new Vector2(Rect.W + 0.01f / Screen.width * Screen.height, Rect.H + 0.01f),
            UltiDraw.Black.Transparent(0.5f)
            );
        if (Plotting == PLOTTING.Curve)
        {
            UltiDraw.DrawGUIFunction(
                new Vector2(Rect.X, Rect.Y),
                new Vector2(Rect.W, Rect.H),
                Values,
                0f,
                Maximum,
                UltiDraw.White.Transparent(0.5f),
                UltiDraw.Black
                );
        }
        if (Plotting == PLOTTING.Bars)
        {
            UltiDraw.DrawGUIBars(
                new Vector2(Rect.X, Rect.Y),
                new Vector2(Rect.W, Rect.H),
                Values,
                0f,
                Maximum,
                0.75f * Rect.W / Values.Length,
                UltiDraw.White.Transparent(0.5f),
                UltiDraw.Black
                );
        }
        UltiDraw.End();
    }
示例#3
0
    void OnRenderObject()
    {
        if (!Application.isPlaying)
        {
            return;
        }

        if (NN.GetTensor(ID) == null)
        {
            return;
        }

        UltiDraw.Begin();

        float[] values = new float[Values.Length];
        for (int i = 0; i < Values.Length; i++)
        {
            values[i] = NN.GetTensor(ID).GetValue(i, 0);
        }

        //Utility.SoftMax(ref values);

        for (int i = 0; i < Values.Length; i++)
        {
            Values[i].Dequeue();
            Values[i].Enqueue(values[i]);
        }

        switch (Mode)
        {
        case MODE.Function:
            Vector2 center = new Vector2(X, Y);
            float   border = 0.0025f;
            UltiDraw.DrawGUIRectangle(
                center,
                new Vector2(W + 2f * border / Screen.width * Screen.height, H + 2f * border),
                UltiDraw.Black);
            UltiDraw.DrawGUIRectangle(
                center,
                new Vector2(W, H),
                UltiDraw.White);

            Color[] colors = UltiDraw.GetRainbowColors(Values.Length);
            for (int i = 0; i < colors.Length; i++)
            {
                DrawControlPoint(center.x - W / 2f, center.y + H / 2f, W, H, Values[i], colors[i]);
            }
            //for(int i=0; i<colors.Length; i++) {
            //	Vector2 start = center - new Vector2(width/2f, -height/2f);
            //	UltiDraw.DrawGUIRectangle(start + (float)i/(float)(colors.Length-1)*new Vector2(width, 0f), new Vector2(0.025f, 0.025f), colors[i]);
            //}
            break;

        case MODE.Bars:

            break;

        case MODE.Graph:
            Vector2 pivot  = new Vector2(X, Y);
            float   radius = 0.2f * W;
            UltiDraw.DrawGUICircle(pivot, W * 1.05f, UltiDraw.Gold);
            UltiDraw.DrawGUICircle(pivot, W, UltiDraw.White);
            Vector2[] anchors = new Vector2[Values.Length];
            for (int i = 0; i < Values.Length; i++)
            {
                float step = (float)i / (float)Values.Length;
                anchors[i] = new Vector2((W - radius / 2f) * Screen.height / Screen.width * Mathf.Cos(step * 2f * Mathf.PI), (W - radius / 2f) * Mathf.Sin(step * 2f * Mathf.PI));
                UltiDraw.DrawGUICircle(pivot + anchors[i], Mathf.Max(0.5f * radius, Utility.Normalise(values[i], 0f, 1f, 0.5f, 1f) * radius), UltiDraw.Black);
            }
            Vector2[] positions = new Vector2[Frames];
            for (int i = 0; i < Values.Length; i++)
            {
                int _index = 0;
                foreach (float value in Values[i])
                {
                    positions[_index] += value * anchors[i];
                    _index            += 1;
                }
            }
            for (int i = 1; i < positions.Length; i++)
            {
                UltiDraw.DrawGUILine(pivot + positions[i - 1], pivot + positions[i], 0.1f * radius, UltiDraw.Black.Transparent((float)(i + 1) / (float)positions.Length));
            }
            for (int i = 0; i < Values.Length; i++)
            {
                UltiDraw.DrawGUILine(pivot + positions[positions.Length - 1], pivot + anchors[i], 0.1f * radius, UltiDraw.Black.Transparent(values[i]));
            }
            UltiDraw.DrawGUICircle(pivot + positions[positions.Length - 1], 0.5f * radius, UltiDraw.Purple);
            break;
        }

        UltiDraw.End();
    }
示例#4
0
    void OnRenderObject()
    {
        Tensor t = Model.GetTensor(ID);

        if (t == null)
        {
            return;
        }

        T = Tensor.PointwiseAbsolute(t, T);
        float minimum = float.MaxValue;
        float maximum = float.MinValue;

        if (Operator == OPERATOR.AbsSum)
        {
            if (Axis == AXIS.X)
            {
                Values = new float[T.GetRows()];
                for (int i = 0; i < T.GetRows(); i++)
                {
                    Values[i] = T.RowSum(i);
                    minimum   = Mathf.Min(minimum, Values[i]);
                    maximum   = Mathf.Max(maximum, Values[i]);
                }
            }
            if (Axis == AXIS.Y)
            {
                Values = new float[T.GetCols()];
                for (int i = 0; i < T.GetCols(); i++)
                {
                    Values[i] = T.ColSum(i);
                    minimum   = Mathf.Min(minimum, Values[i]);
                    maximum   = Mathf.Max(maximum, Values[i]);
                }
            }
        }

        UltiDraw.Begin();
        UltiDraw.DrawGUIRectangle(
            new Vector2(Rect.X, Rect.Y),
            new Vector2(Rect.W + 0.01f / Screen.width * Screen.height, Rect.H + 0.01f),
            UltiDraw.Black.Transparent(0.5f)
            );
        if (Plotting == PLOTTING.Curve)
        {
            UltiDraw.DrawFunction(
                new Vector2(Rect.X, Rect.Y),
                new Vector2(Rect.W, Rect.H),
                Values,
                minimum,
                maximum,
                UltiDraw.White.Transparent(0.5f),
                UltiDraw.Black
                );
        }
        if (Plotting == PLOTTING.Bars)
        {
            UltiDraw.DrawBars(
                new Vector2(Rect.X, Rect.Y),
                new Vector2(Rect.W, Rect.H),
                Values,
                minimum,
                maximum,
                0.75f * Rect.W / Values.Length,
                UltiDraw.White.Transparent(0.5f),
                UltiDraw.Black
                );
        }
        UltiDraw.End();

        /*
         * Feature[] features = new Feature[Values.Length];
         * for(int i=0; i<Values.Length; i++) {
         *  features[i] = new Feature(i, Values[i]);
         * }
         * System.Array.Sort(features,
         *              delegate(Feature a, Feature b) {
         *                      return b.Value.CompareTo(a.Value);
         *              }
         *      );
         * for(int i=0; i<30; i++) {
         *  Debug.Log(i + " - " + "Value: " + features[i].Value + " Index: " + features[i].Index);
         * }
         */
    }
示例#5
0
    public void Draw()
    {
        if (ShowMotion)
        {
            for (int i = 0; i < GetState().PastBoneTransformations.Count; i++)
            {
                GetActor().DrawSimple(Color.Lerp(UltiDraw.Blue, UltiDraw.Cyan, 1f - (float)(i + 1) / 6f).Transparent(0.75f), GetState().PastBoneTransformations[i]);
            }

            /*
             * for(int i=1; i<=5; i++) {
             *      MotionData.Frame future = Data.GetFrame(Mathf.Clamp(GetState().Timestamp + (float)i/5f, 0f, Data.GetTotalTime()));
             *      GetActor().DrawSimple(Color.Lerp(UltiDraw.Red, UltiDraw.Orange, (float)(i+1)/5f).Transparent(0.75f), future.GetBoneTransformations(Mirror));
             * }
             */
        }
        if (ShowVelocities)
        {
            UltiDraw.Begin();
            for (int i = 0; i < GetActor().Bones.Length; i++)
            {
                UltiDraw.DrawArrow(
                    GetActor().Bones[i].Transform.position,
                    GetActor().Bones[i].Transform.position + GetState().BoneVelocities[i],
                    0.75f,
                    0.0075f,
                    0.05f,
                    UltiDraw.Purple.Transparent(0.5f)
                    );
            }
            UltiDraw.End();
        }
        if (ShowTrajectory)
        {
            GetState().Trajectory.Draw();
        }

        if (ShowHeightMap)
        {
            GetState().HeightMap.Draw();
        }

        if (ShowDepthMap)
        {
            GetState().DepthMap.Draw();
        }

        UltiDraw.Begin();
        UltiDraw.DrawGUIRectangle(Vector2.one / 2f, Vector2.one, UltiDraw.Mustard);
        UltiDraw.End();

        if (ShowDepthImage)
        {
            UltiDraw.Begin();
            Vector2 size = new Vector2(0.5f, 0.5f * Screen.width / Screen.height);
            for (int x = 0; x < GetState().DepthMap.GetResolution(); x++)
            {
                for (int y = 0; y < GetState().DepthMap.GetResolution(); y++)
                {
                    float distance  = Vector3.Distance(GetState().DepthMap.Points[GetState().DepthMap.GridToArray(x, y)], GetState().DepthMap.Pivot.GetPosition());
                    float intensity = 1f - distance / GetState().DepthMap.GetDistance();
                    //intensity = Utility.TanH(intensity);
                    UltiDraw.DrawGUIRectangle(Vector2.one / 2f - size / 2f + new Vector2((float)x * size.x, (float)y * size.y) / (GetState().DepthMap.GetResolution() - 1), size / (GetState().DepthMap.GetResolution() - 1), Color.Lerp(Color.black, Color.white, intensity));
                }
            }
            UltiDraw.End();
        }

        //Motion Function
        MotionData.Frame[] frames = Data.GetFrames(Mathf.Clamp(GetState().Timestamp - 1f, 0f, Data.GetTotalTime()), Mathf.Clamp(GetState().Timestamp + 1f, 0f, Data.GetTotalTime()));
        float[]            values = new float[frames.Length];
        for (int i = 0; i < frames.Length; i++)
        {
            values[i] = frames[i].GetBoneVelocity(0, Mirror).magnitude;
        }
        Debug.Log(values[0]);
        UltiDraw.Begin();
        UltiDraw.DrawGUIFunction(new Vector2(0.5f, 0.5f), new Vector2(1f, 1f), values, -2f, 2f, 0.0025f, UltiDraw.DarkGrey, UltiDraw.Green);
        UltiDraw.DrawGUILine(new Vector2(0.5f, 1f), new Vector2(0.5f, 0f), 0.0025f, UltiDraw.IndianRed);
        UltiDraw.End();

        /*
         * MotionData.Frame[] frames = Data.GetFrames(Mathf.Clamp(GetState().Timestamp-1f, 0f, Data.GetTotalTime()), Mathf.Clamp(GetState().Timestamp+1f, 0f, Data.GetTotalTime()));
         * List<float[]> values = new List<float[]>();
         * for(int i=0; i<Actor.Bones.Length; i++) {
         *      values.Add(new float[frames.Length]);
         * }
         * for(int i=0; i<frames.Length; i++) {
         *      for(int j=0; j<Actor.Bones.Length; j++) {
         *              values[j][i] = frames[i].GetBoneVelocity(j, Mirror).magnitude;
         *      }
         *      //Vector3 motion = frames[i].GetRootMotion(Mirror);
         *      //values[0][i] = motion.x;
         *      //values[1][i] = motion.y / 180f;
         *      //values[2][i] = motion.z;
         * }
         * UltiDraw.Begin();
         * UltiDraw.DrawGUIFunctions(new Vector2(0.5f, 0.5f), new Vector2(1f, 1f), values, -2f, 2f, 0.0025f, UltiDraw.DarkGrey, UltiDraw.GetRainbowColors(values.Count));
         * UltiDraw.DrawGUILine(new Vector2(0.5f, 1f), new Vector2(0.5f, 0f), 0.0025f, UltiDraw.Green);
         * UltiDraw.End();
         */
        //Agility Function

        /*
         * MotionData.Frame[] frames = Data.GetFrames(Mathf.Clamp(GetState().Timestamp-1f, 0f, Data.GetTotalTime()), Mathf.Clamp(GetState().Timestamp+1f, 0f, Data.GetTotalTime()));
         * List<float[]> values = new List<float[]>();
         * for(int i=0; i<Data.Source.Bones.Length; i++) {
         *      values.Add(new float[frames.Length]);
         *      for(int j=0; j<frames.Length; j++) {
         *              values[i][j] = frames[j].GetAgility(i, Mirror);
         *      }
         * }
         * UltiDraw.Begin();
         * UltiDraw.DrawGUIFunctions(new Vector2(0.5f, 0.5f), new Vector2(1f, 1f), values, -1f, 1f, 0.0025f, UltiDraw.DarkGrey, UltiDraw.GetRainbowColors(values.Count));
         * UltiDraw.DrawGUILine(new Vector2(0.5f, 1f), new Vector2(0.5f, 0f), 0.0025f, UltiDraw.Green);
         * UltiDraw.End();
         */
    }
示例#6
0
    void OnRenderObject()
    {
        if (!Application.isPlaying)
        {
            return;
        }

        if (!Setup())
        {
            return;
        }

        M = Matrix.PointwiseAbsolute(Model.GetMatrix(ID), M);
        float minimum = float.MaxValue;
        float maximum = float.MinValue;

        if (Axis == AXIS.X)
        {
            Values = new float[M.GetRows()];
            for (int i = 0; i < M.GetRows(); i++)
            {
                Values[i] = M.RowSum(i);
                minimum   = Mathf.Min(minimum, Values[i]);
                maximum   = Mathf.Max(maximum, Values[i]);
            }
        }
        if (Axis == AXIS.Y)
        {
            Values = new float[M.GetCols()];
            for (int i = 0; i < M.GetCols(); i++)
            {
                Values[i] = M.ColSum(i);
                minimum   = Mathf.Min(minimum, Values[i]);
                maximum   = Mathf.Max(maximum, Values[i]);
            }
        }

        UltiDraw.Begin();
        UltiDraw.DrawGUIRectangle(
            new Vector2(Rect.X, Rect.Y),
            new Vector2(Rect.W + 0.01f / Screen.width * Screen.height, Rect.H + 0.01f),
            UltiDraw.Black.Transparent(0.5f)
            );
        if (Plotting == PLOTTING.Curve)
        {
            UltiDraw.DrawGUIFunction(
                new Vector2(Rect.X, Rect.Y),
                new Vector2(Rect.W, Rect.H),
                Values,
                0f,
                maximum,
                UltiDraw.White.Transparent(0.5f),
                UltiDraw.Black
                );
        }
        if (Plotting == PLOTTING.Bars)
        {
            UltiDraw.DrawGUIBars(
                new Vector2(Rect.X, Rect.Y),
                new Vector2(Rect.W, Rect.H),
                Values,
                0f,
                maximum,
                0.75f * Rect.W / Values.Length,
                UltiDraw.White.Transparent(0.5f),
                UltiDraw.Black
                );
        }
        UltiDraw.End();
    }