Scene Graph
Home | About XEngine | Engine API | SceneGraph | Changelog | Programming Guide |
Introduction
The SceneGraph API is a scene management toolkit for the XEngine renderer. Although in principle it can be easily modified to work as a standalone library, it is designed to operate in par with the XEngine API. The toolkit provides for building dynamic scene graphs and its design makes it easy to expand and provide more elaborate nodes and behaviors. The scene graph is accessed in two ways:
- Through XML files which use the Scene Description Language
- Through the SceneGraph API which exposes some of SceneGraph's core functionality, so that it can be accessed programmatically
The scene graph essentially consists of a number of collection and leaf nodes, each one instanciating a functional part of a three-dimentional world. The root node of this directed graph is the World3D node. Every node in the hierarchy is derived from the generic Node3D class, which implements all message passing and event processing mechanisms. A major category of subclasses of the Node3D class is the grouping nodes or collections (Group3D). Apart from the essential operation of managing a group of children nodes and passing the operations performed on the scene graph down to them, Group3D-derived node types also provide key functions in the scene graph such as queries by node name and by node type. World3D is a special Group3D node that essentially provides the entry point to the whole of the scene graph and a connection to the underlying rendering system. Upon creation, all nodes maintain reference to the unique World3D instance in the scene graph (protected member World3D *world) and their parent node (protected member Node3D * parent).
The tag format of the scene files is described in detail below in the SceneGraph scene description language.
The minimum set of node types in the scene graph are:
- Node3D. The node type all other nodes are subclassed from. It provides basic states such as visible and active, the message queuing mechanism and the interface for polymorphic call of all basic operations in the scene graph.
- World3D. This is the root node of the scene graph and of course a subclass of Group3D.
- User3D. This type of node implements an autonomous entity that can navigate through the virtual world as a result of a controller that provides input and therefore drives the node. Despite its name, this is not a unique node; many User3D instances may populate the virtual world, each one representing a different actual user (e.g. for multiplayer games) or computer-controlled characters, animals or avatars in general. The User3D nodes do not implement a viewing system, as this is part of the Camera3D node, which of course can be bound (attached) to any scene graph node, including a User3D instance. Cameras and users are completely different entities in SceneGraph API, allowing a large diversity of configurations, multiple angles, multiple users and any dynamic combination of them. User3D is a subclass of Group3D (actually it is derived from a TransformNode3D which is in turn subclassed from a Group3D) and can therefore contain other nodes. This makes the addition of a visual represntation of the avatar very easy, as you only add whatever node you want as the content of the user and it will move along with it.
- Camera3D. The eye to the world. It can be configured to follow a specific user or any other node, to be left standing alone or to be transformed as a normal geometric node in a kinematic chain. Multiple cameras can be defined but only one acts as the primary one that gets displayed to the output viewport.
- Input3D. This is the base class for all types of controller nodes. The basic input node implements user input from the GUI using the mouse and keyboard or alternatively via the joystick. This is an abstract device interface which provides normalized axes values and button states for navigation and event triggering. It is accompanied by a large number of predefined events, primarily associated with the changes in the state of its variables.
- Group3D. The basic collection of nodes in the scene graph. Every node that needs to contain multiple connections to other nodes must be subclassed from this one or from one of its subclasses. It provides hierarchical traversal for rendering, culling, behavior simulation, initialization and reset as well as hierarchical queries and parsing.
- TransformNode3D. Implements a standard geometric transformation node. OpenGL-style rotation, change of scale and translation is supported as well as methods to obtain and set the matrix directly. The transformation can be reset using event messages. The order of transformations is fixed: Scale, then Rotation and finally Translation.
- Geometry3D. This is the simplest node to represent geometric data. For the moment, it is used for managing and displaying static geometry loaded from a file.
Scene Graph Node Types
Please follow the links below to view each node's API functions as well as its XML specification:
- Scene Description Language
- Camera
- Directory
- Eventmessage
- Geometry
- Group
- Input
- Light
- Node
- Primitives
- Root
- Spinner
- Transformation
- User
Last updated: 31 May. 2013