コード例 #1
0
        bool UpdateMaterialElement(XElement materialElement, CharacterAttachmentMaterial material)
        {
            Debug.LogAlways("Updating material element for attachment {0} in slot {1}", material.Attachment.Name, material.Attachment.Slot.Name);
            var modifiedMaterial = false;

            var genMaskAttribute = materialElement.Attribute("StringGenMask");

            if (genMaskAttribute != null && genMaskAttribute.Value.Contains("%COLORMASKING"))
            {
                Debug.LogAlways("Writing color mask");
                var publicParamsElement = materialElement.Element("PublicParams");

                publicParamsElement.SetAttributeValue("ColorMaskR", material.ColorRed.ToString());
                publicParamsElement.SetAttributeValue("ColorMaskG", material.ColorGreen.ToString());
                publicParamsElement.SetAttributeValue("ColorMaskB", material.ColorBlue.ToString());
                publicParamsElement.SetAttributeValue("ColorMaskA", material.ColorAlpha.ToString());

                modifiedMaterial = true;
            }

            var texturesElement = materialElement.Element("Textures");

            if (texturesElement != null)
            {
                if (WriteTexture(texturesElement, "Diffuse", material.DiffuseTexture) ||
                    WriteTexture(texturesElement, "Specular", material.SpecularTexture) ||
                    WriteTexture(texturesElement, "Bumpmap", material.BumpmapTexture) ||
                    WriteTexture(texturesElement, "Custom", material.CustomTexture))
                {
                    modifiedMaterial = true;
                }
            }

            if (!UnusedMarker.IsUnused(DiffuseColor))
            {
                materialElement.SetAttributeValue("Diffuse", DiffuseColor.ToString());
            }

            if (!UnusedMarker.IsUnused(SpecularColor))
            {
                materialElement.SetAttributeValue("Specular", SpecularColor.ToString());
            }

            return(modifiedMaterial);
        }
コード例 #2
0
        internal CharacterAttachmentMaterial(CharacterAttachment attachment, XElement element, CharacterAttachmentMaterial parentMaterial = null)
        {
            Element    = element;
            Attachment = attachment;

            ParentMaterial = parentMaterial;

            var subMaterialElements = element.Elements("Submaterial");

            Submaterials = new CharacterAttachmentMaterial[subMaterialElements.Count()];

            for (var i = 0; i < subMaterialElements.Count(); i++)
            {
                var subMaterialElement = subMaterialElements.ElementAt(i);

                Submaterials[i] = new CharacterAttachmentMaterial(attachment, subMaterialElement, this);
            }

            if (parentMaterial == null)
            {
                var pathAttribute = element.Attribute("path");
                if (pathAttribute != null)
                {
                    BaseFilePath = pathAttribute.Value;
                }
            }
            else
            {
                var nameAttribute = element.Attribute("name");
                if (nameAttribute != null)
                {
                    BaseFilePath = nameAttribute.Value;
                }
            }

            var colorModifierElement = element.Element("ColorModifier");

            if (colorModifierElement != null)
            {
                var redAttribute = colorModifierElement.Attribute("red");
                if (redAttribute != null)
                {
                    ColorRed = ParseColor(redAttribute.Value);
                }

                var greenAttribute = colorModifierElement.Attribute("green");
                if (greenAttribute != null)
                {
                    ColorGreen = ParseColor(greenAttribute.Value);
                }

                var blueAttribute = colorModifierElement.Attribute("blue");
                if (blueAttribute != null)
                {
                    ColorBlue = ParseColor(blueAttribute.Value);
                }

                var alphaAttribute = colorModifierElement.Attribute("alpha");
                if (alphaAttribute != null)
                {
                    ColorAlpha = ParseColor(alphaAttribute.Value);
                }
            }

            var diffuseElement = element.Element("Diffuse");

            DiffuseColor = UnusedMarker.Vec3;

            if (diffuseElement != null)
            {
                var texPathAttribute = diffuseElement.Attribute("path");
                if (texPathAttribute != null)
                {
                    DiffuseTexture = texPathAttribute.Value;
                }

                var colorAttribute = diffuseElement.Attribute("color");
                if (colorAttribute != null)
                {
                    DiffuseColor = ParseColor(colorAttribute.Value);
                }
            }

            var specularElement = element.Element("Specular");

            SpecularColor = UnusedMarker.Vec3;

            if (specularElement != null)
            {
                var texPathAttribute = specularElement.Attribute("path");
                if (texPathAttribute != null)
                {
                    SpecularTexture = texPathAttribute.Value;
                }

                var colorAttribute = specularElement.Attribute("color");
                if (colorAttribute != null)
                {
                    SpecularColor = ParseColor(colorAttribute.Value);
                }
            }

            var bumpmapElement = element.Element("Bumpmap");

            if (bumpmapElement != null)
            {
                var texPathAttribute = bumpmapElement.Attribute("path");
                if (texPathAttribute != null)
                {
                    BumpmapTexture = texPathAttribute.Value;
                }
            }

            var customTexElement = element.Element("Custom");

            if (customTexElement != null)
            {
                var texPathAttribute = customTexElement.Attribute("path");
                if (texPathAttribute != null)
                {
                    CustomTexture = texPathAttribute.Value;
                }
            }
        }
コード例 #3
0
        bool UpdateMaterialElement(XElement materialElement, CharacterAttachmentMaterial material)
        {
            Debug.LogAlways("Updating material element for attachment {0} in slot {1}", material.Attachment.Name, material.Attachment.Slot.Name);
            var modifiedMaterial = false;

            var genMaskAttribute = materialElement.Attribute("StringGenMask");
            if (genMaskAttribute != null && genMaskAttribute.Value.Contains("%COLORMASKING"))
            {
                Debug.LogAlways("Writing color mask");
                var publicParamsElement = materialElement.Element("PublicParams");

                publicParamsElement.SetAttributeValue("ColorMaskR", material.ColorRed.ToString());
                publicParamsElement.SetAttributeValue("ColorMaskG", material.ColorGreen.ToString());
                publicParamsElement.SetAttributeValue("ColorMaskB", material.ColorBlue.ToString());
                publicParamsElement.SetAttributeValue("ColorMaskA", material.ColorAlpha.ToString());

                modifiedMaterial = true;
            }

            var texturesElement = materialElement.Element("Textures");
            if (texturesElement != null)
            {
                if (WriteTexture(texturesElement, "Diffuse", material.DiffuseTexture)
                    || WriteTexture(texturesElement, "Specular", material.SpecularTexture)
                    || WriteTexture(texturesElement, "Bumpmap", material.BumpmapTexture)
                    || WriteTexture(texturesElement, "Custom", material.CustomTexture))
                {
                    modifiedMaterial = true;
                }
            }

            if (!UnusedMarker.IsUnused(DiffuseColor))
                materialElement.SetAttributeValue("Diffuse", DiffuseColor.ToString());

            if (!UnusedMarker.IsUnused(SpecularColor))
                materialElement.SetAttributeValue("Specular", SpecularColor.ToString());

            return modifiedMaterial;
        }
コード例 #4
0
        internal CharacterAttachmentMaterial(CharacterAttachment attachment, XElement element, CharacterAttachmentMaterial parentMaterial = null)
        {
            Element = element;
            Attachment = attachment;

            ParentMaterial = parentMaterial;

            var subMaterialElements = element.Elements("Submaterial");
            Submaterials = new CharacterAttachmentMaterial[subMaterialElements.Count()];

            for(var i = 0; i < subMaterialElements.Count(); i++)
            {
                var subMaterialElement = subMaterialElements.ElementAt(i);

                Submaterials[i] = new CharacterAttachmentMaterial(attachment, subMaterialElement, this);
            }

            if (parentMaterial == null)
            {
                var pathAttribute = element.Attribute("path");
                if (pathAttribute != null)
                    BaseFilePath = pathAttribute.Value;
            }
            else
            {
                var nameAttribute = element.Attribute("name");
                if (nameAttribute != null)
                    BaseFilePath = nameAttribute.Value;
            }

            var colorModifierElement = element.Element("ColorModifier");
            if (colorModifierElement != null)
            {
                var redAttribute = colorModifierElement.Attribute("red");
                if (redAttribute != null)
                    ColorRed = ParseColor(redAttribute.Value);

                var greenAttribute = colorModifierElement.Attribute("green");
                if (greenAttribute != null)
                    ColorGreen = ParseColor(greenAttribute.Value);

                var blueAttribute = colorModifierElement.Attribute("blue");
                if (blueAttribute != null)
                    ColorBlue = ParseColor(blueAttribute.Value);

                var alphaAttribute = colorModifierElement.Attribute("alpha");
                if (alphaAttribute != null)
                    ColorAlpha = ParseColor(alphaAttribute.Value);
            }

            var diffuseElement = element.Element("Diffuse");
            DiffuseColor = UnusedMarker.Vec3;

            if (diffuseElement != null)
            {
                var texPathAttribute = diffuseElement.Attribute("path");
                if (texPathAttribute != null)
                    DiffuseTexture = texPathAttribute.Value;

                var colorAttribute = diffuseElement.Attribute("color");
                if (colorAttribute != null)
                    DiffuseColor = ParseColor(colorAttribute.Value);
            }

            var specularElement = element.Element("Specular");
            SpecularColor = UnusedMarker.Vec3;

            if (specularElement != null)
            {
                var texPathAttribute = specularElement.Attribute("path");
                if (texPathAttribute != null)
                    SpecularTexture = texPathAttribute.Value;

                var colorAttribute = specularElement.Attribute("color");
                if (colorAttribute != null)
                    SpecularColor = ParseColor(colorAttribute.Value);
            }

            var bumpmapElement = element.Element("Bumpmap");
            if (bumpmapElement != null)
            {
                var texPathAttribute = bumpmapElement.Attribute("path");
                if (texPathAttribute != null)
                    BumpmapTexture = texPathAttribute.Value;
            }

            var customTexElement = element.Element("Custom");
            if (customTexElement != null)
            {
                var texPathAttribute = customTexElement.Attribute("path");
                if (texPathAttribute != null)
                    CustomTexture = texPathAttribute.Value;
            }
        }