3D graphs

Is there an OpenGL library (or tutorial or code) for scientific visualization?

I’m trying to make a 3D graph out of a single indexed triangle strip but its surface is “streaky”.

Here is the mess:
http://members.tripod.ca/~peterkennedy/OpenGL/OpenGL.htm

Any suggestions (or tutorials) on how I could make a really excellent 3D graph?

This is a good question! You have assigned a normal to each vertex and you have smoothed normals. How did you smooth these normals? Average of all connected triangle normals?
I had a similiar problem, but it was for a mesh composed of triangles and I used GLTRIANGLES instead of strips of triangles.
What happened is when I averaged the normals of all connected triangles, I had a bad smooth but when I average normals of all connected triangles with a certain angle between normals (like < 30 degrees), I had a good smooth. Although not as nice as the one you ilustrate on your web page.
I think that has to do with the way you set-up materials and lighting.

Thanks for your post.

I’m especially interested in your angle dependent normal calculation. I’ll give it a try.

I can’t understand why my version has alternating bands of light and dark. Here is the code summary:

I used a single triangle strip to draw the graph (with a switch-back for every new line of data). Normals were calculated by creating vectors from 3 consecutive vertices and taking the cross product.

//Get First vertex of triangle
FirstPoint = pVertex->GetAt(pIndex->GetAt(nTrueOffset + nCtr));

//Get second vertex of triangle
SecondPoint = pVertex->GetAt(pIndex->GetAt(nTrueOffset +nCtr+1));
//Get third vertex of triangle
ThirdPoint = pVertex->GetAt(pIndex->GetAt(nTrueOffset +nCtr+2));

///////////////////////////////////
// Create two vectors in triangle //
////////////////////////////////////

//Get first vector of triangle
FirstVector = FirstPoint -SecondPoint;
//Get second vector of triangle
SecondVector = ThirdPoint -SecondPoint;

/////////////////////////////////////////
// Make normal of triangle from vectors //
//////////////////////////////////////////

NormalVector = SecondVector*FirstVector;
//make normal a unit vector
NormalVector = NormalVector.Normalise();

Smoothing was done by averaging each set of three vertices specified by the index array (the average of all connected triangle normals).

I saw an example where they averaged all connected normals. When I tried it I had also a “streaky” effect.
I had this geometry that was a 3D solid tube formed by a set of triangles. On the lateral surface I wanted a smooth aspect to look perfectly round. The “streaky” effect was due to normals pointing to the viewer and away from the viewer alternatively. Then I averaged with the normals angle in mind. Only the connected triangles on the round surface entered in this calculation and it worked ok.

without fully reading your question/replies this might be wrong but you can’t make a fully 3d arear out of a SINGLE triangle strip. When I amde a simple terrain engine I tried to do everything in one strip and the effect was stripey becuase it textures over the top of each other this may be similar for your lighting. You have to make rows of triangle strips.

Billy: I suspect my normals are alternating (towards the user and away from the user). I’ll check them! I just don’t see how this is possible from my calculation of the normals.

Tim Stirling: That would explain things.
Do you know more specifically what the restrictions are on using a single triangle strip to produce an area (when they become “stripey”)?

I am puzzled why the stripes are perpendicular to directions that the triangle strips are drawn. I draw the single triangle strip in a zig-zag pattern but the stripes are perpendicular to the zig-zags.

[This message has been edited by PeterK (edited 01-20-2001).]

Thanks billy! You were right about the normals alternating. My code has a logic error. For triangle strips, odd numbered normals calculations (using my method of calculation) should be inverted.

Thanks again. I’m going to fix it now.