[dx9] help me with some trig?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: [dx9] help me with some trig?

  1. #1
    Join Date
    Feb 2007
    Posts
    43

    [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?

  2. #2
    Join Date
    Feb 2007
    Posts
    43

    Smile 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center