Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Camera to Projection plane distance

Author
Message
luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 9th Oct 2007 04:18 Edited at: 9th Oct 2007 04:18
What determines the distance the camera is located from the 3D projection plane, as in the accompanied picture?

Attachments

Login to view attachments
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 9th Oct 2007 05:22
you can set this, think its SET CAMERA DISTANCE
you set near and far distances for your camera's vision.

In programming, nothing exists
luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 9th Oct 2007 05:41 Edited at: 9th Oct 2007 05:41
That's not what I meant. I want to know what determines the distance between the camera and the plain that "sees" the 3D world. Here's another picture of what I want. I think it is related to the camera's FOV...

Attachments

Login to view attachments
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 9th Oct 2007 05:55
@luke810

You need to know the screen width and height, and the field of view. It's basically right triangle trig.

I use the screen height because it keeps things unskewed and matches pretty accurately to the 3d screen in DBC:



What this does is, gets the field of view (in radians) coverts that to degrees and divides it in half. So now degrees ~ 31. We do that because we are going to make a triangle from the camera, to the center of the viewing plane, then to the edge of the screen. I use the screen height because that will keeps things nice and square so the FOV isn't skewed because of a larger width.

Next we divide half of the screen height by the tan(degrees) and that gives us the zdist to the camera.

This formula is taken from the right triangle math.
SOHCAHTOA which is

sine(angle) = opposite/hypotenuse
cosine(angle = adjacent/hypotenuse
tangent(angle) = opposite/adjacent

I used the last formula where the adjacent value is what we are solving for. The opposite value is half of the screen height, and angle is approxiametly 31 degrees in this case.

Enjoy your day.
luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 9th Oct 2007 07:41
Alright, thanks Latch. I didn't know what the distance was based on. It seemed obvious it had to do with the FOV and the screen dimensions but I just wasn't sure how the field of view worked and I was getting confused because I thought it was originally supposed to be pi radians, but that didn't make any sense; Apparently its 3.14/2.905.

Login to post a reply

Server time is: 2025-05-31 21:20:49
Your offset time is: 2025-05-31 21:20:49