文章目录[隐藏]
坐标系的转换
1 2 3 |
FbxAxisSystem unityAxisSystem(FbxAxisSystem::eYAxis, FbxAxisSystem::eParityOdd, FbxAxisSystem::eRightHanded); if (sceneAxisSystem != unityAxisSystem) unityAxisSystem.ConvertScene(lScene); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
void FBXAMatixToUnityMatrix(FBXGameObject* kgo, FbxAMatrix globalMatrix) { kgo->matrix[0] = static_cast<float>(globalMatrix.Double44()[0][0]); kgo->matrix[1] = static_cast<float>(-globalMatrix.Double44()[1][0]); kgo->matrix[2] = static_cast<float>(-globalMatrix.Double44()[2][0]); kgo->matrix[3] = static_cast<float>(-globalMatrix.Double44()[3][0]); kgo->matrix[4] = static_cast<float>(-globalMatrix.Double44()[0][1]); kgo->matrix[5] = static_cast<float>(globalMatrix.Double44()[1][1]); kgo->matrix[6] = static_cast<float>(globalMatrix.Double44()[2][1]); kgo->matrix[7] = static_cast<float>(globalMatrix.Double44()[3][1]); kgo->matrix[8] = static_cast<float>(-globalMatrix.Double44()[0][2]); kgo->matrix[9] = static_cast<float>(globalMatrix.Double44()[1][2]); kgo->matrix[10] = static_cast<float>(globalMatrix.Double44()[2][2]); kgo->matrix[11] = static_cast<float>(globalMatrix.Double44()[3][2]); kgo->matrix[12] = static_cast<float>(globalMatrix.Double44()[0][3]); kgo->matrix[13] = static_cast<float>(globalMatrix.Double44()[1][3]); kgo->matrix[14] = static_cast<float>(globalMatrix.Double44()[2][3]); kgo->matrix[15] = static_cast<float>(globalMatrix.Double44()[3][3]); } |
单位转换
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
//转换为米 if (SceneSystemUnit != FbxSystemUnit::m) { const FbxSystemUnit::ConversionOptions lConversionOptions = { false, /* mConvertRrsNodes */ true, /* mConvertAllLimits */ true, /* mConvertClusters */ true, /* mConvertLightIntensity */ true, /* mConvertPhotometricLProperties */ true /* mConvertCameraClipPlanes */ }; FbxSystemUnit::m.ConvertScene(lScene, lConversionOptions); } |
读取顶点的正确坐标
在这个问题上折腾挺长时间,主要是 getFBXGeometryTransform 和 EvaluateLocalTransform ,计算位置。
转载请注明:veyvin » Unity使用FBXSDK 读取模型注意事项