示例#1
0
        /// <summary>
        ///		Exports a mesh to the file specified.
        /// </summary>
        /// <param name="mesh">Reference to the mesh to export.</param>
        /// <param name="fileName">The destination filename.</param>
        public void ExportMesh(Mesh mesh, string fileName)
        {
            // call implementation
            MeshSerializerImpl serializer = (MeshSerializerImpl)implementations[currentVersion];

            serializer.ExportMesh(mesh, fileName);
        }
示例#2
0
        /// <summary>
        ///		Imports mesh data from a .mesh file.
        /// </summary>
        /// <param name="stream">The stream holding the .mesh data. Must be initialised (pos at the start of the buffer).</param>
        /// <param name="mesh">Reference to the Mesh object which will receive the data. Should be blank already.</param>
        public void ImportMesh(Stream stream, Mesh mesh)
        {
            BinaryMemoryReader reader = new BinaryMemoryReader(stream);

            // read the header ID
            ushort headerID = ReadUShort(reader);

            if (headerID != (ushort)MeshChunkID.Header)
            {
                throw new AxiomException("File header not found.");
            }

            // read version
            string fileVersion = ReadString(reader);

            // set jump back to the start of the reader
            Seek(reader, 0, SeekOrigin.Begin);

            // barf if there specified version is not supported
            if (!implementations.ContainsKey(fileVersion))
            {
                throw new AxiomException("Cannot find serializer implementation for version '{0}'.", fileVersion);
            }

            LogManager.Instance.Write("Mesh: Loading '{0}'...", mesh.Name);

            // call implementation
            MeshSerializerImpl serializer = (MeshSerializerImpl)implementations[fileVersion];

            serializer.ImportMesh(reader, mesh);

            // warn on old version of mesh
            if (fileVersion != currentVersion)
            {
                LogManager.Instance.Write("WARNING: {0} is an older format ({1}); you should upgrade it as soon as possible using the OgreMeshUpdate tool.", mesh.Name, fileVersion);
            }

            LogManager.Instance.Write("Mesh: Finished loading '{0}'", mesh.Name);
        }