changes of matrix_world between 2.5 and 2.6?

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

_patrice_
Posts: 6
Joined: Tue Feb 28, 2012 6:13 pm

changes of matrix_world between 2.5 and 2.6?

Postby _patrice_ » Tue May 22, 2012 11:38 am

Dear Experts,

I have a problem that drives me crazy. I wrote a plugin once for blender 2.5 where I render a scene from different viewpoints and store depth as well as some parameters, see below:

Code: Select all

RT = camobj.matrix_world.inverted()
# Intrinsic
C = Matrix().to_3x3()
C[0][0] = -w/2 / tan(cam.data.angle/2)
ratio = w/h
C[1][1] = -h/2. / tan(cam.data.angle/2) * ratio
C[0][2] = w / 2.  #w = width of rendered image
C[1][2] = h / 2.  #h = height of rendered image
C[2][2] = 1.
C.transpose()


( With this matrices and the depth in blender units I want to calculate instead of the depth a disparity map for each rendered view by retrace each point from the neighbored view and compare the destination positions in the rendered views. )

However, the problem now is, that the camobj.matrix_world.inverted() object for the same viewpoints in blender 2.5 looks like this:

Code: Select all

[(0.0, 0.0, 1.0, 0.0),
(1.0, 0.0, 0.0, 0.0),
(0.0, 1.0, 0.0, 0.0),
(-1.0, -0.5, -20.0, 1.0)]


and in blender 2.6 like this:

Code: Select all

[(0.0,  1.0, 0.0,   0.0)
(0.0,  0.0,  1.0   0.5)
(1.0,  0.0, 0.0 -20.0)
(0.0, 0.0,  0.0,   1.0)]


Is anyone able to explain me why and what I should do to get similar results?

Thanks in advance and best regards,
_patrice_

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Tue May 22, 2012 7:14 pm

see this:
http://blenderartists.org/forum/showthr ... ender-2.62

matrices are now row-major instead of column major.

your 2.6 matrix transposed:

Code: Select all

[(0.0, 0.0, 1.0, 0.0)
(1.0, 0.0, 0.0, 0.0)
(0.0, 1.0, 0.0, 0.0)
(0.0, 0.5, -20.0, 1.0)]


almost the same as your 2.5 matrix

you might have to swap the order of vectors and matrices in multiplications to get it right
I'm sitting, waiting, wishing, building Blender in superstition...

ldo
Posts: 544
Joined: Sun Nov 07, 2010 11:30 pm
Location: Hamilton, New Zealand

Postby ldo » Wed May 23, 2012 11:14 am

The order and meaning of operations should not have changed. The only thing that should be affected is direct examination/construction of the matrix elements.


Return to “Python”

Who is online

Users browsing this forum: No registered users and 1 guest