Mail Archives: djgpp/1998/03/22/11:46:00
Charles Mennerat writes:
>In the 3d world when shapes have negatives values(for z negatif) the
>perspective projection draws lines not the way we expect them.(they
>cross one another)What can I do to enter z<0 values?
You need to make sure that you never try to project a negative
coordinate, because there is no logical way for that to be done. A
perspective projection works out where a 3d point is located on the 2d
screen, but if you think about it, something that is behind you can
never be visible, so there is no way for this to produce any output at
all.
A simple implementation could just ignore any polygons that have very
small or negative depths, but a better solution is to clip your polygon
to the viewing cone before you display it. Allegro doesn't have any code
to do that, but you can find some routines in the AllegroPak addon by
Andrei Ellman, or there is a good discussion of 3d clipping algorithms
in the book "Computer Graphics, Principles and Practice", by Foley & Van
Damme.
>When you calculate (x,y,z) values rotating a shape, the shape doesn't
>seem constant.For instance going left and after coming back right the
>shape doesn't come back at the same place.What is my mistake?
Computer math is never exact, so small errors will build up over time.
You must preserve your original coordinates, and apply a complete
transformation on every frame to get from the original reference
position to wherever the object is currently located.
>Using Allegro, in rotation you must enter angles "in binary, 256 degrees
>to a circle format".What does that meen?
itofix(0) = no rotation.
itofix(256) = spin right around and end up exactly where you started.
itofix(64) = rotate by one right angle.
>What does this do: itofix(1) & itofix(256).
I don't understand: can you clarify this question?
>Why can't we just enter an angle?
You are: Allegro just uses a different unit of measurement to what you
are used to. Binary angles are cool because they can be wrapped neatly
with a bitmask operation, so you can write (angle&0xFFFFFF) to clamp it
into a single rotation range, rather than having to use slow conditional
branches or modulus operations.
--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
"Pigs use it for a tambourine" - Frank Zappa
- Raw text -