OpenGL:如何获取变换后特定点的坐标?
假设我有一个点在 (250,125,-20)。 经过以下转换后,
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(100.0, 50.0, 0.0);
glRotatef(-25.0, 0.0, 1.0, 0.0);
如何获取该点的当前坐标值? 我需要编写一个子程序来将矩阵乘以向量吗? 有没有内置的解决方案?
Suppose I have a point at (250,125,-20).
After the following transformation,
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(100.0, 50.0, 0.0);
glRotatef(-25.0, 0.0, 1.0, 0.0);
How can I get the value of current coordinates of that point?
Need I write a subroutine to multiply a matrix to a vector?
Are there any built-in solutions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
转换后您无法获取特定顶点(点)的坐标,但是对于这种特殊情况,您可以在应用平移/旋转后获取ModelViewMatrix。
OpenGL 中没有魔术带,您必须编写自己的框架,例如:对于您世界中的每个对象,都有一个类,您可以在其中保存顶点以及您认为相关的数据。
You can't get the coordinates for a specific vertex (point) after a transformation, however for this particular case you can get the ModelViewMatrix after the translate/rotate is applied.
There is no magic tape in OpenGL, you will have to write your own framework e.g: for every objects in your world a class where you hold the vertices and what data you find relevant.