Mail Archives: djgpp/1998/03/07/08:01:13
From: | ovek AT arcticnet DOT no (Ove Kaaven)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: 3D clipping in Allegro (sorta)
|
Date: | Sat, 07 Mar 1998 12:43:05 GMT
|
Organization: | Arctic Net AS
|
Lines: | 31
|
Message-ID: | <350140ba.142174296@isflak.arcticnet.no>
|
References: | <3500E3E8 DOT 54BA AT ainop DOT com>
|
NNTP-Posting-Host: | villager.arcticnet.no
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Brinkerhoff <brinks AT ainop DOT com> wrote:
>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.
Congratulations, you've just managed to understand the basic idea of
viewplane clipping. A few notes:
* Don't clip at z=0, clip at somewhere in front (z=1, z=0.1, or
whatever), otherwise you'll just end up with a bunch of division by
zero errors.
* Interpolate u and v and any color gradients in exactly the same way
as you interpolated a' and b'.
In order to avoid overflows and stuff with polygons far and away, you
may also want to extend clipping to the planes that correspond to the
edges of the screen, and perhaps also to a plane very far away. This
is called frustum clipping, and happens to be a bit more complex.
- Raw text -