Dev Guide: Object Renderer
The RendererObjects
class is responsible for rendering the objects in the system.
For this, every object contains an instance of the ObjectGraphicsAdapter
class which represents the object in the render system.
This instance has to be registered in the RendererObjects
in order to be displayed.
Once an object is registered, the ObjectGraphicsAdapter
generates a mesh for the object and updates it every time the object is changed.
The mesh consists of four triangles for every hexagon in the object and additional triangles between the hexagons at the borders of the object.
These are necessary because the vertices at the borders are placed closer to their hexagon's center so that there is a gap between an object and neighboring particles or other objects.
In order to render the objects with different colors, the RendererObjects
maintains a dictionary of material property blocks using colors as keys.
Every time an object is registered or a registered object changes its color, a corresponding property block is created or taken from the dictionary.
The material used to render the objects is Resources/Materials/Base/ObjectMat.mat
.
It is a very simple material giving the object mesh a solid color.
When the Render
method of the RendererObjects
is called, it renders each object individually, using the TRS matrix computed by the object's ObjectGraphicsAdapter
.
If animations are enabled, the matrix uses an interpolated position between the previous and current object position.