Edit::
I will leave this here for anyone who does something as stupid as I did
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
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 =[