The root node for all 2D elements in the scene.
The root node for all 3D elements in the scene.
Draws the scene by updating the camera's world transform, updating the lights, and drawing the 3D and 2D elements.
The camera used to draw the scene.
Traverses the 3D and 2D elements of the scene, recursively calling the traverseSceneGraph() method on each element.
The Scene class contains and organizes all of the 2D and 3D objects that GopherGfx can draw each frame. In computer graphics, the classic way to organize all these objects is in a graph data structure called a "scene graph". This Scene class actually contains two such scene graphs, one for all the 2D objects in the scene and one for all the 3D objects in the scene. Each scene graph follows a tree structure with one root node (see root2d and root3d), and every object in the scene needs to be added to one of these root nodes, either as a direct child of the root node or a child of a child, or child of a child of a child, etc.
For the 2D scene graph the base class for every object that can be added to the scene graph is Node2. If you look at the Node2 class, you will see every Node2 has a postion, rotation, scale, and a number of other properties.
For the 3D scene graph the base class for every object is Node3. Again, each Node3 has a position, rotation, scale, etc. It is possible to create Node3s directly, and the main reason for this would be to setup a hierarchy of nodes in the scenegraph, for example
If you don't need a complex hierarchy, you may never deal directly with a Node3 and instead just work with subclasses of Node3, like Mesh3 and PointLight. In the car example above, none of the Node3s that have been added so far actually draw anything because none of them are meshes. They are just there for organization. A next step in creating the car would be to add 4 cylinders Mesh3s under the wheels node, for example:
There are several benefits to using a hierarchy like this to organize our Meshes. If we want to reposition the entire car in the scene, then we can change the position of the carParentNode and all of the wheels, doors, etc, will move because they are all children of the carParentNode. We may also want to loop through all of the wheels of the car, for example, to make them spin, and we can do this by looping through all of the children of the "wheels" node.