It is currently Sat Aug 22, 2020 4:14 am


All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Saving / Loading
PostPosted: Wed Apr 06, 2011 1:29 am 

Joined: Fri Mar 11, 2011 2:50 am
Posts: 1
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 =[


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Saving / Loading
PostPosted: Wed Apr 06, 2011 9:49 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 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