[Bf-python] Possible bug with transformations
Ken Hughes
khughes at pacific.edu
Wed Dec 28 18:23:41 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?
Sorry, totally misunderstood what you were getting at.
When you do position.resize4D(), the new fourth component is zero, so
when you multiply with the transform matrix the translation is not
applied. I verified by setting position[3]=1 befor the multiplication.
Something similar was added to the bug tracker on the 25th related to
resizing matrices (bug #3661), but I'm not sure if this is a bug. I
don't think you would always want the new vector element to be set to 1.
Ken
More information about the Bf-python
mailing list