public void Generate() { var wythoff = new WythoffPoly(PolyType, PrismP, PrismQ); wythoff.BuildFaces(); poly = new ConwayPoly(wythoff); if (ApplyOp) { var o1 = new OpParams { valueA = op1Amount1, valueB = op1Amount2, facesel = op1Facesel }; poly = poly.ApplyOp(op1, o1); } if (Canonicalize) { poly = poly.Canonicalize(0.01, 0.01); } poly = poly.Transform(Position, Rotation, Scale); var pos = SlicePosition; if (animateSlice > 0) { pos.y = .1f + transform.position.y + ((Time.time % 2f) * animateSlice); } var result = poly.SliceByPlane(new Plane(Quaternion.Euler(SliceRotation) * Vector3.up, pos), Cap, includeTop, includeBottom); poly = result.bottom; var top = result.top.Transform(topTransform); poly.Append(top); // var sliceWythoff = new WythoffPoly(PolyTypes.Cube, 3, 3); // sliceWythoff.BuildFaces(); // var slicePoly = new ConwayPoly(wythoff); // slicePoly = slicePoly.Transform(SlicePosition, SliceRotation, Vector3.one * SliceScale); // var result = poly.SliceByPoly(slicePoly, Cap); // poly = result.outside; // var top = result.outside.Transform(topTransform); if (Weld) { poly = poly.Weld(0.0001f); } if (ApplyOp) { var o2 = new OpParams { valueA = op2Amount1, valueB = op2Amount2, facesel = op2Facesel }; poly = poly.ApplyOp(op2, o2); } var mesh = PolyMeshBuilder.BuildMeshFromConwayPoly(poly, false, null, ColorMethod); GetComponent <MeshFilter>().mesh = mesh; }
public void Generate() { var wythoff = new WythoffPoly(PolyType, PrismP, PrismQ); wythoff.BuildFaces(); poly = new ConwayPoly(wythoff); if (ApplyOp) { var o1 = new OpParams { valueA = op1Amount1, valueB = op1Amount2, facesel = op1Facesel }; poly = poly.ApplyOp(op1, o1); } if (Canonicalize) { poly = poly.Canonicalize(0.01, 0.01); } poly = poly.Transform(Position, Rotation, Scale); var pos = SlicePosition; if (animateSlice > 0) { pos.y = .1f + transform.position.y + ((Time.time % 2f) * animateSlice); } var rot = Quaternion.Euler(SliceRotation) * Vector3.up; var slicePlane = new Plane(rot, pos); var result = poly.SliceByPlane(slicePlane, Cap, includeTop, includeBottom); poly = result.bottom; var slicePoint = slicePlane.normal * (-slicePlane.distance + SegmentHeight); slicePlane.SetNormalAndPosition(slicePlane.normal, slicePoint); var(top, segment, _) = result.top.SliceByPlane(slicePlane, Cap, includeTop, includeBottom); segment = segment.Transform(SegmentTransform); poly.Append(top); poly.Append(segment); if (Weld) { poly = poly.Weld(0.0001f); } if (ApplyOp) { var o2 = new OpParams { valueA = op2Amount1, valueB = op2Amount2, facesel = op2Facesel }; poly = poly.ApplyOp(op2, o2); } var mesh = PolyMeshBuilder.BuildMeshFromConwayPoly(poly, false, null, ColorMethod); GetComponent <MeshFilter>().mesh = mesh; }