www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/05/18:06:45

From: Edward_hill <ha AT nochance DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Another 3D question.
Date: Wed, 05 May 1999 10:40:08 +0100
Organization: GEC-Marconi
Message-ID: <373011F8.24DD4038@nochance.com>
References: <372b346c AT news DOT ismi DOT net>
NNTP-Posting-Host: pc02372.gmsws.gecm.com
Mime-Version: 1.0
X-Mailer: Mozilla 4.51 [en] (Win95; I)
X-Accept-Language: en
Lines: 38
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com


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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019