Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

NOMADMAN

SIMPLE NEWBIE QUESTION

This topic is 5774 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m new and havn''t gotten the hang of working in 3d coords. I have a single quad, on the xy plane (z is up). All I want the quad to do is rotate on its center. (ie spin in place). But I need it to be able to do this from any (x,y) coord. So if its at (2,3) I want it to stay more-or-less on top of (2,3). It should be a really simple answer. Here is the code I have so far: void square::DisplaySq() { glPushMatrix(); glRotatef(theta, 0, 0, 1); glTranslatef(x[0], y[0], 0); glBegin(GL_QUADS); for (int i=0; i<4; i++) { glColor3f(r, g, b); glVertex3f(x, y[i], z[i]); } glEnd(); glPopMatrix(); } Can anyone help? NOMAD

Share this post


Link to post
Share on other sites
Advertisement
Solved it myself, I used glTranslatef(...). I thought it would translate the object not the coord plane. I''m such a newbie!

NOMAD

Here the code that worked if anyone cares:
void square::DisplaySq()
{
glPushMatrix();
glTranslatef((x[0]+x[2])/2, (y[0]+y[2])/2, 0);
glRotatef(theta, 0, 0, 1);
glColor3f(r, g, b);
glBegin(GL_QUADS);
glVertex3f((-1)*(width/2), (-1)*(width/2), z[0]);
glVertex3f((width/2), (-1)*(width/2), z[0]);
glVertex3f((width/2), (width/2), z[0]);
glVertex3f((-1)*(width/2), (width/2), z[0]);
glEnd();
glPopMatrix();
}

Share this post


Link to post
Share on other sites
Yep, translatef moves the whole modelview matrix, not just an object. Also, making your whole subject header in caps won''t win u any friends

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!