Mail Archives: djgpp/1999/05/05/18:06:45
Ike wrote:
:
: I've recently started testing out some of the cool 3D functions in
the
: Allegro library, and this is my first time doing anything constructive
in
: 3D. Well using the matrix routines and V3D_f structure I can get a
: four-faced pyrmid to roate around the Z-axis, but Im having some
trouble.
: The faces on the back of the triangle show through the faces on the
front
: becase they are drawn first and I can't figure out how to Zsort them
so the
: ones on top get blitted first.
: Is there a function in the Allegro libarary that will do this for
me?
: How exactly is it done? Any help would be greatly appreciated.
Thanks!
I don't know about Allegro but I coded something like this recently,
I used back-face culling, using normals to the polygons (a line
perpendicular
to the face) The angle from the normal to the viewpoint gives the
direction the
polygon is facing, don't draw anything facing away from you.
I can mail you the source if you like.
OR
Draw the polygons from back to front, er painters algorithm I recall.
Work out the average Z for the polygon and then sort them in order of Z.
This will of course never look right for certain complex shapes.
Sum the Z values for the poly abd divide by the no of values to get
a fairly reasonable average suitable for your needs.
Ed
- Raw text -