[Bf-python] getWorldMatrix() Implimented

Campbell Barton cbarton at metavr.com
Fri Jun 25 05:14:20 CEST 2004


Yeah. Im the same, either way.

your probably right- fully backwards compatable is better AND works the 
same is the betBoneMatrix.
There is still the issue with other functs calling getMatrix, jsut have 
2 functions 1 for internal use, and another that takes an argument.
- Cam


Joseph Gilbert wrote:

>Great idea. Although maybe the default should be local? Don't know really.
>You can decide - but getMatrix() now gets localspace - which would make
>things fully backward compatible. However - if objects aren't parenting it
>doesn't matter anyway :) So probably either one is good. I do like the idea
>of having the option at least of specifying which space' type - just for
>clarity sake. I you have the time and inclination the loc/size/rot would
>also be on this list too I guess :)
>
>-----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 7:21 PM
>To: bf-python at blender.org
>Subject: Re: [Bf-python] getWorldMatrix() Implimented
>
>
>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
>>
>>
>>
>>
>>    
>>
>
>_______________________________________________
>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