#### Archived

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

# SIMPLE NEWBIE QUESTION

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

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

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);
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 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 on other sites
That brings me to the conclusion of: "Dont do crack. Drugs are bad... even for newbies"

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 33
• ### Forum Statistics

• Total Topics
632633
• Total Posts
3007543
• ### Who's Online (See full list)

There are no registered users currently online

×