예제 #1
0
        private void parseStandardMaterial(TgcMaterialData material, XmlElement matNode)
        {
            material.name = matNode.Attributes["name"].InnerText;
            material.type = matNode.Attributes["type"].InnerText;

            //Valores de Material
            var ambientStr = matNode.GetElementsByTagName("ambient")[0].InnerText;

            material.ambientColor = TgcParserUtils.parseFloat4Array(ambientStr);
            TgcParserUtils.divFloatArrayValues(ref material.ambientColor, 255f);

            var diffuseStr = matNode.GetElementsByTagName("diffuse")[0].InnerText;

            material.diffuseColor = TgcParserUtils.parseFloat4Array(diffuseStr);
            TgcParserUtils.divFloatArrayValues(ref material.diffuseColor, 255f);

            var specularStr = matNode.GetElementsByTagName("specular")[0].InnerText;

            material.specularColor = TgcParserUtils.parseFloat4Array(specularStr);
            TgcParserUtils.divFloatArrayValues(ref material.specularColor, 255f);

            var opacityStr = matNode.GetElementsByTagName("opacity")[0].InnerText;

            material.opacity = TgcParserUtils.parseFloat(opacityStr) / 100f;

            var alphaBlendEnableNode = matNode.GetElementsByTagName("alphaBlendEnable")[0];

            if (alphaBlendEnableNode != null)
            {
                var alphaBlendEnableStr = alphaBlendEnableNode.InnerText;
                material.alphaBlendEnable = bool.Parse(alphaBlendEnableStr);
            }

            //Valores de Bitmap
            var bitmapNode = matNode.GetElementsByTagName("bitmap")[0];

            if (bitmapNode != null)
            {
                material.fileName = bitmapNode.InnerText;

                //TODO: formatear correctamente TILING y OFFSET
                var uvTilingStr = bitmapNode.Attributes["uvTiling"].InnerText;
                material.uvTiling = TgcParserUtils.parseFloat2Array(uvTilingStr);

                var uvOffsetStr = bitmapNode.Attributes["uvOffset"].InnerText;
                material.uvOffset = TgcParserUtils.parseFloat2Array(uvOffsetStr);
            }
            else
            {
                material.fileName = null;
                material.uvTiling = null;
                material.uvOffset = null;
            }
        }