[Bf-python] Animation keys and vertex influences

Willian Padovani Germano wgermano at ig.com.br
Fri Jul 25 23:32:23 CEST 2003


On Fri, 2003-07-25 at 22:46, Jiba wrote:
> Hi all,
> 
> I am writing a Blender => Cal3D converter, using the new Blender 2.28 Python API (Cal3D is a 3D animation library, http://cal3d.sourceforge.net).
> 
> I am running into some problem, though :
> 
> First NMesh.getVertexInfluences() seems buggy :
>  - it segfaults if the vertex has several influences.
>  - it does not work on raw data (e.g. a NMesh given by Blender.NMesh.GetRawFromObject(), on a mesh that use SubSurf) : all vertices has empty influences.

Yes, I read a report on the python forum about the segfault, some days
ago.  I'd appreciate if you could send directly to me a sample .blend
file for this or better: explain me how to assign multiple influences to
a vertex, so I can fix the function.  I don't have enough experience
with armatures, only played a little with it in Blender long ago.

About not working on a mesh coming from getRawFromObject, here's the
function, from NMesh.c:
---------------------------------
static PyObject *M_NMesh_GetRawFromObject(PyObject *self, PyObject
*args) 
{
  char *name;
  Object *ob;
  PyObject *nmesh;

  if (!PyArg_ParseTuple(args, "s", &name))
       return EXPP_ReturnPyObjError (PyExc_TypeError,
               "expected string argument");

  ob = (Object*)GetIdFromList(&(G.main->object), name);

  if (!ob)
    return EXPP_ReturnPyObjError (PyExc_AttributeError, name);
  else if (ob->type != OB_MESH)
    return EXPP_ReturnPyObjError (PyExc_AttributeError,
                    "Object does not have Mesh data");
  else {
    Mesh *me = (Mesh*)ob->data;
    DispList *dl;

    if (mesh_uses_displist(me) && (dl = find_displist(&me->disp,
DL_MESH)))
      nmesh = new_NMesh_internal(me, dl->mesh, NULL);
    else if ((dl= find_displist(&ob->disp, DL_VERTS)))
      nmesh = new_NMesh_internal(me, NULL, dl->verts);
    else
      nmesh = new_NMesh(me);
  }

/* hack: to mark that (deformed) mesh is readonly, so the update
function
 * will not try to write it. */

  ((BPy_NMesh *) nmesh)->mesh = 0;

	return nmesh;
}
--------------------------------

As can be seen from above, the original programmer(s) tried to preserve
the existing mesh in Blender.  By making nmesh->mesh = 0, they force the
NMesh_update() function to create a new mesh in Blender for this nmesh. 
And the new mesh created of course has mesh->dvert == NULL (no vertices 
deformation).  They probably protected the original mesh because of its
display list, where the actual raw info is coming from.

Can't you use NMesh.GetRaw with the meshes, instead of
NMesh.GetRawFromObject with the objects?  You can do something like: for
each object check if it's a mesh, and if so use NMesh.GetRaw(obj.data).

> Secondly, i have trouble for getting the animation data (probably what is called "Ipo" by Blender ?). What i need is to recover the information entered in Blender's "action" window, in particular the time at which keyframe have been entered. Does someone knows which property of Ipo or IpoCurve object contains this information ?
> 
> Any help is welcome !

Jacques maintains the Ipo module, so he is the one who can help you
here.

Thanks,

--
Willian, wgermano at ig.com.br




More information about the Bf-python mailing list