www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/10/03:15:39

From: qballlives AT aol DOT com (QBallLives)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: 3D clipping in Allegro (sorta)
Date: 10 Mar 1998 08:01:09 GMT
Lines: 77
Message-ID: <19980310080100.DAA29444@ladder03.news.aol.com>
NNTP-Posting-Host: ladder03.news.aol.com
Organization: AOL http://www.aol.com
References: <3500E3E8 DOT 54BA AT ainop DOT com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>This idea may have been done before, but I've never heard of it being done 
>before.
>
>I haven't tried it, but it seems like it should work, and it seems like it is
>
>mathematically correct.
>
>I came up with the idea to make walls for a 3d engine, but it should work 
>with any polygons.
>
>The idea is that with Allegro, polygons that have points that all have a 
>positive z value will all be drawn properly (pretty much).  I have searched 
>the net for info on clipping, and frustrum (is this the correct word?) 
>clipping is a little too complicated for me, and it seems to me that it 
>is too much work.  I haven't actually sat down and compared or benchmarked 
>it, but my idea seems that it should be faster. 
>
>Suppose you have a wall (a four sided poly).  Lemme try a diagram to help 
>explain.
>
>                  (d,e,f)
>              | / 
>              |/|
>              | / (j,k,l)
>             /|/
>     (a,b,c)/ |
>            |/|
>            / |
>     (g,h,i)
>              ^(xy plane, where z=0)
>
>Notice that one side of the poly is in the negative z region.  So, find the 
>slope of the lines (a,b,c)-(d,e,f) and (g,h,i)-(j,k,l).  Using these slopes, 
>find where the lines intersect the xy plane (by finding an x slope and a y 
>slope, if this makes sense to you), giving you points (a',b',0) and 
>(g',h',0).  When you draw your poly, use these points, instead, making all 
>your points end up in front of the xy plane instead of behind it (btw, what i
>
>call the xy plane is the plane that contains both the x and y axis where 
>z=o).
>
>Since I do not understand completely how allegro texture maps, this is where 
>the difficulty begins.  but I was thinking that if you used the distance 
>formula to find the distance between (a,b,c) and (a',b',0), you could just 
>take this value and add it to your u value for texture mapping.
>
>Im open for criticism.  If anyone can find a way to improve upon this without
>
>destroying the original idea or making it too complex, id like to know.  id 
>also like to know if my ideas for texture mapping would work, and if they 
>wont, what will?
>
>Glen Ellis Brinkerhoff

Allegro does clip, but it doesn't do OBJECT CULLING as is...

That's one thing you'll definitely need to do...

As far as the clipping, I'm definitely going to check out this thread,
one friend of mine has a solution where, for his purposes, he just says: if z
is less than 0, make it 1....

Of course, that isn't a cure-all.

The bottom line is, it isn't a flaw in the tmapping, it's just an area where
you'll have to find some good clipping/object culling code to plug in to
Allegro.

It still rocks!




Jim the loiterer
aloiterer AT juno DOT com
http://www.fortunecity.com/skyscraper/gigahertz/179/index.html

- Raw text -


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