[Bf-python] Possible bug with transformations
Ken Hughes
khughes at pacific.edu
Tue Dec 27 23:24:36 CET 2005
Tron Thomas wrote:
> I have run across what I think is a bug in the Python scripting API. I
> wanted to run it pass people on this mailing list to make sure.
> From the default scene, I ran the following script:
>
>
> import Blender
>
> transform = Blender.Object.Get('Cube').getMatrix()
> mesh = Blender.Mesh.Get('Cube')
>
> for vertex in mesh.verts:
> position = Blender.Mathutils.Vector(vertex.co)
> position.resize4D()
> position *= transform
> position.resize3D()
> print position
>
>
> This produced the following output:
>
> [1.000000, 1.000000, -1.000000](vector)
> [1.000000, -1.000000, -1.000000](vector)
> [-1.000000, -1.000000, -1.000000](vector)
> [-1.000000, 1.000000, -1.000000](vector)
> [1.000000, 0.999999, 1.000000](vector)
> [0.999999, -1.000001, 1.000000](vector)
> [-1.000000, -1.000000, 1.000000](vector)
> [-1.000000, 1.000000, 1.000000](vector)
>
>
> I then translated the cube one unit along the X axis and ran the script
> again. I got the same output. It seems that the X component of the
> outputted vectors should have ranged between zero and 2 rather than -1
> and 1.
>
> How correct is this assumption?
You're making a new vector and applying the transform to the copy;
you're not applying the transform to the mesh vertices. Try this:
import Blender
transform = Blender.Object.Get('Cube').getMatrix()
mesh = Blender.Mesh.Get('Cube')
for vertex in mesh.verts:
vertex.co *= transform
Ken
More information about the Bf-python
mailing list