View Full Version : how to simulate curved surfaces?

10-04-2002, 01:47 AM
hi all,

i recently got an assignment as followings:

You are to create three separate, non-overlapping windows. You are also to create two different objects that will appear in all three of these windows.

The windows will have the following specifications:

Window 1 : In this window each object is to be displayed using flat shading. Two light sources are to be included and each of the objects is also to display different colours and material characteristics. This is an opportunity for you to experiment with surface characteristics of the objects to see what type of surfaces that you can simulate.

Window 2 : Objects in this window are to be displayed using Gouraud shading. The two light sources and material characteristics used in window 1 will also be used here.

Window 3 : Again you are to use a Gouraud shade with the same light sources and material factors. This time, though, you are to simulate curved surfaces by the process of averaging normals. These normals have to be calculated within your program.

i have successfully done window 1 and window 2. now i'm quite confused about window 3. what is meant by simulating curved surfaces? how to computer averaging normals.


10-04-2002, 02:40 AM
Huh! Computers can't draw curves! They can approximate them by drawing lots of little straight lines, so the more little lines used to draw a circle the more circular it will look. As for averaging normals, the normal for a polygon surface may be the average of the normals at each of its vertices, and these normals at the vertices are dependant on the adjoining polygons.

10-04-2002, 02:52 AM
it seems not hard to calculate the average normal. then what shall i do?

10-04-2002, 03:16 AM
it seems not hard to calculate the average normal. then what shall i do?
add your normals then divide the sum by the number of normals you have, then normalize if necessary.


10-04-2002, 03:33 AM
thank u. what i'm really interested in after i get the averaging normals, what shall i do next?

10-04-2002, 04:15 AM
Read the opengl manual!
Well you have to define the normal for each poygon/vertex you draw.

10-04-2002, 05:07 AM
well, maybe i should provide the complete requirements:

The objects can be generated (i) using a package such as 3D Studio Max, (ii) taken from the web or (iii) you can design the objects yourself. In any of these situations it must be made clear as to where the model has come from. The information for the objects must be read from a file and you will find that you will need to include both a vertex list for position and a face (polygon) list for topological information. The face list that you use in your program will need to include the colour and materials values for each face. These may come from an external source with the vertex and polygon data but all other information must be generated within your program.

what i did was i dragged an object from the website and exported it as a .asc file. i read the data from the file so i dont actually know which part displayed on the screen is for which data. now could someone explain me in more detail what window 3 asks me to do?

thank u.

10-04-2002, 05:19 AM
look in the SDK and there is an example for a sphere, this should show you the idea of approximating a curved surface using polygons. You can work out the normal for each polygon and specify this in the code. So now when you shade and light this curved surface each polygon will light differently (due to the normal facing in a different direction) giving the illusion the surface is curved (if you have enough polys). Alternately have a play with glutSolidSphere which does all of the approximation and normal averaging fpor you but you can see the shading part a little better

10-04-2002, 03:27 PM
a silly question: what is SDK?

10-05-2002, 12:57 AM
software development kit
download the opengl source as opposed to just the binaries.

10-05-2002, 06:57 AM
now could someone explain me in more detail what window 3 asks me to do?
Yes, someone could: your professor! Don't you think he could clarify the assignment better than a bunch of complete strangers?

The assignment is not worded very clearly, but it sounds like you are being asked to subdivide the triangles of the object and just draw more Gouraud-shaded triangles for window 3. I think by "the process of averaging normals" he means the normals for the new vertices should be calculated by interpolation. To interpolate the normals, you could just linearly interpolate each component of the normal and then renormalize. Of course, I'm just guessing here. Ask the prof!

add your normals then divide the sum by the number of normals you have, then normalize if necessary.This will only give you the correct normal if the vertex is exactly in the center of the polygon. And normalization is always necessary if you want the lighting to look correct.

[This message has been edited by *Aaron* (edited 10-05-2002).]

10-05-2002, 07:00 AM
Yeah, what Aaron just said.

[This message has been edited by *Aaron* (edited 10-05-2002).]

10-05-2002, 07:33 AM
SGI's implementation (http://oss.sgi.com/projects/ogl-sample/) is open source.