public static GOMesh SliceExtrudePremesh(GOMesh mesh, float height, float topSectionH, float bottomSectionH, float sliceHeight) { if (height < sliceHeight) { return(ExtrudePremesh(mesh, height)); } int numberOfSlices = (int)Mathf.Ceil((height) / sliceHeight); sliceHeight = height / numberOfSlices; List <Matrix4x4> extrusion = new List <Matrix4x4> (); for (int i = numberOfSlices; i > -1; i--) { Vector3 pos = Vector3.zero; pos.y = (i - 1) * sliceHeight; Matrix4x4 mat = Matrix4x4.TRS(pos + new Vector3(0, sliceHeight, 0), Quaternion.identity, Vector3.one); extrusion.Add(mat); } mesh.sliceHeight = sliceHeight; GOMeshExtrusion.ExtrudeMesh(mesh, mesh, extrusion.ToArray(), false); // FixPremeshUV (mesh,height); return(mesh); }
public static GOMesh ExtrudePremesh(GOMesh mesh, float height) { Matrix4x4 [] extrusionPath = new Matrix4x4 [2]; Matrix4x4 a = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one); Matrix4x4 b = Matrix4x4.TRS(Vector3.zero + new Vector3(0, height, 0), Quaternion.identity, Vector3.one); extrusionPath [0] = b; extrusionPath [1] = a; GOMeshExtrusion.ExtrudeMesh(mesh, mesh, extrusionPath, false); mesh.sliceHeight = height; // FixPremeshUV (mesh,height); return(mesh); }
public static GOMesh SliceExtrudePremesh(GOMesh mesh, float height, float topSectionH, float bottomSectionH, float sliceHeight) { if (height < sliceHeight) { return(ExtrudePremesh(mesh, height)); } int numberOfSlices = (int)Mathf.Ceil((height) / sliceHeight); sliceHeight = height / numberOfSlices; mesh.sliceHeight = sliceHeight; mesh.heightOriginal = sliceHeight; List <Matrix4x4> extrusion = new List <Matrix4x4> (); for (int i = numberOfSlices; i > -1; i--) { float h = sliceHeight; Vector3 pos = Vector3.zero; pos.y = (i - 1) * h; Matrix4x4 mat = Matrix4x4.TRS(pos + new Vector3(0, h, 0), Quaternion.identity, Vector3.one); extrusion.Add(mat); if (numberOfSlices % 2 == 0 && i == 1 && mesh.uvMappingStyle == GOUVMappingStyle.TopFitSidesSliced) { extrusion.Add(mat); } } GOMeshExtrusion.ExtrudeMesh(mesh, mesh, extrusion.ToArray(), false); //FixPremeshUV (mesh, height); return(mesh); }