[Bf-python] getWorldMatrix() Implimented

Gilbert, Joseph jgilbert at tigr.org
Thu Jun 24 18:18:24 CEST 2004


I haven't looked at the implementation but It looks fine. Can we rename
getMatrix to getLocalMatrix then and create an alias for getMatrix (for
compatibility)? The reason for this is to avoid confusion between 2
matrix functions. Either that or can we can combine this into a single
function with an optional string?
static PyObject *Object_getMatrix (BPy_Object *self, PyObect *args)
{
    PyObject * matrix;
    char *name_str = "worldspace";

    if (!PyArg_ParseTuple (args, "|s", &name_str))
	return (EXPP_ReturnPyObjError (PyExc_AttributeError,
	"expected string or empty argument"));

    matrix = newMatrixObject(NULL, 4, 4);

    switch(name_str){
      case "worldspace":
        where_is_object(self->object);
        Mat4CpyMat4(*((MatrixObject*)matrix)->matrix, 
        self->object->obmat); 
      case "localspace":
        object_to_mat4(self->object, *((MatrixObject*)matrix)->matrix);
      default:
        return (EXPP_ReturnPyObjError (PyExc_AttributeError,
	  "localspace or worldspace expected"));
    }
    return matrix;
}
Anyways just an idea.
Joseph

-----Original Message-----
From: bf-python-admin at blender.org [mailto:bf-python-admin at blender.org]
On Behalf Of Campbell Barton
Sent: Thursday, June 24, 2004 10:56 AM
To: bf-python at blender.org
Subject: [Bf-python] getWorldMatrix() Implimented

Hi, I got sick of an objects matrix not takingh into account the parents

location or parent verts.

I added the function to Object.c that works a treat, I have tested it 
for exporters and it works as expected.

See the function in bold below. Just add it below getMatrix as well as 
the obvious places in the code.

This is simple but realy needed for exporters-
Cam



static PyObject *Object_getMatrix (BPy_Object *self)
{
    PyObject * matrix;
    matrix = newMatrixObject(NULL, 4, 4);
    object_to_mat4(self->object, *((MatrixObject*)matrix)->matrix);
    return matrix;
}


*static PyObject *Object_getWorldMatrix (BPy_Object *self)
{
    PyObject * matrix;
   
    matrix = newMatrixObject(NULL, 4, 4);
   
    /* Worldspace matrix */
    where_is_object(self->object);
    Mat4CpyMat4(*((MatrixObject*)matrix)->matrix, 
self->object->obmat);       
   
    return matrix;
}

*
_______________________________________________
Bf-python mailing list
Bf-python at blender.org
http://www.blender.org/mailman/listinfo/bf-python



More information about the Bf-python mailing list