当前位置: 首页>>代码示例>>C#>>正文


C# Plane.Flip方法代码示例

本文整理汇总了C#中UnityEngine.Plane.Flip方法的典型用法代码示例。如果您正苦于以下问题:C# Plane.Flip方法的具体用法?C# Plane.Flip怎么用?C# Plane.Flip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Plane的用法示例。


在下文中一共展示了Plane.Flip方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnToolbarGUI

        void OnToolbarGUI(int windowID)
        {
            GUI.enabled = (targetBrush != null);
            EditorGUILayout.BeginHorizontal();

            if (SabreGUILayout.Button("Clip"))
            {
                ApplyClipPlane(false);
            }

            if (SabreGUILayout.Button("Split"))
            {
                ApplyClipPlane(true);
            }
            if (SabreGUILayout.Button("Flip Plane"))
            {
                isFlipped = !isFlipped;
            }
            EditorGUILayout.EndHorizontal();

            GUI.enabled = (pointSelected > -1);
            if(SabreGUILayout.Button("Snap To Grid"))
            {
                float snapDistance = CurrentSettings.PositionSnapDistance;
                Vector3 newPosition = points[pointSelected];
                newPosition = targetBrush.transform.TransformPoint(newPosition);
                newPosition = MathHelper.RoundVector3(newPosition, snapDistance);
                newPosition = targetBrush.transform.InverseTransformPoint(newPosition);

                points[pointSelected] = newPosition;
            }

            displayPlane = new Plane(points[2], points[1], points[0]);
            if(isFlipped)
            {
                displayPlane = displayPlane.Flip();
            }

            planePosition = (points[0] + points[1] + points[2]) / 3f;
        }
开发者ID:5thFloorGames,项目名称:FollowTheLight,代码行数:40,代码来源:ClipEditor.cs

示例2: ApplyClipPlane

        void ApplyClipPlane(bool keepBothSides)
        {
            if(targetBrush != null)
            {
                if(keepBothSides)
                {
                    Undo.RecordObject(targetBrush, "Split Brush");
                }
                else
                {
                    Undo.RecordObject(targetBrush, "Clipped Brush");
                }

                // Recalculate the clip plane from the world points, converting to local space for this transform
                Plane localClipPlane = new Plane(targetBrushTransform.InverseTransformPoint(points[2]),
                    targetBrushTransform.InverseTransformPoint(points[1]),
                    targetBrushTransform.InverseTransformPoint(points[0]));

                // If the user has specified to flip the plane, flip the plane we just calculated
                if(isFlipped)
                {
                    localClipPlane = localClipPlane.Flip();
                }

                // Clip the polygons against the plane
                List<Polygon> polygonsFront;
                List<Polygon> polygonsBack;

                if(PolygonFactory.SplitPolygonsByPlane(targetBrush.Polygons.ToList(), localClipPlane, false, out polygonsFront, out polygonsBack))
                {
                    // Update the brush with the new polygons
                    targetBrush.SetPolygons(polygonsFront.ToArray(), true);

                    // If they have decided to split instead of clip, create a second brush with the other side
                    if(keepBothSides)
                    {
                        GameObject newObject = targetBrush.Duplicate();

                        // Finally give the new brush the other set of polygons
                        newObject.GetComponent<PrimitiveBrush>().SetPolygons(polygonsBack.ToArray(), true);
                        newObject.transform.SetSiblingIndex(targetBrush.transform.GetSiblingIndex());
                        Undo.RegisterCreatedObjectUndo(newObject, "Split Brush");
                    }
                }
            }
        }
开发者ID:5thFloorGames,项目名称:FollowTheLight,代码行数:46,代码来源:ClipEditor.cs


注:本文中的UnityEngine.Plane.Flip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。