Esempio n. 1
0
        private static ObjFile ReadObj(string content)
        {
            var buffer = Encoding.UTF8.GetBytes(content);

            using (var stream = new MemoryStream(buffer, false))
            {
                return(ObjFile.FromStream(stream));
            }
        }
Esempio n. 2
0
        protected ObjFile LoadObjFixture(string filePath)
        {
            var lines = File
                        .ReadAllLines(filePath)
                        .Where(l => !l.StartsWith("usemtl"))                          // remove material references
                        .Select(l => l.StartsWith("o ") ? "g " + l.Substring(2) : l); // change object to group

            // now, parse
            using (var memStream = new MemoryStream(Encoding.ASCII.GetBytes(string.Join("\n", lines)))) {
                return(ObjFile.FromStream(memStream));
            }
        }
Esempio n. 3
0
        public void Read_Stream_Valid()
        {
            using (var stream = new MemoryStream())
            {
                string text   = "shadow_obj a.a";
                byte[] buffer = Encoding.UTF8.GetBytes(text);
                stream.Write(buffer, 0, buffer.Length);
                stream.Seek(0, SeekOrigin.Begin);

                var obj = ObjFile.FromStream(stream);

                Assert.Equal("a.a", obj.ShadowObjectFileName);
            }
        }
Esempio n. 4
0
 public void Read_NullStream_Throws()
 {
     Assert.Throws <ArgumentNullException>("stream", () => ObjFile.FromStream(null));
 }