Original Post
So simple and yet I'm stumped. I have four points (with x, y, z coordinates) that make up a rectangle. I want to rotate the rectangle around it's own center. How do I do that?
render(){ // push current modelview matrix onto stack // note, I assume the modelview matrix is already set as expected, whether it be in // world space, or transformed into eyespace by the camera or whatever glPushMatrix(); // note, if this was a class then you would probably have this matrix defined inside it, and have // functions to alter it, but I just do these things here to make the example easier to read CMatrix rectMatrix; rectMatrix.location = pivot.position; // set origin to position of pivot rectMatrix.rotate(1, 0, 0, 45.0f); // rotate 45 degrees around X axis // note, the group of points should be defined in object space glMultMatrix(rectMatrix.matrix); // multiply/combine with current opengl modelview matrix OnDrawGroupOfPoints(); // draw group of points // restore previous modelview matrix from stack glPopMatrix();}This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more