0
$\begingroup$

I'm currently trying to create an importer, and i'm trying to create the meshes completely via the BMesh module. Adding vertices and faces works perfectly fine so far, but for some reason, after adding and assigning the shape keys and their offsets, they dont make it into the mesh on "to_mesh()"

mesh = bpy.data.meshes.new(meName)
bm = bmesh.new()
bm.from_mesh(mesh)

if len(skNames) > 0:
    bm.verts.layers.shape.verify()
    for i, s in enumerate(skNames):
        skNames[i] = bm.verts.layers.shape.new(s)

    bm.verts.ensure_lookup_table()

for v in vertexData:
    bmv = bm.verts.new(v.position)
    for i, s in enumerate(skNames):
        bmv[s] = map(sum, zip(v.position, v.shapes[i]))
    v.SetVertex(bmv)


for p in faceData:
    verts = [None] * len(p.loops)
    for i, l in enumerate(p.loops):
        verts[i] = l.vertex.vertex

    try:
        bm.faces.new(verts)
    except ValueError:
        debug("   Some face appeared already")

bm.verts.ensure_lookup_table()
bm.to_mesh(mesh)
bm.free()

when checking whether the vertices contain shape data on respective layer, they do hold the offsets, but none of it gets transported over to the actual mesh. the problem is that i am creating the mesh before assigning it to an object (multiple objects can have the same mesh in the format, thus the meshes are being created before the objects themselves)

any idea what to do to solve the issue? thanks!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.