Community
FBX Forum
Welcome to Autodesk’s FBX Forums. Share your knowledge, ask questions, and explore popular FBX topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Exception when trying to access element material indices.

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
685 Views, 3 Replies

Exception when trying to access element material indices.

 

I am getting a crash when trying to access polygon material IDs when parsing Fbx Meshes. 

I am unable to access the element material indices array.

 

 


auto fbxGeometryElementMaterial = fbxMesh->GetElementMaterial(); FbxLayerElementArray& indArray = fbxGeometryElementMaterial->GetIndexArray(); int count = indArray.GetCount();

 

My mesh has multiple materials, and can be read back into 3dsmax. 

I get a crash on the call to GetCount. GetCount calls into ReadLock where the exception is thrown.

 

Exception thrown at 0x00007FF8C1A9462C (FbxAsset.dll) in TestingSG.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

If there is a handler for this exception, the program may be safely continued.

 

Note: I have been using code provided in DisplayMesh.cxx, and getting this error. I am using FbxSDK217.

 

Thanks

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

ok, I figured this out. 

 

I was calling GetIndexArray twice, and the first time assigning by value, not reference.

 

e..g first time it works.
auto first = fbxMaterialAssignment->GetIndexArray();

 

second time it crashes.
auto second = fbxMaterialAssignment->GetIndexArray();

 

usinig a reference fixes the crash.
auto& first = fbxMaterialAssignment->GetIndexArray();

Message 3 of 4
Anonymous
in reply to: Anonymous

Also ran into this issue, except the crash on second access was hidden inside fbxExporter->Export(mScene) .

 

The stack trace looked like this:

Exception thrown at 0x00007FF638299D7C in myapp.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

myapp.exe!fbxsdk::FbxLayerElementArray::ReadLock(void)	C++
myapp.exe!fbxsdk::FbxLayerElementArray::GetCount(void)	C++
myapp.exe!fbxsdk::FbxWriterFbx7_Impl::WriteFbxLayerElementNormals(class fbxsdk::FbxLayerContainer &,class fbxsdk::FbxMultiMap &)	C++
myapp.exe!fbxsdk::FbxWriterFbx7_Impl::WriteGeometry(class fbxsdk::FbxGeometry &)	C++
myapp.exe!fbxsdk::FbxWriterFbx7_Impl::WriteMesh(class fbxsdk::FbxMesh &)	C++
myapp.exe!fbxsdk::FbxWriterFbx7_Impl::WriteNodeAttribute(class fbxsdk::FbxNodeAttribute *)	C++
myapp.exe!fbxsdk::FbxWriterFbx7_Impl::WriteFbxObject(class fbxsdk::FbxNodeAttribute &)	C++
myapp.exe!fbxsdk::FbxWriterFbx7_Impl::WriteFbxObjects<class fbxsdk::FbxNodeAttribute>(class fbxsdk::FbxDocument *,class fbxsdk::FbxNodeAttribute const *)	C++
myapp.exe!fbxsdk::FbxWriterFbx7_Impl::WriteObjectProperties(class fbxsdk::FbxDocument *)	C++
myapp.exe!fbxsdk::FbxWriterFbx7::Write(class fbxsdk::FbxDocument *,class fbxsdk::FbxIO *)	C++
myapp.exe!fbxsdk::FbxWriterFbx7::Write(class fbxsdk::FbxDocument *)	C++
myapp.exe!fbxsdk::FbxExporter::ExportProcess(class fbxsdk::FbxDocument *)	C++
myapp.exe!fbxsdk::FbxExporter::Export(class fbxsdk::FbxDocument *,bool)	C++

 

 

 

Message 4 of 4
Anonymous
in reply to: Anonymous

I'm getting a similar error and stack trace using FbxExporter->Export(Scene). Anyone have any tips on how to debug this? Is there even a way to step in to the source code of these functions? (Apologies for dumb question, I'm still somewhat new to c++ dev, it seems I can't step into source code bc this library is pre-compiled and doesn't provide sources?)

 

Error: Unhandled exception at 0x00007FF6CEC66C7C in CreateVolcapFBX.exe: 0xC0000005: Access violation reading location 0x0000000000000010.

 

 	CreateVolcapFBX.exe!fbxsdk::FbxLayerElementArray::ReadLock(void)	C++
 	CreateVolcapFBX.exe!fbxsdk::FbxLayerElementArray::GetCount(void)	C++
 	CreateVolcapFBX.exe!fbxsdk::FbxWriterFbx7_Impl::WriteFbxLayerElementUVsChannel(class fbxsdk::FbxLayerContainer &,enum fbxsdk::FbxLayerElement::EType,class fbxsdk::FbxMultiMap &)	C++
 	CreateVolcapFBX.exe!fbxsdk::FbxWriterFbx7_Impl::WriteFbxLayerElementUVs(class fbxsdk::FbxLayerContainer &,class fbxsdk::FbxMultiMap &)	C++
 	CreateVolcapFBX.exe!fbxsdk::FbxWriterFbx7_Impl::WriteGeometry(class fbxsdk::FbxGeometry &)	C++
 	CreateVolcapFBX.exe!fbxsdk::FbxWriterFbx7_Impl::WriteMesh(class fbxsdk::FbxMesh &)	C++
 	CreateVolcapFBX.exe!fbxsdk::FbxWriterFbx7_Impl::WriteNodeAttribute(class fbxsdk::FbxNodeAttribute *)	C++
 	CreateVolcapFBX.exe!fbxsdk::FbxWriterFbx7_Impl::WriteFbxObject(class fbxsdk::FbxNodeAttribute &)	C++
 	CreateVolcapFBX.exe!fbxsdk::FbxWriterFbx7_Impl::WriteFbxObjects<class fbxsdk::FbxNodeAttribute>(class fbxsdk::FbxDocument *,class fbxsdk::FbxNodeAttribute const *)	C++
 	CreateVolcapFBX.exe!fbxsdk::FbxWriterFbx7_Impl::WriteObjectProperties(class fbxsdk::FbxDocument *)	C++
 	CreateVolcapFBX.exe!fbxsdk::FbxWriterFbx7::Write(class fbxsdk::FbxDocument *,class fbxsdk::FbxIO *)	C++
 	CreateVolcapFBX.exe!fbxsdk::FbxWriterFbx7::Write(class fbxsdk::FbxDocument *)	C++
 	CreateVolcapFBX.exe!fbxsdk::FbxExporter::ExportProcess(class fbxsdk::FbxDocument *)	C++
 	CreateVolcapFBX.exe!fbxsdk::FbxExporter::Export(class fbxsdk::FbxDocument *,bool)	C++
>	CreateVolcapFBX.exe!SaveScene(fbxsdk::FbxManager * pSdkManager, fbxsdk::FbxDocument * pScene, const char * pFilename, int pFileFormat, bool pEmbedMedia) Line 160	C++
 	CreateVolcapFBX.exe!Export(const char * pFilename, int pFileFormat) Line 173	C++
 	CreateVolcapFBX.exe!fbxFromTextureMesh(pcl::TextureMesh & mesh) Line 338	C++
 	CreateVolcapFBX.exe!main(int argc, char * * argv) Line 348	C++

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report