It is currently Sat Aug 22, 2020 2:02 pm


All times are UTC




Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Save Voxel Data to Disk
PostPosted: Thu Mar 17, 2011 3:13 pm 
User avatar

Joined: Tue Feb 22, 2011 8:04 am
Posts: 101
While I fight some tough errors, I might as well work on another portion of my project.

I am creating terrain out of voxels. At some point it would be great if I could
save the maps I am creating to disk.

Does anyone have any suggestions on how to go about saving polyvox
information to disk? I'm sure I could implement a naive method by looping
through all values in each volume, but I'm guessing there are some less
expensive methods.

Thanks for your help.

_________________
--Real Programmers use a magnetized needle and a steady hand.
--xkcd--


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Save Voxel Data to Disk
PostPosted: Fri Mar 18, 2011 3:34 am 

Joined: Sun Jan 23, 2011 6:06 am
Posts: 92
Due to the PolyVox interface, wouldn't anything other than looping through voxel values require changing PolyVox itself? Unless there are functions I am not aware of for getting all voxels in a region at once, like accessing blocks directly.

I am just breaking the volume up into regions, iterating through voxels in a region and saving them to disk using zlib compression. Saving a whole volume would be good for compression but be way too slow for streaming I imagine...


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Save Voxel Data to Disk
PostPosted: Fri Mar 18, 2011 5:54 pm 
User avatar

Joined: Tue Feb 22, 2011 8:04 am
Posts: 101
I suppose you're right. I guess I was a little optimistic to think there was a better way. I thought maybe there was a way to save the memory stream to disk.

So do you save each voxel chunk to a separate file, or to different parts of the same file?

Also how would I go about using zlib compression? I'm not sure how I want to go about this yet, but it doesn't hurt to do research.

_________________
--Real Programmers use a magnetized needle and a steady hand.
--xkcd--


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Save Voxel Data to Disk
PostPosted: Fri Mar 18, 2011 9:17 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
There is some serialisation code in Serialization.h/inl which is in the PolyVoxUtil project. But they just do what you describe - they iterate over the voxels and add them to the stream. There is also some RLE compression in there.

I can see why you would want raw access to the data for serialiseation but unfortunatly this would mean exposing the internal representation of the Volume class, which I don't want to do. It's still changing anyway (e.g. for the streaming).

The provided code writes whole volumes to and from disk. In the future it will probably get redone to just write specified regions.

Be aware that several functions are deprecated (they have asserts to try and catch you if you call them). You shouold just call loadVolume() and saveVolume(). I hope they still work - haven't used them for a while myself.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Save Voxel Data to Disk
PostPosted: Fri Mar 18, 2011 9:28 pm 

Joined: Sat Sep 18, 2010 9:45 pm
Posts: 189
If you doing something similar to Minecraft perhaps consider using B-trees. I'm planning to integrate B-tree for my saving needs. Although I haven't fully considered all the pros and cons of using B-tree but I do think it should be enough for my needs where I load / store regions using B-tree.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Save Voxel Data to Disk
PostPosted: Sat Mar 19, 2011 5:29 am 

Joined: Sun Jan 23, 2011 6:06 am
Posts: 92
GM: saving/loading data using zlib is really easy using the streaming classes from the POCO library.

I will post a code example when I get home from work.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Save Voxel Data to Disk
PostPosted: Sat Mar 19, 2011 6:50 am 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
Oh, I'd like an example too.

But speaking of which, how would one go to handle saving with the new streaming functionalities in PolyVox? Imagine we start a new world and create empty areas from -1 to 1. Now we moved to one, we wish to unload -1 and load 2.

Would you save each region into its own file or will you save them into one file? How would you go about editing that file when changes are made? accessing the exact right region when you wish to load it?

I am not very familiar with file systems yet.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Save Voxel Data to Disk
PostPosted: Sat Mar 19, 2011 10:10 am 
User avatar

Joined: Wed Jan 26, 2011 3:20 pm
Posts: 203
Location: Germany
in minecraft and custom c++ minecraft servers this is handled by creating a file for every region. usually some kind of hexadecimal naming scheme is used. if the file doesn't exist yet, the data is generated. some servers only save modified data, but usually loading data is faster than generating.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Save Voxel Data to Disk
PostPosted: Sat Mar 19, 2011 11:19 am 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
Yes, that would be easier. But I'd love to devise a way to keep it all in one file, is it possible?

I guess it would be, if the volume has a specific size, but that could be quite a large file.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Save Voxel Data to Disk
PostPosted: Sat Mar 19, 2011 12:49 pm 
User avatar

Joined: Wed Jan 26, 2011 3:20 pm
Posts: 203
Location: Germany
simple: create a database :D I'm sure sql is not the best idea, but there are databases that might just offer what you need.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net