Mail Archives: djgpp/1998/10/17/16:39:04
Message-ID: | <008801bdfa0e$21821020$9aafccc2@d9a9a4>
|
From: | "Linxman" <linxman AT polbox DOT com>
|
To: | <djgpp AT delorie DOT com>
|
Subject: | Re: perspective
|
Date: | Sat, 17 Oct 1998 22:38:04 +0200
|
MIME-Version: | 1.0
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Mailer: | Microsoft Outlook Express 4.72.3110.1
|
X-MimeOLE: | Produced By Microsoft MimeOLE V4.72.3110.3
|
Reply-To: | djgpp AT delorie DOT com
|
There's a great 3D tutorial on http://www.gameprog.com/codex/source.html
Check "3D Algebra Tutorial" if you want info about projection and other
basic stuff.
>jud wrote:
>>
>> im making a cad type program and i was wondering if any of you know a
good
>> algorithm for calculationg perspective
>
>Well, make the translations needed to get your screencoordinates(like
>translation and rotations) then either use the matrix:
>
>1 0 0 0
>0 1 0 0
>0 0 0 -1/d
>0 0 0 1
>
>where (0,0,d) is the projection plane.
>
>or (same thing but without the use of a matrix):
>
>multiply all x and y (after the translations) with
>the z-coordinate *(-d)
>
>I think
>
>s=0;
>if(1-z/5000>0)
> s=1/(1-z/5000);
>x=x*s;
>y=y*s;
>
>(and then just translate the coordinates to the center of the
>screen(like x+=320;y+=240; in a 640x480 window))
>
>will work, but it's just ripped out of an old code so I don't know if
>it'l work or not...
>
>Hop it helped anyway.
>
>Ludvig Larsson
>
- Raw text -