wblut/HE_Mesh

Iteratively adding faces or vertices to a mesh

Closed this issue · 2 comments

Hi @wblut,

Congratulations for the new release !

I'm wondering, how would you add new faces or vertices to a mesh ?

Let's say I have an Icosahedron and I want to divide one of its faces into 3 new faces by inserting a new vertex at its center, would that be possible with Hemesh ?

add_library('peasycam')
add_library('hemesh')

def setup():
    size(1000, 600, P3D)
    smooth(8)
           
    global mesh, render
    mesh = HE_Mesh(HEC_Icosahedron())
    render = WB_Render(this)
    cam = PeasyCam(this, 800)

def draw():
    background('#DCDCDC')
    lights()
    
    render.drawFaces(mesh)

def keyReleased():
    # select a face at random
    # compute its center and place a new vertex
    # create 3 new faces around that new vertex
    # remove old face
wblut commented

In the example "spielerei\SprayNozzle" there's some code that does this, it adds vertices and splits faces where a ray intersects the mesh.
HEM_TriSplit.splitFaceTri(HE_Mesh mesh, HE_Face face, WB_Coord p) will do that for you.
How to get the face you need can be a challenge since HE_Mesh doesn't come with an interface. The example "hemesh\select\Ref_SelectingFaces2" can help.

Many thanks for the swift reply, that helped a lot.