Simple Rotation Problem :/
Translate to the orgin do your rotation then translate back to the object's orginal position
glTrans
glRot
glTrans
glTrans
glRot
glTrans
More specifically you need to translate to the center of the object.
glTranslate(obj.width/2, obj.height/2, obj.depth/2)
glRotatef(roty, 0, 1, 0);
glColor3f(0, 0, 1);
glCallList(dList);
glPopMatrix();
glTranslate(obj.width/2, obj.height/2, obj.depth/2)
glRotatef(roty, 0, 1, 0);
glColor3f(0, 0, 1);
glCallList(dList);
glPopMatrix();
From your code
Quad[4][3][2] = 0 + loc[2] + width;
Completely off topic but why is there a 0 here. I am just curious if there is a reason for this I am not aware of.
not 100% but try this
trans(-loc[0], -loc[1], -loc[2])
rot
trans(loc[0], loc[1], loc[2])
or LoadIndentiy after push matrix
Quad[4][3][2] = 0 + loc[2] + width;
Completely off topic but why is there a 0 here. I am just curious if there is a reason for this I am not aware of.
not 100% but try this
trans(-loc[0], -loc[1], -loc[2])
rot
trans(loc[0], loc[1], loc[2])
or LoadIndentiy after push matrix
or try this
glTranslate*(objx,objy,objz);
glPushMatrix();
glLoadIdentity();
glRotate*();
drawobj();
glPopMatrix();
glTranslate*(objx,objy,objz);
glPushMatrix();
glLoadIdentity();
glRotate*();
drawobj();
glPopMatrix();
theres 2 things that i know of that cause this.
1. the objects in your matrix arent centered.
or
2. you perform a rotation before translation.
the former would look more "orbity" though.
1. the objects in your matrix arent centered.
or
2. you perform a rotation before translation.
the former would look more "orbity" though.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement