Ejemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            serializedObject.Update();

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Center", GUILayout.MaxWidth(buttonMaxWidth)))
            {
                VegetationMaskUtils.CenterMainHandle(mask);
            }
            else if (GUILayout.Button("Grow", GUILayout.MaxWidth(buttonMaxWidth)))
            {
                VegetationMaskUtils.Grow(mask, resizeFactor);
            }
            else if (GUILayout.Button("Shrink", GUILayout.MaxWidth(buttonMaxWidth)))
            {
                VegetationMaskUtils.Shrink(mask, resizeFactor);
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Circle", GUILayout.MaxWidth(buttonMaxWidth)))
            {
                VegetationMaskUtils.CreateCircle(mask);
            }
            else if (GUILayout.Button("Hexagon", GUILayout.MaxWidth(buttonMaxWidth)))
            {
                VegetationMaskUtils.CreateHexagon(mask);
            }
            else if (GUILayout.Button("Convex Hull", GUILayout.MaxWidth(buttonMaxWidth)))
            {
                VegetationMaskUtils.ConvexHull(mask);
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Subdivide", GUILayout.MaxWidth(buttonMaxWidth)))
            {
                VegetationMaskUtils.Subdivide(mask);
            }
            else if (GUILayout.Button("Unsubdivide", GUILayout.MaxWidth(buttonMaxWidth)))
            {
                VegetationMaskUtils.Unsubdivide(mask);
            }

            GUILayout.EndHorizontal();

            serializedObject.ApplyModifiedProperties();
        }
        /// <summary>
        /// Get the positions depending on the data source
        /// </summary>
        /// <returns></returns>
        private List <Vector3> GetPositions()
        {
            List <Vector3> positions;

            switch (editorTarget.dataSourceType)
            {
            case VegetationMaskLineExtension.DataSourceType.Container:
                positions = GetContainerChildrenPositions();
                break;

            case VegetationMaskLineExtension.DataSourceType.TrainController:
                positions = trainControllerIntegration.GetTrainControllerPositions();
                break;

            default:
                throw new Exception("Invalid data source: " + editorTarget.dataSourceType);
            }

            positions = VegetationMaskUtils.ApplyDoublesPeucker(positions, editorTarget.douglasPeuckerReductionTolerance);

            return(positions);
        }