Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

how to rotate a cube an efficent rotate ???!!!!!!

NaderElMasryNaderElMasry Posts: 1Member
i know that many people may see this topic bit strange,but of course the problem is not to rotate a cube actually.

i made an application to rotate a cube and i know that it is very simple one but the problem that when i rotate the cube it rotate the (X,Y,Z) axis with it !!!!
u can see it when i rotate the cube with angle 90 around Y-axis then when i rotate around X-axis it rotate around Z-axis because i rotate the axis with the cube ?!!!
Sample of the Code :
Gl.glPushMatrix();
Gl.glScalef(45, 45, 45);
Gl.glRotatef(cubeAngley, 0, 1, 0);
Gl.glRotatef(cubeAnglex, 1, 0, 0);
DrawCube();
Gl.glPopMatrix();

private void Oglctrl_KeyDown(object sender, KeyEventArgs e)
{
// rotating cube
if (e.KeyCode == Keys.W)
{
cubeAnglex -= 5;
}
else if (e.KeyCode == Keys.S)
{
cubeAnglex += 5;
}
else if (e.KeyCode == Keys.A)
{
cubeAngley -= 5;
}
else if (e.KeyCode == Keys.D)
{
cubeAngley += 5;
}
}
Sign In or Register to comment.