opengl--移动旋转、放缩中心
我的源程序(部分代码)
问题:实现鼠标控制图片在某指定点旋转,第一控制旋转时没有什么问题,从第二次开始就有问题了
void CDialogGLDlg::RenderScene()
{
LPBLOB bpb;
bpb = m_lpBlobs;
int i;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0,0.0,-8.0);
Draw();
for(i = 0;i < 2;i++)
{
glLoadName(i + 1);
glPushMatrix(); // Position / translation (mouse rotation)
glTranslatef(0.0,0.0,zmove);
glTranslatef(xmove,0.0f,0.0f);
glTranslatef(0.0f,ymove,0.0f);
float xx = (point1[1].x-width / 2)/ratiox - xmove;
float yy = (point1[1].y-height / 2)/ratioy + ymove;
//point1是鼠标右键按下后记录的点,程序是要实现鼠标控制图片在定点point1旋转
//width、height是窗口的宽高,ratiox是比例系数,xmove是鼠标控制图片移动的距离
glTranslatef(xx, -yy,0.0f);
glRotatef(-m_Rotate,0.0,0.0,1.0);
glScalef(m_Scale,m_Scale,1.0);
glTranslatef(-xx,yy,0.0f);
glCallList(i + 1);//画的一个矩形,有贴图的
glPopMatrix();
glTranslatef(3.0,1.0,0.0f);
}
}
很急,很着急!谢谢各位高手了
还有个问题,我想控制物体相对某个定点放缩,应该怎么做