Пример #1
0
        /// <summary>
        ///     Parses the shell information for a 3DReferenceRep out of the xml document into the internal representation.
        ///     the methods opens external 3DReferenceRep files automatically.
        /// </summary>
        /// <param name="threeDReferenceRepXmlElement">The 3DReferenceRep xml representation with all attributes and sup nodes</param>
        /// <param name="nameOfExternalRepFileDiscription">
        ///     name of the external 3DReferenceRep xml file, is empty if the
        ///     representation is in the same file.
        /// </param>
        /// <param name="archive">The unziped file archive of the 3dxml model</param>
        /// <returns>A Shell of a Mesh, which is holding the trinagular information.</returns>
        private static Shell GetShell(XElement threeDReferenceRepXmlElement, string nameOfExternalRepFileDiscription,
                                      IThreeDXMLArchive archive)
        {
            XDocument        xmlReferenceRep;
            IList <Triangle> triangles = new List <Triangle>();

            if (nameOfExternalRepFileDiscription != null && nameOfExternalRepFileDiscription.Any())
            {
                xmlReferenceRep = archive.GetNextDocument(ParseUtility.CleanUpFileName(nameOfExternalRepFileDiscription));
            }
            else
            {
                xmlReferenceRep = threeDReferenceRepXmlElement.Document;
            }
            var bagReps = GetBagRepXmlElements(xmlReferenceRep);

            foreach (var bagRep in bagReps)
            {
                IList <XElement> faces =
                    bagRep.Descendants("{http://www.3ds.com/xsd/3DXML}Faces")
                    .Where(x => x.Parent.Name.LocalName.ToLower() != "polygonallod")
                    .ToList();
                var verticies = GetVerticesFromXml(bagRep);

                foreach (var face in faces.Elements("{http://www.3ds.com/xsd/3DXML}Face"))
                {
                    triangles = triangles.Concat(GetTrianglesFromXml(face, verticies)).ToList();
                    triangles = triangles.Concat(GetFansFromXml(face, verticies)).ToList();
                    triangles = triangles.Concat(GetStripsFromXml(face, verticies)).ToList();
                }
            }

            return(new Shell(triangles));
        }
Пример #2
0
        /// <summary>
        /// Reads the manifest(the entry point for the 3Dxml parsing) and datamines where to start.
        /// </summary>
        /// <param name="archive">The unziped file archive of the 3dxml model</param>
        /// <returns></returns>
        public static XDocument ReadManifest(IThreeDXMLArchive archiv)
        {
            var manifest = archiv.GetManifest();
            //check if the manifest contains the asset information, if the root element is not the manifest then load and return it.
            var rootElement = manifest.Root.Element("Root");

            if (rootElement != null && !rootElement.IsEmpty)
            {
                manifest = archiv.GetNextDocument(CleanUpFileName(rootElement.Value));
            }

            return(manifest);
        }