Sign in to follow this  
  • entries
    45
  • comments
    44
  • views
    50146

L Spiro on scene managers vs state managers

Sign in to follow this  
Norman Barrows

1051 views

L Spiro on scene managers vs state managers

an excellent description of scene and state managers by L Spiro from a recent thread:




[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]A scene manager manages a scene in your game.[/background]

[/font][/color]
[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]A scene is any spacial 2D or 3D area in your game (a scene manager must be dedicated to either 2D scenes or 3D scenes, not both).[/background]

[/font][/color]
[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]It inherits from nothing and contains and manages all objects in the scene.[/background]

[/font][/color]
[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]This means:[/background]

[/font][/color]

  • As a container:

    1. It contains a master list of all objects in the scene. All cameras, terrain instances, foliage data, sky, characters, models, static geometry, etc. The objects can be traversed linearly this way. It is not necessary to store them all in a single bucket--it is perfectly fine to store an array of terrains, an array of non-static geometry, an array of animated geometry, etc.
    2. It contains a spatial partition for traversing spacially more easily. For example when gathering objects for a render and performing frustum culling, or broadphase culling for physics.


    • As a manager:

      1. It manages the interactions between objects. This means kicking off the physics engine to perform physics etc.
      2. It is able to abstractly gather objects together for various other sub-systems such as frustum-culling for graphics.
      3. It alerts objects of certain things around them. An object doesn't know what the player's camera is by itself--there are many cameras in a scene, including those for rendering shadows. The scene manager uses an abstract interface to tell objects to update themselves according to their orientation with the main camera. This could be used to select LOD levels or create imposters.

      [color=rgb(40,40,40)][font=helvetica]


      desdemian, on 29 Jun 2015 - 10:04 PM, said:snapback.png

      [/font][/color][quote name="desdemian" post="5237605" timestamp="1435629880"]
      For example the main menu is a scene.
      The screen that shows the logo at the beginning of my game is a scene.
      The screen with highscores, and the settings menu are also scenes.
      Each level of the game is a scene.
      Even a pop-up dialog could be a scene.[/quote]
      [color=rgb(40,40,40)][font=helvetica]

      [background=rgb(250,251,252)]These are better described as states.[/background]

      [/font][/color]

      [color=rgb(40,40,40)][font=helvetica]

      [background=rgb(250,251,252)]A game state manages a state of the game. The main menu, credits, gameplay area, bonus-round area, stage-select, etc.[/background]

      [/font][/color]
      [color=rgb(40,40,40)][font=helvetica]

      [background=rgb(250,251,252)]All of these states have wildly different logic and requirements. A typical scene manager is unsuitable for this task.[/background]

      [/font][/color]


      [color=rgb(40,40,40)][font=helvetica]

      [background=rgb(250,251,252)]The relationship is instead:[/background]

      [/font][/color]

      • CMyGame inherits from CGame. CMyGame has data persistent throughout the game, such as your player stats.

        • CGame has a CStateManager object for managing game states.

        • A CStateManager object has a current state (CState). It could optionally have a stack of states depending on how you want to handle system messages such as a low battery on Nintendo Wii U.
        • CMainMenuState inherits from CState. All logic for the main menu is implemented here. There are no scene managers.
        • CGamePlayState inherits from CState. All logic for the gameplay state is implemented here. There is a single scene manager for managing the 3D world of your game. Thus CGamePlayState has an instance of CSceneManager. Upon loading, it fills the scene manager with objects based on which level is being loaded etc. The rest is largely up to the scene manager.

          [color=rgb(40,40,40)][font=helvetica]

          [background=rgb(250,251,252)]L. Spiro [/background]

          [/font][/color]





          [color=rgb(40,40,40)][font=helvetica]

          [background=rgb(250,251,252)]original thread:[/background]

          [/font][/color]
          https://www.gamedev.net/topic/669599-what-are-scene-managers-and-how-do-they-work/
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now