示例#1
0
    void Draw()
    {
        UltiDraw.Begin();

        float window = 0.25f;

        MotionData.Frame[] frames = GetEditor().Data.GetFrames(Mathf.Clamp(GetEditor().GetState().Timestamp - window / 2f, 0f, GetEditor().Data.GetTotalTime()), Mathf.Clamp(GetEditor().GetState().Timestamp + window / 2f, 0f, GetEditor().Data.GetTotalTime()));

        List <float[]> values = new List <float[]>();

        for (int i = 0; i < States.Count; i++)
        {
            values.Add(new float[frames.Length]);
        }
        for (int i = 0; i < frames.Length; i++)
        {
            float[] stateVector = GetStateVector(frames[i]);
            for (int j = 0; j < States.Count; j++)
            {
                values[j][i] = stateVector[j];
            }
        }

        UltiDraw.DrawGUIFunctions(0.5f * Vector2.one, Vector2.one, values, 0f, 1f, UltiDraw.DarkGrey, UltiDraw.GetRainbowColors(States.Count));

        UltiDraw.End();
    }
示例#2
0
        public void Draw(bool gui = true)
        {
            UltiDraw.Begin();

            if (gui)
            {
                List <float[]> functions = new List <float[]>();
                for (int i = 0; i < Actions.Length; i++)
                {
                    float[] function = new float[TimeSeries.Samples.Length];
                    for (int j = 0; j < function.Length; j++)
                    {
                        function[j] = Values[TimeSeries.Samples[j].Index][i];
                    }
                    functions.Add(function);
                }
                UltiDraw.DrawGUIFunctions(new Vector2(0.875f, 0.875f), new Vector2(0.2f, 0.1f), functions, 0f, 1f, 0.0025f, UltiDraw.DarkGrey, UltiDraw.GetRainbowColors(Actions.Length), 0.0025f, UltiDraw.Black);
                UltiDraw.DrawGUIRectangle(new Vector2(0.875f, 0.875f), new Vector2(0.005f, 0.1f), UltiDraw.White.Transparent(0.5f));
            }

            for (int i = 0; i < TimeSeries.KeyCount; i++)
            {
                // if(i == TimeSeries.KeyCount-1) {
                float     size           = Utility.Normalise((float)i / (float)(TimeSeries.KeyCount - 1), 0f, 1f, 0.5f, 1f);
                Matrix4x4 transformation = Transformations[TimeSeries.GetKey(i).Index];                         UltiDraw.DrawWiredSphere(transformation.GetPosition(), Quaternion.LookRotation(transformation.GetForward(), Vector3.up), size * 0.2f, UltiDraw.Magenta.Transparent(0.5f), UltiDraw.Black);
                UltiDraw.DrawTranslateGizmo(transformation.GetPosition(), Quaternion.LookRotation(transformation.GetForward(), Vector3.up), size * 0.4f);
                // }
            }
            UltiDraw.End();
        }
示例#3
0
        public void Draw()
        {
            UltiDraw.Begin();
            List <float[]> functions = new List <float[]>();

            for (int i = 0; i < Styles.Length; i++)
            {
                float[] function = new float[TimeSeries.KeyCount];
                for (int j = 0; j < function.Length; j++)
                {
                    function[j] = Values[TimeSeries.GetKey(j).Index][i];
                }
                functions.Add(function);
            }
            UltiDraw.DrawGUIFunctions(new Vector2(0.875f, 0.685f), new Vector2(0.2f, 0.1f), functions, 0f, 1f, 0.0025f, UltiDraw.DarkGrey, UltiDraw.GetRainbowColors(Styles.Length), 0.0025f, UltiDraw.Black);
            UltiDraw.DrawGUIRectangle(new Vector2(0.875f, 0.685f), new Vector2(0.005f, 0.1f), UltiDraw.White.Transparent(0.5f));
            UltiDraw.End();
        }
    private void DrawFunction()
    {
        UltiDraw.Begin();
        Color[]        colors    = UltiDraw.GetRainbowColors(Values.Length);
        List <float[]> functions = new List <float[]>();
        float          min       = float.MaxValue;
        float          max       = float.MinValue;

        for (int i = 0; i < Values.Length; i++)
        {
            float[] values = Values[i].ToArray();
            min = Mathf.Min(values.Min(), min);
            max = Mathf.Max(values.Max(), max);
            functions.Add(values);
        }
        UltiDraw.DrawGUIFunctions(Rect.GetPosition(), Rect.GetSize(), functions, min, max, 0.001f, UltiDraw.White, colors, 0.001f, UltiDraw.DarkGrey);
        UltiDraw.End();
    }
示例#5
0
        public void Draw()
        {
            UltiDraw.Begin();

            //DEBUG RENDERING
            // {
            //  float _xMin = 0.025f;
            //  float _xMax = 0.25f;
            //  float _yMin = 0.05f;
            //  float _yMax = 0.25f;
            //  for(int b=0; b<Bones.Length; b++) {
            //      float w = (float)b/(float)(Bones.Length-1);
            //      List<float[]> values = new List<float[]>();
            //      float max = 0f;
            //      float[] first = new float[TimeSeries.FutureKeyCount+1];
            //      float[] second = new float[TimeSeries.FutureKeyCount+1];
            //      float[] third = new float[TimeSeries.FutureKeyCount+1];
            //      for(int i=0; i<TimeSeries.FutureKeyCount+1; i++) {
            //          first[i] = _PhaseMagnitudes[TimeSeries.GetKey(i+TimeSeries.PivotKey).Index][b];
            //          second[i] = _PhaseStates[TimeSeries.GetKey(i+TimeSeries.PivotKey).Index][b].magnitude;
            //          third[i] = _PhaseUpdateVectors[TimeSeries.GetKey(i+TimeSeries.PivotKey).Index][b].magnitude;
            //          max = Mathf.Max(max, first[i], second[i], third[i]);
            //      }
            //      values.Add(first);
            //      values.Add(second);
            //      values.Add(third);
            //      float vertical = Utility.Normalise(w, 0f, 1f, _yMin, _yMax);
            //      float height = 0.95f*(_yMax-_yMin)/(Bones.Length-1);
            //      UltiDraw.DrawGUIFunctions(new Vector2(0.5f * (_xMin + _xMax), vertical), new Vector2(_xMax-_xMin, height), values, 0f, max, UltiDraw.DarkGrey, new Color[3]{Color.yellow, Color.magenta, Color.cyan});
            //  }
            // }
            // {
            //  float _xMin = 0.025f;
            //  float _xMax = 0.25f;
            //  float _yMin = 0.3f;
            //  float _yMax = 0.5f;
            //  for(int b=0; b<Bones.Length; b++) {
            //      float w = (float)b/(float)(Bones.Length-1);
            //      List<float[]> values = new List<float[]>();
            //      float[] first = new float[TimeSeries.FutureKeyCount+1];
            //      float[] second = new float[TimeSeries.FutureKeyCount+1];
            //      for(int i=0; i<TimeSeries.FutureKeyCount+1; i++) {
            //          first[i] = _PhaseUpdateValues[TimeSeries.GetKey(i+TimeSeries.PivotKey).Index][b];
            //          second[i] = Utility.PhaseUpdate(0f, Utility.PhaseValue(_PhaseUpdateVectors[TimeSeries.GetKey(i+TimeSeries.PivotKey).Index][b]));
            //      }
            //      values.Add(first);
            //      values.Add(second);
            //      float vertical = Utility.Normalise(w, 0f, 1f, _yMin, _yMax);
            //      float height = 0.95f*(_yMax-_yMin)/(Bones.Length-1);
            //      UltiDraw.DrawGUIFunctions(new Vector2(0.5f * (_xMin + _xMax), vertical), new Vector2(_xMax-_xMin, height), values, 0f, 0.1f, UltiDraw.DarkGrey, new Color[2]{Color.yellow, Color.magenta});
            //  }
            // }
            //

            float xMin = 0.3f;
            float xMax = 0.7f;
            float yMin = 0.75f;
            float yMax = 0.95f;

            //This is phase vector rendering
            for (int b = 0; b < Bones.Length; b++)
            {
                float   w      = (float)b / (float)(Bones.Length - 1);
                float[] values = new float[TimeSeries.KeyCount];
                Color[] colors = new Color[TimeSeries.KeyCount];
                for (int i = 0; i < TimeSeries.KeyCount; i++)
                {
                    values[i] = Phases[TimeSeries.GetKey(i).Index][b];
                    colors[i] = UltiDraw.White.Transparent(Magnitudes[TimeSeries.GetKey(i).Index][b]);
                }
                float vertical = Utility.Normalise(w, 0f, 1f, yMin, yMax);
                float height   = 0.95f * (yMax - yMin) / (Bones.Length - 1);
                UltiDraw.DrawGUIBars(new Vector2(0.5f * (xMin + xMax), vertical), new Vector2(xMax - xMin, height), values, 1f, 1f, 0.01f, UltiDraw.DarkGrey, Color.white);
                // UltiDraw.DrawGUICircularPivot(new Vector2(xMax + height/2f, vertical), height/2f, UltiDraw.DarkGrey, 360f*Phases[TimeSeries.Pivot][b], 1f, colors[TimeSeries.PivotKey]);
                UltiDraw.DrawGUICircularPivot(new Vector2(xMax + height / 2f, vertical), height / 2f, UltiDraw.DarkGrey, 360f * Phases[TimeSeries.Pivot][b], Magnitudes[TimeSeries.Pivot][b], colors[TimeSeries.PivotKey]);

                for (int i = 0; i < TimeSeries.KeyCount; i++)
                {
                    float horizontal = Utility.Normalise((float)i / (float)(TimeSeries.KeyCount - 1), 0f, 1f, xMin, xMax);
                    // UltiDraw.DrawGUICircularPivot(new Vector2(horizontal, vertical + height/4f), height/4f, UltiDraw.DarkGrey, 360f*Phases[TimeSeries.GetKey(i).Index][b], 1f, colors[i]);
                    UltiDraw.DrawGUICircularPivot(new Vector2(horizontal, vertical + height / 4f), height / 4f, UltiDraw.DarkGrey, 360f * Utility.PhaseUpdate(Phases[TimeSeries.Pivot][b], Phases[TimeSeries.GetKey(i).Index][b]), 1f, colors[i]);

                    // UltiDraw.DrawGUICircularPivot(new Vector2(horizontal, vertical + height/4f), height/4f, UltiDraw.DarkGrey, 360f*Values[TimeSeries.GetKey(i).Index][b], 1f, UltiDraw.Cyan);
                    // Vector2 phase = Utility.PhaseVectorUpdate(Vectors[TimeSeries.Pivot][b], Vectors[TimeSeries.GetKey(i).Index][b]);
                    // UltiDraw.DrawGUICircularPivot(new Vector2(horizontal, vertical + height/4f), height/4f, UltiDraw.DarkGrey, -Vector2.SignedAngle(Vector2.up, phase), 1f, colors[i]);
                }
            }

            // //This is phase rendering
            // for(int b=0; b<Bones.Length; b++) {
            //  float w = (float)b/(float)(Bones.Length-1);
            //  float[] values = new float[TimeSeries.KeyCount];
            //  Color[] colors = new Color[TimeSeries.KeyCount];
            //  for(int i=0; i<TimeSeries.KeyCount; i++) {
            //      values[i] = Values[TimeSeries.GetKey(i).Index][b];
            //      colors[i] = UltiDraw.White.Transparent(Mathf.Clamp(Magnitudes[TimeSeries.GetKey(i).Index][b], 0f, 1f));
            //  }
            //  float vertical = Utility.Normalise(w, 0f, 1f, yMin, yMax);
            //  float height = 0.95f*(yMax-yMin)/(Bones.Length-1);
            //  UltiDraw.DrawGUIBars(new Vector2(0.5f * (xMin + xMax), vertical), new Vector2(xMax-xMin, height), values, 01f, 1f, 0.01f, UltiDraw.DarkGrey, colors);
            //  UltiDraw.DrawGUICircularPivot(new Vector2(xMax + height/2f, vertical), height/2f, UltiDraw.DarkGrey, 360f*Values[TimeSeries.Pivot][b], 1f, UltiDraw.Cyan);
            // }

            //This is energy rendering
            // for(int b=0; b<Bones.Length; b++) {
            //  float w = (float)b/(float)(Bones.Length-1);
            //  float[] values = new float[TimeSeries.KeyCount];
            //  Color[] colors = new Color[TimeSeries.KeyCount];
            //  for(int i=0; i<TimeSeries.KeyCount; i++) {
            //      values[i] = 1f;
            //      float weight = Vector2.Angle(Vector2.up, Utility.PhaseVector(Values[TimeSeries.GetKey(i).Index][b])) / 180f;
            //      colors[i] = Color.Lerp(UltiDraw.Cyan, UltiDraw.Orange, weight).Transparent(Mathf.Clamp(Magnitudes[TimeSeries.GetKey(i).Index][b], 0f, 1f));
            //  }
            //  float vertical = Utility.Normalise(w, 0f, 1f, yMin, yMax);
            //  float height = 0.95f*(yMax-yMin)/(Bones.Length-1);
            //  UltiDraw.DrawGUIBars(new Vector2(0.5f * (xMin + xMax), vertical), new Vector2(xMax-xMin, height), values, 01f, 1f, 0.01f, UltiDraw.DarkGrey, colors);
            //  UltiDraw.DrawGUICircle(new Vector2(xMax + height/2f, vertical), height/2f, colors[TimeSeries.PivotKey]);
            // }

            {
                float          max    = 0f;
                List <float[]> values = new List <float[]>();
                for (int b = 0; b < Bones.Length; b++)
                {
                    float[] v = new float[TimeSeries.KeyCount];
                    for (int i = 0; i < TimeSeries.KeyCount; i++)
                    {
                        v[i] = Magnitudes[TimeSeries.GetKey(i).Index][b];
                        max  = Mathf.Max(max, v[i]);
                    }
                    values.Add(v);
                }
                float vertical = yMin - 1f * (yMax - yMin) / (Bones.Length - 1);
                float height   = 0.95f * (yMax - yMin) / (Bones.Length - 1);
                UltiDraw.DrawGUIFunctions(new Vector2(0.5f * (xMin + xMax), vertical), new Vector2(xMax - xMin, height), values, 0f, Mathf.Max(1f, max), UltiDraw.DarkGrey, UltiDraw.GetRainbowColors(values.Count));
            }

            //This is vector rendering
            // for(int b=0; b<Bones.Length; b++) {
            //  float w = (float)b/(float)(Bones.Length-1);
            //  float[] values = new float[TimeSeries.KeyCount];
            //  Color[] colors = new Color[TimeSeries.KeyCount];
            //  for(int i=0; i<TimeSeries.KeyCount; i++) {
            //      values[i] = Utility.PhaseValue(Vectors[TimeSeries.GetKey(i).Index][b]);
            //      colors[i] = UltiDraw.White.Transparent(Mathf.Clamp(Vectors[TimeSeries.GetKey(i).Index][b].magnitude, 0f, 1f));
            //  }
            //  float vertical = Utility.Normalise(w, 0f, 1f, yMin, yMax);
            //  float height = 0.95f*(yMax-yMin)/(Bones.Length-1);
            //  UltiDraw.DrawGUIBars(new Vector2(0.5f * (xMin + xMax), vertical), new Vector2(xMax-xMin, height), values, 01f, 1f, 0.01f, UltiDraw.DarkGrey, colors);
            //  UltiDraw.DrawGUICircularPivot(new Vector2(xMax + height/2f, vertical), height/2f, UltiDraw.DarkGrey, 360f*Utility.PhaseValue(Vectors[TimeSeries.Pivot][b]), 1f, UltiDraw.Cyan);
            // }
            // {
            //  float max = 0f;
            //  List<float[]> values = new List<float[]>();
            //  for(int b=0; b<Bones.Length; b++) {
            //      float[] v = new float[TimeSeries.KeyCount];
            //      for(int i=0; i<TimeSeries.KeyCount; i++) {
            //          v[i] = Vectors[TimeSeries.GetKey(i).Index][b].magnitude;
            //          max = Mathf.Max(max, v[i]);
            //      }
            //      values.Add(v);
            //  }
            //  float vertical = yMin - 1*(yMax-yMin)/(Bones.Length-1);
            //  float height = 0.95f*(yMax-yMin)/(Bones.Length-1);
            //  UltiDraw.DrawGUIFunctions(new Vector2(0.5f * (xMin + xMax), vertical), new Vector2(xMax-xMin, height), values, 0f, Mathf.Max(2f, max), UltiDraw.DarkGrey, UltiDraw.GetRainbowColors(values.Count));
            // }
            // {
            //  List<float[]> values = new List<float[]>();
            //  for(int b=0; b<Bones.Length; b++) {
            //      float[] v = new float[TimeSeries.KeyCount];
            //      for(int i=0; i<TimeSeries.KeyCount; i++) {
            //          v[i] = Frequencies[TimeSeries.GetKey(i).Index][b];
            //      }
            //      values.Add(v);
            //  }
            //  float vertical = yMin - 2*(yMax-yMin)/(Bones.Length-1);
            //  float height = 0.95f*(yMax-yMin)/(Bones.Length-1);
            //  UltiDraw.DrawGUIFunctions(new Vector2(0.5f * (xMin + xMax), vertical), new Vector2(xMax-xMin, height), values, 0f, Mathf.Max(0.5f, 2.5f), UltiDraw.DarkGrey, UltiDraw.GetRainbowColors(values.Count));
            // }

            // {
            //  float[] combination = new float[TimeSeries.KeyCount];
            //  for(int i=0; i<TimeSeries.KeyCount; i++) {
            //      combination[i] = GetAveragePhase(TimeSeries.GetKey(i).Index);
            //  }
            //  float vertical = yMin - 2f*(yMax-yMin)/(Bones.Length-1);
            //  float height = 0.95f*(yMax-yMin)/(Bones.Length-1);
            //  UltiDraw.DrawGUIBars(new Vector2(0.5f * (xMin + xMax), vertical), new Vector2(xMax-xMin, height), combination, 01f, 1f, 0.01f, UltiDraw.DarkGrey, UltiDraw.Red);
            //  UltiDraw.DrawGUICircularPivot(new Vector2(xMax + height/2f, vertical), height/2f, UltiDraw.DarkGrey, 360f*combination[TimeSeries.PivotKey], 1f, UltiDraw.DarkRed);
            // }

            /*
             * for(int i=0; i<Values.Length; i++) {
             *      float min = 0.1f;
             *      float max = 0.9f;
             *      float size = 1f * (max-min) / Values.Length;
             *      float w = (float)i/(float)(Values.Length-1);
             *      Vector2 center = new Vector2(Utility.Normalise(w, 0f, 1f, min, max), 0.1f);
             *      UltiDraw.DrawGUICircularPivot(center, size, UltiDraw.DarkGrey, Values[i] * 360f, 1f, UltiDraw.Cyan);
             * }
             *
             * for(int i=0; i<Values.Length; i++) {
             *      float min = 0.1f;
             *      float max = 0.9f;
             *      float size = 1f * (max-min) / Values.Length;
             *      float w = (float)i/(float)(Values.Length-1);
             *      Vector2 center = new Vector2(Utility.Normalise(w, 0f, 1f, min, max), 0.1f);
             *      //UltiDraw.DrawGUICircularPivot(center, size, UltiDraw.DarkGrey, -Vector2.SignedAngle(Vector2.up, Vectors[i]), 1f, UltiDraw.Cyan);
             * }
             */

            //UltiDraw.DrawGUIBars(new Vector2(0.875f, 0.510f), new Vector2(0.2f, 0.1f), Values, 01f, 1f, 0.01f, UltiDraw.DarkGrey, UltiDraw.White);

            UltiDraw.End();
        }
示例#6
0
    public void Draw(Color boneColor, Color jointColor, float alpha)
    {
        UltiDraw.Begin();
        if (DrawRoot)
        {
            UltiDraw.DrawWiredSphere(GetRoot().position, GetRoot().rotation, 0.1f, UltiDraw.DarkRed, UltiDraw.Black);
            UltiDraw.DrawTranslateGizmo(GetRoot().position, GetRoot().rotation, 0.1f);
        }

        if (DrawSkeleton)
        {
            Action <Bone> recursion = null;
            recursion = new Action <Bone>((bone) => {
                if (bone.GetParent() != null)
                {
                    //if(bone.GetLength() > 0.05f) {
                    UltiDraw.DrawBone(
                        bone.GetParent().Transform.position,
                        Quaternion.FromToRotation(bone.GetParent().Transform.forward, bone.Transform.position - bone.GetParent().Transform.position) * bone.GetParent().Transform.rotation,
                        12.5f * BoneSize * bone.GetLength(), bone.GetLength(),
                        boneColor.Transparent(alpha)
                        );
                    //}
                }
                UltiDraw.DrawSphere(
                    bone.Transform.position,
                    Quaternion.identity,
                    5f / 8f * BoneSize,
                    jointColor.Transparent(alpha)
                    );
                for (int i = 0; i < bone.Childs.Length; i++)
                {
                    recursion(bone.GetChild(i));
                }
            });
            if (Bones.Length > 0)
            {
                recursion(Bones[0]);
            }
        }

        if (DrawVelocities)
        {
            for (int i = 0; i < Bones.Length; i++)
            {
                UltiDraw.DrawArrow(
                    Bones[i].Transform.position,
                    Bones[i].Transform.position + Bones[i].Velocity,
                    0.75f,
                    0.0075f,
                    0.05f,
                    UltiDraw.DarkGreen.Transparent(0.5f)
                    );
            }
        }

        if (DrawAccelerations)
        {
            for (int i = 0; i < Bones.Length; i++)
            {
                UltiDraw.DrawArrow(
                    Bones[i].Transform.position,
                    Bones[i].Transform.position + Bones[i].Acceleration,
                    0.75f,
                    0.0075f,
                    0.05f,
                    UltiDraw.DarkBlue.Transparent(0.5f)
                    );
            }
        }

        if (DrawForces)
        {
            for (int i = 0; i < Bones.Length; i++)
            {
                UltiDraw.DrawArrow(
                    Bones[i].Transform.position,
                    Bones[i].Transform.position + Bones[i].Force,
                    0.75f,
                    0.0075f,
                    0.05f,
                    UltiDraw.DarkRed.Transparent(0.5f)
                    );
            }
        }

        if (DrawTransforms)
        {
            Action <Bone> recursion = null;
            recursion = new Action <Bone>((bone) => {
                UltiDraw.DrawTranslateGizmo(bone.Transform.position, bone.Transform.rotation, 0.05f);
                for (int i = 0; i < bone.Childs.Length; i++)
                {
                    recursion(bone.GetChild(i));
                }
            });
            if (Bones.Length > 0)
            {
                recursion(Bones[0]);
            }
        }
        UltiDraw.End();

        if (DrawHistory)
        {
            if (DrawSkeleton)
            {
                for (int i = 0; i < History.Count; i++)
                {
                    Sketch(History[i].Transformations, UltiDraw.GetRainbowColor(Index, 2).Transparent(0.5f));
                }
            }
            if (DrawVelocities)
            {
                float          max       = 0f;
                List <float[]> functions = new List <float[]>();
                for (int i = 0; i < Bones.Length; i++)
                {
                    float[] function = new float[History.Count];
                    for (int j = 0; j < function.Length; j++)
                    {
                        function[j] = History[j].Velocities[i].magnitude;
                        max         = Mathf.Max(max, function[j]);
                    }
                    functions.Add(function);
                }
                UltiDraw.Begin();
                UltiDraw.DrawGUIFunctions(new Vector2(0.5f, 0.05f), new Vector2(0.9f, 0.1f), functions, 0f, max, 0.0025f, UltiDraw.DarkGrey, UltiDraw.GetRainbowColors(functions.Count));
                UltiDraw.End();
            }
            if (DrawAccelerations)
            {
                float          max       = 0f;
                List <float[]> functions = new List <float[]>();
                for (int i = 0; i < Bones.Length; i++)
                {
                    float[] function = new float[History.Count];
                    for (int j = 0; j < function.Length; j++)
                    {
                        function[j] = History[j].Accelerations[i].magnitude;
                        max         = Mathf.Max(max, function[j]);
                    }
                    functions.Add(function);
                }
                UltiDraw.Begin();
                UltiDraw.DrawGUIFunctions(new Vector2(0.5f, 0.175f), new Vector2(0.9f, 0.1f), functions, 0f, max, 0.0025f, UltiDraw.DarkGrey, UltiDraw.GetRainbowColors(functions.Count));
                UltiDraw.End();
            }
        }
    }
示例#7
0
    public void Draw()
    {
        if (GetCurrentFile() == null)
        {
            return;
        }

        //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]);
        //	}
        //}

        /*
         * UltiDraw.Begin();
         * //Exp Map
         * int window = 10;
         * for(int k=0; k<3; k++) {
         *      List<float[]> functions = new List<float[]>();
         *      for(int i=0; i<Actor.Bones.Length; i++) {
         *              List<float> values = new List<float>();
         *              for(int j=Mathf.Clamp(GetCurrentFrame().Index - window, 1, GetCurrentFile().Data.GetTotalFrames()); j<=Mathf.Clamp(GetCurrentFrame().Index + window, 1, GetCurrentFile().Data.GetTotalFrames()); j++) {
         *                      Frame frame = GetCurrentFile().Data.GetFrame(j);
         *                      Vector3 exp = frame.Local[i].GetRotation().GetLog();
         *                      if(k==0) {
         *                              values.Add(exp.x);
         *                      }
         *                      if(k==1) {
         *                              values.Add(exp.y);
         *                      }
         *                      if(k==2) {
         *                              values.Add(exp.z);
         *                      }
         *              }
         *              functions.Add(values.ToArray());
         *      }
         *      UltiDraw.DrawGUIFunctions(new Vector2(0.5f, 0.1f + k*0.2f), new Vector2(0.8f, 0.175f), functions, -1f, 1f, UltiDraw.DarkGrey, UltiDraw.GetRainbowColors(functions.Count));
         *      UltiDraw.DrawGUILine(new Vector2(0.5f, 0f), new Vector2(0.5f, 1f), 0.0025f, UltiDraw.Green.Transparent(0.5f));
         * }
         * UltiDraw.End();
         */


        UltiDraw.Begin();

        Trajectory previous = ((TrajectoryModule)GetCurrentFile().Data.GetModule(Module.TYPE.Trajectory)).GetTrajectory(GetCurrentFrame().GetPreviousFrame(), Mirror);
        Trajectory current  = ((TrajectoryModule)GetCurrentFile().Data.GetModule(Module.TYPE.Trajectory)).GetTrajectory(GetCurrentFrame(), Mirror);
        Trajectory next     = ((TrajectoryModule)GetCurrentFile().Data.GetModule(Module.TYPE.Trajectory)).GetTrajectory(GetCurrentFrame().GetNextFrame(), Mirror);

        Color[] colors = UltiDraw.GetRainbowColors(previous.Styles.Length);

        List <float[]> signalInput = new List <float[]>();

        for (int i = 0; i < current.Styles.Length; i++)
        {
            float[] s = new float[current.Points.Length];
            for (int j = 0; j < current.Points.Length; j++)
            {
                s[j] = current.Points[j].Signals[i];
            }
            signalInput.Add(s);
        }
        UltiDraw.DrawGUIFunctions(new Vector2(0.5f, 0.9f), new Vector2(0.75f, 0.1f), signalInput, -1f, 1f, UltiDraw.DarkGrey, colors);

        List <float[]> stateInput = new List <float[]>();

        for (int i = 0; i < current.Styles.Length; i++)
        {
            float[] s = new float[current.Points.Length];
            for (int j = 0; j < current.Points.Length; j++)
            {
                s[j] = current.Points[j].Styles[i];
            }
            stateInput.Add(s);
        }
        UltiDraw.DrawGUIFunctions(new Vector2(0.5f, 0.75f), new Vector2(0.75f, 0.1f), stateInput, 0f, 1f, UltiDraw.DarkGrey, colors);

        /*
         * List<float[]> stateUpdateInput = new List<float[]>();
         * for(int i=0; i<current.Styles.Length; i++) {
         *      float[] s = new float[current.Points.Length];
         *      for(int j=0; j<current.Points.Length; j++) {
         *              s[j] = current.Points[j].Styles[i] - previous.Points[j].Styles[i];
         *      }
         *      stateUpdateInput.Add(s);
         * }
         * UltiDraw.DrawGUIFunctions(new Vector2(0.5f, 0.6f), new Vector2(0.75f, 0.1f), stateUpdateInput, -1f, 1f, UltiDraw.DarkGrey, colors);
         */
        List <float[]> stateOutput = new List <float[]>();

        for (int i = 0; i < next.Styles.Length; i++)
        {
            float[] s = new float[next.Points.Length];
            for (int j = 0; j < next.Points.Length; j++)
            {
                s[j] = next.Points[j].Styles[i];
            }
            stateOutput.Add(s);
        }
        UltiDraw.DrawGUIFunctions(new Vector2(0.5f, 0.6f), new Vector2(0.75f, 0.1f), stateOutput, 0f, 1f, UltiDraw.DarkGrey, colors);

        /*
         * List<float[]> stateUpdateOutput = new List<float[]>();
         * for(int i=0; i<next.Styles.Length; i++) {
         *      float[] s = new float[next.Points.Length];
         *      for(int j=0; j<next.Points.Length; j++) {
         *              s[j] = next.Points[j].Styles[i] - current.Points[j].Styles[i];
         *      }
         *      stateUpdateOutput.Add(s);
         * }
         * UltiDraw.DrawGUIFunctions(new Vector2(0.5f, 0.1f), new Vector2(0.75f, 0.1f), stateUpdateOutput, -1f, 1f, UltiDraw.DarkGrey, colors);
         */
        UltiDraw.DrawGUILine(new Vector2(0.5f - 0.75f / 2f + 6f / 11f * 0.75f, 1f), new Vector2(0.5f - 0.75f / 2f + 6f / 11f * 0.75f, 0f), 0.0025f, UltiDraw.Green);

        UltiDraw.End();


        for (int i = 0; i < GetCurrentFile().Data.Modules.Length; i++)
        {
            GetCurrentFile().Data.Modules[i].Draw(this);
        }
    }
示例#8
0
    public void Draw()
    {
        if (GetCurrentFile() == null)
        {
            return;
        }

        //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 (Velocities)
        {
            UltiDraw.Begin();
            Vector3[] velocities = GetCurrentFrame().GetBoneVelocities(Mirror);
            for (int i = 0; i < velocities.Length; i++)
            {
                UltiDraw.DrawArrow(
                    GetActor().Bones[i].Transform.position,
                    GetActor().Bones[i].Transform.position + velocities[i],
                    0.75f,
                    0.0075f,
                    0.05f,
                    UltiDraw.Purple.Transparent(0.5f)
                    );
            }
            UltiDraw.End();
        }

        UltiDraw.Begin();
        //Exp Map
        int window = 10;

        for (int k = 0; k < 3; k++)
        {
            List <float[]> functions = new List <float[]>();
            for (int i = 0; i < Actor.Bones.Length; i++)
            {
                List <float> values = new List <float>();
                for (int j = Mathf.Clamp(GetCurrentFrame().Index - window, 1, GetCurrentFile().Data.GetTotalFrames()); j <= Mathf.Clamp(GetCurrentFrame().Index + window, 1, GetCurrentFile().Data.GetTotalFrames()); j++)
                {
                    Frame   frame = GetCurrentFile().Data.GetFrame(j);
                    Vector3 exp   = frame.World[i].GetRotation().GetLog();
                    if (k == 0)
                    {
                        values.Add(exp.x);
                    }
                    if (k == 1)
                    {
                        values.Add(exp.y);
                    }
                    if (k == 2)
                    {
                        values.Add(exp.z);
                    }
                }
                functions.Add(values.ToArray());
            }
            UltiDraw.DrawGUIFunctions(new Vector2(0.5f, 0.1f + k * 0.2f), new Vector2(0.8f, 0.175f), functions, -1f, 1f, UltiDraw.DarkGrey, UltiDraw.GetRainbowColors(functions.Count));
        }
        UltiDraw.End();

        for (int i = 0; i < GetCurrentFile().Data.Modules.Length; i++)
        {
            GetCurrentFile().Data.Modules[i].Draw(this);
        }
    }