how to "connect" the grid for curved surface?

I have help in the following code for drawing a 3D 1/4 hollow cylinder, much like a piece of paper with sides folded upwards. But not sure how to render it using triangles, anyone can help? also, i need the normal as i am using lighting but does that mean every point on the surface have to find a normal? how to do that?

// Generic 3-float vertex struct
struct Point{
float x, y, z;};
// 50 vertices along the arc, 100 vertices in length
Point VertexGrid[50][100];
// This is the angle variablefloat
t;
// Fill the grid
for (int z = 0; z < 100; z++)
// loop for the length of it
{ t = 0.0f;
for (int x = 0; x < 50; x++)
// loop from right to left
{
// Have t increment from 0 rads to PI over the width
t = (float)x / 49 * PI;
VertexGrid[x][z].x = cos(t)*radius; VertexGrid[x][z].y = -sin(t)radius; VertexGrid[x][z].z = -(float)z /99length;
}
}

[This message has been edited by coda (edited 01-12-2004).]

[This message has been edited by coda (edited 01-12-2004).]

You already calculate all the vertices so I don’t get the problem, can’t you just use glBegin( GL_TRIANGLES) or glBegin( GL_TRIANGLE_STRIP) ?

You need to calculate a normal for each vertex, all the other ones are interpolated by OpenGL.

Mikael

i tried the following code instead (normal is auto-calculated) of the above and found that the surface doesn’t look exactly like a 1/4 of a cylinder, it is still a curve surface but not accurate. Where is the problem? also the surface is meshed but I want it to be smooth and filled, any other code i need to add? thank you

GLint nNumPoints=3;

//drawing surface (Curved) and d is radius
GLfloat ctrlPoints[3][3][3]={{
{-d,0.0f,1.0f},{-0.7071fd,-0.7071fd,1.0f},{0.0f,-d,1.0f}}, //v=0
{{-d,0.0f,0.0f},{-0.7071fd,
-0.7071f
d,0.0f},{0.0f,-d,0.0f}}, //v=1
{{-d,0.0f,-1.0f},{-0.7071fd,-0.7071fd,
-1.0f},{0.0f,-d,-1.0f}}};//v=2

// the setup function
glMap2f(GL_MAP2_VERTEX_3, // Type of data generated
0.0f, // Lower u range
10.0f, // Upper u range
3, // Distance between points in the data
3, // Dimension in u direction (order)
0.0f, // Lower v range
10.0f, // Upper v range
9, // Distance between points in the data
3, // Dimension in v direction (order)
&ctrlPoints[0][0][0]); // array of control points

// Enable the evaluator
glEnable(GL_MAP2_VERTEX_3);

// Map a grid of 100 points from 0 to 100
glMapGrid2f(10,0.0f,10.0f,10,0.0f,10.0f);
// Evaluate the grid, using lines
glEvalMesh2(GL_LINE,0,10,0,10);

glEnable(GL_AUTO_NORMAL);

[This message has been edited by coda (edited 01-13-2004).]

[This message has been edited by coda (edited 01-13-2004).]