public PolySet Inset(PolySet polys, float interpolation) { PolySet stitchedPolys = StitchIdentifiedPolys(polys); List <int> verts = polys.GetUniqueVerts(); //Calculate the average center of all the vertices in these Polygons. Vector3 center = Vector3.zero; foreach (int vert in verts) { center += m_Vertices[vert]; } center /= verts.Count; // Pull each vertex towards the center, then correct it's height so that it's as far from the center of // the planet as it was before. foreach (int vert in verts) { Vector3 v = m_Vertices[vert]; float height = v.magnitude; v = Vector3.Lerp(v, center, interpolation); v = v.normalized * height; m_Vertices[vert] = v; } return(stitchedPolys); }
public PolySet Extrude(PolySet polys, float height) { PolySet stitchedPolys = StitchIdentifiedPolys(polys); List <int> verts = polys.GetUniqueVerts(); // Take each vertex in this list of polys, and push it away from the center of the Planet by the height parameter. foreach (int vert in verts) { Vector3 v = m_Vertices[vert]; v = v.normalized * (v.magnitude + height); m_Vertices[vert] = v; } return(stitchedPolys); }