Posts: 1,556
Threads: 298
Joined: Dec 2002
Ok, let's say I just wanted to put a pixel in a location that applies to perspective variables... What I am asking is how would I put a pixel somewhere using these variables...
CameraX
CameraY
CameraZ
CameraRotateX (left and right)
CameraRotateZ (up and down)
CameraRotateY (tilt left and tilt right)
PixelX
PixelY
PixelZ
If I forgot any obvious ones, jsut add it. But pretty much, I want a formula that would plot a pixel in the right spot according to those variables. Thanks.
PS: Assume that 320 and 200 is the center of the screen in a 640 by 400 resolution. The Center Z calue is 0 (or higher if negative numbers don't work...)
Posts: 3,288
Threads: 167
Joined: Nov 2001
Code:
Distance=256-Z
if Distance then
Px=320+(256*X/Distance)+CamX
py=240-(256*Y/Distance)+CamY
Pset(px,Py),15
Else
End if
[/code]
Posts: 1,556
Threads: 298
Joined: Dec 2002
Thank you, but how would I apply camera rotation to it? (don't really)
Posts: 1,166
Threads: 62
Joined: Apr 2003
Quote:--- Start copying
***********************| COSINE TABLES |*************************
c! = cos(angle * 3.14 / 180)
s! = sin(angle * 3.14 / 180)
***********************| NON 3D ROTATION |***********************
X2 = X * c! + Y * s!
Y2 = Y * c! - X * s!
***********************| 3D ROTATIONS |**************************
Theta = Left Right Phi = Up Down
X2 = -x * s!(theta) + y * c!(theta)
Y2 = -x * c!(theta) * s!(phi) - y * s!(theta) * s!(phi) - Z * c!(phi) + p
Z2 = -x * c!(theta) * c!(phi) - y * s!(theta) * c!(phi) + Z * s!(phi)
***********************| 2D to 3D Conversion |*******************
X3 = 256 * (x2 / (Z2 + zCenter)) + xCenter
Y3 = 256 * (y2 / (Z2 + zCenter)) + yCenter
***************| FIND OUT WHAT DIRECTION IT IS GOING |**********
stepx = s!(angle)
stepy = c!(angle)
--- Stop!, open a new document and paste it into it...
am an asshole. Get used to it.
Posts: 566
Threads: 86
Joined: Feb 2003
http://heigeas.free.fr/laure/ray_tracing/index.html
This girl is a professional... The pics may help you, and the site is really interesting anyway!
hink Global, Make Symp' All ! ®
Posts: 1,166
Threads: 62
Joined: Apr 2003
You're forgetting we don't know FRENCH! Gah...
am an asshole. Get used to it.
Posts: 566
Threads: 86
Joined: Feb 2003
that's why I suggested you could try to babelfish the pages...
There is also the superb site of Hugo Elias, which is in english:
http://freespace.virgin.net/hugo.elias/
hink Global, Make Symp' All ! ®