Contents |
A typical 3D scene is composed of many different elements that work together. For example, geometry objects, materials, textures, animation controllers. In SceneEngine all these elements are known as Blocks. Literally speaking, a Block is an element in the Directed Acyclic Graph. The Block controls the dependencies in the DAG and takes care of deleting the blocks that are not being referenced any more.
This is the main class in SceneEngine. All components of the scene that need to interact with other components should be derived from this class. This class takes care of keeeping all the dependencies updated and also is responsible for the garbage collection when this block looses all its dependants, this is when no other block is referencing this block as a dependency.
Almost all SceneEngine elements are derived from this class, for example Node, Material, TriMeshObject, DataTable, are all classes derived from Block.
There should be at least one constructor that receives a bool create_dependencies parameter. This constructor should be immplemented so if create_dependencies is false, all the dependencies are defined as NULL. And is create_dependencies is true, then the constructor must take care of creating all the dependencies it needs. For example, Node creates its transform dependency and the BlockVector dependency for the children.
The BlockType uniquely identifies a Block class. This value is the same for all block instances of the same block class. The BlockType has 3 unsigned int members. The last two, aa and bb, are two random integers that give uniqueness. The first one is the type, this value lets the developer know what type of block this is, a Node, or an Object, or Material, or Texture, etc. This values are defined in BlockType in enum TYPES.
List of all Block_Types
For each Block class, there should be a BlockFactory class. One instance of each of these classes is created at the beginning of the application and stored in SceneEngine block_factories static table. These BlockFactories are responsible for creating new instances of a Block during loading, or they can be used to created a new block during runtime.