Reputation: 2268
I am importing FBX files using assimp and also want to get the Transformation of the mesh from the model.
This is the function that gets the position of the mesh.
This works but sometimes the application crashes while importing certain models and if i remove the transformation part than model imports successfully.
void processNode(aiNode* node, const aiScene *scene)
{
// process each mesh located at the current node
for (unsigned int i = 0; i < node->mNumMeshes; i++)
{
aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
ai_real x = scene->mRootNode->mChildren[iModel]->mTransformation.a4;
ai_real y = scene->mRootNode->mChildren[iModel]->mTransformation.b4;
ai_real z = scene->mRootNode->mChildren[iModel]->mTransformation.c4;
std::cout << x << " " << y << " " << z; // if i comment this than no crash
}
}
Upvotes: 0
Views: 1638
Reputation: 2843
You need to use the instance of aiNode where the mesh is referenced and perform the whole transformation chain from your node up to the root node. The you can extract the position out of it. So in short:
With this global transformation you have the information where your mesh is located in the World-Space.
Upvotes: 2