February 13th, 2010, 05:20 AM
[dx9] help me with some trig?
I'm writing a 3d program using meshes moving only along x,y, with z=0 at all times. I say 3-d because it uses lighting and rotations.
I'd like to calculate the screen bounds in world space as a float value, given just fovy, screen ratio, and z distance of the camera.
Can anyone who's better than me at math (i.e. anyone at all) help me do this without calculating frustum planes? I think frustum planes are overkill if there's no movement along the z-axis, right?
February 13th, 2010, 07:01 AM
Got it, but still don't fully understand it! :)
Well, I finally figured out the relationship by pure brute force: bounced objects off the side of the screen and used message boxes to output the values. Thank God I used pi/4 rads as the fovy (field of view y used in the D3DXMatrixPerspectiveFov), or it would have been nigh impossible to figure out. (for me, anyway)
If anybody else needs to calculate their screen bounds in world space, it goes like this:
Ymax = z * tan (fovy/2)
Xmax = Ymax * aspect ratio
This assumes that the camera is straight back along the z-axis. But for a 2D game using 3D meshes, the camera doesn't move, so simple trig is good enough.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.