Exemple #1
0
    void OnRenderObject()
    {
        if (Application.isPlaying)
        {
            if (NN.Parameters == null)
            {
                return;
            }

            if (ShowTrajectory)
            {
                UltiDraw.Begin();
                UltiDraw.DrawLine(Trajectory.Points[RootPointIndex].GetPosition(), Trajectory.Points[RootPointIndex].GetPosition() + TargetDirection, 0.05f, 0f, UltiDraw.Red.Transparent(0.75f));
                UltiDraw.DrawLine(Trajectory.Points[RootPointIndex].GetPosition(), Trajectory.Points[RootPointIndex].GetPosition() + TargetVelocity, 0.05f, 0f, UltiDraw.Green.Transparent(0.75f));
                UltiDraw.End();
                Trajectory.Draw(10);
            }

            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 + Velocities[i],
                        0.75f,
                        0.0075f,
                        0.05f,
                        UltiDraw.Purple.Transparent(0.5f)
                        );
                }
                UltiDraw.End();
            }

            UltiDraw.Begin();
            Color[] colors = UltiDraw.GetRainbowColors(Controller.Styles.Length);
            float   phase  = GetPhase();
            for (int i = 0; i < Controller.Styles.Length; i++)
            {
                float x = (float)i / (float)(Controller.Styles.Length - 1);
                x = Utility.Normalise(x, 0f, 1f, 0.3f, 0.7f);
                float y = 0.85f;
                UltiDraw.DrawGUICircularPivot(new Vector2(x, y), 0.04f, UltiDraw.DarkGrey, phase * 360f, GetSample(6).Styles[i], colors[i]);
            }
            UltiDraw.End();

            //HeightMap.Draw();
        }
    }
Exemple #2
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();
        }