示例#1
0
        private void OnEdgeSelect(EdgeDetectionTool.EdgeSelectResult result)
        {
            if (UndoRedoRecordObject != null)
            {
                Undo.RecordObject(UndoRedoRecordObject, "Line Tool Edge Detect Result");
            }

            if (TransformResult != null)
            {
                result = TransformResult(result);
            }

            Line.Start.SetParent(result.Target);
            Line.Start.Position = result.Edge.Start;
            Line.Start.Rotation = CalculateRotation(result.Edge, AGXUnity.Utils.ShapeUtils.Direction.Positive_Z);

            Line.End.SetParent(result.Target);
            Line.End.Position = result.Edge.End;
            Line.End.Rotation = CalculateRotation(result.Edge, AGXUnity.Utils.ShapeUtils.Direction.Negative_Z);

            StartFrameToolEnable = true;
            EndFrameToolEnable   = true;

            EdgeDetectionToolEnable = false;
        }
示例#2
0
        private EdgeDetectionTool.EdgeSelectResult OnCuttingDirectionResult(EdgeDetectionTool.EdgeSelectResult result)
        {
            var refCamera = FindDirectionReferenceCamera();

            if (refCamera == null)
            {
                return(result);
            }
            if (Vector3.Dot(result.Edge.Direction, refCamera.transform.forward) > 0.0)
            {
                AGXUnity.Utils.Math.Swap(ref result.Edge.Start, ref result.Edge.End);
            }
            result.Edge.End = result.Edge.Start + 0.5f * result.Edge.Direction;
            return(result);
        }
示例#3
0
        private EdgeDetectionTool.EdgeSelectResult OnEdgeResult(EdgeDetectionTool.EdgeSelectResult result)
        {
            var refCamera = FindDirectionReferenceCamera();

            if (refCamera == null)
            {
                return(result);
            }

            // Assuming the user is viewing "into" the bucket, i.e.,
            // the camera is located in front of the bucket. The
            // edge should go from left to right on screen.
            var startX = refCamera.WorldToViewportPoint(result.Edge.Start).x;
            var endX   = refCamera.WorldToViewportPoint(result.Edge.End).x;

            if (startX > endX)
            {
                AGXUnity.Utils.Math.Swap(ref result.Edge.Start, ref result.Edge.End);
            }
            return(result);
        }