private void PokeFace(Face face, int num) { var solid = face.Parent; // Remove the face solid.Faces.Remove(face); face.Parent = null; _selection.Remove(face); var center = face.BoundingBox.Center + face.Plane.Normal * num; foreach (var edge in face.GetEdges()) { var v1 = face.Vertices.First(x => x.Location == edge.Start); var v2 = face.Vertices.First(x => x.Location == edge.End); var verts = new[] { v1.Location, v2.Location, center }; var f = new Face(Document.Map.IDGenerator.GetNextFaceID()) { Parent = solid, Plane = new Plane(verts[0], verts[1], verts[2]), Colour = solid.Colour, Texture = face.Texture.Clone() }; f.Vertices.AddRange(verts.Select(x => new Vertex(x, face))); f.UpdateBoundingBox(); f.AlignTextureToFace(); solid.Faces.Add(f); _selection.Add(f); } solid.UpdateBoundingBox(); UpdateSelection(); MainTool.SetDirty(true, true); }
private void BevelFace(Face face, int num) { var solid = face.Parent; var vertexCoordinates = face.Vertices.ToDictionary(x => x, x => x.Location); // Scale the face a bit and move it away by the bevel distance face.Transform(new UnitScale(Coordinate.One * 0.9m, face.BoundingBox.Center), TransformFlags.TextureLock); face.Transform(new UnitTranslate(face.Plane.Normal * num), TransformFlags.TextureLock); foreach (var edge in face.GetEdges()) { var v1 = face.Vertices.First(x => x.Location == edge.Start); var v2 = face.Vertices.First(x => x.Location == edge.End); var verts = new[] { vertexCoordinates[v1], vertexCoordinates[v2], v2.Location, v1.Location }; var f = new Face(Document.Map.IDGenerator.GetNextFaceID()) { Parent = solid, Plane = new Plane(verts[0], verts[1], verts[2]), Colour = solid.Colour, Texture = face.Texture.Clone() }; f.Vertices.AddRange(verts.Select(x => new Vertex(x, face))); f.UpdateBoundingBox(); f.AlignTextureToFace(); solid.Faces.Add(f); _selection.Add(f); } solid.UpdateBoundingBox(); UpdateSelection(); MainTool.SetDirty(true, true); }