Scene vs Screen Element

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Scene vs Screen Element

      I think I am confused as to the differences between a Scene and a Screen Element as mentioned in the book and how they are used. Both are inherited by the ScreenElementScene class (inheriting Scene and IScreenElement) which is only a component of the HumanView class where it is a component twice, once as a pointer to itself and once as a list of IScreenElement's. I'm also not really sure why its included as a pointer as it is only referred to in the constructor, but not used anywhere else and the list is what appears to call Scene's functions through the ScreenElementScene class.

      Here is my understanding thus far:

      Scene:
      - Container/manager for SceneNodes with each node representing a rendered game object
      - I see this as a container for what is in the current level, area, etc, allowing for different scenes to represent different levels of objects. When a new level or area is loaded its corresponding scene is used.

      Screen Element:
      - "anything that draws and accepts input" (pg 284 of book)
      - from what I can tell it appears to be mainly used for menus, buttons, and other UI elements, but on page 285 it says that "other games use multiple screens to set up the characters or misison." This would imply that it is involved with game objects as well, not just UI.

      Both have functions that render, restore, update, and what to do on lost device. Some questions that will hopefully help clarify/organize my confusion:

      1) What is the relationship between a Screen Element and a Scene?
      2) Why not implement screen elements as scene nodes? Each menu could be a node with sub-menus and other elements as children nodes.
      3) If they are to help divide the UI and main menu from the game world and its objects why the combo class (ScreenElementScene)?
    • The implication I got from the book was that a 3D scene really is actually rendered as a 2D plane once mapped to screen space, so you can think of it as only one of the different layers of graphics that make up a game. This should also help to make the ordering of UI and the Scene easier.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • "1) What is the relationship between a Screen Element and a Scene?"

      So GCC does something a little funky which i don't agree with (but its a minor grivence). If you look in UserInterface.h you'll see

      "class ScreenElementScene : public IScreenElement, public Scene"

      ScrenElementScene is both an IScreenElement AND a Scene. If I had programmed this then there would have just been a Scene member variable as part of ScreenElementScene, but meh, a minor grievance. I've always felt multiple inheritance us best avoided unless absolutely necessary.

      Anyways, look in HumanView.cpp. In VOnRender you'll see an iterator that cycles through all the ScreenElements and renders them one by one. If I recall correctly, GCC has 2 ScreenElemets, the Scene Graph and the UI overlay.

      "2) Why not implement screen elements as scene nodes? Each menu could be a node with sub-menus and other elements as children nodes."

      The UI is supposed to render on top of EVERYTHING as an overlay. The scenegraph is in 3D space while the overlay is in 2D space. I can't even think of a non-horribly painful way to merge the UI overlay into the 3D scenegraph.
      Furthermore, these elements should very rarely, if ever interact with each other. For example, UI elements don't cast shadows, they don't emit light, they don't have collision hulls, they aren't occluded since the are always visible.

      "3) If they are to help divide the UI and main menu from the game world and its objects why the combo class (ScreenElementScene)?"

      Think of a "Scene" as a collection of stuff. The UI is simply a collection of elements that need to be rendered, whether its a window, button, or picture of a kitty cat. Let me reiterate that the game scene is in 3D space while the UI scene is in 2D space, hence the necessary separation.
    • Electrohamster - what an excellent explanation! Thanks so much.

      Regarding multiple inheritance - I generally avoid it too, but I make a small exception when one of the base classes is an interface class. I get stomachaches when I see classes created by simply combining other classes through inheritance.
      Mr.Mike
      Author, Programmer, Brewer, Patriot