Skip to main content
added 6 characters in body
Source Link
Adrian Mole
  • 52.1k
  • 193
  • 61
  • 101

I am creating my C++ game engine and I wanted to be able to export my scenes using the FBX format.

So, when I tried to export an FBX from a previously imported OBJ file, that actually renders correctly. ItBut it is not exported correctly when exporting to anything other than what it was originally imported from.

std::unique_ptr<Assimp::Exporter> exporter = std::make_unique<Assimp::Exporter>(); const auto* scene = mesh->mScene; exporter->Export(scene, "fbx", "assets/output.fbx"); 

Here, mesh->mScene is the aiScene imported previously. This

This code actually works and Export() returns success, butsuccess; however, the output file does not include the proper data of the mesh. Only when imported from an FBX it is thenit correct and can be imported in Maya without problems.

I need a way to convert assimp aiSceneAssim::aiScene to be exported in the FBX format., because assimpAssimp only allows to export meshes to the same format as it is imported from.

Also, I wanted to be able to modify the meshes, let's say I want to replace the diffuse texture.

//Yeah, sorry I am still a beginner :) auto* aiMaterial = mesh->mScene->mMaterials[index]; if (aiMaterial->RemoveProperty("$clr.diffuse") != 0 || aiMaterial->AddProperty(texture->getPath().c_str(), 1, "$clr.diffuse") != 0) { assert(false, "Failed to add property!"); } 

This code also runs fine but it does not change anything in the mesh.

I am creating my C++ game engine and I wanted to be able to export my scenes using the FBX format.

So when I tried to export an FBX from a previously imported OBJ file that actually renders correctly. It is not exported correctly when exporting to anything other than what was originally imported from.

std::unique_ptr<Assimp::Exporter> exporter = std::make_unique<Assimp::Exporter>(); const auto* scene = mesh->mScene; exporter->Export(scene, "fbx", "assets/output.fbx"); 

mesh->mScene is aiScene imported previously. This code actually works and Export() returns success, but, the output file does not include the proper data of the mesh. Only when imported from an FBX it is then correct and can be imported in Maya without problems.

I need a way to convert assimp aiScene to be exported in the FBX format. because assimp only allows to export meshes to the same format as it is imported from.

Also, I wanted to be able to modify the meshes, let's say I want to replace the diffuse texture.

//Yeah, sorry I am still a beginner :) auto* aiMaterial = mesh->mScene->mMaterials[index]; if (aiMaterial->RemoveProperty("$clr.diffuse") != 0 || aiMaterial->AddProperty(texture->getPath().c_str(), 1, "$clr.diffuse") != 0) { assert(false, "Failed to add property!"); } 

This code also runs fine but it does not change anything in the mesh.

I am creating my C++ game engine and I wanted to be able to export my scenes using the FBX format.

So, when I tried to export an FBX from a previously imported OBJ file, that actually renders correctly. But it is not exported correctly when exporting to anything other than what it was originally imported from.

std::unique_ptr<Assimp::Exporter> exporter = std::make_unique<Assimp::Exporter>(); const auto* scene = mesh->mScene; exporter->Export(scene, "fbx", "assets/output.fbx"); 

Here, mesh->mScene is the aiScene imported previously.

This code actually works and Export() returns success; however, the output file does not include the proper data of the mesh. Only when imported from an FBX is it correct and can be imported in Maya without problems.

I need a way to convert Assim::aiScene to be exported in the FBX format, because Assimp only allows to export meshes to the same format as it is imported from.

Also, I wanted to be able to modify the meshes, let's say I want to replace the diffuse texture.

//Yeah, sorry I am still a beginner :) auto* aiMaterial = mesh->mScene->mMaterials[index]; if (aiMaterial->RemoveProperty("$clr.diffuse") != 0 || aiMaterial->AddProperty(texture->getPath().c_str(), 1, "$clr.diffuse") != 0) { assert(false, "Failed to add property!"); } 

This code also runs fine but it does not change anything in the mesh.

Source Link

How to export an fbx from an imported obj using assimp

I am creating my C++ game engine and I wanted to be able to export my scenes using the FBX format.

So when I tried to export an FBX from a previously imported OBJ file that actually renders correctly. It is not exported correctly when exporting to anything other than what was originally imported from.

std::unique_ptr<Assimp::Exporter> exporter = std::make_unique<Assimp::Exporter>(); const auto* scene = mesh->mScene; exporter->Export(scene, "fbx", "assets/output.fbx"); 

mesh->mScene is aiScene imported previously. This code actually works and Export() returns success, but, the output file does not include the proper data of the mesh. Only when imported from an FBX it is then correct and can be imported in Maya without problems.

I need a way to convert assimp aiScene to be exported in the FBX format. because assimp only allows to export meshes to the same format as it is imported from.

Also, I wanted to be able to modify the meshes, let's say I want to replace the diffuse texture.

//Yeah, sorry I am still a beginner :) auto* aiMaterial = mesh->mScene->mMaterials[index]; if (aiMaterial->RemoveProperty("$clr.diffuse") != 0 || aiMaterial->AddProperty(texture->getPath().c_str(), 1, "$clr.diffuse") != 0) { assert(false, "Failed to add property!"); } 

This code also runs fine but it does not change anything in the mesh.