Universe.Framework.SceneInfo.UuidGatherer.GatherMaterialsUuids C# (CSharp) Method

GatherMaterialsUuids() public method

Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps
public GatherMaterialsUuids ( ISceneChildEntity part, AssetType>.IDictionary assetUuids ) : void
part ISceneChildEntity
assetUuids AssetType>.IDictionary
return void
        public void GatherMaterialsUuids (ISceneChildEntity part, IDictionary<UUID, AssetType> assetUuids)
        {
            // scan through the rendermaterials of this part for any textures used as materials
            if (part.RenderMaterials == null)
                return;

            lock (part.RenderMaterials) {
                OSDArray matsArr = part.RenderMaterials as OSDArray;
                foreach (OSDMap matMap in matsArr) {
                    try {
                        if (matMap.ContainsKey ("Material"))
                        {
                            OSDMap mat = matMap ["Material"] as OSDMap;
                            if (mat.ContainsKey ("NormMap"))
                            {
                                UUID normalMapId = mat ["NormMap"].AsUUID ();
                                if (normalMapId != UUID.Zero)
                                {
                                    assetUuids [normalMapId] = AssetType.Texture;
                                    //MainConsole.Instance.Info("[UUID Gatherer]: found normal map ID: " + normalMapId);
                                }
                            }

                            if (mat.ContainsKey ("SpecMap"))
                            {
                                UUID specularMapId = mat ["SpecMap"].AsUUID ();
                                if (specularMapId != UUID.Zero)
                                {
                                    assetUuids [specularMapId] = AssetType.Texture;
                                    //MainConsole.Instance.Info("[UUID Gatherer]: found specular map ID: " + specularMapId);
                                }
                            }
                        }

                        //Add the material itself
                        assetUuids [matMap ["ID"].AsUUID ()] = AssetType.Texture;
                    } catch (Exception e) {
                        MainConsole.Instance.Warn ("[UUID Gatherer]: exception getting materials: " + e);
                    }
                }
            }
        }