|
Working through the examples and I’m having an issue.
I exported a basic teapot mesh out of 3ds Max. I than am directing the functionm below to find the mesh.
I realize this code is super simple, but no need to go more complex till i have the basics working.
I load a basic teapot mesh and everything succeeds until I try to read the mesh data
I get read access errors when I try to access ANY other data. I’m confused as to what I did wrong.
Edit: Ok the Scene isn’t even initializing the rootnode. I’m confused now if the rootnode isn’t initialized than tha means there isn’t any data thus the load should fail, but it doesn’t.
bool gl_LoadModel(const char* FilePath,KFbxSdkManager* pManager,::GLTriangleBatch& Batch) {
int lFileMajor, lFileMinor, lFileRevision;
int lSDKMajor, lSDKMinor, lSDKRevision;
//int lFileFormat = -1;
bool lStatus;
char lPassword[1024];
KFbxScene* pScene = KFbxScene::Create(pManager,"");
// Get the file version number generate by the FBX SDK.
KFbxSdkManager::GetFileFormatVersion(lSDKMajor, lSDKMinor, lSDKRevision);
// Create an importer.
KFbxImporter* lImporter = KFbxImporter::Create(pManager,"");
// Initialize the importer by providing a filename.
bool lImportStatus = lImporter->Initialize(FilePath, -1, pManager->GetIOSettings());
lImporter->GetFileVersion(lFileMajor, lFileMinor, lFileRevision);
if( !lImportStatus )
{ #if _DEBUG
printf("Call to KFbxImporter::Initialize() failed.\n");
printf("Error returned: %s\n\n", lImporter->GetLastErrorString());
if (lImporter->GetLastErrorID() == KFbxIO::eFILE_VERSION_NOT_SUPPORTED_YET ||
lImporter->GetLastErrorID() == KFbxIO::eFILE_VERSION_NOT_SUPPORTED_ANYMORE)
{
printf("FBX version number for this FBX SDK is %d.%d.%d\n", lSDKMajor, lSDKMinor, lSDKRevision);
printf("FBX version number for file %s is %d.%d.%d\n\n", FilePath, lFileMajor, lFileMinor, lFileRevision);
} #endif
return false;
}
if(lImporter->IsFBX())
{
}
lStatus = lImporter->Import(pScene);
if(lStatus == false && lImporter->GetLastErrorID() == KFbxIO::ePASSWORD_ERROR)
{
}
lImporter->Destroy();
KFbxNode* pRoot = pScene->GetRootNode();
KFbxNodeAttribute::EAttributeType lAttributeType;
KFbxMesh* pMesh = 0;
for(unsigned int i = 0; i < pRoot->GetChildCount();++i)
{
if(pMesh != 0)
break;
lAttributeType = pRoot->GetChild(i)->GetNodeAttribute()->GetAttributeType();
switch(lAttributeType)
{
case KFbxNodeAttribute::eMESH:
pMesh = (KFbxMesh*)pRoot->GetChild(i);
break;
default:
break;
}
}
if(pMesh == 0)
{
pScene->Destroy();
return false;
}
//Fail here
if(!pMesh->IsTriangleMesh())
{
KFbxMesh* Temp;
KFbxGeometryConverter Geometry(pManager);
Temp = Geometry.TriangulateMeshAdvance(pMesh,lStatus);
if(lStatus)
{
pMesh->Destroy();
pMesh = Temp;
}
else
{
pScene->Destroy(false,true);
return false;
}
}
//Also fails here if I comment out the block above
int i,j,lPolygonCount = pMesh->GetPolygonCount();
//Never can access farther code because of crash.
}
|