how can i rotate a cube in an efficient way ???!!!!

Started by Nader El Masry, March 29, 2010, 02:16:39 AM

Previous topic - Next topic

Nader El Masry

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;
}
}

zemtex

Thinking of rotation as rotation from a programmers point of view is probably not correct. You are not rotating anything, once you grab that its easier to optimize things.

The watcher/observer is percieving things being rotated, but you shouldnt use that term as a programmer. Once you get rid of that term as a programmer it will also open up new ways to do things. You will only limit yourself when you put general terms to your philosophy and code.
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

oex

We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

dedndave

about a year ago, Farabi did some stuff on this that was quite good
use the forum search tool with advanced options and limit to Farabi posts