Hi all,
I am trying to read/write abc files from a python script. In my case the ABC files are simple, and only contain one animated mesh. I managed to write the code to read the files using cask (getting a list of faces and list of arrays of vertex positions - see below), but I am struggling to write the code to write information to an abc file - are there any examples on how to do so? (it doesn't need to be in cask) From what I understand so far, I'd need to create a polymesh, with a schema containing the face indices, and a sequence of samples containing vertex positions.
I am trying to create the hierarchy I see in the files I am reading, but I get stuck on how to define the faces and the samples:
a = cask.Archive()
a.top.children['xform'] = cask.Xform()
polymesh = a.top.children['xform'].children['polymesh'] = cask.PolyMesh()
polymesh.schema = alembic.AbcGeom.OPolyMeshSchema()
# how to specify the face indices?
If it helps, here is my code to read the ABC file:
a = cask.Archive(fname) # cask.Archive
root = a.top # cast.Top
xform = root.children[xform_name] #cask.Xform
polymesh = xform.children[polymesh_name] #cask.PolyMesh
# This is how I extract the information of the faces (later I parse these to a list of vertex idx)
schema = polymesh.schema.getValue()
face_indices = np.array(schema.getFaceIndices())
n_vertex_per_face = np.array(schema.getFaceCounts())
# This is how I extract the vertex positions over time (btw this is very slow, not sure if I'm using it right)
points = []
for item in polymesh.samples:
points.append(np.array(item.getPositions()))
Thanks in advance for any help on this!
Luiz Gustavo Hafemann