Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Scene hierarchy

Daan Michiels edited this page Aug 23, 2014 · 5 revisions

The organization of objects on the screen is as follows (from top to bottom):

  • Scene
  • object
  • mesh

The object and mesh struct are pretty light-weight. The rendering code is in the Scene class, mostly because this simplifies the handling of the modelview matrix as a uniform parameter to the shaders.

Scene

The highest level in the hierarchy. A scene has a camera and a collection of objects. The Scene class does the rendering of the lower-level items (object, mesh).

The objects are kept track of by reference, so that transforming an object has effect on what the scene looks like. Caution: this also means that one should not add an object to a scene that will go out of scope!

object

The main unit of organization. An object has

  • a name (mostly for debugging purposes),
  • geometry (a list of meshes that make up the object),
  • a position and orientation (stored as a 4x4 transformation matrix),
  • a list of children.

The transformation of an object will propagate to its children during rendering. For example, if you have an object A representing a human head and an object B representing a pair of glasses, you would make B a child of A (after positioning correctly using B's transformation). Whenever the head moves, the glasses will move with it.

A child object should not be added to a scene directly. Instead, add its parent (or the parent of that parent).

The directed graph representing parent-child relationships must be acyclic. For example, if A is a child of B and B is a child of A, an infinite loop will occur during rendering.

Though not recommended, an object can have multiple parents. It will cause the object (and its children) to be rendered multiple times, once for each parent. (However, it seems possible that in the future, multiple parents will not be allowed.)

mesh

Simple collection of geometry, stored in GPU using a vertex array object (VAO). It is essentially just a handle to a VAO, but it has a couple of extra attributes that are needed to be able to draw it with OpenGL (arguments to glDrawArrays).

Clone this wiki locally