永发信息网

OpenGL 中如何得到鼠标选择的物体?

答案:2  悬赏:10  手机版
解决时间 2021-03-11 14:50
  • 提问者网友:眉目添风霜
  • 2021-03-10 16:26
用List管理一系列的物体,怎样用鼠标拣选?
最佳答案
  • 五星知识达人网友:夜余生
  • 2021-03-10 17:46
glLoadName;通过opengl的选择模式进行拾取,百度一下相关内容就知道了
全部回答
  • 1楼网友:廢物販賣機
  • 2021-03-10 19:01
首先在windows下获取鼠标按下/抬起/移动的消息 然后再进行判断 如果鼠标按下且移动 则进行gltranslatef/glulookat操作 左键按下时使glrotatef里的变量相应改变。我是这样做的,不过右键也响应啦,呵呵,参考一下:) void arrowkeys(int key, int x, int y) { if (key == glut_key_left) // rotate in the negative z myimage.zrot -= 5.0f; if (key == glut_key_right) // rotate in the positive z myimage.zrot += 5.0f; if (key == glut_key_up) // rotate in the negative x myimage.xrot -= 5.0f; if (key == glut_key_down) // rotate in the postive x myimage.xrot += 5.0f; if (key == glut_key_page_up) // rotate in the negative y myimage.yrot -= 5.0f; if (key == glut_key_page_down) // rotate in the postive y myimage.yrot += 5.0f; // check x,y and z rotation values to keep 0-355 if (myimage.xrot > 356.0f) myimage.xrot = 0.0f; if (myimage.xrot < 0.0f) myimage.xrot = 355.0f; if (myimage.yrot > 356.0f) myimage.yrot = 0.0f; if (myimage.yrot < 0.0f) myimage.yrot = 355.0f; if (myimage.zrot > 356.0f) myimage.zrot = 0.0f; if (myimage.zrot < 0.0f) myimage.zrot = 355.0f; // refresh the window glutpostredisplay(); } // do any needed rotation glrotatef(myimage.xrot, 1.0f, 0.0f, 0.0f); glrotatef(myimage.yrot, 0.0f, 1.0f, 0.0f); glrotatef(myimage.zrot, 0.0f, 0.0f, 1.0f);
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯