Now I've been trying to calculate my own crap in EQ for matrix transformations and such. Now I've got translation and scaling however I'm having a slight problem calculating my rotation.
Here is my code for calculating the vertices
Code: Select all
if ( Pos.r != 0 ) {
float sinn = sinf(Pos.r);
float cosn = cosf(Pos.r);
const float LEFT = Pos.x - (Pos.w / 2);
const float RIGHT = Pos.x + (Pos.w / 2);
const float TOP = Pos.y - (Pos.h / 2);
const float BOTTOM = Pos.y + (Pos.h / 2);
Verts[0].x = (LEFT * cosn) - (TOP * sinn);
Verts[0].y = (LEFT * sinn) + (TOP * cosn);
Verts[1].x = (RIGHT * cosn) - (TOP * sinn);
Verts[1].y = (RIGHT * sinn) + (TOP * cosn);
Verts[2].x = (RIGHT * cosn) - (BOTTOM * sinn);
Verts[2].y = (RIGHT * sinn) + (BOTTOM * cosn);
Verts[3].x = (LEFT * cosn) - (BOTTOM * sinn);
Verts[3].y = (LEFT * sinn) + (BOTTOM * cosn);
}
else {
Verts[0].x = ((-Pos.w / 2) + Pos.x); Verts[0].y = ((-Pos.h / 2) + Pos.y);
Verts[1].x = ((Pos.w / 2) + Pos.x); Verts[1].y = ((-Pos.h / 2) + Pos.y);
Verts[2].x = ((Pos.w / 2) + Pos.x); Verts[2].y = ((Pos.h / 2) + Pos.y);
Verts[3].x = ((-Pos.w / 2) + Pos.x); Verts[3].y = ((Pos.h / 2) + Pos.y);
}
Try drawing a quad like this:
Code: Select all
glTranslatef();
glRotatef();
//blah
Code: Select all
glRotatef();
glTranslatef();
Thanks.
P.S. Please don't send me to that topic in the education index because I've been to it