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

Best Approach for Multiple Cameras

Last post 04-15-2008 5:37 PM by PikeTheHuman. 2 replies.
  • 04-15-2008 1:54 AM

    Best Approach for Multiple Cameras

    I'm messing around with making my engine work with multiple cameras (for multi-player and/or rendering to a texture), and am trying to figure out the best/cleanest way to do it.

    Any thoughts regarding which of the following approaches would be preferable?  Is there a third alternative that is better?

    Scenario 1.  Loop through the scene once, passing the list of cameras to the drawable objects

       foreach drawable object in scene
          foreach camera
             apply camera settings (view, projection, etc.)
             draw it

    Pros: Textures/Vertices/etc. for a given object only need to be set once
    Cons: Drawable objects need to be aware of cameras, camera settings applied repetively

    Scenario 2. Loop through the scene once for each camera

       foreach camera
          apply camera settings (view, projection, etc.)
             foreach drawable object in scene
                draw it

    Pros: Cleaner code.  Camera settings only need to be applied once per camera
    Cons: Textures/Vertices/etc. on a given object may need to be set once per camera

     

    Thanks!

  • 04-15-2008 3:14 AM In reply to

    Re: Best Approach for Multiple Cameras

    Answer
    Scenario 2.

    Cleaner and less coupled code should always win unless and until actual performance issues require something else.

    Besides, there are other/better ways to minimize state changes. You can minimize them by using a retained mode renderer that sorts by state changes (and maybe depth for correct transparent object rendering) and it will improve your performance more without making your code less clean or more coupled.
  • 04-15-2008 5:37 PM In reply to

    Re: Best Approach for Multiple Cameras

    Thanks!
Page 1 of 1 (3 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG