[Question]Saving Voxel Engine Terrain[Question]

Hello! Can anyone help me save Voxel Engine generated terrain? I can’t figure out how to do it :/… Thank You!

PS: It looks like this :

How did you generate it. You need to help us help you.

i started a project yesterday to build a voxel engine
i managed to save and reload

using System.IO;
public static string[,] myworld =new string[100,100,100];

void saveWorld ()
{
int x ,y,z ;
using (StreamWriter theWriter = new StreamWriter(“World.dat”))
{
for(y=0;y<=99;y++)
{
for(z=0;z<=99;z++)
{
for(x=0;x<=99;x++)
{
theWriter.WriteLine(myworld[x,y,z]);
}
}
}
}
print (“World Saved”);
} // complete
void loadWorld ()
{
int x=0 ,y=0,z=0 ;
using (StreamReader theReader = new StreamReader(“World.dat”))
{
for(y=0;y<=99;y++)
{
for(z=0;z<=99;z++)
{
for(x=0;x<=99;x++)
{
myworld[x,y,z]=theReader.ReadLine();
}
}
}
}
print (“World Loaded”);
} // complete

it works very good (but array is fixed as you see )
you can make the first line store the array dimensions then create array based on that dimensions once you load your game

you must have noticed i use a 3d array to store my world – trying understand chanks now
i hope i helped you
and plz if you can share resourses or code or ideas to help me build my game that will be greate

if you using chanks and that what i intend to do
i will keep a world array
and while rendering i will build chanks of about 101010 but in every time i will build 9 chanks one im in and the others that arround me when my character move from chank to another i should remove all unnecessary chanks and build the new chanks in my new position

what im looking foor now is a way to create cubes that is less waisting for resources
as now i create cube opject its name = position ex “10,5,100” then translate the block from 000 to this position
that sems bad way so s search for better way to create opject in place directly
also want to make it not renderd so i render it when i want ( if i look at it as examble );

This is probably one of the most common misconceptions in the world of voxels. The voxels themselves are not cubes, but ‘fake’ cubes that are turned into a single mesh per chunk. A cube has 24 verts and 12 triangles, but most of the voxels are completely invisible, inside your ground and hills and stuff. Even a small world can mean millions of cubes which is really hard on the CPU and GPU. The ‘cube engines’ that are usually used have a world, with an array of chunks, which have an array of voxels objects. These voxels are not gameObjects, but just the normal System objects, and would have parameters like solidity and transparency( I find these very important, but you might want to do something else), and also the type, color/texture, etc. Then you build a procedural mesh from the fake voxels(Something like, If this voxel is solid, and the voxel on this side is transparent, build part of the mesh there.) and apply it to the chunk. This means that Each time a voxel is edited, the chunk must be rebuilt, but this is generally a very fast process and it is worth it to use chunks. This is one of those things that you really can’t make a voxel game without, as it allows nearly infinite worlds to be rendered with little cost. I found this very helpful in making my engine: http://www.blockstory.net/node/56.
This guy made what is pretty much an RPG version of minecraft, with an engine that is several more times as powerful.

I hope this helps.

using System.IO;
public static string[,] myworld =new string[100,100,100];

void saveWorld ()
{
int x ,y,z ;
using (StreamWriter theWriter = new StreamWriter(“World.dat”))
{
for(y=0;y<=99;y++)
{
for(z=0;z<=99;z++)
{
for(x=0;x<=99;x++)
{
theWriter.WriteLine(myworld[x,y,z]);
}
}
}
}
print (“World Saved”);
} // complete
void loadWorld ()
{
int x=0 ,y=0,z=0 ;
using (StreamReader theReader = new StreamReader(“World.dat”))
{
for(y=0;y<=99;y++)
{
for(z=0;z<=99;z++)
{
for(x=0;x<=99;x++)
{
myworld[x,y,z]=theReader.ReadLine();
}
}
}
}
print (“World Loaded”);
} // complete

dont work i have the error CS0116