OpenGL

Moderators: Sephiroth
Number of threads: 107
Number of posts: 202

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
how to rotate a cube an efficent rotate ???!!!!!! Posted by NaderElMasry on 28 Mar 2010 at 7:16 PM
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;
}
}



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.