Here we go: Iâ€™ve decided to make the sample open source and host it on google code. Hopefully this step will raise public awareness and make it easier for other developers to download and reuse the code.
As a first step Iâ€™ve hijacked a DirectX 9 programming assignment I did a while ago and removed all assignment specific code. What Iâ€™m left with at this point is a bare bones program skeleton of a windowed DirectX 9 application, a frame rate timer and a very rudimentary display list implementation. Iâ€™ve also added Assimp to the project and the first test model import worked fine – well at least it didn’t throw any errors. I donâ€™t have a renderer yet so thereâ€™s no way of verifying the imported data 🙂
The model import itself is surprisingly simple: Create an instance of
Assmp::Importer and call
Assimp::Importer::ReadFile() [The following code is mostly taken from the Assimp tutorial]
const aiScene* scene = modelImporter.ReadFile( mFileName,
// If the import failed, report it
std::cout << modelImporter.GetErrorString() << std::endl; MessageBox( NULL, modelImporter.GetErrorString(), "import failed", MB_OK ); return false; } [/sourcecode] Thatâ€™s it. Obviously thereâ€™s a million parameters you can pass to
ReadFile() but they are mostly self explaining. The most important one in my setting would be
aiProcess_ConvertToLeftHanded because Assimp assumes a Right Handed Coordinate System whereas DirectX uses a left hand coordinate system by default.
In case the import fails
Assimp::ModelImporter returns a
NULL pointer and you can get extended error information via