I have a program that is supposed to render 3D objects, using 2D drawing tools. The 3D objects are stored as meshes (points & faces type). The program converts all the 3D points into 2D points, and then draws the faces as polygons, in order from most to least distant faces.
Here's an example 3D box:

(link)
Here's the definition of the above box:
<object> <points> vector= figure1 1 (0, 0, 0) 2 (0, 0, 100) 3 (800, 0, 100) 4 (800, 0, 0) 5 (0, 500, 0) 6 (0, 500, 100) 7 (800, 500, 100) 8 (800, 500, 0) </points> <faces> 1, 2, 3, 4 = #FF0000 and 5, 6, 7, 8 = #0000FF and 2, 6, 7, 3 = #00FF00 and 1, 2, 6, 5 = #FF00FF and 3, 4, 8, 7 = #FFFF00 and 1, 4, 8, 5 = #00FFFF </faces> </object>
The program averages the z value of the points of each face, and orders the faces based on that. The problem, however, is that sometimes the average is not quite the best thing to do; for example, take a look at this:

(link)
It's the same box, just from another angle and position. The average of the points of the face on the right is closer to the camera than that of the face on top.
So I wanted to ask, do you guys have any ideas for how to figure out which face comes before which?
Thanks.
RR


Sign In
Create Account


Back to top









