[Bf-python] Applying an Object matrix using mathutils.
Campbell Barton
cbarton at metavr.com
Tue Jun 8 01:32:03 CEST 2004
Im just writing because I think there must be a better way to apply an
object matrix when exporting vert positions.
The problem is that I cant use Mathutils because a vector is a [3]
length vector and an object matrix is 4x4.
I have used the function below, mabe It can be done in mathutils, or an
extra function that replaces this could be added to mathutils.
- Cam
#==================#
# Apply Transform #
#==================#
def apply_transform(vert, matrix):
x, y, z = vert
xloc, yloc, zloc = matrix[3][0], matrix[3][1], matrix[3][2]
xcomponent = x*matrix[0][0] + y*matrix[1][0] + z*matrix[2][0] + xloc
ycomponent = x*matrix[0][1] + y*matrix[1][1] + z*matrix[2][1] + yloc
zcomponent = x*matrix[0][2] + y*matrix[1][2] + z*matrix[2][2] + zloc
return [xcomponent, ycomponent, zcomponent]
More information about the Bf-python
mailing list