public static ConwayPoly GyroelongatedBirotunda() { int sides = 10; float bodyHeight = _CalcAntiprismHeight(sides); ConwayPoly poly = Rotunda(); ConwayPoly baseDome = poly.Duplicate(); var boundaryEdges1 = poly.Faces.Remove(poly.Faces.Last()); baseDome.Mirror(Vector3.up, -bodyHeight); baseDome.Halfedges.Flip(); baseDome = baseDome.Rotate(Vector3.up, 36f / 2f); poly.Append(baseDome); var boundaryEdges2 = poly.Faces.Remove(poly.Faces.Last()); boundaryEdges2.Reverse(); for (var i = 0; i < boundaryEdges1.Count; i++) { var edge1 = boundaryEdges1[i]; var edge2 = boundaryEdges2[i]; var side1 = new List <Vertex> { edge1.Vertex, edge1.Prev.Vertex, edge2.Prev.Vertex }; poly.Faces.Add(side1); poly.FaceRoles.Add(ConwayPoly.Roles.New); poly.FaceTags.Add(new HashSet <Tuple <string, ConwayPoly.TagType> >()); var side2 = new List <Vertex> { edge2.Vertex, edge2.Prev.Vertex, edge1.Prev.Vertex, }; poly.Faces.Add(side2); poly.FaceRoles.Add(ConwayPoly.Roles.NewAlt); poly.FaceTags.Add(new HashSet <Tuple <string, ConwayPoly.TagType> >()); } poly.Halfedges.MatchPairs(); return(poly); }
public Mesh MakeMorphTarget(int morphIndex, float amount) { var morphedPoly = poly.Duplicate(); for (var i = 0; i < Morphs.Count; i++) { float a = i == morphIndex ? amount : 0; // Zero amount for ops other than the requested one var morphOp = Morphs[i]; var morphParams = new OpParams( Mathf.Lerp(morphOp.opAmount1Start, morphOp.opAmount1End, a), Mathf.Lerp(morphOp.opAmount2Start, morphOp.opAmount2End, a), morphOp.opFacesel ); morphedPoly = morphedPoly.ApplyOp(morphOp.op, morphParams); morphedPoly = morphedPoly.ApplyOp(PostMorph.op, new OpParams(PostMorph.opAmount1, PostMorph.opAmount2, PostMorph.opFacesel)); } var result = PolyMeshBuilder.BuildMeshFromConwayPoly(morphedPoly, false, null, ColorMethod); // result.RecalculateNormals(); // result.RecalculateTangents(); return(result); }
private ConwayPoly MakeWings(ConwayPoly spaceship, Func <FilterParams, bool> sideFaceFilter) { // Creates wings positioned on the last section created var wing = spaceship.Duplicate(); // Only keep the new section wing = wing.FaceKeep(new OpParams { facesel = FaceSelections.AllNew }); // And only the faces pointing out mostly level wing = wing.FaceKeep(new OpParams { filterFunc = sideFaceFilter }); // Scale them down wing = wing.FaceScale(new OpParams { facesel = FaceSelections.All, valueA = Random.Range(0, 0.5f) }); // Extrude out the wings wing = wing.Loft(new OpParams { valueA = Random.Range(0, 1f), valueB = Random.Range(.5f, 2f) }); for (int i = 0; i < Random.Range(0, 3); i++) { wing = wing.Loft(new OpParams { valueA = Random.Range(0, 1f), valueB = Random.Range(.15f, 1.5f), facesel = FaceSelections.Existing }); if (Random.value < 0.5f) { wing = wing.FaceSlide(new OpParams { valueA = Random.Range(-.5f, .5f), valueB = Random.Range(-1, .25f), facesel = FaceSelections.Existing }); } } return(wing); }