Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Plotting a pixel in perspective space...
#1
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...)
Reply
#2
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]
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#3
Thank you, but how would I apply camera rotation to it? (don't really)
Reply
#4
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.
Reply
#5
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 ! ®
[Image: Banner.gif]
Reply
#6
You're forgetting we don't know FRENCH! Gah...
am an asshole. Get used to it.
Reply
#7
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 ! ®
[Image: Banner.gif]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)