Ejemplo n.º 1
0
        // ================================================================================ Scene
        public override void OnSceneGui()
        {
            var settings = Settings;

            var rotation = Tools.pivotRotation == PivotRotation.Global ? Quaternion.identity : Curve.transform.rotation;

            if (Curve.PointsCount != 0 && settings.VRay)
            {
                painter = painter ?? new BGCurvePainterHandles(Editor.Math);
                painter.DrawCurve();
            }

            editorPoint.OnSceneGUIStart(settings);

            var frustum = GeometryUtility.CalculateFrustumPlanes(SceneView.currentDrawingSceneView.camera);

            Curve.ForEach((point, index, count) => editorPoint.OnSceneGUI(point, index, settings, rotation, frustum));

            //tangents
            if (settings.ShowCurve && settings.ShowTangents && Editor.Math.SectionsCount > 0 && Editor.Math.IsCalculated(BGCurveBaseMath.Field.Tangent))
            {
                BGEditorUtility.SwapHandlesColor(settings.TangentsColor, () =>
                {
                    var math          = Editor.Math;
                    var sectionsCount = math.SectionsCount;
                    var sections      = math.SectionInfos;

                    for (var i = 0; i < sectionsCount; i++)
                    {
                        var section = sections[i];
                        var points  = section.Points;
                        ShowTangent(points[0].Position, points[0].Tangent, settings.TangentsSize);
                        if (settings.TangentsPerSection > 1)
                        {
                            var sectionLength = section.Distance;
                            var part          = sectionLength / settings.TangentsPerSection;
                            for (var j = 1; j < settings.TangentsPerSection; j++)
                            {
                                var distanceWithinSection = part * j;
                                Vector3 position;
                                Vector3 tangent;
                                section.CalcByDistance(distanceWithinSection, out position, out tangent, true, true);
                                ShowTangent(position, tangent, settings.TangentsSize);
                            }
                        }
                    }
                });
            }


            editorSelection.Scene(rotation);

            var currentEvent = Event.current;

            overlay.Process(currentEvent);

            editorSelection.Process(currentEvent);
        }
Ejemplo n.º 2
0
        // ================================================================================ Scene
        public override void OnSceneGui(Plane[] frustum)
        {
            var settings = Settings;

            var curveRotation = GetRotation(Curve.transform);

            if (settings.VRay && settings.ShowCurve && Curve.PointsCount != 0)
            {
                painter = painter ?? new BGCurvePainterHandles(Editor.Math);
                painter.DrawCurve();
            }

            Curve.ForEach((point, index, count) => editorPoint.OnSceneGUI(point, index, settings, curveRotation, frustum));

            //tangents
            if (settings.ShowCurve && settings.ShowTangents && Editor.Math.SectionsCount > 0 && Editor.Math.IsCalculated(BGCurveBaseMath.Field.Tangent))
            {
                BGEditorUtility.SwapHandlesColor(settings.TangentsColor, () =>
                {
                    var math          = Editor.Math;
                    var sectionsCount = math.SectionsCount;
                    var sections      = math.SectionInfos;

                    for (var i = 0; i < sectionsCount; i++)
                    {
                        if (!settings.RestrictGizmozSettings.IsShowing(i))
                        {
                            continue;
                        }
                        var section = sections[i];
                        var points  = section.Points;
                        ShowTangent(points[0].Position, points[0].Tangent, settings.TangentsSize);
                        if (settings.TangentsPerSection > 1)
                        {
                            var sectionLength = section.Distance;
                            var part          = sectionLength / settings.TangentsPerSection;
                            for (var j = 1; j < settings.TangentsPerSection; j++)
                            {
                                var distanceWithinSection = part * j;
                                Vector3 position;
                                Vector3 tangent;
                                section.CalcByDistance(distanceWithinSection, out position, out tangent, true, true);
                                ShowTangent(position, tangent, settings.TangentsSize);
                            }
                        }
                    }
                });
            }


            editorSelection.Scene(curveRotation);

            overlay.Process(Event.current);

            CheckPointsTransforms();
        }