01-07-2006, 04:43 AM

Hello.

I have a ready code where I manipulate a 3D body - rotate/translate with mouse/keys. it looks like that:

void My DrawCallBack()

{

if (first_time)

glLoadIdentity();

else

glPopMatrix();

retrieve_transformation_delta(parameters..);

delta_transform(parameters..);

draw_body();

glPushMatrix();

}

so with each key pressed or mouse movement/event - the body moves along.

The problem is that the first transformation applied is the delta_transform, then the rest (inherited by glPopMatrx), resulting in body rotating around its own axes, and not around the screen axes.

as a solution I'm trying to retrtieve the delta_transform matrix and reverse the order:

..

glLoadIdentity();

retrieve_delta(..);

delta_transform(..)

glGetDoublev(GL_MODELVIEW_MATRIX,mymatrix_pointer) ;

glPopMatrix();

reverse_multiply(current and mymatrix);

draw_body();

glPushMatrix();

..

I get access violation error ;

Am I allowed to retrieve and manipulate the matrix directly?

Is there a more elegant way of reversing the order?

Thanks in advance.

Runner.

I have a ready code where I manipulate a 3D body - rotate/translate with mouse/keys. it looks like that:

void My DrawCallBack()

{

if (first_time)

glLoadIdentity();

else

glPopMatrix();

retrieve_transformation_delta(parameters..);

delta_transform(parameters..);

draw_body();

glPushMatrix();

}

so with each key pressed or mouse movement/event - the body moves along.

The problem is that the first transformation applied is the delta_transform, then the rest (inherited by glPopMatrx), resulting in body rotating around its own axes, and not around the screen axes.

as a solution I'm trying to retrtieve the delta_transform matrix and reverse the order:

..

glLoadIdentity();

retrieve_delta(..);

delta_transform(..)

glGetDoublev(GL_MODELVIEW_MATRIX,mymatrix_pointer) ;

glPopMatrix();

reverse_multiply(current and mymatrix);

draw_body();

glPushMatrix();

..

I get access violation error ;

Am I allowed to retrieve and manipulate the matrix directly?

Is there a more elegant way of reversing the order?

Thanks in advance.

Runner.