03-31-2005, 07:19 PM
I read in a file to create my object. The format is pretty basic, the first int tells you the number of vertices and the second int tells you the number of polygons. Then the coordinates for the vertices are listed followed by the information for the polygons (the first number tells you how many vertices make up the polygon and the subsequent numbers tell you what vertex to use). Below is a very basic object in the described format (other objects have 40000+ polygons).
In order to perform the shading for the object I calculate the polygon normal. The problem I am running into is that you can see the polygons that form the object. I was told that in order to see a more realistic object I need to calculate the vertex normal for the object.
My question is: has anyone done something like this before? Like I stated earlier these objects can be relatively large. What do you think would be the best way to determine this information?
I would hate to have to traverse the file and create some data structure to store the polygons that share a common vertex (although I am assuming this is my only course of action). Is my thought process correct or is there a better way to get the results that I am looking for...
data 12 8
-.5 0.0 -.5
0.0 0.0 -.5
0.0 .5 -.5
.5 .5 -.5
.5 -.5 -.5
-.5 -.5 -.5
-.5 0.0 .5
0.0 0.0 .5
0.0 .5 .5
.5 .5 .5
.5 -.5 .5
-.5 -.5 .5
4 3 9 10 4
4 1 7 8 2
4 12 6 5 11
4 7 1 6 12
4 9 3 2 8
4 10 11 5 4
6 9 8 7 12 11 10
6 4 5 6 1 2 3
In order to perform the shading for the object I calculate the polygon normal. The problem I am running into is that you can see the polygons that form the object. I was told that in order to see a more realistic object I need to calculate the vertex normal for the object.
My question is: has anyone done something like this before? Like I stated earlier these objects can be relatively large. What do you think would be the best way to determine this information?
I would hate to have to traverse the file and create some data structure to store the polygons that share a common vertex (although I am assuming this is my only course of action). Is my thought process correct or is there a better way to get the results that I am looking for...
data 12 8
-.5 0.0 -.5
0.0 0.0 -.5
0.0 .5 -.5
.5 .5 -.5
.5 -.5 -.5
-.5 -.5 -.5
-.5 0.0 .5
0.0 0.0 .5
0.0 .5 .5
.5 .5 .5
.5 -.5 .5
-.5 -.5 .5
4 3 9 10 4
4 1 7 8 2
4 12 6 5 11
4 7 1 6 12
4 9 3 2 8
4 10 11 5 4
6 9 8 7 12 11 10
6 4 5 6 1 2 3