Skip to content

Instantly share code, notes, and snippets.

@nothke
Last active October 2, 2019 20:20
Show Gist options
  • Select an option

  • Save nothke/c192c9ec267d03a861264eb5a5860467 to your computer and use it in GitHub Desktop.

Select an option

Save nothke/c192c9ec267d03a861264eb5a5860467 to your computer and use it in GitHub Desktop.
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