Hello
I have come across an issue which I can not seem to figure out.
I'm writing some 3D code and I started using ASSIMP to load a simple 3DS scene.
The code to load a scene is provided as such:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
bool DoTheImportThing( const std::string& pFile)
{
// Create an instance of the Importer class
Assimp::Importer importer;
// And have it read the given file with some example postprocessing
// Usually - if speed is not the most important aspect for you - you'll
// propably to request more postprocessing than we do in this example.
const aiScene* scene = importer.ReadFile( pFile,
aiProcess_CalcTangentSpace |
aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_SortByPType);
// If the import failed, report it
if( !scene)
{
DoTheErrorLogging( importer.GetErrorString());
return false;
}
// Now we can access the file's contents.
DoTheSceneProcessing( scene);
// We're done. Everything will be cleaned up by the importer destructor
return true;
}
|
It works really well, except, I am not able to "retain" the scene object outside the scope of this function.
What I'd like to do, is import the scene, and pass it, or some of its members to some of my other functions, in this case, I want the Mesh and it's members so I can have my graphics engine draw it.
According to the documentation, when importer is finished, it will destroy all of its contents, along with the scene and all of its data, which leaves the pointer pointing to, well nothing useful.
This is something I have not come across, and I thought a bit of experimenting would get me through this easily, but I'm stuck :(
I tried creating scenes and importers as globals, but nothing seems to work.
I could really use some help as to how to retain the data I am looking for so I can pass it onto other components of my project.
I'm using VS2010 Pro, and I'm coding with PhysX, Irrlicht, and ASSIMP at the moment trying to import a very simple 3DS file.
Any help will be greatly appreciated
Regards
xp