开发者

Object rotation without "animation"

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 ha开发者_如何学Pythonve 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.


Although your question is a bit unclear, it sounds like you are not aware of glPushMatrix and glPopMatrix. With glPushMatrix you can essentially save the currently selected matrix and then restore it again with glPopMatrix. But keep sure to follow every glPushMatrix with a corresponding glPopMatrix somewhere in time. But you definitely don't need to use another library.

So I think you want to do

for(i=0; i<3; ++i)
{
    glPushMatrix();
    glRotatef(...);
    wall(i);
    glPopMatrix();
}


You just need to set the transformation on the object.

For example - section 9.020 of the OpenGL resources pages has this example:

glPushMatrix();
glRotatef(90., 1., 0., 0.);
gluCylinder(quad,1,1,2,36,12);
glPopMatrix();

This will rotate a cylinder 90 degrees around the X axis

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜