Hello,
I am working on using the particle system to visualize my Point Cloud. I have CloudCompare and am using a PC visualizer that consumes .ply files. It works great but the performance is an issue. So, partially to compare performance and partially to learn something new, I am trying this out.
I have the code to visualize the PC using Particles. I have saved the PC file to a txt file that contains xyz and rgb values for each point. The issue is getting the xyz and rgb from the .txt file and into my List. I think my code is close but not quite there. I am getting this error: “Input string was not in correct format. \r\n.…” It mentions an issue at line 72 which is where the the XYZ values should be input into the List. The txt file is formatted like so:
-1.27959657 -0.13457896 -4.51264572 224 208 193
-1.27935028 -0.13580444 -4.51264286 225 209 194
-1.27885675 -0.13697970 -4.51239252 226 210 195
Each line is a point and its xyz rgb values. I am trying to go line by line and separate by spaces.
Here is an image of the Debug console:
Here is my code:
public void NewParse()
{
string[] temp;
float x, y, z, r, g, b;
try
{
using(StreamReader reader = new StreamReader(filePath))
{
while(reader.Peek() >= 0)
{
temp = extractedString.Split(' ');
x = float.Parse(temp[0]); y = float.Parse(temp[1]); z = float.Parse(temp[2]);
r = float.Parse(temp[3]); g = float.Parse(temp[4]); b = float.Parse(temp[5]);
Vector3 finalValuePos = new Vector3(x, y, z);
Vector3 finalValueCol = new Vector3(r, g, b);
pointPosValues.Add(finalValuePos);
pointColValues.Add(finalValueCol);
}
}
}
catch (System.Exception e)
{
Debug.Log("Something was invalid");
}
}
What i can tell from testing is that the first 5 values are being read properly, but the “b” variable shows up as 0 instead of the actual first value (should be 193). I am obviously not great at Parsing and reading text files so any help is appreciated.