[Bf-python] getWorldMatrix() Implimented

Campbell Barton cbarton at metavr.com
Fri Jun 25 01:20:34 CEST 2004


Hi. getMatrix('worldspace') is probably the best option (consistant with 
the Bone - getMatrix() function), though I tried it and other functions 
that use .getMatrix() within Object.c complained about not senting a 
python arg to the .getMatrix() function.

An empty python arg needs to be sent by these objects..... that, or have 
an internal .getMatrix() function that dosent look for a python arg.

I think for backwards compatability we should keep ob.getMatrix() - 
Weather the default is global or locale needs to be decieded. as long is 
its documented and the python coder can deciede.

ob.getMatrix() # Default to world space.
ob.getMatrix('worldspace') # mabe dosent need to exist since its the 
default anyway???
ob.getMatrix('localespace') # the way it works now.

I want to be backwards compatable however Id say thered be very few 
scripts that require the matrix of an object to be relative to its parent.
so I dont think we'll mess anybody up by having worldspace is the 
default, its probably what they want anyway.

This could also be applied to ob.getLocation('worldspace'), 
ob.getRotation('worldspace'), ob.getSize('worldspace') I think this 
would be very usefull too.

incase anybody is scepticle this script uses the same function that 
drawobject.c uses so we'll be seeing the same matrix thats used to 
display the object (failsafe IMHO)

- Cam


Gilbert, Joseph wrote:

>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
>_______________________________________________
>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