Volumes Of Fun
http://www.volumesoffun.com/phpBB3/

Saving / Loading
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=189
Page 1 of 1

Author:  dracanus [ Wed Apr 06, 2011 1:29 am ]
Post subject:  Saving / Loading

Edit::
I will leave this here for anyone who does something as stupid as I did :D
so the streams had values of 0x000000 and Bad_Ptr, apparently that's fine in c++Land but who knew! (probably anyone else reading).
The issue was something far less sinister
:oops: I forgot to initialise my volume. I thought that as the load function would read in a volume it would initialise the volume with a set size but instead it resizes your current volume to fit the loaded data. obviously as my volume didn't exist properly it threw exceptions! lesson learned. On the plus side while trying to understand about 60million aspects of code, I watched 3 movies so all in all, a good time!

So there is a chance I am doing something very stupid but my knowledge of c++ isn't that great and streams are definitely not an area I'm comfortable with.

The save function I created

Code:
bool VolumeModel::SaveVolume( LPCWSTR filename )
{   
   ofstream outFile;
   outFile.open(filename,ios::out | ios::binary | ios::trunc);
   ostream outstream(outFile.rdbuf());
PolyVox::saveVolume<PolyVox::MaterialDensityPair44>(outstream,*volume);


   return true;

}


seems to work fine, in that I have a file and it has data in it.

The load function however just doesn't want to work. I have tried all sorts of variations of objects and function calls but it always fails. I have even put the volumeFile into several debug directories in case it was something stupid like pointing to the wrong folder / directory.

at the moment I am trying

Code:
bool VolumeModel::LoadVolume(LPCWSTR filename)
{
   ifstream infile;
   infile.open(filename,ios::in);
   istream instream(infile.rdbuf());
   PolyVox::loadVolume<PolyVox::MaterialDensityPair44>(instream,*volume);//,listener);
      //fb.close();
      ExtractMeshToSurfaceMesh();
      return true;
   
}


the second line "infile.open" does not seem to do anything to infile. i analysed variables inside and they seem to have Bad_Ptr and such and trying if infile.is_open or infile.good still return true it just doesn't have the data properly.

I have tried so many different ideas here and my brain has melted so any help would be greatly appreciated =[

Author:  David Williams [ Wed Apr 06, 2011 9:49 pm ]
Post subject:  Re: Saving / Loading

Ok, so just to be clear you have solved your problem? I didn't read it in detail because of the edit at the top suggesting it was solved.

Be aware that with the latest version of PolyVox there may be issues with the serialization code. I'm not sure it plays well with the paging volume support. If it works for you then great, but it's something to watch out for

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/