如何在OPENGL中旋转或平移单个对象实例? [英] How do I rotate or translate individual object instances in OPENGL?
本文介绍了如何在OPENGL中旋转或平移单个对象实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个包含四个立方体的场景.我怎么说在OpenGL中仅旋转/转换这些多维数据集中的两个,而不会使用glrotatef和gltranslate更改其他多维数据集?我不想定义自己的同类坐标.
Lets say i have a scene with four cubes. How do I say rotate/translate only two of these cubes in OpenGL without changing the others using glrotatef anf gltranslate? I dont wanna define my own homogeneous co-ordinates.
推荐答案
- 您照常绘制前两个立方体
- 推送视图模型矩阵(
glPushMatrix(GL_MODELVIEW_MATRIX)
) - 调用glRotate/glTranslate设置要以不同方式绘制的两个立方体的旋转
- 画另外两个立方体
- 弹出原始视图模型矩阵(
glPopMatrix(GL_MODELVIEW_MATRIX)
)
- You draw your first two cubes as usual
- Push the view-model matrix (
glPushMatrix(GL_MODELVIEW_MATRIX)
) - Call glRotate/glTranslate to setup the rotation of the two cubes which you want to draw in a different way
- Draw the other two cubes
- Pop the original view-model matrix (
glPopMatrix(GL_MODELVIEW_MATRIX)
)
这篇关于如何在OPENGL中旋转或平移单个对象实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文