本文整理汇总了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;
}
示例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");
}
}
}
}