/// <summary>
        /// Levanta la informacion de una animacion a partir del XML
        /// </summary>
        /// <param name="xmlString">Contenido que el XML</param>
        /// <returns>Información parseada</returns>
        public TgcSkeletalAnimationData parseAnimationFromString(string xmlString)
        {
            XmlDocument dom = new XmlDocument();

            dom.LoadXml(xmlString);
            XmlElement root = dom.DocumentElement;

            TgcSkeletalAnimationData animation = new TgcSkeletalAnimationData();

            //Parsear informacion general de animation
            XmlElement animationNode = (XmlElement)root.GetElementsByTagName("animation")[0];

            animation.name        = animationNode.Attributes["name"].InnerText;
            animation.bonesCount  = int.Parse(animationNode.Attributes["bonesCount"].InnerText);
            animation.framesCount = int.Parse(animationNode.Attributes["framesCount"].InnerText);
            animation.frameRate   = int.Parse(animationNode.Attributes["frameRate"].InnerText);
            animation.startFrame  = int.Parse(animationNode.Attributes["startFrame"].InnerText);
            animation.endFrame    = int.Parse(animationNode.Attributes["endFrame"].InnerText);

            //Parsear boundingBox, si esta
            XmlNodeList boundingBoxNodes = animationNode.GetElementsByTagName("boundingBox");

            if (boundingBoxNodes != null && boundingBoxNodes.Count == 1)
            {
                XmlNode boundingBoxNode = boundingBoxNodes[0];
                animation.pMin = TgcParserUtils.parseFloat3Array(boundingBoxNode.Attributes["min"].InnerText);
                animation.pMax = TgcParserUtils.parseFloat3Array(boundingBoxNode.Attributes["max"].InnerText);
            }

            //Parsear bones
            XmlNodeList boneNodes = animationNode.GetElementsByTagName("bone");

            animation.bonesFrames = new TgcSkeletalAnimationBoneData[boneNodes.Count];
            int boneIdx = 0;

            foreach (XmlElement boneNode in boneNodes)
            {
                TgcSkeletalAnimationBoneData boneData = new TgcSkeletalAnimationBoneData();
                boneData.id             = (int)TgcParserUtils.parseInt(boneNode.Attributes["id"].InnerText);
                boneData.keyFramesCount = (int)TgcParserUtils.parseInt(boneNode.Attributes["keyFramesCount"].InnerText);
                boneData.keyFrames      = new TgcSkeletalAnimationBoneFrameData[boneData.keyFramesCount];

                //Parsear frames
                int frames = 0;
                foreach (XmlElement frameNode in boneNode.ChildNodes)
                {
                    TgcSkeletalAnimationBoneFrameData frameData = new TgcSkeletalAnimationBoneFrameData();
                    frameData.frame    = TgcParserUtils.parseInt(frameNode.Attributes["n"].InnerText);
                    frameData.position = TgcParserUtils.parseFloat3Array(frameNode.Attributes["pos"].InnerText);
                    frameData.rotation = TgcParserUtils.parseFloat4Array(frameNode.Attributes["rotQuat"].InnerText);

                    boneData.keyFrames[frames++] = frameData;
                }

                animation.bonesFrames[boneIdx++] = boneData;
            }


            return(animation);
        }
Exemplo n.º 2
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;
            }
        }
        /// <summary>
        /// Levanta la informacion del mesh a partir de un XML
        /// </summary>
        /// <param name="xmlString">contenido del XML</param>
        /// <returns></returns>
        public TgcSkeletalMeshData parseMeshFromString(string xmlString)
        {
            XmlDocument dom = new XmlDocument();

            dom.LoadXml(xmlString);
            XmlElement root = dom.DocumentElement;

            TgcSkeletalMeshData meshData = new TgcSkeletalMeshData();

            //Ver si tiene exportacion de texturas
            XmlNode texturesExportNode    = root.GetElementsByTagName("texturesExport")[0];
            bool    texturesExportEnabled = bool.Parse(texturesExportNode.Attributes["enabled"].InnerText);

            if (texturesExportEnabled)
            {
                meshData.texturesDir = texturesExportNode.Attributes["dir"].InnerText;
            }

            //Parsear Texturas
            XmlNodeList materialNodes = root.GetElementsByTagName("materials")[0].ChildNodes;

            meshData.materialsData = new TgcMaterialData[materialNodes.Count];
            int i = 0;

            foreach (XmlElement matNode in materialNodes)
            {
                //determinar tipo de Material
                TgcMaterialData material = new TgcMaterialData();
                material.type = matNode.Attributes["type"].InnerText;

                //Standard Material
                if (material.type.Equals(TgcMaterialData.StandardMaterial))
                {
                    parseStandardMaterial(material, matNode);
                }

                //Multi Material
                else if (material.type.Equals(TgcMaterialData.MultiMaterial))
                {
                    material.name = matNode.Attributes["name"].InnerText;
                    XmlNodeList subMaterialsNodes = matNode.GetElementsByTagName("subM");
                    material.subMaterials = new TgcMaterialData[subMaterialsNodes.Count];
                    for (int j = 0; j < subMaterialsNodes.Count; j++)
                    {
                        TgcMaterialData subMaterial = new TgcMaterialData();
                        parseStandardMaterial(subMaterial, (XmlElement)subMaterialsNodes[j]);
                        material.subMaterials[j] = subMaterial;
                    }
                }

                meshData.materialsData[i++] = material;
            }


            //Parsear Mesh
            XmlElement meshNode = (XmlElement)root.GetElementsByTagName("mesh")[0];

            //parser y convertir valores
            meshData.name       = meshNode.Attributes["name"].InnerText;
            meshData.materialId = int.Parse(meshNode.Attributes["matId"].InnerText);
            meshData.color      = TgcParserUtils.parseFloat3Array(meshNode.Attributes["color"].InnerText);

            //TODO: formatear bien visibility
            string visibilityStr = meshNode.Attributes["visibility"].InnerText;

            //boundingBox, si esta
            XmlNodeList boundingBoxNodes = root.GetElementsByTagName("boundingBox");

            if (boundingBoxNodes != null && boundingBoxNodes.Count == 1)
            {
                XmlNode boundingBoxNode = boundingBoxNodes[0];
                meshData.pMin = TgcParserUtils.parseFloat3Array(boundingBoxNode.Attributes["min"].InnerText);
                meshData.pMax = TgcParserUtils.parseFloat3Array(boundingBoxNode.Attributes["max"].InnerText);
            }


            int count;

            //parsear coordinatesIdx
            XmlNode coordinatesIdxNode = meshNode.GetElementsByTagName("coordinatesIdx")[0];

            count = int.Parse(coordinatesIdxNode.Attributes["count"].InnerText);
            meshData.coordinatesIndices = TgcParserUtils.parseIntStream(coordinatesIdxNode.InnerText, count);

            //parsear textCoordsIdx
            XmlNode textCoordsIdxNode = meshNode.GetElementsByTagName("textCoordsIdx")[0];

            count = int.Parse(textCoordsIdxNode.Attributes["count"].InnerText);
            meshData.texCoordinatesIndices = TgcParserUtils.parseIntStream(textCoordsIdxNode.InnerText, count);

            //parsear colorsIdx
            XmlNode colorsIdxNode = meshNode.GetElementsByTagName("colorsIdx")[0];

            count = int.Parse(colorsIdxNode.Attributes["count"].InnerText);
            meshData.colorIndices = TgcParserUtils.parseIntStream(colorsIdxNode.InnerText, count);

            //parsear matIds
            if (meshData.materialsData.Length > 0)
            {
                XmlNode matIdsNode = meshNode.GetElementsByTagName("matIds")[0];
                count = int.Parse(matIdsNode.Attributes["count"].InnerText);
                meshData.materialsIds = TgcParserUtils.parseIntStream(matIdsNode.InnerText, count);
            }

            //parsear vertices
            XmlNode verticesNode = meshNode.GetElementsByTagName("vertices")[0];

            count = int.Parse(verticesNode.Attributes["count"].InnerText);
            meshData.verticesCoordinates = TgcParserUtils.parseFloatStream(verticesNode.InnerText, count);

            //parsear texCoords
            XmlNode texCoordsNode = meshNode.GetElementsByTagName("texCoords")[0];

            count = int.Parse(texCoordsNode.Attributes["count"].InnerText);
            meshData.textureCoordinates = TgcParserUtils.parseFloatStream(texCoordsNode.InnerText, count);

            //parsear colors
            XmlNode colorsNode = meshNode.GetElementsByTagName("colors")[0];

            count = int.Parse(colorsNode.Attributes["count"].InnerText);
            float[] colorsArray = TgcParserUtils.parseFloatStream(colorsNode.InnerText, count);
            //convertir a format TV
            meshData.verticesColors = new int[count / 3];
            for (int j = 0; j < meshData.verticesColors.Length; j++)
            {
                meshData.verticesColors[j] = Color.FromArgb(
                    (int)colorsArray[j * 3],
                    (int)colorsArray[j * 3 + 1],
                    (int)colorsArray[j * 3 + 2]).ToArgb();
            }

            //parsear esqueleto
            XmlNode skeletonNode = meshNode.GetElementsByTagName("skeleton")[0];

            TgcSkeletalBoneData[] bonesData = new TgcSkeletalBoneData[skeletonNode.ChildNodes.Count];
            int boneCount = 0;

            foreach (XmlElement boneNode in skeletonNode.ChildNodes)
            {
                TgcSkeletalBoneData boneData = new TgcSkeletalBoneData();
                boneData.id            = int.Parse(boneNode.Attributes["id"].InnerText);
                boneData.name          = boneNode.Attributes["name"].InnerText;
                boneData.parentId      = int.Parse(boneNode.Attributes["parentId"].InnerText);
                boneData.startPosition = TgcParserUtils.parseFloat3Array(boneNode.Attributes["pos"].InnerText);
                boneData.startRotation = TgcParserUtils.parseFloat4Array(boneNode.Attributes["rotQuat"].InnerText);

                bonesData[boneCount++] = boneData;
            }
            meshData.bones = bonesData;

            //parsear Weights
            XmlNode weightsNode = meshNode.GetElementsByTagName("weights")[0];

            count = int.Parse(weightsNode.Attributes["count"].InnerText);
            meshData.verticesWeights = TgcParserUtils.parseFloatStream(weightsNode.InnerText, count);


            return(meshData);
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Parsea la información de PortalRendering
        /// </summary>
        public TgcPortalRenderingData parseFromXmlNode(XmlElement portalRenderingNode)
        {
            var portalRenderingData = new TgcPortalRenderingData();
            int count;
            int i;

            char[] meshSeparator = { ',' };

            //Cells
            var cellsNode = portalRenderingNode.GetElementsByTagName("cells")[0];
            var cellNodes = cellsNode.ChildNodes;

            portalRenderingData.cells = new TgcPortalRenderingCellData[cellNodes.Count];
            i = 0;
            foreach (XmlElement cellElement in cellNodes)
            {
                var cellData = new TgcPortalRenderingCellData();
                portalRenderingData.cells[i++] = cellData;

                //id
                cellData.id = int.Parse(cellElement.Attributes["id"].InnerText);

                //name
                cellData.name = cellElement.Attributes["name"].InnerText;

                //facePlanes
                var facePlanesNode = cellElement.GetElementsByTagName("facePlanes")[0];
                count = int.Parse(facePlanesNode.Attributes["count"].InnerText);
                cellData.facePlanes = TgcParserUtils.parseFloatStream(facePlanesNode.InnerText, count);

                //boundingVertices
                var boundingVerticesNode = cellElement.GetElementsByTagName("boundingVertices")[0];
                count = int.Parse(boundingVerticesNode.Attributes["count"].InnerText);
                cellData.boundingVertices = TgcParserUtils.parseFloatStream(boundingVerticesNode.InnerText, count);

                //meshes
                var meshesNode = cellElement.GetElementsByTagName("meshes")[0];
                count           = int.Parse(meshesNode.Attributes["count"].InnerText);
                cellData.meshes = meshesNode.InnerText.Split(meshSeparator);
            }

            //Portals
            var portalsNode = portalRenderingNode.GetElementsByTagName("portals")[0];
            var portalNodes = portalsNode.ChildNodes;

            portalRenderingData.portals = new TgcPortalRenderingPortalData[portalNodes.Count];
            i = 0;
            foreach (XmlElement portalElement in portalNodes)
            {
                var portalData = new TgcPortalRenderingPortalData();
                portalRenderingData.portals[i++] = portalData;

                //name
                portalData.name = portalElement.Attributes["name"].InnerText;

                //boundingBox
                var boundingBoxNode = portalElement.GetElementsByTagName("boundingBox")[0];
                portalData.pMin = TgcParserUtils.parseFloat3Array(boundingBoxNode.Attributes["min"].InnerText);
                portalData.pMax = TgcParserUtils.parseFloat3Array(boundingBoxNode.Attributes["max"].InnerText);

                //cellA
                var cellAElement = (XmlElement)portalElement.GetElementsByTagName("cellA")[0];
                portalData.cellA = int.Parse(cellAElement.Attributes["id"].InnerText);

                //planeA
                var planeANode = cellAElement.GetElementsByTagName("plane")[0];
                portalData.planeA = TgcParserUtils.parseFloat4Array(planeANode.InnerText);

                //verticesA
                var verticesANode = cellAElement.GetElementsByTagName("vertices")[0];
                count = int.Parse(verticesANode.Attributes["count"].InnerText);
                portalData.boundingVerticesA = TgcParserUtils.parseFloatStream(verticesANode.InnerText, count);

                //cellB
                var cellBElement = (XmlElement)portalElement.GetElementsByTagName("cellB")[0];
                portalData.cellB = int.Parse(cellBElement.Attributes["id"].InnerText);

                //planeB
                var planeBNode = cellBElement.GetElementsByTagName("plane")[0];
                portalData.planeB = TgcParserUtils.parseFloat4Array(planeBNode.InnerText);

                //verticesB
                var verticesBNode = cellBElement.GetElementsByTagName("vertices")[0];
                count = int.Parse(verticesBNode.Attributes["count"].InnerText);
                portalData.boundingVerticesB = TgcParserUtils.parseFloatStream(verticesBNode.InnerText, count);
            }

            return(portalRenderingData);
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Levanta la informacion del XML
        /// </summary>
        /// <param name="xmlString">contenido del XML</param>
        /// <returns></returns>
        public TgcSceneData parseSceneFromString(string xmlString)
        {
            var dom = new XmlDocument();

            dom.LoadXml(xmlString);
            var root = dom.DocumentElement;

            var sceneName    = root.GetElementsByTagName("name")[0].InnerText;
            var tgcSceneData = new TgcSceneData();

            tgcSceneData.name = sceneName;

            //Ver si tiene exportacion de texturas
            var texturesExportNode    = root.GetElementsByTagName("texturesExport")[0];
            var texturesExportEnabled = bool.Parse(texturesExportNode.Attributes["enabled"].InnerText);

            if (texturesExportEnabled)
            {
                tgcSceneData.texturesDir = texturesExportNode.Attributes["dir"].InnerText;
            }

            //Ver si tiene LightMaps
            var lightmapsExportNode = root.GetElementsByTagName("lightmapExport")[0];

            tgcSceneData.lightmapsEnabled = bool.Parse(lightmapsExportNode.Attributes["enabled"].InnerText);
            if (tgcSceneData.lightmapsEnabled)
            {
                tgcSceneData.lightmapsDir = lightmapsExportNode.Attributes["dir"].InnerText;
            }

            //sceneBoundingBox, si está
            var sceneBoundingBoxNodes = root.GetElementsByTagName("sceneBoundingBox");

            if (sceneBoundingBoxNodes != null && sceneBoundingBoxNodes.Count == 1)
            {
                var sceneBoundingBoxNode = sceneBoundingBoxNodes[0];
                tgcSceneData.pMin = TgcParserUtils.parseFloat3Array(sceneBoundingBoxNode.Attributes["min"].InnerText);
                tgcSceneData.pMax = TgcParserUtils.parseFloat3Array(sceneBoundingBoxNode.Attributes["max"].InnerText);
            }

            //Parsear Texturas
            var materialNodes = root.GetElementsByTagName("materials")[0].ChildNodes;

            tgcSceneData.materialsData = new TgcMaterialData[materialNodes.Count];
            var i = 0;

            foreach (XmlElement matNode in materialNodes)
            {
                //determinar tipo de Material
                var material = new TgcMaterialData();
                material.type = matNode.Attributes["type"].InnerText;

                //Standard Material
                if (material.type.Equals(TgcMaterialData.StandardMaterial))
                {
                    parseStandardMaterial(material, matNode);
                }

                //Multi Material
                else if (material.type.Equals(TgcMaterialData.MultiMaterial))
                {
                    material.name = matNode.Attributes["name"].InnerText;
                    var subMaterialsNodes = matNode.GetElementsByTagName("subM");
                    material.subMaterials = new TgcMaterialData[subMaterialsNodes.Count];
                    for (var j = 0; j < subMaterialsNodes.Count; j++)
                    {
                        var subMaterial = new TgcMaterialData();
                        parseStandardMaterial(subMaterial, (XmlElement)subMaterialsNodes[j]);
                        material.subMaterials[j] = subMaterial;
                    }
                }

                tgcSceneData.materialsData[i++] = material;
            }

            //Parsear Meshes
            var meshesNodes = root.GetElementsByTagName("meshes")[0].ChildNodes;

            tgcSceneData.meshesData = new TgcMeshData[meshesNodes.Count];
            i = 0;
            int count;

            foreach (XmlElement meshNode in meshesNodes)
            {
                var meshData = new TgcMeshData();
                tgcSceneData.meshesData[i++] = meshData;

                //parser y convertir valores
                meshData.name       = meshNode.Attributes["name"].InnerText;
                meshData.materialId = int.Parse(meshNode.Attributes["matId"].InnerText);
                meshData.color      = TgcParserUtils.parseFloat3Array(meshNode.Attributes["color"].InnerText);
                meshData.lightmap   = meshNode.Attributes["lightmap"].InnerText;

                //type
                var typeAttr = meshNode.Attributes["type"];
                meshData.instanceType = TgcMeshData.ORIGINAL;
                if (typeAttr != null)
                {
                    meshData.instanceType = typeAttr.InnerText;
                }

                //layer
                var layerAttr = meshNode.Attributes["layer"];
                if (layerAttr != null)
                {
                    meshData.layerName = layerAttr.InnerText;
                }

                //visibility
                var visibility = TgcParserUtils.parseFloat(meshNode.Attributes["visibility"].InnerText);
                meshData.alphaBlending = visibility != 1.0f ? true : false;

                //parsear boundingBox
                var boundingBoxNodes = meshNode.GetElementsByTagName("boundingBox");
                if (boundingBoxNodes != null && boundingBoxNodes.Count == 1)
                {
                    var boundingBoxNode = boundingBoxNodes[0];
                    meshData.pMin = TgcParserUtils.parseFloat3Array(boundingBoxNode.Attributes["min"].InnerText);
                    meshData.pMax = TgcParserUtils.parseFloat3Array(boundingBoxNode.Attributes["max"].InnerText);
                }

                //parsear datos de mesh Original
                if (meshData.instanceType.Equals(TgcMeshData.ORIGINAL))
                {
                    //parsear coordinatesIdx
                    var coordinatesIdxNode = meshNode.GetElementsByTagName("coordinatesIdx")[0];
                    count = int.Parse(coordinatesIdxNode.Attributes["count"].InnerText);
                    meshData.coordinatesIndices = TgcParserUtils.parseIntStream(coordinatesIdxNode.InnerText, count);

                    //parsear textCoordsIdx
                    var textCoordsIdxNode = meshNode.GetElementsByTagName("textCoordsIdx")[0];
                    count = int.Parse(textCoordsIdxNode.Attributes["count"].InnerText);
                    meshData.texCoordinatesIndices = TgcParserUtils.parseIntStream(textCoordsIdxNode.InnerText, count);

                    //parsear colorsIdx
                    var colorsIdxNode = meshNode.GetElementsByTagName("colorsIdx")[0];
                    count = int.Parse(colorsIdxNode.Attributes["count"].InnerText);
                    meshData.colorIndices = TgcParserUtils.parseIntStream(colorsIdxNode.InnerText, count);

                    //parsear matIds
                    //TODO: ver bien como calcula esto el SCRIPT de Exportacion
                    if (meshData.materialId != -1)
                    {
                        var matIdsNode = meshNode.GetElementsByTagName("matIds")[0];
                        count = int.Parse(matIdsNode.Attributes["count"].InnerText);
                        meshData.materialsIds = TgcParserUtils.parseIntStream(matIdsNode.InnerText, count);
                    }

                    //parsear textCoordsLightMapIdx
                    meshData.lightmapEnabled = tgcSceneData.lightmapsEnabled && meshData.lightmap.Trim().Length > 0;
                    if (meshData.lightmapEnabled)
                    {
                        var textCoordsLightMapIdxNode = meshNode.GetElementsByTagName("textCoordsLightMapIdx")[0];
                        count = int.Parse(textCoordsLightMapIdxNode.Attributes["count"].InnerText);
                        meshData.texCoordinatesIndicesLightMap =
                            TgcParserUtils.parseIntStream(textCoordsLightMapIdxNode.InnerText, count);
                    }

                    //parsear vertices
                    var verticesNode = meshNode.GetElementsByTagName("vertices")[0];
                    count = int.Parse(verticesNode.Attributes["count"].InnerText);
                    meshData.verticesCoordinates = TgcParserUtils.parseFloatStream(verticesNode.InnerText, count);

                    //parsear normals
                    var normalsNode = meshNode.GetElementsByTagName("normals")[0];
                    count = int.Parse(normalsNode.Attributes["count"].InnerText);
                    meshData.verticesNormals = TgcParserUtils.parseFloatStream(normalsNode.InnerText, count);

                    //parsear tangents, si hay
                    var tangentsNodes = meshNode.GetElementsByTagName("tangents");
                    if (tangentsNodes != null && tangentsNodes.Count == 1)
                    {
                        var tangentsNode = tangentsNodes[0];
                        count = int.Parse(tangentsNode.Attributes["count"].InnerText);
                        meshData.verticesTangents = TgcParserUtils.parseFloatStream(tangentsNode.InnerText, count);
                    }

                    //parsear binormals, si hay
                    var binormalsNodes = meshNode.GetElementsByTagName("binormals");
                    if (binormalsNodes != null && binormalsNodes.Count == 1)
                    {
                        var binormalsNode = binormalsNodes[0];
                        count = int.Parse(binormalsNode.Attributes["count"].InnerText);
                        meshData.verticesBinormals = TgcParserUtils.parseFloatStream(binormalsNode.InnerText, count);
                    }

                    //parsear texCoords
                    var texCoordsNode = meshNode.GetElementsByTagName("texCoords")[0];
                    count = int.Parse(texCoordsNode.Attributes["count"].InnerText);
                    meshData.textureCoordinates = TgcParserUtils.parseFloatStream(texCoordsNode.InnerText, count);

                    //parsear colors
                    var colorsNode = meshNode.GetElementsByTagName("colors")[0];
                    count = int.Parse(colorsNode.Attributes["count"].InnerText);
                    var colorsArray = TgcParserUtils.parseFloatStream(colorsNode.InnerText, count);
                    //convertir a formato DirectX
                    meshData.verticesColors = new int[count / 3];
                    for (var j = 0; j < meshData.verticesColors.Length; j++)
                    {
                        meshData.verticesColors[j] = Color.FromArgb(
                            (int)colorsArray[j * 3],
                            (int)colorsArray[j * 3 + 1],
                            (int)colorsArray[j * 3 + 2]).ToArgb();
                    }

                    //parsear texCoordsLightMap
                    if (meshData.lightmapEnabled)
                    {
                        var texCoordsLightMapNode = meshNode.GetElementsByTagName("texCoordsLightMap")[0];
                        count = int.Parse(texCoordsLightMapNode.Attributes["count"].InnerText);
                        meshData.textureCoordinatesLightMap =
                            TgcParserUtils.parseFloatStream(texCoordsLightMapNode.InnerText, count);
                    }
                }

                //parsear datos de mesh Instancia
                else if (meshData.instanceType.Equals(TgcMeshData.INSTANCE))
                {
                    //originalMesh
                    var originalMeshNode = meshNode.GetElementsByTagName("originalMesh")[0];
                    meshData.originalMesh = TgcParserUtils.parseInt(originalMeshNode.InnerText);

                    //transform
                    var transformNode = meshNode.GetElementsByTagName("transform")[0];
                    meshData.position = TgcParserUtils.parseFloat3Array(transformNode.Attributes["pos"].InnerText);
                    meshData.rotation = TgcParserUtils.parseFloat4Array(transformNode.Attributes["rotQuat"].InnerText);
                    meshData.scale    = TgcParserUtils.parseFloat3Array(transformNode.Attributes["scale"].InnerText);
                }

                //Parsear userProperties, si hay
                var userPropsNodes = meshNode.GetElementsByTagName("userProps");
                if (userPropsNodes != null && userPropsNodes.Count == 1)
                {
                    meshData.userProperties = new Dictionary <string, string>();
                    var userPropsNode = (XmlElement)userPropsNodes[0];
                    foreach (XmlElement prop in userPropsNode.ChildNodes)
                    {
                        meshData.userProperties.Add(prop.Name, prop.InnerText);
                    }
                }
            }

            //Parsear PortalRendering, si hay información
            var portalRenderingNodes = root.GetElementsByTagName("portalRendering");

            if (portalRenderingNodes != null && portalRenderingNodes.Count == 1)
            {
                var portalRenderingNode = (XmlElement)portalRenderingNodes[0];
                var portalParser        = new TgcPortalRenderingParser();
                tgcSceneData.portalData = portalParser.parseFromXmlNode(portalRenderingNode);
            }

            return(tgcSceneData);
        }