Example #1
0
        /// <inheritdoc/>
        protected internal override void Draw()
        {
            HandleDrawing.Layer     = 1;
            HandleDrawing.Transform = Matrix4.TRS(Position, Rotation, Vector3.One);
            float handleSize = Handles.GetHandleSize(EditorApplication.SceneViewCamera, position);

            // Draw arcs
            if (xAxis.State == HandleSlider.StateType.Active)
            {
                HandleDrawing.Color = Color.White;
            }
            else if (xAxis.State == HandleSlider.StateType.Hover)
            {
                HandleDrawing.Color = Color.BansheeOrange;
            }
            else
            {
                HandleDrawing.Color = Color.Red;
            }

            HandleDrawing.DrawWireArc(Vector3.Zero, Vector3.XAxis, 1.0f, GetXStartAngle(false), new Degree(180.0f), handleSize);

            if (yAxis.State == HandleSlider.StateType.Active)
            {
                HandleDrawing.Color = Color.White;
            }
            else if (yAxis.State == HandleSlider.StateType.Hover)
            {
                HandleDrawing.Color = Color.BansheeOrange;
            }
            else
            {
                HandleDrawing.Color = Color.Green;
            }

            HandleDrawing.DrawWireArc(Vector3.Zero, Vector3.YAxis, 1.0f, GetYStartAngle(false), new Degree(180.0f), handleSize);

            if (zAxis.State == HandleSlider.StateType.Active)
            {
                HandleDrawing.Color = Color.White;
            }
            else if (zAxis.State == HandleSlider.StateType.Hover)
            {
                HandleDrawing.Color = Color.BansheeOrange;
            }
            else
            {
                HandleDrawing.Color = Color.Blue;
            }

            HandleDrawing.DrawWireArc(Vector3.Zero, Vector3.ZAxis, 1.0f, GetZStartAngle(false), new Degree(180.0f), handleSize);

            // Draw "bounds" and free handle
            Color   gray         = new Color(1.0f, 1.0f, 1.0f, 0.3f);
            Vector3 cameraNormal = EditorApplication.SceneViewCamera.SceneObject.Rotation.Rotate(Vector3.ZAxis);

            HandleDrawing.Transform = Matrix4.TRS(Position, Quaternion.Identity, Vector3.One);
            HandleDrawing.Color     = gray;

            HandleDrawing.DrawWireDisc(cameraNormal * 0.1f, cameraNormal, 1.0f, handleSize);

            if (freeAxis.State == HandleSlider.StateType.Active)
            {
                HandleDrawing.Color = Color.White;
            }
            else if (freeAxis.State == HandleSlider.StateType.Hover)
            {
                HandleDrawing.Color = Color.BansheeOrange;
            }
            else
            {
                HandleDrawing.Color = gray;
            }

            HandleDrawing.DrawWireDisc(Vector3.Zero, cameraNormal, 1.2f, handleSize);

            // Draw active rotation pie
            HandleDrawing.Color     = gray;
            HandleDrawing.Transform = Matrix4.TRS(Position, EditorApplication.SceneViewCamera.SceneObject.Rotation, Vector3.One);

            if (freeAxis.State == HandleSlider.StateType.Active)
            {
                HandleDrawing.DrawArc(Vector3.Zero, -Vector3.ZAxis, 1.2f, freeAxis.StartAngle, -freeAxis.Delta, handleSize);
            }

            HandleDrawing.Transform = Matrix4.TRS(Position, dragStartRotation, Vector3.One);

            if (xAxis.State == HandleSlider.StateType.Active)
            {
                HandleDrawing.DrawArc(Vector3.Zero, Vector3.XAxis, 1.0f, xAxis.StartAngle, -xAxis.Delta, handleSize);
            }
            else if (yAxis.State == HandleSlider.StateType.Active)
            {
                HandleDrawing.DrawArc(Vector3.Zero, Vector3.YAxis, 1.0f, yAxis.StartAngle, -yAxis.Delta, handleSize);
            }
            else if (zAxis.State == HandleSlider.StateType.Active)
            {
                HandleDrawing.DrawArc(Vector3.Zero, Vector3.ZAxis, 1.0f, zAxis.StartAngle, -zAxis.Delta, handleSize);
            }
        }