Last active
October 2, 2019 20:20
-
-
Save nothke/c192c9ec267d03a861264eb5a5860467 to your computer and use it in GitHub Desktop.
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
| struct CubeWithColor | |
| { | |
| public float3 position; | |
| public Color32 color; | |
| } | |
| List<CubeWithColor> ParseMVPointsFile(string filePath) | |
| { | |
| const string HEADER_LINE = "end_header"; | |
| string[] lines = File.ReadAllLines(filePath); | |
| var cubes = new List<CubeWithColor>(); | |
| bool readLine = false; | |
| for (int i = 0; i < lines.Length; i++) | |
| { | |
| if (!readLine) | |
| { | |
| if (lines[i] == HEADER_LINE) | |
| readLine = true; | |
| } | |
| else | |
| { | |
| string[] nums = lines[i].Split(' '); | |
| if (nums == null || nums.Length != 6) continue; | |
| cubes.Add(new CubeWithColor() | |
| { | |
| position = new float3( | |
| int.Parse(nums[0]), | |
| int.Parse(nums[1]), | |
| int.Parse(nums[2])), | |
| color = new Color32( | |
| byte.Parse(nums[3]), | |
| byte.Parse(nums[4]), | |
| byte.Parse(nums[5]), 0) | |
| }); | |
| } | |
| } | |
| return cubes; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment