infinitbelt

02-06-2010, 10:22 PM

Hi,

I need to create a model of a car and I am having trouble creating the wheels for it. The wheel has to be formed from 8 triangles rotated in a circle about a point. However, I am having difficulty with that.

Here's what I have so far:

void draw_triangle ()

{

glBegin(GL_TRIANGLES);

glColor3f(0.0, 0.0, 1.0);

glVertex3f( 0.0, 0.0, 10);

glColor3f(1.0, 0.0, 0.0);

glVertex3f(0.0, 0, -10);

glColor3f(0.0, 1.0, 0.0);

glVertex3f( 0.0, -10, 0);

glEnd();

}

void draw_wheel ()

{

glMatrixMode(GL_MODELVIEW);

glPushMatrix();

glTranslatef(0.0, 10.0, 0.0);

draw_triangle();

glRotatef(45, 1.0, 0.0, 0.0);

draw_triangle();

glPopMatrix();

}

However, it is not giving me the desired result. If I can draw just one wheel correctly, I think I can manage drawing four wheels and placing them in the right locations but I just cannot seem to get it.

Any help is appreciated. Thank you!

I need to create a model of a car and I am having trouble creating the wheels for it. The wheel has to be formed from 8 triangles rotated in a circle about a point. However, I am having difficulty with that.

Here's what I have so far:

void draw_triangle ()

{

glBegin(GL_TRIANGLES);

glColor3f(0.0, 0.0, 1.0);

glVertex3f( 0.0, 0.0, 10);

glColor3f(1.0, 0.0, 0.0);

glVertex3f(0.0, 0, -10);

glColor3f(0.0, 1.0, 0.0);

glVertex3f( 0.0, -10, 0);

glEnd();

}

void draw_wheel ()

{

glMatrixMode(GL_MODELVIEW);

glPushMatrix();

glTranslatef(0.0, 10.0, 0.0);

draw_triangle();

glRotatef(45, 1.0, 0.0, 0.0);

draw_triangle();

glPopMatrix();

}

However, it is not giving me the desired result. If I can draw just one wheel correctly, I think I can manage drawing four wheels and placing them in the right locations but I just cannot seem to get it.

Any help is appreciated. Thank you!