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

DisplayMaterial

Contents


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

  1. The node posts a MSG_MATERIAL_REPLACED event.
  2. The message is processed by SceneManager::ProcessEvent (a listener of the Node).
  3. The node's BlockProxy is set as dirty.
  4. Program Event Loop
  5. The loop calls SceneManager::UpdateBlockProxies.
  6. NodeGUI::GetViewportEntities creates the DisplayMaterial.

ShaderMaterial color changed

  1. ShaderMaterial posts a MSG_MATERIAL_CHANGED event.
  2. SceneManager is a listener of ShaderMaterial, so it receives the event message at the SceneManager::ProcessEvent method.
  3. SceneManager looks for the DisplayMaterial associated with the ShaderMaterial, and if it exists, it's set as dirty.
  4. SceneManager requests a viewport update (SceneManagerApp::UpdateViewports)
  5. Program Event Loop
  6. 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

  1. ShaderMaterial posts a MSG_MATERIAL_CHANGED event.
  2. SceneManager is a listener of ShaderMaterial, so it receives the event message at the SceneManager::ProcessEvent method.
  3. SceneManager gets DisplayMaterial associated with the ShaderMaterial sets it as dirty.
  4. Program Event Loop
  5. The loop calls SceneManager::UpdateBlockProxies.
  6. SceneManager::UpdateBlockProxies calls DisplayMaterial::Update.
  7. DisplayMaterial::Build identifies the new BitmapTexture, creates a new DisplayTexture and sets it in the diffuse channel.
Views