(2017-10-22, 20:52)Michael Horvath Wrote:(2017-10-22, 4:16)Travis Cobbs Wrote: LDLCamera::rotate should in fact take the Euler angles, but a transformation matrix has a lot more in it than just that. If you have a rotation-only transformation matrix, then what you're doing is probably fine.
Will this create the correct type of matrix?
Code:TCFloat identity[16] =
{
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
};
TCVector::calcRotationMatrix(cameraXRotate, cameraYRotate, identity);
I believe it will. That function rotates around X and then rotates around Y by the given amounts. Side note: you don't have to initialize the array of floats that you pass in; that's a purely out parameter.
(2017-10-22, 20:52)Michael Horvath Wrote: Also, I have written a matrix to euler converter in Lua for another project. Could someone explain how to convert it to C++?
The array of floats has indices that go from 0 to 15. I can't remember if it is horizontal first, or vertical first. If it is horizontal first, the mapping would be:
r00 = matrix[0];
r01 = matrix[1];
r02 = matrix[2];
r10 = matrix[4];
r11 = matrix[5];
r12 = matrix[6];
r20 = matrix[8];
r21 = matrix[9];
r22 = matrix[10];
(Note that the 4th column is skipped, because the rotation portion is a 3x3 matrix, but the data in LDView is a 4x4 matrix.)
If it vertical first, the mapping would be:
r00 = matrix[0];
r00 = matrix[4];
r02 = matrix[8];
r10 = matrix[1];
r11 = matrix[5];
r12 = matrix[9];
r20 = matrix[2];
r21 = matrix[6];
r22 = matrix[10];