/// <summary> /// Creates a copy of a brush, translated by the given offset. /// </summary> public static UnrealBrush Duplicate(UnrealBrush brush, Vector3D translateOffset) { var result = Duplicate(brush); if (!translateOffset.IsZero()) { result.Translate(translateOffset); } return(result); }
protected UnrealBrush(UnrealBrush brush) : base(brush) { Operation = brush.Operation; PolyFlags = brush.PolyFlags; IsInvisible = brush.IsInvisible; IsPortal = brush.IsPortal; MainScale = brush.MainScale; PostScale = brush.PostScale; polygons = brush.polygons.Select(p => new Polygon(p)).ToList(); vertices = brush.vertices.Select(p => new Point3D(p)).ToList(); edges = brush.edges.Select(l => new Line3D(l)).ToList(); }
/// <summary> /// Instantiates an actor with the correct type. /// </summary> public static UnrealActor FromText(string text) { if ((text.StartsWith("Begin Actor Class=Brush ") || text.StartsWith("Begin Actor Class=Mover ")) && text.Contains("Begin Brush ")) // some "Brushes" do not contain geometry, no idea why { return(UnrealBrush.FromText(text)); } else { return(UnrealActor.FromText(text)); } }
/// <summary> /// Generates the T3D representation of a brush instance. /// </summary> public static string GenerateText(UnrealBrush brush) { var builder = new StringBuilder(); // Add header builder.AppendLine("Begin Actor Class=Brush Name=" + brush.Name); // Add all properties builder.AppendLine(GenerateProperties(brush)); // Add geometry part builder.AppendLine(brush.GeometryText); // Add footer builder.AppendLine("End Actor"); return(builder.ToString()); }
/// <returns> /// Whether this brush overlaps with or touches another brush, /// i.e. at least one point is common. If the result is unknown, /// null is returned. /// </returns> public bool?OverlapsWith(UnrealBrush other) { bool overlapX = (GetXMin() - other.GetXMax()) * (GetXMax() - other.GetXMin()) <= 0.0; bool overlapY = (GetYMin() - other.GetYMax()) * (GetYMax() - other.GetYMin()) <= 0.0; bool overlapZ = (GetZMin() - other.GetZMax()) * (GetZMax() - other.GetZMin()) <= 0.0; bool possible = (overlapX && overlapY && overlapZ); if (IsCuboid()) { return(possible); } if (possible) { // The vertex bounds don't tell the whole story here // TODO: devise an algorithm return(null); } else { return(false); } }
/// <summary> /// Creates a modifiable deep copy of a brush. /// </summary> public static UnrealBrush Duplicate(UnrealBrush brush) { return(brush.Duplicate()); }