Exemple #1
0
 private void InitializeMaterials()
 {
     for (int i = 0; i < Material.Entries.Length; i++)
     {
         var entry     = Material.Entries[i];
         var rMaterial = MatlToMaterial.CreateMaterial(entry, i, TextureByName);
         MaterialByName.Add(rMaterial.MaterialLabel, rMaterial);
     }
 }
Exemple #2
0
        private void InitializeMaterials(Matl?matl)
        {
            if (matl == null)
            {
                return;
            }

            MaterialByName.Clear();
            for (int i = 0; i < matl.Entries.Length; i++)
            {
                var entry     = matl.Entries[i];
                var rMaterial = MatlToMaterial.CreateMaterial(entry, i, TextureByName);
                MaterialByName.Add(rMaterial.MaterialLabel, rMaterial);
            }
        }
Exemple #3
0
        private void UpdateMaterials()
        {
            foreach (ModlEntry modlEntry in Modl.ModelEntries)
            {
                // Find the right material and assign it to the render meshes.
                if (!MaterialByName.TryGetValue(modlEntry.MaterialLabel, out Material meshMaterial))
                {
                    var matlEntry = Material.Entries.Where(e => e.MaterialLabel == modlEntry.MaterialLabel).FirstOrDefault();
                    if (matlEntry == null)
                    {
                        continue;
                    }
                    meshMaterial = MatlToMaterial.CreateMaterial(matlEntry, TextureByName);
                    MaterialByName.Add(meshMaterial.Name, meshMaterial);
                }

                AssignMaterialToMeshes(modlEntry, meshMaterial);
            }
        }