Hi there!
Is there a way to save the current transformation matrix calculated by scaling-, translating- and rotating-function in a lua-table?
I have to send this matrix to a shader.
Transformation Matrix
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Transformation Matrix
Admittedly, I've never worked with transformation matrices, but I've done some normal transformation/rotation/scaling.
Can you not create an empty matrix and copy the data into that?
http://www.lua.org/pil/11.2.html
Can you not create an empty matrix and copy the data into that?
http://www.lua.org/pil/11.2.html
Re: Transformation Matrix
As far as I know you cannot directly access the transformation matrix, love uses. Maybe you can overwrite the transformation function from love.graphics (.translate .scale .rotate) so that they also output a transformation matrix.
In case you are not familiar with it. Each transformation has the form
where x_old and x_new are column vectors containing coordinates, A is the 2x2-transformation matrix and t is the translation (also a column vector).
Rotation is t = (0;0) and A = [cos(alpha), -sin(alpha); sin(alpha), cos(alpha)]
Scaling is t = (0;0) and A = [s, 0; 0, s]
Translation is t = (t1;t2) and A = [1, 0; 0, 1]
("," means next element in same row and ";" means next row)
If you use multiple transformations after each other, you have to insert the first x_new into the second equation as x_old. You then find the transformation matrix and the translation vector by calculating a matrix-matrix product and a matrix-vector product respectively.
In case you are not familiar with it. Each transformation has the form
Code: Select all
x_new = A*x_old + t
Rotation is t = (0;0) and A = [cos(alpha), -sin(alpha); sin(alpha), cos(alpha)]
Scaling is t = (0;0) and A = [s, 0; 0, s]
Translation is t = (t1;t2) and A = [1, 0; 0, 1]
("," means next element in same row and ";" means next row)
If you use multiple transformations after each other, you have to insert the first x_new into the second equation as x_old. You then find the transformation matrix and the translation vector by calculating a matrix-matrix product and a matrix-vector product respectively.
Check out my blog on gamedev
Who is online
Users browsing this forum: Google [Bot] and 5 guests