我不知道如何使用Exporter
以dae
格式导出我的场景。现在,我正在这样做:
void Model::save(const std::string &path)
{
// Create a new scene
aiScene scene;
scene.mRootNode = new aiNode();
// Create a material
scene.mMaterials = new aiMaterial *[1];
scene.mMaterials[0] = new aiMaterial();
scene.mNumMaterials = 1;
// Create a mesh
scene.mMeshes = new aiMesh *[_meshes.size()];
scene.mNumMeshes = _meshes.size();
// Set our mesh to the root node
scene.mRootNode->mMeshes = new unsigned[_meshes.size()];
scene.mRootNode->mNumMeshes = _meshes.size();
// Build meshes
for (unsigned i = 0; i < scene.mNumMeshes; ++i) {
auto mesh = scene.mMeshes[i] = new aiMesh();
// Set our material
scene.mMeshes[i]->mMaterialIndex = 0;
scene.mRootNode->mMeshes[i] = i;
buildAiMesh(_meshes[i], mesh);
}
// Export to file
Assimp::Exporter exporter;
auto format = exporter.GetExportFormatDescription(0);
exporter.Export(&scene, format->id, path);
}
我确定这是不对的,但是我找不到任何干净的文档来做到这一点。
已更新:
解决方案非常简单...我需要直接指定格式:
exporter.Export(&scene, "collada", path);