[Bf-python] Mathutils

Joseph Gilbert models at paposo.com
Mon Feb 16 12:37:04 CET 2004


I just had to update the object class to take the new version of
newMatrixObject. The other thing is that the python matrix object structure
has a pointer-to-pointer called 'matrix' which holds all of the matrix data.
It's kinda cool actually :) The original matrix class had a matrix3ptr
typedef which was a pointer to 3 or 4 *float's. The new class has a pointer
to a pointer to *float's, so the 'matrix' of the matrix is one step removed.
What's cool about this is that you can define any size matrix dynamically
(although it's size checked at the newMatrixObject step) and you can access
elements like an array PyMatrix->matrix[row][col] = 3.0f;  However, if you
want to pass the entire matrix to those pesky functions that take variables
of type float[][3] you can do this:  function(*PyMatrix->matrix);  Sweet!
Anyway had to change that too in object.c.

I was playing with setting the matrix in object.c and didn't get too far
because if you set the matrix of the PyObject nothing seemed to happen (boo
hoo :( ) so, what I was doing was using .setLocation() and setEuler() for
the object class from a transformation matrix. So you could do:

mat = object.matrix
matR = RotationMatrix(90, 3, 'y')

mat *= matR
trans = mat.translationPart()
rot = mat.rotationPart()
eul = rot.toEuler()

object.setLocation(trans)
object.setEuler(eul[0], eul[1], eul[2])

This works! pretty cool, but not as usefull as if you could simply do a
transformation on the matrix itself. I'll keep playing with it and see how
to work it.


-----Original Message-----
Now, maybe a very stupid question, but have you thought of how to apply
a matrix to an object? I couldn't find a new function in the Object
module. Maybe I didn't look hard enough.
_______________________________________________
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