void processHeightMapPoint(string msgData) { int charCounter = 0; int charIndex0 = 0; // GET MESSAGE TYPE strMessage.Replace(" ", null); foreach(char c in msgData) { if(c == ':') { charIndex0 = charCounter; break; } charCounter++; } string data = msgData.Substring(3+charIndex0, msgData.Length-charIndex0-4); Debug.Log(data); string number = ""; HeightMapPoint point = new HeightMapPoint(); int numC = 0; bool lastWasNumber = false; foreach(char m in data) { if( Char.IsNumber(m) || m == '.' ) { number += m; lastWasNumber = true; } else { if(numC == 0 && lastWasNumber) { point.x = (Convert.ToInt32(number)); Debug.Log(number); numC++; number = ""; lastWasNumber = false; } else if(numC == 1 && lastWasNumber) { point.y = (Convert.ToInt32(number)); numC++; number = ""; lastWasNumber = false; } else if(lastWasNumber && numC == 2) { point.z = (float) (Convert.ToDouble(number)); points.Add(point); Debug.Log(point.x.ToString()); Debug.Log(point.y.ToString()); Debug.Log(point.z.ToString()); point = new HeightMapPoint(); numC = 0; number = ""; lastWasNumber = false; } } } //UpdateSync(); }
void processHeightMapPoint(string msgData) { int charCounter = 0; int charIndex0 = 0; // GET MESSAGE TYPE strMessage.Replace(" ", null); foreach (char c in msgData) { if (c == ':') { charIndex0 = charCounter; break; } charCounter++; } string data = msgData.Substring(3 + charIndex0, msgData.Length - charIndex0 - 4); Debug.Log(data); string number = ""; HeightMapPoint point = new HeightMapPoint(); int numC = 0; bool lastWasNumber = false; foreach (char m in data) { if (Char.IsNumber(m) || m == '.') { number += m; lastWasNumber = true; } else { if (numC == 0 && lastWasNumber) { point.x = (Convert.ToInt32(number)); Debug.Log(number); numC++; number = ""; lastWasNumber = false; } else if (numC == 1 && lastWasNumber) { point.y = (Convert.ToInt32(number)); numC++; number = ""; lastWasNumber = false; } else if (lastWasNumber && numC == 2) { point.z = (float)(Convert.ToDouble(number)); points.Add(point); Debug.Log(point.x.ToString()); Debug.Log(point.y.ToString()); Debug.Log(point.z.ToString()); point = new HeightMapPoint(); numC = 0; number = ""; lastWasNumber = false; } } } //UpdateSync(); }