XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

screen boundaries

Last post 06/11/2008 16:36 by Crying Monkey Studio. 4 replies.
  • 06/11/2008 4:46

    screen boundaries

    hey all,

    i'm working on a (mostly) 2d game, but in 3d space...so everything is at y=0, camera is at (0,800,0) looking down.  my question is how can i get the 3d coordinates of the boundaries of what is visible?  specifically, if an object is at y=0, what are the maximum and minimum x and z values that are within the camera's view volume?  of course, i need to account for varying resolutions, etc, so trial and error isn't a good option :)

    i'm sure there's an easy solution, but i'm not seeing it.

    thanks,
    mike
    Coming soon! Zulu Hour.
  • 06/11/2008 5:28 In reply to

    Re: screen boundaries

    It is really just basic trigonometry, assuming your floor is flat at y=0

    You need to have the height and the angle, so you need to get the length of the hypotenuse, which can be attained by:
    (1/cos(FOV/2))*height
    That will get the height of the viewable rectangle. To get the width, just multiply it by the aspect ratio.
    The FOV and Aspect Ratio come from your Projection Matrix and the height, you said was 800. So just plug it in and go!
    Regards,
    Louis Ingenthron
    Fortis Venaliter
    Lead Developer of FV ProductionsFV Productions
  • 06/11/2008 14:18 In reply to

    Re: screen boundaries

    Louis Ingenthron:
    It is really just basic trigonometry, assuming your floor is flat at y=0

    You need to have the height and the angle, so you need to get the length of the hypotenuse, which can be attained by:
    (1/cos(FOV/2))*height
    That will get the height of the viewable rectangle. To get the width, just multiply it by the aspect ratio.
    The FOV and Aspect Ratio come from your Projection Matrix and the height, you said was 800. So just plug it in and go!


    the thing that's messing me up is the resolution, which isn't in that equation.   basically, 1280x720 will have a bigger viewable area than 640-480.  or am i rethinking things?
    Coming soon! Zulu Hour.
  • 06/11/2008 15:11 In reply to

    Re: screen boundaries

    Think about a first person shooter. When you go up in resolution, does your view become wider? Nope, you just get more detail. How much you actually see is set in the projection matrix, which doesn't change with the resolution (except for aspect ratio).
    Regards,
    Louis Ingenthron
    Fortis Venaliter
    Lead Developer of FV ProductionsFV Productions
  • 06/11/2008 16:36 In reply to

    Re: screen boundaries

    fair enough.

    thanks for the help...feel pretty dumb now :) .
    Coming soon! Zulu Hour.
Page 1 of 1 (5 items) Previous Next