Mail Archives: djgpp/1998/03/06/21:17:08
From: | Brinkerhoff <brinks AT ainop DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | 3D clipping in Allegro (sorta)
|
Date: | Fri, 06 Mar 1998 22:06:32 -0800
|
Organization: | Dave's Machine Service
|
Lines: | 50
|
Message-ID: | <3500E3E8.54BA@ainop.com>
|
NNTP-Posting-Host: | mast65.ainop.com
|
Mime-Version: | 1.0
|
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
- Raw text -