DIM mat[16]
mat[0..3] = forward (local x-axis) (x,y,z,0)
mat[4..7] = local up (x,y,z,0)
mat[8..11]=local right (x,y,z,0)
mat[12..16]=translation (offset) from origin (x,y,z,1)
X_MULTMATRIX mat[]
If you want to use X_ROTATION and stuff, too - use the X_PUSHMATRIX before X_MULTMATRIX.
*quoted from gernot*
QuoteNote from Hemlos:
Im currently working with this new command and will update this in more detail as i get more information.
Create rotation/translation matrix:
// Roll, Pitch, Yaw, Translate
FUNCTION BuildMatrix: ry, rz, rx, x, y, z, M[]
LOCAL sa,sb,sc, ca,cb,cc
LOCAL sacb, cacb
DIM M[16]
//LOCAL a[], B[], C[]
// NewtonRollMatrix (rx, a[])
// NewtonPitchMatrix(ry, B[])
// NewtonMultMatrix(a[], B[], C[])
// NewtonYawMatrix (rz, a[])
// NewtonMultMatrix(a[], C[], M[])
// M[12]= x
// M[13]= y
// M[14]= z
ca = COS(-ry);
sa = SIN(-ry);
sb = COS(rz);
cb = SIN(rz);
cc = COS(-rx);
sc = SIN(-rx);
sacb=sa*cb
cacb=ca*cb
M[0] = sb * cc;
M[1] = -sb * sc;
M[2] = -cb;
M[4] = -sacb * cc + ca * sc;
M[5] = sacb * sc + ca * cc;
M[6] = -sa * sb;
M[8] = cacb * cc + sa * sc;
M[9] = -cacb * sc + sa * cc;
M[10] = ca * sb;
M[12]= x
M[13]= y
M[14]= z
M[15]= 1;
ENDFUNCTION
interesting, and doesnt gimbal lock..but it rotates like x_rotation still, minus the gimbal..
This method works with 2 axes that are fixed to the world and one to the object.