Hi everyone,
I have this problem… hope u guys can provide me with some insights:
I have a 3D model, which must be able to be rotated, translated and scaled on mouse movement. I have added into my code the necessary interaction code. whenever i scale and rotate my model, there is no problem. whenever i translate and scale my model, there is no problem. But whenever i try to rotate my model after i translate it, my model will rotate not about its object coordinates, but about some arbitary world coordinates. I want it to rotate about its own object coordinates after translation. my partial code is as follows:
Translate * Rotate * Scale, or -->
/translate/
glTranslated(m_XTranslate,m_YTranslate,0);
/rotate/
if(firsttime==0)
{
glRotated(m_AngleX, 1, 0, 0);
glRotated(m_AngleZ, 0, 0, 1);
glRotated(m_AngleY, 0, 1, 0);
glGetFloatv(GL_MODELVIEW_MATRIX, tempMatrix);
}
firsttime = 1;
if(firsttime==1)
{
glRotated(m_AngleX, 1, 0, 0);
glRotated(m_AngleZ, 0, 0, 1);
glRotated(m_AngleY, 0, 1, 0);
m_AngleX = m_AngleY = m_AngleZ= 0;
glMultMatrixf(tempMatrix);
glGetFloatv(GL_MODELVIEW_MATRIX, tempMatrix);
}
/scale/
glScaled(m_scale, m_scale, m_scale);
This is really gettin on my nerves… I hope someone out there can help me? thanks a lot…