Re: A92: About 3D.


[Prev][Next][Index][Thread]

Re: A92: About 3D.




VINCENT VIVES wrote:
> 
> Hi.
> I'm writting that can draw any shapes, if you give it the coordinates of
> each vertex, and the links between them.
> I know that when you have a point  let's say : A ( x, y, z).
> when you want to project the point in a 2 coordinates a plane, to keep the
> perspective you have to do :
> 
> screen_x= x/z
> screen_y= y/z
> 
> But I don't really see how I could do this in ASM, since ASM only deals with
> integers.
> If someone could give me a hand, it would be very kind.
> 
> VIVES Fabien
> vives@NOSPAMwanadoo.fr
> ( Enlevez NOSPAM pour me repondre )
> ( Get NOSPAM off to answer me )..
> ICQ : 16950211


Floating point math would give you great precision, but the price would
be speed.  Instead, you could use scaled integers as coordinates.  That
is, all of your coordinates are multiplied by 1000 for example.  Then
you'd adjust your perspective to compensate for your scale:

screen_x = (x/z)/1000
screen_y = (y/z)/1000

The 68000 can easily handle integer division, and scaling like this gives
you precision to 1.0x10-3.  You can also scale sine and cosine tables in
the same fashion (really speeds up rotation).  Thus, you get the advantage
of high speed rendering plus a little added precision for accuracy.

Have fun!

Keith Kirton
kkirton@acex.com


Follow-Ups: References: