Hmmm im trying to convert 4 vectors into the matrix to rotate an object.
The object is oriented so that the object is facing +z, and it top is facing +y.
The 4 vectors are defined as follows and never vary from thier original lengths, they are always 1 length in distance from each other and can rotate around the origin in 6 degrees of freedom.
The 4 vectors are always locally oriented to each other as follows:
A. an origin position in 3d (x,y,z)
B. a vector oriented to the right of origin, is locally -x direction
C. a vector oriented in front of the origin, is locally +z direction
D. a vector oriented directly above the origin, is locally +y direction
Again, B C and D vectors are 1 unit length away from the origin.
Here is the local orientation as a diagram, how these positions are related:
// orientation vector desciption
// (C=0,1,0) up - locally +y in respect to origin
// | /(D=0,0,1) look - locally + z in respect to origin
// | /
// |/___(B=-1,0,0) right - locally -x in respect to origin
// (A=0,0,0) origin - local x y z
I can rotate all 3(BCD) around the origin in 6 degrees of freedom with quaternions...no problem...
I have tried the sequence of vector inputs into a matrix array, but they always seem to be attached to 0,0,0 no matter what.
Here is the code i have, converted with the function set below this:
DIM m[4][4]
m[0][0]=cam1.rx
m[1][0]=cam1.ry
m[2][0]=cam1.rz
m[3][0]=0
m[0][1]=cam1.ux
m[1][1]=cam1.uy
m[2][1]=cam1.uz
m[3][1]=0
m[0][2]= cam1.lx
m[1][2]= cam1.ly
m[2][2]= cam1.lz
m[3][2]=0
m[0][3]=0
m[1][3]=0
m[2][3]=0
m[3][3]=1
DIM mat[16]
mXY_Matrix()
X_MOVEMENT x,y,z
X_PUSHMATRIX
X_MULTMATRIX mat[]
X_DRAWOBJ Object,0
X_POPMATRIX
This object is always attached in the middle of the object to point xyz (0,0,0)...the pushmatrix isnt moving the object....and the object is stretched out meeting at the look vector....and the object seems flat. I also tried using mYX_Matrix(), and it is messed up looking also, scaling the object up to huge proportions.
Can you help make a function to convert these vectors into the X_MULT, so it moves and rotates an object?
Here are the converters:
//Where m[4][4] = m[column][row] = m[x][y]
FUNCTION Opengl_XY_Matrix:
//opengl matrix
DIM mat[16]
mat[0]= m[0][0]
mat[1]= m[0][1]
mat[2]= m[0][2]
mat[3]= m[0][3]
mat[4]= m[1][0]
mat[5]= m[1][1]
mat[6]= m[1][2]
mat[7]= m[1][3]
mat[8]= m[2][0]
mat[9]= m[2][1]
mat[10]= m[2][2]
mat[11]= m[2][3]
mat[12]= m[3][0]
mat[13]= m[3][1]
mat[14]= m[3][2]
mat[15]= m[3][3]
RETURN 1
ENDFUNCTION
//Where m[4][4] = m[row][column] = m[y][x]
FUNCTION Opengl_YX_Matrix:
//opengl matrix
DIM mat[16]
mat[0]= m[0][0]
mat[2]= m[1][0]
mat[1]= m[2][0]
mat[3]= m[3][0]
mat[4]= m[0][1]
mat[5]= m[1][1]
mat[6]= m[2][1]
mat[7]= m[3][1]
mat[8]= m[0][2]
mat[9]= m[1][2]
mat[10]= m[2][2]
mat[11]= m[3][2]
mat[12]= m[0][3]
mat[13]= m[1][3]
mat[14]= m[2][3]
mat[15]= m[3][3]
RETURN 1
ENDFUNCTION