zukko

10-26-2004, 03:40 PM

im using the following code to draw a torus knot:

float r,x,y,z;

int DrawGLScene(GLvoid)

{

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glLoadIdentity();

glTranslatef(0,0,-5.0f);

glRotatef(90,1.0f,0.0f,0.0f);

glBegin(GL_TRIANGLE_STRIP);

for(double i = 0; i < 2 * PI; i += PI / 720)

{

r=0.5f*(2+sin(8*i));

x=r*cos(3*i);

y=r*cos(8*i);

z=r*sin(3*i);

glColor3f(1.0, 0.0, 0.0);

glVertex3f(x,y,z);

glColor3f(0.0, 0.0, 1.0);

glVertex3f(x+0.1f,y+0.1f,z+0.1f);

glColor3f(0.0, 1.0, 0.0);

glVertex3f(x+0.2f,y+0.2f,z+0.2f);

}

glEnd();

return TRUE;

}

i have 2 questions:

1) how do i make the camera follow the knot or make the knot 'move'

2) how do i make the triangles be conected not just a secuence of triangles ??

thanks in advance

float r,x,y,z;

int DrawGLScene(GLvoid)

{

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glLoadIdentity();

glTranslatef(0,0,-5.0f);

glRotatef(90,1.0f,0.0f,0.0f);

glBegin(GL_TRIANGLE_STRIP);

for(double i = 0; i < 2 * PI; i += PI / 720)

{

r=0.5f*(2+sin(8*i));

x=r*cos(3*i);

y=r*cos(8*i);

z=r*sin(3*i);

glColor3f(1.0, 0.0, 0.0);

glVertex3f(x,y,z);

glColor3f(0.0, 0.0, 1.0);

glVertex3f(x+0.1f,y+0.1f,z+0.1f);

glColor3f(0.0, 1.0, 0.0);

glVertex3f(x+0.2f,y+0.2f,z+0.2f);

}

glEnd();

return TRUE;

}

i have 2 questions:

1) how do i make the camera follow the knot or make the knot 'move'

2) how do i make the triangles be conected not just a secuence of triangles ??

thanks in advance