Archived

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

Xiachunyi

Rotating around a makeshift axis of a makeshift object

Recommended Posts

Hello, this is probably a more of a logic question than an API question but since it involves the manipulation of a group of matrixes then I thought about stipulating it to the Opengl forum. This is a function to render a circle that I am currently working on:
void xia_Circle(int orientation, double place_x, double place_y, double place_z, double diameter, double thickness)
{
    static float x_before=cos(0), x_after=sin(0);
    static float y_before=0.0, y_after=0.0;
    glTranslatef(place_x, place_y, place_z);
    glLineWidth(thickness);
    for(int loop=0; loop < 360; loop++)
    {
        x_after=diameter*cos(loop);
        y_after=diameter*sin(loop);
        glBegin(GL_LINES);
            glVertex3f(x_before,y_before,cos(loop));
            glVertex3f(x_after,y_after,sin(loop));
        glEnd();
        x_before=x_after;
        y_before=y_after;
    }
}
The circle is drawn out correctly but what I want to do is rotate it on its "pseudo" axis, like an object. The implementation is shown below:
...
                  glColor3f(1.0,1.0,0.0);
	              glDisable(GL_LIGHTING);
                  glDisable(GL_COLOR_MATERIAL);
                  glDisable(GL_TEXTURE_2D);
                  glPushMatrix();
                      xia_Circle(0, 0.0, 0.0, -5.0, 2.0, 0.5);
                  glPopMatrix();
	              glEnable(GL_LIGHTING);
                  glEnable(GL_COLOR_MATERIAL);
                  glEnable(GL_TEXTURE_2D);
...
  
I've tried utilizing glRotatef, but that only serves to translate it across the screen either in a horizontal, vertical, or circular direction within the confines of the lines. I think I must manipulate the matrixes some how to allow it to turn. For those of you who are familar with .hack//sign, I am trying to recreate the portal. Thank you. [edited by - Xiachunyi on January 17, 2004 4:22:40 PM]

Share this post


Link to post
Share on other sites