www.jpct.net
jPCT  a 3d engine for Java => Support => Topic started by: AGP on March 05, 2010, 09:47:05 pm

I'm trying to convert between Max's camera matrix to jPCT (which, by the way, will make for a good Wiki). Problem is that the documentation doesn't specify how the matrices are arranged (just that it's a 4x4 matrix), and jPCT's matrix doesn't match Max's. So, what is the order?

Like the docs for Matrix state: All matrices in jPCT are row major....and that's true, as long as you are using the set()method in Matrix. If you are using setDump() to set a float[16], it's different. That one does this:
int cnt = 0;
for (int i = 0; i < 4; i++) {
mat[i][0] = dump[cnt];
mat[i][1] = dump[cnt + 1];
mat[i][2] = dump[cnt + 2];
mat[i][3] = dump[cnt + 3];
cnt += 4;
}
With i being the row, [0...3] the columns.

I read the wikipedia on row major. Not completely clear to me yet. Does anyone have any idea about Max's 4x3 matrices?

Conversion between row and columnmajor isn't difficult. If this is a rowmajor matrix:
a b c d
e f g h
i j l m
n o p q
then this is the column major variant:
a e i n
b f j o
c g l p
d h m q
Plus, if your are doing matrix multiplications, the order changes. I.e. a*b with rowmajor matrices becomes b*a for columnmajor.