fbx_sdk_transform_question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
Below is a crane one of our artist created. We are currently using Fbx SDK 2020.2.1 and what we notices is that the boom is scaled very tiny see FbxSdk_tiny_boom.png.
In some softwares, i.e. Maya2023, FBX Review (1.3.1.0) the boom is scaled correctly. But in others, i.e. Rhino 6.0/Naviswork 2023, MS Paint3D, Visual Studio 2017, the boom is scaled tiny. I have no ideas what the other softwares are using internally to parse the fbx, but at least in our software we are seeing the same incorrect behaviour as Rhino, Navisworks etc...
Below is the code we used to fetch the matrices...
I have also attached the FBX file and pictures of the problem.
Thanks,
Grace
// Contains the geometry transform (not inherited!)
FbxAMatrix GetGlobalTransform ( FbxNode *a_pNode )
{
FbxVector4 vGeoTransform = a_pNode->GetGeometricTranslation ( FbxNode::eSourcePivot );
FbxVector4 vGeoScale = a_pNode->GetGeometricScaling ( FbxNode::eSourcePivot );
FbxVector4 vGeoRotate = a_pNode->GetGeometricRotation ( FbxNode::eSourcePivot );
FbxAMatrix mGeoFull ( vGeoTransform, vGeoRotate, vGeoScale );
FbxAMatrix mNodeTransform = a_pNode->EvaluateGlobalTransform();
return mNodeTransform * mGeoFull;
}
void FBXModelLoader::AppendMesh ( FbxNode *a_pNode, FbxMesh *a_pMesh, const FbxAMatrix &a_mLocal, KEHashMap64 *a_pUniqueMaterials, bool a_bUndoMirroring )
{
if ( a_bUndoMirroring )
{
FbxAMatrix mWorld = GetGlobalTransform ( a_pNode );
Matrix mMyProgWorld = FbxAMatrixToMyProgramMatrix ( mWorld );
if ( !Matrix_Mirrored ( &mMyProgWorld ) )
{
a_bUndoMirroring = false;
}
}
FbxAMatrix mGlobalTransformInvScaling = a_mLocal;
if (m_bUseParentNodeXForm)
{
FbxNode *pParentNode = a_pNode->GetParent();
if ( pParentNode )
{
FbxAMatrix mInvUnitMatrix = pParentNode->EvaluateGlobalTransform();
mGlobalTransformInvScaling = mInvUnitMatrix.Inverse() * mGlobalTransformInvScaling;
}
}
...
}
void FBXModelLoader::WriteEntities ( FbxNode *a_pNode, u32 dwModelId, Handle *a_pCacheEntryHandle, const FbxAMatrix &a_mInvBaseTransform, KEHashMap64 *a_pUniqueMaterials, bool a_bUndoMirroring )
{
if ( !a_pNode || a_pNode->GetObjectFlags ( FbxObject::eHidden ) )
{
return;
}
KEHashMap64 uniqueMaterials;
FbxAMatrix mWorld = GetGlobalTransform ( a_pNode );
FbxAMatrix mLocal = a_mInvBaseTransform * mWorld;
bool bCreateMesh = false;
if ( HasMesh ( a_pNode ) )
{
const u32 dwNumAttributes = a_pNode->GetNodeAttributeCount();
for ( u32 dwAttrIdx = 0; dwAttrIdx < dwNumAttributes; dwAttrIdx++ )
{
const FbxNodeAttribute *pCurAttribute = a_pNode->GetNodeAttributeByIndex ( dwAttrIdx );
if ( pCurAttribute && pCurAttribute->GetAttributeType() == FbxNodeAttribute::eMesh && !pCurAttribute->GetObjectFlags ( FbxObject::eHidden ) )
{
FbxMesh *pMesh = (FbxMesh *)pCurAttribute;
AppendMesh ( a_pNode, pMesh, mLocal, a_pUniqueMaterials, a_bUndoMirroring );
}
}
}
for ( s32 i = 0; i < a_pNode->GetChildCount(); i++ )
{
WriteEntities ( a_pNode->GetChild ( i ), dwModelId, a_pCacheEntryHandle, a_mInvBaseTransform, a_pUniqueMaterials, a_bUndoMirroring );
}
...
}
----------------- Start ---
m_pImporter->Import ( m_pScene );
FbxAxisSystem engineAxis ( FbxAxisSystem::OpenGL );
FbxSystemUnit engineUnit ( FbxSystemUnit::m );
const FbxSystemUnit &unit = m_pScene->GetGlobalSettings().GetSystemUnit();
const FbxAxisSystem &axis = m_pScene->GetGlobalSettings().GetAxisSystem();
if ( unit != engineUnit )
{
engineUnit.ConvertScene ( m_pScene );
}
if ( axis != engineAxis )
{
engineAxis.ConvertScene ( m_pScene );
}
{
FbxGeometryConverter lGeomConverter( m_pSdkManager );
lGeomConverter.Triangulate( m_pScene, true );
}
FbxNode *pRootNode = m_pScene->GetRootNode();
if ( pRootNode )
{
WriteEntities ( pRootNode, 0, nullptr, FbxAMatrix(), &uniqueMats, true );
}
}
Link copied