coda

01-12-2004, 09:17 PM

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 /99*length;

}

}

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

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

// 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 /99*length;

}

}

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

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