Rotation Questions...
I''m trying to rotate an an object which isn''t at the origin, about it''s current axis..
What is the sequence I need to use ?
start drawing the scene
push the matrix
draw my object at the origin..
rotate it
translate it
pop the matrix
exit draw ?
I create my objects out at a specified point..
So I subtract the values to get that object at the origin..
how do I get it back where I want it though..
here is my code.
glPushMatrix();
//glLoadIdentity();
//glTranslatef(-xtrans, 0, -ztrans);
glRotatef(rotationx, 1.0, 0.0, 0.0);
glRotatef(rotationy, 0.0, 1.0, 0.0);
glRotatef(rotationz, 0.0, 0.0, 1.0);
glBindTexture(GL_TEXTURE_2D, texture[1]);
if(mode == GL_SELECT)
{
glLoadName(Leg_1);
}
shape.Rect_3D_Texture(tableLegs[0] - xtrans, tableLegs[1], tableLegs[2] -ztrans,
tableLegs[3], tableLegs[4], tableLegs[5]);
if(mode == GL_SELECT)
{
glLoadName(Leg_2);
}
shape.Rect_3D_Texture(tableLegs[6]- xtrans, tableLegs[7], tableLegs[8] - ztrans,
tableLegs[9], tableLegs[10], tableLegs[11]);
if(mode == GL_SELECT)
{
glLoadName(Leg_3);
}
shape.Rect_3D_Texture(tableLegs[12] - xtrans, tableLegs[13], tableLegs[14] -ztrans,
tableLegs[15], tableLegs[16], tableLegs[17]);
if(mode == GL_SELECT)
{
glLoadName(Leg_4);
}
shape.Rect_3D_Texture(tableLegs[18] -xtrans, tableLegs[19], tableLegs[20] - ztrans,
tableLegs[21], tableLegs[22], tableLegs[23]);
glTranslatef(xtrans, 0, ztrans);
glPopMatrix();
So I subtract the values to get that object at the origin..
how do I get it back where I want it though..
here is my code.
glPushMatrix();
//glLoadIdentity();
//glTranslatef(-xtrans, 0, -ztrans);
glRotatef(rotationx, 1.0, 0.0, 0.0);
glRotatef(rotationy, 0.0, 1.0, 0.0);
glRotatef(rotationz, 0.0, 0.0, 1.0);
glBindTexture(GL_TEXTURE_2D, texture[1]);
if(mode == GL_SELECT)
{
glLoadName(Leg_1);
}
shape.Rect_3D_Texture(tableLegs[0] - xtrans, tableLegs[1], tableLegs[2] -ztrans,
tableLegs[3], tableLegs[4], tableLegs[5]);
if(mode == GL_SELECT)
{
glLoadName(Leg_2);
}
shape.Rect_3D_Texture(tableLegs[6]- xtrans, tableLegs[7], tableLegs[8] - ztrans,
tableLegs[9], tableLegs[10], tableLegs[11]);
if(mode == GL_SELECT)
{
glLoadName(Leg_3);
}
shape.Rect_3D_Texture(tableLegs[12] - xtrans, tableLegs[13], tableLegs[14] -ztrans,
tableLegs[15], tableLegs[16], tableLegs[17]);
if(mode == GL_SELECT)
{
glLoadName(Leg_4);
}
shape.Rect_3D_Texture(tableLegs[18] -xtrans, tableLegs[19], tableLegs[20] - ztrans,
tableLegs[21], tableLegs[22], tableLegs[23]);
glTranslatef(xtrans, 0, ztrans);
glPopMatrix();
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement