DisplayMaterial
DisplayMaterial is the system that represents materials in CrackArt's viewport.
Classes
The system is composed of four classes:
DisplayMtlBase
This is the base class, and it implements the methods common to all DisplayMaterial classes, like name management, dirty status, and management of sub-materials and textures.
DisplayMaterial
This class represents a Material in the viewport.
DisplayMaterialTable
This class represents a Material with sub-materials in the viewport.
DisplayTexture
This class represents a Texture in the viewport.
DisplayMaterial Update
When a material changes, CrackArt needs to update it's viewports to display these changes. This is a short list of the steps involved in this mechanism for various cases.
ShaderMaterial is applied to node
- The node posts a MSG_MATERIAL_REPLACED event.
- The message is processed by SceneManager::ProcessEvent (a listener of the Node).
- The node's BlockProxy is set as dirty.
- Program Event Loop
- The loop calls SceneManager::UpdateBlockProxies.
- NodeGUI::GetViewportEntities creates the DisplayMaterial.
ShaderMaterial color changed
- ShaderMaterial posts a MSG_MATERIAL_CHANGED event.
- SceneManager is a listener of ShaderMaterial, so it receives the event message at the SceneManager::ProcessEvent method.
- SceneManager looks for the DisplayMaterial associated with the ShaderMaterial, and if it exists, it's set as dirty.
- SceneManager requests a viewport update (SceneManagerApp::UpdateViewports)
- Program Event Loop
- The loop calls SceneManager::UpdateBlockProxies.
- If the DisplayMaterial didn't exist, it's created with BuildDisplayMaterial.
- If the DisplayMaterial is dirty, it gets updated with DisplayMtlBase::Update.
BitmapTexture is applied to ShaderMaterial diffuse channel
- ShaderMaterial posts a MSG_MATERIAL_CHANGED event.
- SceneManager is a listener of ShaderMaterial, so it receives the event message at the SceneManager::ProcessEvent method.
- SceneManager gets DisplayMaterial associated with the ShaderMaterial sets it as dirty.
- Program Event Loop
- The loop calls SceneManager::UpdateBlockProxies.
- SceneManager::UpdateBlockProxies calls DisplayMaterial::Update.
- DisplayMaterial::Build identifies the new BitmapTexture, creates a new DisplayTexture and sets it in the diffuse channel.
Views