[Bf-python] Re: problem with absolute vertex coords

Melchior FRANZ mfranz at aon.at
Thu Feb 3 03:11:38 CET 2005


* joeedh -- Thursday 03 February 2005 02:32:
* * Melchior FRANZ -- Thursday 03 February 2005 01:08:
> > I wrote a Python script[1] that outputs vertex coordinates to an xml file that I
> > can directly use for FlightGear[2] animations. But it turned out that the coords
> > aren't correct -- they are too big.

> You have to multiply the vertex by the object's 4x4 3d transformation 
> matrix.  I think this involves Mathutils.  You just copy the vertex 
> location into a Mathutils.Vector object (it should already be in one, 
> actually I think)  resize it to 4D (as wierd as that sounds, it adds a 
> fourth element to the location array) then use |the MatMulVec mathutils 
> function

Many thanks! Works perfectly. For the archive, this did it:

  import Blender
  from Blender import Mathutils
  from Blender.Mathutils import Vector, VecMultMat
  ...
  mat = object.getMatrix()
  mesh = object.getData()
  for v in mesh.verts:
          vec = Vector([v[0],v[1],v[2]])
          vec.resize4D()
          vec = VecMultMat(vec, mat)
          print vec[0], vec[1], vec[2]

m.



More information about the Bf-python mailing list