Created
October 3, 2013 00:15
-
-
Save jlewin/6802585 to your computer and use it in GitHub Desktop.
Reduce an .obj file to its key components for structure evaluation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var inputPath = @"c:\temp\example.obj"; | |
| var outputPath = @"c:\temp\results.txt"; | |
| var reader = new System.IO.StreamReader(inputPath); | |
| var output = System.IO.File.CreateText(outputPath); | |
| var v = 0; | |
| var vn = 0; | |
| var f = 0; | |
| string line; | |
| while ((line = reader.ReadLine()) != null) | |
| { | |
| var type = line.Substring(0, 2).Trim(); | |
| switch(type) { | |
| case "g": | |
| v = 0; | |
| vn = 0; | |
| f = 0; | |
| break; | |
| case "v": | |
| v++; | |
| if (v > 3) line = null; | |
| break; | |
| case "vn": | |
| vn++; | |
| if (vn > 3) line = null; | |
| break; | |
| case "f": | |
| f++; | |
| if (f > 1) line = null; | |
| break; | |
| case "us": | |
| f = 0; | |
| break; | |
| } | |
| if (line != null) | |
| { | |
| output.WriteLine(line); | |
| } | |
| } | |
| output.Close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment