没有“动画”的对象旋转
我正在尝试在 OpenGL 中旋转一个对象,而不让它在其轴上重复旋转。有没有办法解决这个问题,或者我是否必须获得其他库或其他东西?
我只是想画一些平面正方形并旋转它们以制作一个简单的 3 墙 1 层房间来测试照明和阴影。
I'm trying to rotate an object in OpenGL without it spinning on its axis repeatedly. Is there anyway to fix this or do I have to get some other library or something?
I'm just trying to draw some flat squares and rotate them to make a simple 3 walled 1 floor room to test lighting and shadows in.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然你的问题有点不清楚,但听起来你不知道
glPushMatrix
和glPopMatrix
。使用glPushMatrix
,您基本上可以保存当前选择的矩阵,然后使用glPopMatrix
再次恢复它。但请确保在每个glPushMatrix
后面及时跟随一个相应的glPopMatrix
。但你绝对不需要使用另一个库。所以我想你想做
Although your question is a bit unclear, it sounds like you are not aware of
glPushMatrix
andglPopMatrix
. WithglPushMatrix
you can essentially save the currently selected matrix and then restore it again withglPopMatrix
. But keep sure to follow everyglPushMatrix
with a correspondingglPopMatrix
somewhere in time. But you definitely don't need to use another library.So I think you want to do
您只需在对象上设置变换即可。
例如 - OpenGL 资源页面的第 9.020 节有以下示例
:将围绕 X 轴旋转圆柱体 90 度
You just need to set the transformation on the object.
For example - section 9.020 of the OpenGL resources pages has this example:
This will rotate a cylinder 90 degrees around the X axis