rogergcg

12-07-2010, 09:38 AM

Hello everyone.

I need some help to solve a rotation problem.

I have a set of 2d quads, and I just want to rotate them around the Z axis. The problem is the following: when I apply the rotation, the proportion of the quads are changed, I mean, the length of the sides of the quads change.

This is what I am doing:

-using orthographic projection: gluOrtho2D(0.0,1.0,-1.0,2.0);

-using display lists to generate the quads(actually, they are rectangles). They are generated to fill the whole screen. So, I can generate 10 or say, 100 quads, and in both cases the whole screen is filled. What matters here is the size of the quads, it is the length of the side that changes.

-here is my draw function:

void draw(){

glClear(GL_COLOR_BUFFER_BIT);

glPushMatrix();

glTranslatef(0.5,0.5,0.0); //translate back

glRotatef(-45,0,0,1); //rotation around the Z axis

glTranslatef(-0.5,-0.5,0.0); //translate the center to the origin (0,0)

glCallList(...); //quads are stored here

glPopMatrix();

glutSwapBuffers();

}

Now, you will notice that the translations are in reverse order. I can't understand that, it is just the way it seems to work better.

I appreciate any help guys.

I need some help to solve a rotation problem.

I have a set of 2d quads, and I just want to rotate them around the Z axis. The problem is the following: when I apply the rotation, the proportion of the quads are changed, I mean, the length of the sides of the quads change.

This is what I am doing:

-using orthographic projection: gluOrtho2D(0.0,1.0,-1.0,2.0);

-using display lists to generate the quads(actually, they are rectangles). They are generated to fill the whole screen. So, I can generate 10 or say, 100 quads, and in both cases the whole screen is filled. What matters here is the size of the quads, it is the length of the side that changes.

-here is my draw function:

void draw(){

glClear(GL_COLOR_BUFFER_BIT);

glPushMatrix();

glTranslatef(0.5,0.5,0.0); //translate back

glRotatef(-45,0,0,1); //rotation around the Z axis

glTranslatef(-0.5,-0.5,0.0); //translate the center to the origin (0,0)

glCallList(...); //quads are stored here

glPopMatrix();

glutSwapBuffers();

}

Now, you will notice that the translations are in reverse order. I can't understand that, it is just the way it seems to work better.

I appreciate any help guys.