i still don't understand quaternions. i can't imagine what they are but i borrowed some of your code:

Code:
void ent_getrbmatrix1(ENTITY *entity, D3DXMATRIX *mout)
{
// ignores entity scale -> not needed for rigid bodies -> collision shape size gets defined by bounding box

D3DXMATRIX mpan;
D3DXMatrixRotationZ(&mpan, entity->pan * DEG2RAD);

D3DXMATRIX mtilt;
D3DXMatrixRotationY(&mtilt, -entity->tilt * DEG2RAD); // -tilt?

D3DXMATRIX mroll;
D3DXMatrixRotationX(&mroll, entity->roll * DEG2RAD);

D3DXMATRIX mtranslation;
D3DXMatrixTranslation(&mtranslation,
entity->x * QUANTTOMETER,
entity->y * QUANTTOMETER,
entity->z * QUANTTOMETER);

D3DXMATRIX mtemp1; D3DXMatrixMultiply(&mtemp1, &mroll, &mtilt);
D3DXMATRIX mtemp2; D3DXMatrixMultiply(&mtemp2, &mtemp1, &mpan);
D3DXMatrixMultiply(mout, &mtemp2, &mtranslation);

//printmatrix("g1", mout);
}



void ent_getrbmatrix2(ENTITY *entity, float *mout) // does the same as ent_getrbmatrix1 but in a different way
{
VECTOR xaxis; vec_set(&xaxis, vector(1, 0, 0));
VECTOR yaxis; vec_set(&yaxis, vector(0, 1, 0));
VECTOR zaxis; vec_set(&zaxis, vector(0, 0, 1));

// ignores entity scale -> not needed for rigid bodies -> collision shape size gets defined by bounding box

vec_rotate(&xaxis, &entity->pan);
vec_rotate(&yaxis, &entity->pan);
vec_rotate(&zaxis, &entity->pan);

mout[0] = xaxis.x; mout[1] = xaxis.y; mout[2] = xaxis.z; mout[3] = 0;
mout[4] = yaxis.x; mout[5] = yaxis.y; mout[6] = yaxis.z; mout[7] = 0;
mout[8] = zaxis.x; mout[9] = zaxis.y; mout[10] = zaxis.z; mout[11] = 0;
mout[12] = entity->x * QUANTTOMETER;
mout[13] = entity->y * QUANTTOMETER;
mout[14] = entity->z * QUANTTOMETER;
mout[15] = 1;

//printmatrix("g2", mout);
}



void ent_setrbmatrix(ENTITY *entity, float *m)
{
D3DXVECTOR3 s;
D3DXQUATERNION q;
D3DXVECTOR3 t;

D3DXMatrixDecompose(&s, &q, &t, (D3DXMATRIX*)m);

//todo: check for gimbal lock?
entity->pan = RAD2DEG * atan2f(2 * (q.w*q.z + q.x*q.y), (1-2 * (q.y*q.y + q.z*q.z)));
entity->tilt = RAD2DEG * -asinf((2 * (q.w*q.y - q.x*q.z)));
entity->roll = RAD2DEG * atan2f(2 * (q.w*q.x + q.y*q.z), (1-2 * (q.x*q.x + q.y*q.y)));

entity->x = t.x * METERTOQUANT;
entity->y = t.y * METERTOQUANT;
entity->z = t.z * METERTOQUANT;
}



using quaternions seemed to be the easiest way to convert between eulers and matrices. this is needed if you want to use newton with lite-c.

do you really understand these three quaternion lines? is it 100% reliable this way? with google i found some similar conversion code with checks for gimbal lock?

it seems to work though!