コード例 #1
0
        public IOReadResult ReadFile(Stream stream, IMeshBuilder builder, ReadOptions options, ParsingMessagesHandler messages)
        {
            var reader = new OBJReader();

            reader.warningEvent += messages;
            var result = reader.Read(new StreamReader(stream), options, builder);

            return(result);
        }
コード例 #2
0
        public IOReadResult ReadFile(string sFilename, IMeshBuilder builder, ReadOptions options, ParsingMessagesHandler messages)
        {
            try {
                using (FileStream stream = File.Open(sFilename, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                    OBJReader reader = new OBJReader();
                    if (options.ReadMaterials)
                    {
                        reader.MTLFileSearchPaths.Add(Path.GetDirectoryName(sFilename));
                    }
                    reader.warningEvent += messages;

                    var result = reader.Read(new StreamReader(stream), options, builder);
                    return(result);
                }
            } catch (Exception e) {
                return(new IOReadResult(IOCode.FileAccessError, "Could not open file " + sFilename + " for reading : " + e.Message));
            }
        }
コード例 #3
0
        public IOReadResult ReadFile(string sFilename, IMeshBuilder builder, ReadOptions options, ParsingMessagesHandler messages)
        {
            StreamReader stream = new StreamReader(sFilename);

            if (stream.BaseStream == null)
            {
                return(new IOReadResult(IOCode.FileAccessError, "Could not open file " + sFilename + " for reading"));
            }

            OBJReader reader = new OBJReader();

            if (options.ReadMaterials)
            {
                reader.MTLFileSearchPaths.Add(Path.GetDirectoryName(sFilename));
            }
            reader.warningEvent += messages;

            var result = reader.Read(stream, options, builder);

            stream.Close();
            return(result);
        }