コード例 #1
0
        public static IList <Material> GetMaterialsToHide(DAZSkinV2 skin)
        {
#if (POV_DIAGNOSTICS)
            if (skin == null)
            {
                throw new NullReferenceException("skin is null");
            }
            if (skin.GPUmaterials == null)
            {
                throw new NullReferenceException("skin materials are null");
            }
#endif

            var materials = new List <Material>(MaterialsToHide.Length);

            foreach (var material in skin.GPUmaterials)
            {
                if (!MaterialsToHide.Any(materialToHide => material.name.StartsWith(materialToHide)))
                {
                    continue;
                }

                materials.Add(material);
            }

#if (POV_DIAGNOSTICS)
            // NOTE: Tear is not on all models
            if (materials.Count < MaterialsToHide.Length - 1)
            {
                throw new Exception("Not enough materials found to hide. List: " + string.Join(", ", skin.GPUmaterials.Select(m => m.name).ToArray()));
            }
#endif

            return(materials);
        }
コード例 #2
0
ファイル: KnownMaterials.cs プロジェクト: via5/vam-embody
        public static IList <Material> GetMaterialsToHide(DAZSkinV2 skin)
        {
            var materials = new List <Material>(_materialsToHide.Length);

            foreach (var material in skin.GPUmaterials)
            {
                if (material == null)
                {
                    continue;
                }
                if (!_materialsToHide.Any(materialToHide => material.name.StartsWith(materialToHide)))
                {
                    continue;
                }

                materials.Add(material);
            }

            return(materials);
        }
コード例 #3
0
        public int Configure(DAZSkinV2 skin)
        {
            _skin         = skin;
            _materialRefs = new List <SkinShaderMaterialReference>();

            foreach (var material in GetMaterialsToHide(skin))
            {
#if (IMPROVED_POV)
                if (material == null)
                {
                    throw new InvalidOperationException("Attempts to apply the shader strategy on a destroyed material.");
                }

                if (material.GetInt(SkinShaderMaterialReference.ImprovedPovEnabledShaderKey) == 1)
                {
                    throw new InvalidOperationException("Attempts to apply the shader strategy on a skin that already has the plugin enabled (shader key).");
                }
#endif

                var materialInfo = SkinShaderMaterialReference.FromMaterial(material);

                Shader shader;
                if (!ReplacementShaders.TryGetValue(material.shader.name, out shader))
                {
                    SuperController.LogError("Missing replacement shader: '" + material.shader.name + "'");
                }

                if (shader != null)
                {
                    material.shader = shader;
                }

                _materialRefs.Add(materialInfo);
            }

            // This is a hack to force a refresh of the shaders cache
            skin.BroadcastMessage("OnApplicationFocus", true);
            return(HandlerConfigurationResult.Success);
        }
コード例 #4
0
 public SkinHandler(DAZSkinV2 skin, IEnumerable <string> materialsToHide, int materialsToHideMax)
 {
     _skin               = skin;
     _materialsToHide    = materialsToHide;
     _materialsToHideMax = materialsToHideMax;
 }
コード例 #5
0
ファイル: SkinHandler.cs プロジェクト: via5/vam-embody
 public SkinHandler(DAZSkinV2 skin)
 {
     _skin = skin;
 }