这里是我的问题,我有一个刻度点,它是未投影的鼠标位置。我还有一个“相机”,基本上通过X和Y平移所有对象。我想做的是实现缩放到鼠标位置。
我尝试了以下方法:
但这并没有考虑相机的翻译问题。请问我该如何正确处理?谢谢。
我尝试了以下方法:
1. Find the mouse's x and y coordinates
2. Translate by (x,y,0) to put the origin at those coordinates
3. Scale by your desired vector (i,j,k)
4. Translate by (-x,-y,0) to put the origin back at the top left
但这并没有考虑相机的翻译问题。请问我该如何正确处理?谢谢。
glTranslatef(controls.MainGlFrame.GetCameraX(),
controls.MainGlFrame.GetCameraY(),0);
glTranslatef(current.ScalePoint.x,current.ScalePoint.y,0);
glScalef(current.ScaleFactor,current.ScaleFactor,0);
glTranslatef(-current.ScalePoint.x,-current.ScalePoint.y,0);