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

Get visible models

Last post 7/1/2009 9:05 AM by BJM. 2 replies.
  • 6/30/2009 9:38 PM

    Get visible models

    Hi all,

    I am trying to find a way to get all the models that are visible on the screen. So in the
    end I have a list of all visible models. I think it can be done by using the
    Viewport.Unproject function on every pixel of the rendered frame but is there a better
    way to do this?
  • 6/30/2009 10:33 PM In reply to
    • (2340)
    • premium membership MVP
    • Posts 1,225

    Re: Get visible models

    Normally this is done by testing whether the viewable area (which is frustum-shaped) intersects with a bounding sphere or bounding box fit to a model.  This is much cheaper/quicker than comparing all pixels.

    To help with this, XNA provides the BoundingFrustum class.  You basically just create one with the combined View * Projection matrix you're using for your camera, and then you can use it to test a BoundingBox or BoundingSphere for visibility.  For Model's, you can just use the BoundingSphere provided by each ModelMesh.
    Matt Pettineo | DirectX/XNA MVP


    Ride into The Danger Zone | PIX With XNA Tutorial
  • 7/1/2009 9:05 AM In reply to

    Re: Get visible models

    Tnx,

    However, when there is an object behind and an other one in the frustum it is picked up too while it isn't visible.
    These are the objects I was trying to find. So are there any other possibilities?
Page 1 of 1 (3 items) Previous Next