tango2009
asked on
Opengl spin shape
I am trying to get a sphere to spin on user input in opengl.
I have a class for my sphere which is a weapon in my game like below.
void Weapon::DrawWeapon()
{
glPushMatrix();
// Draw the Handle
glPushMatrix();
glRotatef(90.0f,5.0f,10.0f ,5.0f);
glScalef (2.0, 0.4, 1.0);
glTranslatef(0.5f,-1.0f,0. 6f);
//glRotatef ((GLfloat) weapon, 0.0, 0.0, 1.0);
glutSolidCube(10.0);
glPopMatrix();
}
I have a function for the spin of the sphere
void spinDisplay(void)
{
spin = spin + 2.0;
if (spin > 360.0)
spin = spin - 360.0;
glutPostRedisplay();
}
How do I use this spin function with the sphere can you use it with glrotatef
I have a class for my sphere which is a weapon in my game like below.
void Weapon::DrawWeapon()
{
glPushMatrix();
// Draw the Handle
glPushMatrix();
glRotatef(90.0f,5.0f,10.0f
glScalef (2.0, 0.4, 1.0);
glTranslatef(0.5f,-1.0f,0.
//glRotatef ((GLfloat) weapon, 0.0, 0.0, 1.0);
glutSolidCube(10.0);
glPopMatrix();
}
I have a function for the spin of the sphere
void spinDisplay(void)
{
spin = spin + 2.0;
if (spin > 360.0)
spin = spin - 360.0;
glutPostRedisplay();
}
How do I use this spin function with the sphere can you use it with glrotatef
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There is also the potential problem that your rotation vector is not a unit length.