I have a save/load function in my 3D engine which was working quite well in the past. I've just added terrains (which are very small, no more than 100 triangles big) but I can't get them trough my save/load pipeline. They're quite a bit larger than any single model I've had to deal with in the past. I have no problem loading the model in my engine, it takes less than a second, but I have a problem serializing it for my game save/load function which uses a different format than my model format. The whole terrain model file looks like this:
-25,4.48,-25:251,252,250
-24,4.58,-25:250,253,250
-25,4.62,-24:250,252,251
-24,4.58,-25:250,253,250
-24,4.62,-24:250,253,251
-25,4.62,-24:250,252,251
-25,4.62,-24:250,252,251
-24,4.62,-24:250,253,251
...
but this is nearly irrelevant as my save function only serializes the string using :
data += Serializebytes(Encoding.ASCII.GetBytes(entity.model.StringContent));
where Serializebytes() is :
static string Serializebytes(byte[] bytes)
{
char byteSep = ' ';
string byteString = "";
foreach (byte byten in bytes)
{
byteString += byten.ToString();
byteString += byteSep;
}
return (byteString);
}
The problem really is with my serialize bytes method, the program hangs there as it takes forever to process. This worked fine for the very small model that composed my previous scenes but does not for the terrain.
The function is simply supposed to take the bytes given by Encoding.ASCII.GetByte() and put a space between them. I figure this is something that should be relatively fast, even with very large amount of data. The perfect solution would be a simple function that would replace Serializebytes(). Thanks in advance guys.