结合旋转和平移
我在 OpenGL 中有一个场景,它被旋转和平移,我想沿着它自己的 Z 轴进一步平移它。我该如何反映这一点?
更具体一点: glTranslated (tx,ty,tz) gp旋转 (rx,1,0,0) gp旋转(ry,0,1,0) gpRotated (rz,0,0,1)
我应该对 tx,ty,tz 进行什么修改才能将场景平移到它自己的 Z 轴(对于“相机”来说可能是 X 轴?
I have a scene in OpenGL, which is rotated and translated, and I would like to translate it further along its OWN Z axis. How should I reflect this ?
To be a bit more concrete:
glTranslated (tx,ty,tz)
gpRotated (rx,1,0,0)
gpRotated (ry,0,1,0)
gpRotated (rz,0,0,1)
What modification should I bring to the tx,ty,tz in order to translate the scene toward its own Z axis (which for the "camera" may be the X axis ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用额外的
glTranslate()
修改模型矩阵。模型转换独立于相机,因此您可以在那里做您想做的一切。只需确保将模型放置在世界空间的最后,然后使用在世界空间中工作的视图矩阵(即变换世界->相机空间。)You should modify the model matrix with an additional
glTranslate()
. The model transformation is independent of the camera, so you can do all you want there. Just make sure to place the model in world space at the end and then use a view matrix which works in world-space (i.e. transforms world->camera space.)