I believe I have all the math right, but, as I did it myself, it could easily not be. Here it is.
To render a point: n = 1/(z_of_point - z_of_camera) X position on screen = n * (x_of_point - x_of_camera) Y position on screen = n * (y_of_point - y_of_camera)
I got that by doing this:
- Assume camera is at origin (0,0,0) - Point is at (A,B,C) Parametric says: x = At y = Bt z = Ct This defines a line in 3D space. Solve for t when z=1 (depth is "1" away from camera, basically, displaying what "CAMERA" would see onto a screen 1 unit away from the camera) t = 1/C y = B(1/C) x = A(1/C) And there you have it, the x and y positions of the point as rendered on the screen. If you don't understand, I'll try to explain it better.
I'm basically drawing a line from the camera to the point and finding where it intercepts a plane "1" away from the camera (basically a "wall" or "square" that ends up being my screen) (no rotating cameras yet!)
The question: How do I render a polygon that has part, but not all, of the polygon past the camera?
Last edited by MoreGamesNow (2012-03-29 20:59:38)
Offline
Well your math is right, the problem is you have to consider the Field of View. When you're looking at...well, I guess just looking, you have a certain amount that you can see determined by the farthest angle that your eyes can see. A comfortable FOV is usually around 60 degrees...you can go all the way up to 180...or even 360 if you wanted but it would be really bizarre. Assuming you're using the whole screen for your drawing (480x360) you could do a horizontal FOV of 80 degrees and a vertical FOV of 60 degrees.
You're going to have to calculate intersections between the "edges" of your FOV and the edge/face of your polygon...I can go on, but if you want to try and figure it out from here, I'll stop.
Offline
AtomicBawm3 wrote:
Well your math is right, the problem is you have to consider the Field of View. When you're looking at...well, I guess just looking, you have a certain amount that you can see determined by the farthest angle that your eyes can see. A comfortable FOV is usually around 60 degrees...you can go all the way up to 180...or even 360 if you wanted but it would be really bizarre. Assuming you're using the whole screen for your drawing (480x360) you could do a horizontal FOV of 80 degrees and a vertical FOV of 60 degrees.
You're going to have to calculate intersections between the "edges" of your FOV and the edge/face of your polygon...I can go on, but if you want to try and figure it out from here, I'll stop.
That was pretty much exactly what I needed. Gentle prompt in the right direction, no spoiler. Thanks. Kind of funny that I had a near 180 degree point of view (179.36 vertically ). I'll start on edge-plane intercept now. Thanks again.
Offline