Archived

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

NOMADMAN

SIMPLE NEWBIE QUESTION

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
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