I have a little problem that is driving me crazy.
I have a struct:
Code: Select all
//! Struct for camera data.
struct CAMDATA
{
vector3df Pos;
vector3df Rot;
};
CAMDATA *m_camdata;
Code: Select all
m_camdata = new CAMDATA();
Code: Select all
//Save camera position data.
void CApplication::saveCameraData()
{
//get camera position.
m_camdata[0].Pos = m_camera->getAbsolutePosition();
m_camdata[0].Rot = getCameraRotation();
IWriteFile* file =
m_smgr->getFileSystem()->createAndWriteFile( "campos/campos.gsx", false);
if(file)
{
file->write(&m_camdata, sizeof(m_camdata));
file->drop();
}
}
//Load camera position data.
bool CApplication::loadCameraData()
{
if( (m_smgr->getFileSystem()->existFile("campos/campos.gsx")) )
{
IReadFile* file = m_smgr->getFileSystem()->createMemoryReadFile((char*)&m_camdata,
sizeof(m_camdata), "campos/campos.gsx", false);
if(file)
{
long lSize = file->getSize();
file->read(&m_camdata, lSize );
file->drop();
m_defpos = m_camdata.Pos;
m_defrot = m_camdata.Rot;
return true;
}
}
return false;
}
It writes to file.
When i debug the read function it only reads 0,0,0 for both.
It seems the write function is not writing to the file.
Is there something wrong with the write function and then by default the read one?
Thanks for any help.