我使用assimp库导入一些FBX模型,但我找不到正确检索相机坐标的方法!
有人有这方面的经验吗?
这是我的代码:
// Find the transformation matrix corresponding to the camera node
aiNode* rootNode = _assimpScene->mRootNode;
aiNode* cameraNode = rootNode->FindNode(assimpCamera->mName.data);
aiMatrix4x4 T;
while(cameraNode != rootNode)
{
T = cameraNode->mTransformation * T;
cameraNode = cameraNode->mParent;
}
aiMatrix4x4 R = T;
R.a4 = R.b4 = R.c4 = 0.f;
R.d4 = 1.f;
// Transform
aiVector3D from = T * assimpCamera->mPosition;
aiVector3D up = R * assimpCamera->mUp;
aiVector3D lookAt = R * assimpCamera->mLookAt;
// Set up the camera
camera->eyeFrom = luxrays::Point(from.x, from.y, from.z);
lookAt = lookAt.Normalize();
camera->eyeAt = luxrays::Point(from.x + lookAt.x, from.y + lookAt.y, from.z + lookAt.z);
up = up.Normalize();
camera->eyeUp = luxrays::Point(up.x, up.y, up.z);