Ejemplo n.º 1
0
    void OnRenderObject()
    {
        if (Root == null)
        {
            Root = transform;
        }

        /*
         * UnityGL.Start();
         * UnityGL.DrawGUICircle(0.5f, 0.85f, 0.075f, Utility.Black.Transparent(0.5f));
         * Quaternion rotation = Quaternion.AngleAxis(-360f * Phase / (2f * Mathf.PI), Vector3.forward);
         * Vector2 a = rotation * new Vector2(-0.005f, 0f);
         * Vector2 b = rotation *new Vector3(0.005f, 0f);
         * Vector3 c = rotation * new Vector3(0f, 0.075f);
         * UnityGL.DrawGUITriangle(0.5f + a.x/Screen.width*Screen.height, 0.85f + a.y, 0.5f + b.x/Screen.width*Screen.height, 0.85f + b.y, 0.5f + c.x/Screen.width*Screen.height, 0.85f + c.y, Utility.Cyan);
         * UnityGL.Finish();
         */

        if (ShowTrajectory)
        {
            if (Application.isPlaying)
            {
                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 (!Application.isPlaying)
        {
            Character.FetchTransformations(Root);
        }
        Character.Draw();

        if (ShowVelocities)
        {
            if (Application.isPlaying)
            {
                UltiDraw.Begin();
                for (int i = 0; i < Joints.Length; i++)
                {
                    Character.Segment segment = Character.FindSegment(Joints[i].name);
                    if (segment != null)
                    {
                        UltiDraw.DrawArrow(
                            Joints[i].position,
                            Joints[i].position + Velocities[i] * 60f,
                            0.75f,
                            0.0075f,
                            0.05f,
                            UltiDraw.Cyan.Transparent(0.5f)
                            );
                    }
                }
                UltiDraw.End();
            }
        }
    }
Ejemplo n.º 2
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();
				UltiDraw.DrawGUIHorizontalBar(new Vector2(0.5f, 0.74f), new Vector2(0.25f, 0.025f), UltiDraw.DarkGrey.Transparent(0.5f), 0.0025f, UltiDraw.Black, Trajectory.Points[RootPointIndex].GetVelocity().magnitude / 4f, UltiDraw.DarkGreen);
				UltiDraw.End();
			}
		}
Ejemplo n.º 3
0
 void OnRenderObject()
 {
     UltiDraw.Begin();
     UltiDraw.DrawArrow(transform.position, parentJoint.position, 0.75f,
                        0.0075f,
                        0.05f,
                        UltiDraw.Purple.Transparent(0.5f));
     UltiDraw.End();
 }
Ejemplo n.º 4
0
    public void Draw(Color boneColor, Color jointColor, float alpha)
    {
        UltiDraw.Begin();

        if (DrawSkeleton)
        {
            Action <Segment, Segment> recursion = null;
            recursion = new Action <Segment, Segment>((segment, parent) => {
                if (segment == null)
                {
                    return;
                }
                if (parent != null)
                {
                    UltiDraw.DrawSphere(
                        parent.GetTransformation().GetPosition(),
                        5f / 8f * BoneSize,
                        jointColor.Transparent(alpha)
                        );
                    float distance = Vector3.Distance(parent.GetTransformation().GetPosition(), segment.GetTransformation().GetPosition());
                    if (distance > 0.05f)
                    {
                        UltiDraw.DrawBone(
                            parent.GetTransformation().GetPosition(),
                            Quaternion.FromToRotation(parent.GetTransformation().GetForward(), segment.GetTransformation().GetPosition() - parent.GetTransformation().GetPosition()) * parent.GetTransformation().GetRotation(),
                            4f * BoneSize, distance,
                            boneColor.Transparent(alpha)
                            );
                    }
                }
                parent = segment;
                for (int i = 0; i < segment.GetChildCount(); i++)
                {
                    recursion(segment.GetChild(Hierarchy, i), parent);
                }
            });
            recursion(GetRoot(), null);
        }

        if (DrawTransforms)
        {
            Action <Segment> recursion = null;
            recursion = new Action <Segment>((segment) => {
                UltiDraw.DrawArrow(segment.GetTransformation().GetPosition(), segment.GetTransformation().GetPosition() + 0.05f * (segment.GetTransformation().GetRotation() * Vector3.forward), 0.75f, 0.005f, 0.025f, Color.blue);
                UltiDraw.DrawArrow(segment.GetTransformation().GetPosition(), segment.GetTransformation().GetPosition() + 0.05f * (segment.GetTransformation().GetRotation() * Vector3.up), 0.75f, 0.005f, 0.025f, Color.green);
                UltiDraw.DrawArrow(segment.GetTransformation().GetPosition(), segment.GetTransformation().GetPosition() + 0.05f * (segment.GetTransformation().GetRotation() * Vector3.right), 0.75f, 0.005f, 0.025f, Color.red);
                //UltiDraw.DrawTranslateGizmo(segment.GetTransformation().GetPosition(), segment.GetTransformation().GetRotation(), 0.075f);
                for (int i = 0; i < segment.GetChildCount(); i++)
                {
                    recursion(segment.GetChild(Hierarchy, i));
                }
            });
            recursion(GetRoot());
        }

        UltiDraw.End();
    }
    void OnDrawGizmos()
    {
        if (Visualise)
        {
            UltiDraw.Begin();
            UltiDraw.DrawSphere(transform.position, Quaternion.identity, 0.25f, UltiDraw.Cyan.Transparent(0.5f));

            UltiDraw.DrawArrow(GetPivotPosition(), GetPivotPosition() + 0.25f * (transform.rotation), 0.8f, 0.02f, 0.1f, UltiDraw.Cyan.Transparent(0.5f));
            UltiDraw.End();
        }
    }
    void OnDrawGizmos() // visualise the joint location
    {
        if (Visualise)
        {
            UltiDraw.Begin();
            UltiDraw.DrawSphere(transform.position, Quaternion.identity, 0.25f, UltiDraw.Purple.Transparent(0.5f));

            UltiDraw.DrawArrow(transform.position, transform.position + (directionToCheck.normalized * distanceToCheck), 0.8f, 0.02f, 0.1f, UltiDraw.Cyan.Transparent(0.5f));
            UltiDraw.End();
        }
    }
Ejemplo n.º 7
0
    void OnDrawGizmos() // visualise the joint location
    {
        if (Visualise)
        {
            UltiDraw.Begin();
            UltiDraw.DrawSphere(transform.position, Quaternion.identity, 0.25f, UltiDraw.Purple.Transparent(0.5f));

            UltiDraw.DrawArrow(transform.position, transform.position + 0.25f * (transform.rotation * Axis), 0.8f, 0.02f, 0.1f, UltiDraw.Cyan.Transparent(0.5f));
            UltiDraw.End();
        }
    }
Ejemplo n.º 8
0
 void OnDrawGizmos()
 {
     if (Ankle == null || Normal == Vector3.zero)
     {
         return;
     }
     UltiDraw.Begin();
     UltiDraw.DrawSphere(GetPivotPosition(), Quaternion.identity, 0.025f, UltiDraw.Cyan.Transparent(0.5f));
     UltiDraw.DrawArrow(GetPivotPosition(), GetPivotPosition() + 0.25f * (GetPivotRotation() * Normal), 0.75f, 0.025f, 0.1f, UltiDraw.Cyan.Transparent(0.5f));
     UltiDraw.DrawSphere(GetPivotPosition(), Quaternion.identity, Radius, UltiDraw.Red.Transparent(0.5f));
     UltiDraw.End();
 }
Ejemplo n.º 9
0
 public void Draw()
 {
     UltiDraw.Begin();
     for (int i = 0; i < Keypoints.Count; i++)
     {
         UltiDraw.DrawSphere(Keypoints[i], Quaternion.identity, 0.025f, UltiDraw.Red);
     }
     for (int i = 0; i < Actor.Bones.Length; i++)
     {
         UltiDraw.DrawWireSphere(Actor.Bones[i].Transform.position, Actor.Bones[i].Transform.rotation, 2f * GetRadius(i), UltiDraw.Black.Transparent(0.05f));
         UltiDraw.DrawArrow(Positions[i], Positions[i] + Gradients[i], 0.8f, 0.005f, 0.015f, UltiDraw.Cyan.Transparent(0.5f));
     }
     UltiDraw.End();
 }
Ejemplo n.º 10
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();
        }
    }
    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();
    }
Ejemplo n.º 12
0
    void OnRenderObject()
    {
        if (Root == null)
        {
            Root = transform;
        }

        if (ShowTrajectory)
        {
            if (Application.isPlaying)
            {
                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 (!Application.isPlaying)
        {
            Character.FetchTransformations(Root);
        }
        Character.Draw();

        if (ShowVelocities)
        {
            if (Application.isPlaying)
            {
                UltiDraw.Begin();
                for (int i = 0; i < Joints.Length; i++)
                {
                    Character.Segment segment = Character.FindSegment(Joints[i].name);
                    if (segment != null)
                    {
                        UltiDraw.DrawArrow(
                            Joints[i].position,
                            Joints[i].position + Velocities[i] * 60f,
                            0.75f,
                            0.0075f,
                            0.05f,
                            UltiDraw.Purple.Transparent(0.5f)
                            );
                    }
                }
                UltiDraw.End();
            }
        }
    }
Ejemplo n.º 13
0
    public override void Draw(MotionEditor editor)
    {
        Frame frame = editor.GetCurrentFrame();

        UltiDraw.Begin();
        for (int i = 0; i < Functions.Length; i++)
        {
            Matrix4x4  matrix   = Functions[i].GetPivotTransformation(frame, editor.Mirror);
            Vector3    position = matrix.GetPosition();
            Quaternion rotation = matrix.GetRotation();
            UltiDraw.DrawSphere(position, Quaternion.identity, 0.025f, UltiDraw.Cyan.Transparent(0.5f));
            UltiDraw.DrawArrow(position, position + 0.25f * (rotation * Functions[i].Normal.normalized), 0.8f, 0.02f, 0.1f, UltiDraw.Cyan.Transparent(0.5f));
            UltiDraw.DrawSphere(position, Quaternion.identity, Functions[i].DistanceThreshold, UltiDraw.Mustard.Transparent(0.5f));
        }
        UltiDraw.End();
    }
Ejemplo n.º 14
0
        void OnRenderObject()
        {
            /*
             * UltiDraw.Begin();
             * UltiDraw.DrawGUICircle(new Vector2(0.5f, 0.85f), 0.075f, UltiDraw.Black.Transparent(0.5f));
             * Quaternion rotation = Quaternion.AngleAxis(-360f * NN.GetPhase() / (2f * Mathf.PI), Vector3.forward);
             * Vector2 a = rotation * new Vector2(-0.005f, 0f);
             * Vector2 b = rotation *new Vector3(0.005f, 0f);
             * Vector3 c = rotation * new Vector3(0f, 0.075f);
             * UltiDraw.DrawGUITriangle(new Vector2(0.5f + b.x/Screen.width*Screen.height, 0.85f + b.y), new Vector2(0.5f + a.x/Screen.width*Screen.height, 0.85f + a.y), new Vector2(0.5f + c.x/Screen.width*Screen.height, 0.85f + c.y), UltiDraw.Cyan);
             * UltiDraw.End();
             */

            if (Application.isPlaying)
            {
                if (NN.Parameters == null)
                {
                    return;
                }

                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);

                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();
            }
        }
Ejemplo n.º 15
0
 void OnRenderObject()
 {
     return;;
     if (Ankle == null || Normal == Vector3.zero)
     {
         return;
     }
     if (!Application.isPlaying)
     {
         ComputeNormal();
     }
     UltiDraw.Begin();
     UltiDraw.DrawSphere(GetPivotPosition(), Quaternion.identity, 0.025f, UltiDraw.Cyan.Transparent(0.5f));
     UltiDraw.DrawArrow(GetPivotPosition(), GetPivotPosition() + 0.25f * (GetPivotRotation() * Normal.normalized), 0.8f, 0.02f, 0.1f, UltiDraw.Cyan.Transparent(0.5f));
     UltiDraw.DrawSphere(GetPivotPosition(), Quaternion.identity, Radius, UltiDraw.Mustard.Transparent(0.5f));
     UltiDraw.End();
 }
Ejemplo n.º 16
0
 void OnDrawGizmos()
 {
     if (Visualise)
     {
         if (Ankle == null || Joint == null || Normal == Vector3.zero)
         {
             return;
         }
         if (!Application.isPlaying)
         {
             ComputeNormal();
         }
         UltiDraw.Begin();
         UltiDraw.DrawSphere(GetPivotPosition(), Quaternion.identity, 0.025f, UltiDraw.Cyan.Transparent(0.5f));
         UltiDraw.DrawArrow(GetPivotPosition(), GetPivotPosition() + 0.25f * (GetPivotRotation() * Normal.normalized), 0.8f, 0.02f, 0.1f, UltiDraw.Cyan.Transparent(0.5f));
         UltiDraw.End();
     }
 }
Ejemplo n.º 17
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();
        }

        if (Trajectory)
        {
            GetCurrentFrame().GetTrajectory(Mirror).Draw();
        }

        for (int i = 0; i < GetCurrentFile().Data.Modules.Length; i++)
        {
            GetCurrentFile().Data.Modules[i].Draw(this);
        }
    }
Ejemplo n.º 18
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();
            }

            HeightMap.Draw();
        }
    }
Ejemplo n.º 19
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();
        }
    }
Ejemplo n.º 20
0
    public void Draw(int step = 1)
    {
        UltiDraw.Begin();

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

        //Connections,黑线连接评估点,这些点以step=10为间隔就画一个,总共12个,历史6个,当前1个,预测5个
        for (int i = 0; i < Points.Length - step; i += step)
        {
            UltiDraw.DrawLine(Points[i].GetPosition(), Points[i + step].GetPosition(), 0.01f, UltiDraw.Black);
        }

        //Velocities
        for (int i = 0; i < Points.Length; i += step)
        {
            //Vector3 start = Points[i].GetPosition();
            //Vector3 end = Points[i].GetPosition() + Points[i].GetVelocity();
            //end = Utility.ProjectGround(end, LayerMask.GetMask("Ground"));
            //UltiDraw.DrawLine(start, end, 0.025f, 0f, UltiDraw.DarkGreen.Transparent(0.5f));

            /*
             * float r = 0f;
             * float g = 0f;
             * float b = 0f;
             * for(int j=0; j<Points[i].Styles.Length; j++) {
             *      r += Points[i].Styles[j] * colors[j].r;
             *      g += Points[i].Styles[j] * colors[j].g;
             *      b += Points[i].Styles[j] * colors[j].b;
             * }
             * UltiDraw.DrawLine(Points[i].GetPosition(), Points[i].GetPosition() + Points[i].GetVelocity(), 0.025f, 0f, new Color(r, g, b, 0.5f));
             */

            //UltiDraw.DrawLine(Points[i].GetPosition(), Points[i].GetPosition() + Points[i].GetVelocity(), 0.025f, 0f, UltiDraw.DarkGreen.Transparent(0.5f));
        }

        //Directions,黄色线画个间隔点的方向
        for (int i = 0; i < Points.Length; i += step)
        {
            //Vector3 start = Points[i].GetPosition();
            //Vector3 end = Points[i].GetPosition() + 0.25f * Points[i].GetDirection();
            //end = Utility.ProjectGround(end, LayerMask.GetMask("Ground"));
            //UltiDraw.DrawLine(start, end, 0.025f, 0f, UltiDraw.Orange.Transparent(0.75f));
            UltiDraw.DrawLine(Points[i].GetPosition(), Points[i].GetPosition() + 0.25f * Points[i].GetDirection(), 0.025f, 0f, UltiDraw.Orange.Transparent(0.75f));
        }

        //Styles,方块的颜色是什么信息呢?
        if (Styles.Length > 0)
        {
            for (int i = 0; i < Points.Length; i += step)
            {
                float r = 0f;
                float g = 0f;
                float b = 0f;
                for (int j = 0; j < Points[i].Styles.Length; j++)
                {
                    r += Points[i].Styles[j] * colors[j].r;
                    g += Points[i].Styles[j] * colors[j].g;
                    b += Points[i].Styles[j] * colors[j].b;
                }
                Color color = new Color(r, g, b, 1f);
                UltiDraw.DrawCube(Points[i].GetPosition(), Points[i].GetRotation(), 0.05f, color);
            }
        }

        //Signals

        /*
         * if(Styles.Length > 0) {
         *      for(int i=0; i<Points.Length; i+=step) {
         *              Color color = UltiDraw.Black;
         *              for(int j=0; j<Points[i].Signals.Length; j++) {
         *                      if(Points[i].Signals[j]) {
         *                              color = colors[j];
         *                              break;
         *                      }
         *              }
         *              UltiDraw.DrawCone(Points[i].GetPosition(), Quaternion.identity, 0.1f, 0.1f, color);
         *      }
         * }
         */

        /*
         * //Speed
         * for(int i=0; i<Points.Length; i+=step) {
         *      float r = 0f;
         *      float g = 0f;
         *      float b = 0f;
         *      for(int j=0; j<Points[i].Styles.Length; j++) {
         *              r += Points[i].Styles[j] * colors[j].r;
         *              g += Points[i].Styles[j] * colors[j].g;
         *              b += Points[i].Styles[j] * colors[j].b;
         *      }
         *      UltiDraw.DrawArrow(Points[i].GetPosition(), Points[i].GetPosition() + Points[i].GetSpeed() * Points[i].GetTransformation().GetForward(), 0.8f, 0.02f, 0.04f, new Color(r, g, b, 0.5f));
         * }
         */

        //Projections
        //for(int i=0; i<Points.Length; i+=step) {
        //	Vector3 right = Points[i].GetRightSample();
        //	Vector3 left = Points[i].GetLeftSample();
        //	UltiDraw.DrawCircle(right, 0.01f, UltiDraw.Yellow);
        //	UltiDraw.DrawCircle(left, 0.01f, UltiDraw.Yellow);
        //}

        //Slopes
        //for(int i=0; i<Points.Length; i+=step) {
        //	UltiDraw.DrawLine(Points[i].GetPosition(), Points[i].GetPosition() + 1f * Points[i].GetSlope() * Vector3.up, 0.025f, 0f, UltiDraw.Blue.Transparent(0.75f));
        //}

        //Positions,间隔点再画上黑圈
        for (int i = 0; i < Points.Length; i += step)
        {
            UltiDraw.DrawCircle(Points[i].GetPosition(), 0.025f, UltiDraw.Black);
        }

        //Phase,周期信息是怎么画的呢,为什么demo上看不到?
        for (int i = 0; i < Points.Length; i += step)
        {
            //UltiDraw.DrawLine(Points[i].GetPosition(), Points[i].GetPosition() + Points[i].Phase*Vector3.up, UltiDraw.IndianRed);
            UltiDraw.DrawArrow(Points[i].GetPosition(), Points[i].GetPosition() + Points[i].Phase * Vector3.up, 0.8f, 0.025f, 0.05f, UltiDraw.IndianRed.Transparent(0.5f));
            //UltiDraw.DrawSphere(Points[i].GetPosition(), Quaternion.identity, Points[i].PhaseUpdate / 10f, UltiDraw.Purple.Transparent(0.25f));
        }

        /*
         * List<float[]> signal = new List<float[]>();
         * for(int i=0; i<Styles.Length; i++) {
         *      float[] s = new float[Points.Length];
         *      for(int j=0; j<Points.Length; j++) {
         *              s[j] = Points[j].Signals[i];
         *      }
         *      signal.Add(s);
         * }
         * List<float[]> signalInput = new List<float[]>();
         * for(int i=0; i<Styles.Length; i++) {
         *      float[] s = new float[Points.Length];
         *      for(int j=0; j<Points.Length; j++) {
         *              s[j] = Points[j].Signals[i] - Points[j].Styles[i];
         *      }
         *      signalInput.Add(s);
         * }
         * List<float[]> stateInput = new List<float[]>();
         * for(int i=0; i<Styles.Length; i++) {
         *      float[] s = new float[Points.Length];
         *      for(int j=0; j<Points.Length; j++) {
         *              s[j] = Points[j].Styles[i];
         *      }
         *      stateInput.Add(s);
         * }
         * UltiDraw.DrawGUIFunctions(new Vector2(0.5f, 0.4f), new Vector2(0.75f, 0.1f), signal, 0f, 1f, UltiDraw.DarkGrey, colors);
         * UltiDraw.DrawGUIFunctions(new Vector2(0.5f, 0.25f), new Vector2(0.75f, 0.1f), stateInput, 0f, 1f, UltiDraw.DarkGrey, colors);
         * UltiDraw.DrawGUIFunctions(new Vector2(0.5f, 0.1f), new Vector2(0.75f, 0.1f), signalInput, -1f, 1f, UltiDraw.DarkGrey, colors);
         */

        UltiDraw.End();
    }
Ejemplo n.º 21
0
    public void Draw(Color boneColor, Color jointColor, float alpha)
    {
        UltiDraw.Begin();

        if (DrawSkeleton)
        {
            Action <Bone> recursion = null;
            recursion = new Action <Bone>((bone) =>
            {
                if (bone.Visiable)
                {
                    if (bone.GetParent() != null)
                    {
                        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,
                        3f / 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++)
            {
                if (Bones[i].Visiable)
                {
                    UltiDraw.DrawArrow(
                        Bones[i].Transform.position,
                        Bones[i].Transform.position + Bones[i].Velocity,
                        0.25f,
                        0.025f,
                        0.2f,
                        UltiDraw.DarkGreen.Transparent(0.5f)
                        );
                }
            }
        }

        if (DrawTransforms)
        {
            Action <Bone> recursion = null;
            recursion = new Action <Bone>((bone) =>
            {
                if (bone.Visiable)
                {
                    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();
    }
Ejemplo n.º 22
0
        void OnRenderObject()
        {
            if (Application.isPlaying)
            {
                if (NN.Parameters == null)
                {
                    return;
                }

                if (AnimationAuthoring == null)
                {
                    return;
                }

                if (AnimationAuthoring.ControlPoints.Count <= 0)
                {
                    return;
                }

                if (ShowAuthoring)
                {
                    UltiDraw.SetDepthRendering(true);
                    AnimationAuthoring.StyleColors = new Color[] { AnimationAuthoring.Idle, AnimationAuthoring.Move, AnimationAuthoring.Jump, AnimationAuthoring.Sit, AnimationAuthoring.Stand, AnimationAuthoring.Lie, AnimationAuthoring.Sneak, AnimationAuthoring.Eat, AnimationAuthoring.Hydrate };

                    if (MotionTime <= 0.0f)
                    {
                        MotionTime = AnimationAuthoring.GetControlPoint(AnimationAuthoring.RefTimestamp, 0).GetMotionTime();
                    }
                    if (MotionTime > 0.0f)
                    {
                        GUIStyle style = new GUIStyle();
                        style.normal.textColor = UltiDraw.Red;
                        style.fontSize         = 20;
                        Vector3 pos = AnimationAuthoring.GetLookUpPoint(AnimationAuthoring.RefTimestamp).GetPosition();
#if UNITY_EDITOR
                        Handles.Label(new Vector3(pos.x, pos.y + 1f, pos.z), string.Format("{0:0.0}s", MotionTime), style);
#endif
                    }

                    int countCpInspector = 0;
                    foreach (ControlPoint cp in AnimationAuthoring.ControlPoints)
                    {
                        if (cp.Inspector)
                        {
                            countCpInspector++;
                        }
                        else
                        {
                            continue;
                        }
                        //AnimationAuthoring.LabelCP(cp, (countCpInspector - 1).ToString());
                        UltiDraw.Begin();
                        UltiDraw.DrawSphere(AnimationAuthoring.GetGroundPosition(cp.GetPosition(), cp.Ground), Quaternion.identity, 0.1f, UltiDraw.Red);
                        UltiDraw.End();
                    }

                    Color[] colors = AnimationAuthoring.StyleColors;

                    for (int i = 0; i < AnimationAuthoring.LookUpPoints.Length; i++)
                    {
                        //draw every 4th point
                        if ((i % (4 * AnimationAuthoring.TimeInterval) != 0) || !AnimationAuthoring.GetControlPoint(i * AnimationAuthoring.TimeDelta, +1).Inspector)
                        {
                            continue;
                        }

                        float r = 0f;
                        float g = 0f;
                        float b = 0f;

                        for (int j = 0; j < AnimationAuthoring.LookUpPoints[i].GetStyle().Length; j++)
                        {
                            r += AnimationAuthoring.LookUpPoints[i].GetStyle()[j] * colors[j].r;
                            g += AnimationAuthoring.LookUpPoints[i].GetStyle()[j] * colors[j].g;
                            b += AnimationAuthoring.LookUpPoints[i].GetStyle()[j] * colors[j].b;
                        }
                        Color color = new Color(r, g, b, 1f);
                        UltiDraw.Begin();
                        UltiDraw.DrawCube(AnimationAuthoring.GetPointPositon(i * AnimationAuthoring.TimeDelta), Quaternion.identity, 0.05f, color);
                        UltiDraw.End();
                    }
                }

                if (ShowTrajectory)
                {
                    UltiDraw.SetDepthRendering(false);
                    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.SetDepthRendering(false);
                    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();
                }

                float[] a = new float[100];
                for (int i = 0; i < a.Length; i++)
                {
                    float x = (float)i / (float)(a.Length - 1);
                    a[i] = SmoothStep(x, 2f, .8f);
                }

                UltiDraw.Begin();
                //UltiDraw.DrawGUIFunction(new Vector2(0.5f, 0.5f), new Vector2(1f, 1f), a, 0f, 1f, Color.white, Color.black);
                UltiDraw.End();

                if (DrawLatentSpaces)
                {
                    UltiDraw.SetDepthRendering(false);

                    UltiDraw.Begin();
                    float  YMin = 0f;
                    float  YMax = 0f;
                    Tensor t0   = NN.GetTensor("W0");
                    Tensor t1   = NN.GetTensor("W1");
                    Tensor t2   = NN.GetTensor("W2");

                    float[] arr0 = new float[t0.GetCols()];
                    float[] arr1 = new float[t1.GetCols()];
                    float[] arr2 = new float[t2.GetCols()];
                    for (int i = 0; i < t0.GetCols(); i++)
                    {
                        float x = (float)i / (float)(arr0.Length - 1);
                        //arr[i] = SmoothStep(x, 2f, .8f);
                        float colMean = 0f;
                        for (int j = 0; j < t0.GetRows(); j++)
                        {
                            colMean += t0.GetValue(j, i);
                        }
                        arr0[i] = colMean;
                    }
                    for (int i = 0; i < t1.GetCols(); i++)
                    {
                        float x = (float)i / (float)(arr1.Length - 1);
                        //arr[i] = SmoothStep(x, 2f, .8f);
                        float colMean = 0f;
                        for (int j = 0; j < t1.GetRows(); j++)
                        {
                            colMean += t1.GetValue(j, i);
                        }
                        arr1[i] = colMean;
                    }
                    for (int i = 0; i < t2.GetCols(); i++)
                    {
                        float x = (float)i / (float)(arr2.Length - 1);
                        //arr[i] = SmoothStep(x, 2f, .8f);
                        float colMean = 0f;
                        for (int j = 0; j < t2.GetRows(); j++)
                        {
                            colMean += t2.GetValue(j, i);
                        }
                        arr2[i] = colMean;
                    }
                    YMin = -10f;
                    YMax = 10f;

                    UltiDraw.DrawGUIFunction(new Vector2(0.5f, 0.9f), new Vector2(0.4f, 0.1f), arr0, YMin, YMax, UltiDraw.LightGrey, UltiDraw.Black, 0.002f, UltiDraw.BlackGrey);
                    YMin = -16f;
                    YMax = 13f;
                    UltiDraw.DrawGUIFunction(new Vector2(0.5f, 0.79f), new Vector2(0.4f, 0.1f), arr1, YMin, YMax, UltiDraw.LightGrey, UltiDraw.Black, 0.002f, UltiDraw.BlackGrey);

                    YMin = -2f;
                    YMax = 2f;
                    UltiDraw.DrawGUIFunction(new Vector2(0.5f, 0.68f), new Vector2(0.4f, 0.1f), arr2, YMin, YMax, UltiDraw.LightGrey, UltiDraw.Black, 0.002f, UltiDraw.BlackGrey);

                    UltiDraw.End();
                }
            }
        }
Ejemplo n.º 23
0
        void OnRenderObject()
        {
            if (Application.isPlaying)
            {
                if (NN.Parameters == null)
                {
                    return;
                }

                float[] arr2 = new float[100];
                for (int i = 0; i < arr2.Length; i++)
                {
                    float x = (float)i / (float)(arr2.Length - 1);
                    arr2[i] = SmoothStep(x, 2f, .8f);
                }

                UltiDraw.Begin();
                //UltiDraw.DrawGUIFunction(new Vector2(0.7f, 0.8f), new Vector2(0.1f, 0.1f), arr2, 0f, 1f, Color.white, Color.black);
                if (DrawNetworkSpace)
                {
                    float  YMin = 0f;
                    float  YMax = 0f;
                    Tensor t    = new Tensor(0, 0);
                    if (DrawFirstLayer)
                    {
                        YMin = -10f;
                        YMax = 10f;
                        t    = NN.GetTensor("W0");
                    }
                    else if (DrawSecondLayer)
                    {
                        YMin = -16f;
                        YMax = 13f;
                        t    = NN.GetTensor("W1");
                    }
                    else if (DrawThirdLayer)
                    {
                        YMin = -2f;
                        YMax = 2f;
                        t    = NN.GetTensor("W2");
                    }

                    float[] arr = new float[t.GetCols()];
                    for (int i = 0; i < t.GetCols(); i++)
                    {
                        float x = (float)i / (float)(arr.Length - 1);
                        //arr[i] = SmoothStep(x, 2f, .8f);
                        float colMean = 0f;
                        for (int j = 0; j < t.GetRows(); j++)
                        {
                            colMean += t.GetValue(j, i);
                        }
                        arr[i] = colMean;
                    }

                    Debug.Log(string.Format("MIN: {0}, MAX: {1} COLS: {2}", arr.Min(), arr.Max(), t.GetCols()));
                    UltiDraw.DrawGUIFunction(new Vector2(0.5f, 0.5f), new Vector2(1f, 1f), arr, YMin, YMax, Color.white, Color.black);
                }
                UltiDraw.End();
                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();
                //UltiDraw.DrawGUIHorizontalBar(new Vector2(0.5f, 0.74f), new Vector2(0.25f, 0.025f), UltiDraw.DarkGrey.Transparent(0.5f), 0.0025f, UltiDraw.Black, Trajectory.Points[RootPointIndex].GetVelocity().magnitude / 4f, UltiDraw.DarkGreen);
                UltiDraw.End();
            }
        }
    void OnRenderObject()
    {
        if (ShowTrajectory)
        {
            if (Application.isPlaying)
            {
                //UltiDraw.Begin();
                //UltiDraw.DrawLine(Trajectory.Points[RootPointIndex].GetPosition(), Trajectory.Points[RootPointIndex].GetPosition() + TargetDirection, 0.05f, 0f, UltiDraw.Orange.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 (Application.isPlaying)
        {
            /*
             * for(int i=5; i<6; i++) {
             *      for(int j=0; j<Character.Hierarchy.Length; j++) {
             *              Matrix4x4 mat = Matrix4x4.TRS(PastPositions[j][i*10], Quaternion.LookRotation(PastForwards[j][i*10], PastUps[j][i*10]), Vector3.one);
             *              Character.Hierarchy[j].SetTransformation(mat);
             *      }
             *      Character.DrawSimple(Color.Lerp(UltiDraw.Blue, UltiDraw.Cyan, 1f - (float)(i+1)/6f).Transparent(0.75f));
             * }
             */
            /*
             * for(int i=0; i<5; i++) {
             *      for(int j=0; j<Character.Hierarchy.Length; j++) {
             *              Matrix4x4 mat = Matrix4x4.TRS(FuturePositions[j][i], Quaternion.LookRotation(FutureForwards[j][i], FutureUps[j][i]), Vector3.one);
             *              Character.Hierarchy[j].SetTransformation(mat);
             *      }
             *      Character.DrawSimple(Color.Lerp(UltiDraw.Red, UltiDraw.Orange, (float)(i+1)/5f).Transparent(0.75f));
             * }
             */
        }

        Character.FetchTransformations(transform);
        Character.Draw();

        if (ShowVelocities)
        {
            if (Application.isPlaying)
            {
                UltiDraw.Begin();
                for (int i = 0; i < Joints.Length; i++)
                {
                    Character.Segment segment = Character.FindSegment(Joints[i].name);
                    if (segment != null)
                    {
                        UltiDraw.DrawArrow(
                            Joints[i].position,
                            Joints[i].position + Velocities[i],
                            0.75f,
                            0.0075f,
                            0.05f,
                            UltiDraw.Purple.Transparent(0.5f)
                            );
                    }
                }
                UltiDraw.End();
            }
        }
    }
Ejemplo n.º 25
0
    protected override void OnRenderObjectDerived()
    {
        Controller.Draw();

        if (ShowRoot)
        {
            RootSeries.Draw();
        }
        if (ShowGoal)
        {
            GoalSeries.Draw();
        }
        if (ShowCurrent)
        {
            StyleSeries.Draw();
        }
        if (ShowPhase)
        {
            PhaseSeries.Draw();
        }
        if (ShowContacts)
        {
            ContactSeries.Draw();
        }
        if (ShowEnvironment)
        {
            Environment.Draw(UltiDraw.Mustard.Transparent(0.25f));
        }
        if (ShowInteraction)
        {
            Geometry.Draw(UltiDraw.Cyan.Transparent(0.25f));
        }

        if (ShowBiDirectional)
        {
            UltiDraw.Begin();
            for (int i = 0; i < PosePrediction.Length; i++)
            {
                UltiDraw.DrawSphere(PosePrediction[i], Quaternion.identity, 0.05f, UltiDraw.Magenta);
            }
            for (int i = 0; i < RootPrediction.Length; i++)
            {
                UltiDraw.DrawCircle(RootPrediction[i].GetPosition(), 0.05f, UltiDraw.DarkRed.Darken(0.5f));
                UltiDraw.DrawArrow(RootPrediction[i].GetPosition(), RootPrediction[i].GetPosition() + 0.1f * RootPrediction[i].GetForward(), 0f, 0f, 0.025f, UltiDraw.DarkRed);
                if (i < RootPrediction.Length - 1)
                {
                    UltiDraw.DrawLine(RootPrediction[i].GetPosition(), RootPrediction[i + 1].GetPosition(), UltiDraw.Black);
                }
            }
            for (int i = 0; i < GoalPrediction.Length; i++)
            {
                UltiDraw.DrawCircle(GoalPrediction[i].GetPosition(), 0.05f, UltiDraw.DarkGreen.Darken(0.5f));
                UltiDraw.DrawArrow(GoalPrediction[i].GetPosition(), GoalPrediction[i].GetPosition() + 0.1f * GoalPrediction[i].GetForward(), 0f, 0f, 0.025f, UltiDraw.DarkGreen);
                if (i < GoalPrediction.Length - 1)
                {
                    UltiDraw.DrawLine(GoalPrediction[i].GetPosition(), GoalPrediction[i + 1].GetPosition(), UltiDraw.Black);
                }
            }
            UltiDraw.End();
        }
    }
Ejemplo n.º 26
0
    public void Draw(Color boneColor, Color jointColor, float alpha)
    {
        UltiDraw.Begin();
        if (DrawRoot)
        {
            UltiDraw.DrawTranslateGizmo(GetRoot().position, GetRoot().rotation, 0.1f);
            UltiDraw.DrawSphere(GetRoot().position, GetRoot().rotation, 0.025f, UltiDraw.Black);
            UltiDraw.DrawLine(Bones[0].Transform.position, GetRoot().position, UltiDraw.Mustard);
        }

        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)
        {
            UltiDraw.Begin();
            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.Purple.Transparent(0.5f)
                    );
            }
            UltiDraw.End();
        }

        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();
    }
Ejemplo n.º 27
0
    public void Draw(int step = 1)
    {
        UltiDraw.Begin();

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

        //Connections
        for (int i = 0; i < Points.Length - step; i += step)
        {
            UltiDraw.DrawLine(Points[i].GetPosition(), Points[i + step].GetPosition(), 0.01f, UltiDraw.Black);
        }

        //Velocities
        for (int i = 0; i < Points.Length; i += step)
        {
            //Vector3 start = Points[i].GetPosition();
            //Vector3 end = Points[i].GetPosition() + Points[i].GetVelocity();
            //end = Utility.ProjectGround(end, LayerMask.GetMask("Ground"));
            //UltiDraw.DrawLine(start, end, 0.025f, 0f, UltiDraw.DarkGreen.Transparent(0.5f));

            /*
             * float r = 0f;
             * float g = 0f;
             * float b = 0f;
             * for(int j=0; j<Points[i].Styles.Length; j++) {
             *      r += Points[i].Styles[j] * colors[j].r;
             *      g += Points[i].Styles[j] * colors[j].g;
             *      b += Points[i].Styles[j] * colors[j].b;
             * }
             * UltiDraw.DrawLine(Points[i].GetPosition(), Points[i].GetPosition() + Points[i].GetVelocity(), 0.025f, 0f, new Color(r, g, b, 0.5f));
             */

            //UltiDraw.DrawLine(Points[i].GetPosition(), Points[i].GetPosition() + Points[i].GetVelocity(), 0.025f, 0f, UltiDraw.DarkGreen.Transparent(0.5f));
        }

        //Directions
        for (int i = 0; i < Points.Length; i += step)
        {
            //Vector3 start = Points[i].GetPosition();
            //Vector3 end = Points[i].GetPosition() + 0.25f * Points[i].GetDirection();
            //end = Utility.ProjectGround(end, LayerMask.GetMask("Ground"));
            //UltiDraw.DrawLine(start, end, 0.025f, 0f, UltiDraw.Orange.Transparent(0.75f));
            UltiDraw.DrawLine(Points[i].GetPosition(), Points[i].GetPosition() + 0.25f * Points[i].GetDirection(), 0.025f, 0f, UltiDraw.Orange.Transparent(0.75f));
        }

        //Styles
        if (Styles.Length > 0)
        {
            for (int i = 0; i < Points.Length; i += step)
            {
                float r = 0f;
                float g = 0f;
                float b = 0f;
                for (int j = 0; j < Points[i].Styles.Length; j++)
                {
                    r += Points[i].Styles[j] * colors[j].r;
                    g += Points[i].Styles[j] * colors[j].g;
                    b += Points[i].Styles[j] * colors[j].b;
                }
                Color color = new Color(r, g, b, 1f);
                UltiDraw.DrawCube(Points[i].GetPosition(), Points[i].GetRotation(), 0.05f, color);
            }
        }

        //Signals

        /*
         * if(Styles.Length > 0) {
         *      for(int i=0; i<Points.Length; i+=step) {
         *              Color color = UltiDraw.Black;
         *              for(int j=0; j<Points[i].Signals.Length; j++) {
         *                      if(Points[i].Signals[j]) {
         *                              color = colors[j];
         *                              break;
         *                      }
         *              }
         *              UltiDraw.DrawCone(Points[i].GetPosition(), Quaternion.identity, 0.1f, 0.1f, color);
         *      }
         * }
         */

        /*
         * //Speed
         * for(int i=0; i<Points.Length; i+=step) {
         *      float r = 0f;
         *      float g = 0f;
         *      float b = 0f;
         *      for(int j=0; j<Points[i].Styles.Length; j++) {
         *              r += Points[i].Styles[j] * colors[j].r;
         *              g += Points[i].Styles[j] * colors[j].g;
         *              b += Points[i].Styles[j] * colors[j].b;
         *      }
         *      UltiDraw.DrawArrow(Points[i].GetPosition(), Points[i].GetPosition() + Points[i].GetSpeed() * Points[i].GetTransformation().GetForward(), 0.8f, 0.02f, 0.04f, new Color(r, g, b, 0.5f));
         * }
         */

        //Projections
        //for(int i=0; i<Points.Length; i+=step) {
        //	Vector3 right = Points[i].GetRightSample();
        //	Vector3 left = Points[i].GetLeftSample();
        //	UltiDraw.DrawCircle(right, 0.01f, UltiDraw.Yellow);
        //	UltiDraw.DrawCircle(left, 0.01f, UltiDraw.Yellow);
        //}

        //Slopes
        //for(int i=0; i<Points.Length; i+=step) {
        //	UltiDraw.DrawLine(Points[i].GetPosition(), Points[i].GetPosition() + 1f * Points[i].GetSlope() * Vector3.up, 0.025f, 0f, UltiDraw.Blue.Transparent(0.75f));
        //}

        //Positions
        for (int i = 0; i < Points.Length; i += step)
        {
            UltiDraw.DrawCircle(Points[i].GetPosition(), 0.025f, UltiDraw.Black);
        }

        //Phase
        for (int i = 0; i < Points.Length; i += step)
        {
            //UltiDraw.DrawLine(Points[i].GetPosition(), Points[i].GetPosition() + Points[i].Phase*Vector3.up, UltiDraw.IndianRed);
            UltiDraw.DrawArrow(Points[i].GetPosition(), Points[i].GetPosition() + Points[i].Phase * Vector3.up, 0.8f, 0.025f, 0.05f, UltiDraw.IndianRed.Transparent(0.5f));
            //UltiDraw.DrawSphere(Points[i].GetPosition(), Quaternion.identity, Points[i].PhaseUpdate / 10f, UltiDraw.Purple.Transparent(0.25f));
        }

        UltiDraw.End();
    }
Ejemplo n.º 28
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();
            }
        }
    }
Ejemplo n.º 29
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()));
         * 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();
         */
    }
Ejemplo n.º 30
0
    protected override void DerivedDraw(MotionEditor editor)
    {
        UltiDraw.Begin();

        Frame frame = editor.GetCurrentFrame();

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

        if (ShowDebug)
        {
            for (int i = 0; i < Sensors.Length; i++)
            {
                if (Sensors[i].GetContact(frame, editor.Mirror) == 1f)
                {
                    Vector3 contact   = Sensors[i].GetContactPoint(frame, editor.Mirror);
                    Vector3 corrected = Sensors[i].GetCorrectedContactPoint(frame, editor.Mirror);
                    UltiDraw.DrawArrow(contact, corrected, 0.8f, 0.01f, DrawScale * 0.025f, colors[i].Transparent(0.5f));
                    UltiDraw.DrawSphere(contact, Quaternion.identity, DrawScale * 0.025f, UltiDraw.Yellow);
                    UltiDraw.DrawSphere(corrected, Quaternion.identity, DrawScale * 0.05f, UltiDraw.Gold.Transparent(0.5f));
                }
            }
            for (int i = 0; i < Sensors.Length; i++)
            {
                Matrix4x4 bone      = frame.GetBoneTransformation(Sensors[i].Bone, editor.Mirror);
                Matrix4x4 corrected = Sensors[i].GetCorrectedTransformation(frame, editor.Mirror);
                UltiDraw.DrawCube(bone, DrawScale * 0.025f, UltiDraw.DarkRed.Transparent(0.5f));
                UltiDraw.DrawLine(bone.GetPosition(), corrected.GetPosition(), colors[i].Transparent(0.5f));
                UltiDraw.DrawCube(corrected, DrawScale * 0.025f, UltiDraw.DarkGreen.Transparent(0.5f));
            }
        }

        if (ShowSensors)
        {
            for (int i = 0; i < Sensors.Length; i++)
            {
                Quaternion rot = editor.GetActor().GetBoneTransformation(Sensors[i].GetName()).GetRotation();
                Vector3    pos = editor.GetActor().GetBoneTransformation(Sensors[i].GetName()).GetPosition() + rot * Sensors[i].Offset;
                UltiDraw.DrawCube(pos, rot, DrawScale * 0.025f, UltiDraw.Black);
                UltiDraw.DrawWireSphere(pos, rot, 2f * Sensors[i].Threshold, colors[i].Transparent(0.25f));
                if (Sensors[i].GetContact(frame, editor.Mirror) == 1f)
                {
                    UltiDraw.DrawSphere(pos, rot, 2f * Sensors[i].Threshold, colors[i]);
                }
                else
                {
                    UltiDraw.DrawSphere(pos, rot, 2f * Sensors[i].Threshold, colors[i].Transparent(0.125f));
                }
            }
        }

        if (ShowTolerances)
        {
            for (int i = 0; i < Sensors.Length; i++)
            {
                Quaternion rot = editor.GetActor().GetBoneTransformation(Sensors[i].GetName()).GetRotation();
                Vector3    pos = editor.GetActor().GetBoneTransformation(Sensors[i].GetName()).GetPosition() + rot * Sensors[i].Offset;
                UltiDraw.DrawWireSphere(pos, rot, 2f * (Sensors[i].Tolerance + Sensors[i].Threshold), UltiDraw.DarkGrey.Transparent(0.25f));
            }
        }

        if (ShowContacts)
        {
            for (int i = 0; i < Sensors.Length; i++)
            {
                if (Sensors[i].Edit != Sensor.ID.None)
                {
                    for (float j = 0f; j <= Data.GetTotalTime(); j += Mathf.Max(Step, 1) / Data.Framerate)
                    {
                        Frame reference = Data.GetFrame(j);
                        if (Sensors[i].GetContact(reference, editor.Mirror) == 1f)
                        {
                            UltiDraw.DrawSphere(Sensors[i].GetContactPoint(reference, editor.Mirror), Quaternion.identity, DrawScale * 0.025f, colors[i]);
                        }
                    }
                }
            }
        }

        /*
         * if(ShowSkeletons) {
         *      UltiDraw.End();
         *      float start = Mathf.Clamp(frame.Timestamp-Window, 0f, Data.GetTotalTime());
         *      float end = Mathf.Clamp(frame.Timestamp+Window, 0f, Data.GetTotalTime());
         *      float inc = Mathf.Max(SkeletonStep, 1)/Data.Framerate;
         *      for(float j=start; j<=end; j+=inc) {
         *              Frame reference = Data.GetFrame(j);
         *              float weight = (j-start+inc) / (end-start+inc);
         *              editor.GetActor().Sketch(reference.GetBoneTransformations(editor.GetActor().GetBoneNames(), editor.Mirror), Color.Lerp(UltiDraw.Cyan, UltiDraw.Magenta, weight).Transparent(weight));
         *      }
         *      UltiDraw.Begin();
         * }
         */

        if (TrueMotionTrajectory || CorrectedMotionTrajectory)
        {
            for (int i = 0; i < Sensors.Length; i++)
            {
                if (Sensors[i].Edit != Sensor.ID.None)
                {
                    Vector3 previousPos       = Vector3.zero;
                    Vector3 previousCorrected = Vector3.zero;
                    float   start             = Mathf.Clamp(frame.Timestamp - PastTrajectoryWindow, 0f, Data.GetTotalTime());
                    float   end = Mathf.Clamp(frame.Timestamp + FutureTrajectoryWindow, 0f, Data.GetTotalTime());
                    for (float j = start; j <= end; j += Mathf.Max(Step, 1) / Data.Framerate)
                    {
                        Frame     reference = Data.GetFrame(j);
                        Matrix4x4 bone      = reference.GetBoneTransformation(Sensors[i].Bone, editor.Mirror);
                        Matrix4x4 corrected = Sensors[i].GetCorrectedTransformation(reference, editor.Mirror);
                        if (j > start)
                        {
                            if (TrueMotionTrajectory)
                            {
                                UltiDraw.DrawArrow(previousPos, bone.GetPosition(), 0.8f, DrawScale * 0.005f, DrawScale * 0.025f, UltiDraw.DarkRed.Lighten(0.5f).Transparent(0.5f));
                            }
                            if (CorrectedMotionTrajectory)
                            {
                                UltiDraw.DrawArrow(previousCorrected, corrected.GetPosition(), 0.8f, DrawScale * 0.005f, DrawScale * 0.025f, UltiDraw.DarkGreen.Lighten(0.5f).Transparent(0.5f));
                            }
                            //UltiDraw.DrawLine(previousPos, bone.GetPosition(), UltiDraw.DarkRed.Transparent(0.5f));
                            //UltiDraw.DrawLine(previousCorrected, corrected.GetPosition(), UltiDraw.DarkGreen.Transparent(0.5f));
                        }
                        previousPos       = bone.GetPosition();
                        previousCorrected = corrected.GetPosition();
                        if (TrueMotionTrajectory)
                        {
                            UltiDraw.DrawCube(bone, DrawScale * 0.025f, UltiDraw.DarkRed.Transparent(0.5f));
                        }
                        //UltiDraw.DrawLine(bone.GetPosition(), corrected.GetPosition(), colors[i].Transparent(0.5f));
                        if (CorrectedMotionTrajectory)
                        {
                            UltiDraw.DrawCube(corrected, DrawScale * 0.025f, UltiDraw.DarkGreen.Transparent(0.5f));
                        }
                    }
                }
            }
        }

        if (ContactTrajectories)
        {
            for (int i = 0; i < Sensors.Length; i++)
            {
                if (Sensors[i].Edit != Sensor.ID.None)
                {
                    float start = Mathf.Clamp(frame.Timestamp - Window, 0f, Data.GetTotalTime());
                    float end   = Mathf.Clamp(frame.Timestamp + Window, 0f, Data.GetTotalTime());
                    for (float j = 0f; j <= Data.GetTotalTime(); j += Mathf.Max(Step, 1) / Data.Framerate)
                    {
                        Frame reference = Data.GetFrame(j);
                        if (Sensors[i].GetContact(reference, editor.Mirror) == 1f)
                        {
                            Vector3 contact   = Sensors[i].GetContactPoint(reference, editor.Mirror);
                            Vector3 corrected = Sensors[i].GetCorrectedContactPoint(reference, editor.Mirror);
                            UltiDraw.DrawArrow(contact, corrected, 0.8f, Vector3.Distance(contact, corrected) * DrawScale * 0.025f, Vector3.Distance(contact, corrected) * DrawScale * 0.1f, colors[i].Lighten(0.5f).Transparent(0.5f));
                            UltiDraw.DrawSphere(contact, Quaternion.identity, DrawScale * 0.0125f, colors[i].Transparent(0.5f));
                            UltiDraw.DrawSphere(corrected, Quaternion.identity, DrawScale * 0.05f, colors[i]);
                        }
                    }
                }
            }
        }

        if (ShowDistances)
        {
            for (int i = 0; i < Sensors.Length; i++)
            {
                if (Sensors[i].Edit != Sensor.ID.None)
                {
                    for (float j = frame.Timestamp - PastTrajectoryWindow; j <= frame.Timestamp + FutureTrajectoryWindow; j += Mathf.Max(Step, 1) / Data.Framerate)
                    {
                        Frame reference = Data.GetFrame(j);
                        if (Sensors[i].GetContact(reference, editor.Mirror) == 1f)
                        {
                            UltiDraw.DrawArrow(Sensors[i].GetContactPoint(reference, editor.Mirror), Sensors[i].GetContactPoint(reference, editor.Mirror) - Sensors[i].GetContactDistance(reference, editor.Mirror), 0.8f, DrawScale * 0.0025f, DrawScale * 0.01f, colors[i].Transparent(0.5f));
                        }
                    }
                }
            }
        }

        UltiDraw.End();
    }