News Overview SceneEngine Downloads VideoTutorials Main Page SourceForge Get Involved Bookmark and Share

The Scene

The Scene is like a tree structure that represents the virtual world. This structure is composed of building blocks that have different roles, like Hierarchy Nodes, Objects, Materials, Textures and Animation Controllers. This blocks can interact with the blocks they are connected to, to provide a global functionality.

This tree structure is known as a Directed Acyclic Graph. This type of graph is similar to a tree structure where branches are allowed to merge. The main restriction of this type of graph is that there cannot be cyclic dependecies, this means that a path cannot start and end at the same graph node.

Image:Dag_00.gif

Graph nodes are connected to each other, this connections go from one graph node to another. These connections have direction, so depending of where the graph node is in the DAG it can have dependants and/or dependencies

Image:Dag_dependants_dependencies_00.gif

SceneEngine implements the DAG funcionality with a single class that represents a graph node. This class is ScEng::Block. This class implements all the dependency management and take care of deleting the block when it has no more dependants. All the elements that are part of the scene are derived from the ScEng::Block class. The blocks that are not connected to the scene might work on the current session, but they won't be saved with the scene.

Image:Dag_scene_00.gif

In a typical scene a Block knows what kind of dependencies it needs, and it's the block who manages these dependencies. For example, the StandardMaterial block has a dependency to a Texture block in its diffuse channel, and it rejects blocks that are not textures if they are tried to be set as a diffuse dependency. However, a block doesn't know anything about its dependants. For example, a modifier can have a dependency to a Material, or a Tool can have a dependency to a Node. For this reason the class ScEng::Block implements the methods that deal with the dependants and leaves the dependancy management to the classes that inherits from ScEng::Block by implementing the virtual dependency methods.

Messages

When a block changes internally, it must report this change to its dependants so they can take the appropiate actions. This is done using the method ScEng::Block::ReportChange( message, parameters ).

The Block class processes internally the ReportChange method and sends this message to all the dependants of the node using the virtual method DependancyChanged.

The DependancyChanged method is virtual to allow the custom blocks to process this messages accodingly to the dependancy and the role they play in this block. The block can ignore the message, or it can do some changes internally, or it can change the message and parameters and report this message to its dependants, or it can report the message to its dependants as it received it.

Nodes

Nodes are Blocks that participate in the Hierarchy. Nodes have 3 dependencies, a transform that defines the position, rotation and scale of this node; an object and a material. The object and material dependencies are optional. For example camera objects don't need a material, and nodes without any object are still useful (EmptyNode) since they still define a position in the scene and can participate in the hierarchy, there are many cases where these are the only things you need the node for.

Node Evaluation

When a node is about to be used, for example, when it's going be rendered, or it's going be used in a batch process, the node needs to be evaluated. This is processing all the objects that this node is composed of to create a version of this node.

For example, if the node's object is a BoxObject, the node calls a Evaluate method in the BoxObject, and the BoxObject creates a PolyMeshObject version of the box and stores it in the ObjectHistory of the node.

More complex object structures, like a primitive object with a few modifiers applied, Evaluate the object using the ObjectModifier and the Modifier classes.

For a full explanation of the Node Evaluation, please read ObjectHistory.

Views