Esempio n. 1
0
        public override void OnDrawSpacedGizmo(TArcCone arcCone)
        {
            var arc = arcCone.arc * Mathf.Rad2Deg;

            extremities.Build(arcCone.cone.baseRadius, arcCone.cone.topRadius, arcCone.cone.height, arc);
            var arcDirection = Quaternion.AngleAxis(arc, Vector3.up) * Vector3.forward;

            if (Event.current != null && Event.current.type == EventType.MouseDown)
            {
                m_Dragging = true;
            }
            if (Event.current != null && Event.current.type == EventType.MouseUp)
            {
                m_Dragging = false;
            }

            if (!m_Dragging)
            {
                topRadiusScreen  = (HandleUtility.WorldToGUIPoint(extremities.topCap) - HandleUtility.WorldToGUIPoint(extremities.topCap + Vector3.forward * arcCone.cone.topRadius)).magnitude;
                baseRadiusScreen = (HandleUtility.WorldToGUIPoint(extremities.bottomCap) - HandleUtility.WorldToGUIPoint(extremities.bottomCap + Vector3.forward * arcCone.cone.baseRadius)).magnitude;
            }

            using (new Handles.DrawingScope(Handles.matrix * arcCone.cone.transform))
            {
                if (topRadiusScreen > 2)
                {
                    Handles.DrawWireArc(extremities.topCap, Vector3.up, Vector3.forward, arc, arcCone.cone.topRadius);
                }

                if (baseRadiusScreen > 2)
                {
                    Handles.DrawWireArc(extremities.bottomCap, Vector3.up, Vector3.forward, arc, arcCone.cone.baseRadius);
                }

                for (int i = 0; i < extremities.extremities.Count / 2 && i < extremities.visibleCount; ++i)
                {
                    Handles.DrawLine(extremities.extremities[i], extremities.extremities[i + extremities.extremities.Count / 2]);
                }

                Handles.DrawLine(extremities.topCap, extremities.extremities[0]);
                Handles.DrawLine(extremities.bottomCap, extremities.extremities[extremities.extremities.Count / 2]);

                Handles.DrawLine(extremities.topCap, extremities.topCap + arcDirection * arcCone.cone.topRadius);
                Handles.DrawLine(extremities.bottomCap, arcDirection * arcCone.cone.baseRadius);

                Handles.DrawLine(arcDirection * arcCone.cone.baseRadius, extremities.topCap + arcDirection * arcCone.cone.topRadius);
                var radius = arcCone.cone.baseRadius > arcCone.cone.topRadius ? arcCone.cone.baseRadius : arcCone.cone.topRadius;
                var center = arcCone.cone.baseRadius > arcCone.cone.topRadius ? Vector3.zero : extremities.topCap;

                if (radius != 0)
                {
                    ArcGizmo(center, radius, arc, m_ArcProperty, Quaternion.identity);
                }
            }

            VFXConeGizmo.DrawCone(this, arcCone.cone, ref extremities, m_CenterProperty, m_AnglesProperty, m_ScaleProperty, m_baseRadiusProperty, m_topRadiusProperty, m_HeightProperty, baseRadiusScreen, topRadiusScreen);
        }
Esempio n. 2
0
        public override void OnDrawSpacedGizmo(ArcCone arcCone)
        {
            float arc  = arcCone.arc * Mathf.Rad2Deg;
            Cone  cone = new Cone {
                center = arcCone.center, radius0 = arcCone.radius0, radius1 = arcCone.radius1, height = arcCone.height
            };

            extremities.Build(cone, arc);
            Vector3 arcDirection = Quaternion.AngleAxis(arc, Vector3.up) * Vector3.forward;

            if (Event.current != null && Event.current.type == EventType.MouseDown)
            {
                m_Dragging = true;
            }
            if (Event.current != null && Event.current.type == EventType.MouseUp)
            {
                m_Dragging = false;
            }

            if (!m_Dragging)
            {
                radius1Screen = (HandleUtility.WorldToGUIPoint(extremities.topCap) - HandleUtility.WorldToGUIPoint(extremities.topCap + Vector3.forward * cone.radius1)).magnitude;
                radius0Screen = (HandleUtility.WorldToGUIPoint(extremities.bottomCap) - HandleUtility.WorldToGUIPoint(extremities.bottomCap + Vector3.forward * cone.radius0)).magnitude;
            }

            using (new Handles.DrawingScope(Handles.matrix * Matrix4x4.Translate(arcCone.center)))
            {
                if (radius1Screen > 2)
                {
                    Handles.DrawWireArc(extremities.topCap, Vector3.up, Vector3.forward, arc, arcCone.radius1);
                }

                if (radius0Screen > 2)
                {
                    Handles.DrawWireArc(extremities.bottomCap, Vector3.up, Vector3.forward, arc, arcCone.radius0);
                }

                for (int i = 0; i < extremities.extremities.Count / 2 && i < extremities.visibleCount; ++i)
                {
                    Handles.DrawLine(extremities.extremities[i], extremities.extremities[i + extremities.extremities.Count / 2]);
                }

                Handles.DrawLine(extremities.topCap, extremities.extremities[0]);
                Handles.DrawLine(extremities.bottomCap, extremities.extremities[extremities.extremities.Count / 2]);


                Handles.DrawLine(extremities.topCap, extremities.topCap + arcDirection * arcCone.radius1);
                Handles.DrawLine(extremities.bottomCap, arcDirection * arcCone.radius0);

                Handles.DrawLine(arcDirection * arcCone.radius0, extremities.topCap + arcDirection * arcCone.radius1);
                float   radius = arcCone.radius0 > arcCone.radius1 ? arcCone.radius0 : arcCone.radius1;
                Vector3 center = arcCone.radius0 > arcCone.radius1 ? Vector3.zero : extremities.topCap;

                if (radius != 0)
                {
                    ArcGizmo(center, radius, arc, m_ArcProperty, Quaternion.identity, true);
                }
            }

            VFXConeGizmo.DrawCone(cone, this, ref extremities, m_CenterProperty, m_Radius0Property, m_Radius1Property, m_HeightProperty, radius0Screen, radius1Screen);
        }
Esempio n. 3
0
 public override Bounds OnGetSpacedGizmoBounds(TArcCone value)
 {
     return(VFXConeGizmo.GetBoundsFromCone(value.cone));
 }