Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
Save Voxel Data to Disk http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=176 |
Page 1 of 3 |
Author: | GM_Riscvul [ Thu Mar 17, 2011 3:13 pm ] |
Post subject: | Save Voxel Data to Disk |
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. |
Author: | DefiniteIntegral [ Fri Mar 18, 2011 3:34 am ] |
Post subject: | Re: Save Voxel Data to Disk |
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... |
Author: | GM_Riscvul [ Fri Mar 18, 2011 5:54 pm ] |
Post subject: | Re: Save Voxel Data to Disk |
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. |
Author: | David Williams [ Fri Mar 18, 2011 9:17 pm ] |
Post subject: | Re: Save Voxel Data to Disk |
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. |
Author: | beyzend [ Fri Mar 18, 2011 9:28 pm ] |
Post subject: | Re: Save Voxel Data to Disk |
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. |
Author: | DefiniteIntegral [ Sat Mar 19, 2011 5:29 am ] |
Post subject: | Re: Save Voxel Data to Disk |
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. |
Author: | Shanee [ Sat Mar 19, 2011 6:50 am ] |
Post subject: | Re: Save Voxel Data to Disk |
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. |
Author: | ker [ Sat Mar 19, 2011 10:10 am ] |
Post subject: | Re: Save Voxel Data to Disk |
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. |
Author: | Shanee [ Sat Mar 19, 2011 11:19 am ] |
Post subject: | Re: Save Voxel Data to Disk |
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. |
Author: | ker [ Sat Mar 19, 2011 12:49 pm ] |
Post subject: | Re: Save Voxel Data to Disk |
simple: create a database ![]() |
Page 1 of 3 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |