Advertisement

FBX SDK and DirectX

Started by July 07, 2011 08:16 AM
-1 comments, last by Aqua Costa 13 years, 4 months ago
I'm trying to import FBX models to my DirectX 10 project using the FBX SDK.
This is what I have so far...

Vertex* vertices;
vertices = new Vertex[numVertices];
std::vector<int> indices;

KFbxSdkManager* lSdkManager = KFbxSdkManager::Create();
KFbxIOSettings *ios = KFbxIOSettings::Create(lSdkManager, IOSROOT);
lSdkManager->SetIOSettings(ios);

KFbxGeometryConverter lGConverter(lSdkManager);

// Create an importer using our sdk manager.
KFbxImporter* lImporter = KFbxImporter::Create(lSdkManager,"");

lImporter->Initialize(lFilename, -1, lSdkManager->GetIOSettings());

// Create a new scene so it can be populated by the imported file.
KFbxScene* lScene = KFbxScene::Create(lSdkManager,"myScene");

// Import the contents of the file into the scene.
lImporter->Import(lScene);

//Split meshes per material so each mesh only uses one texture
lGConverter.SplitMeshesPerMaterial(lScene);

KFbxNode* lRootNode = lScene->GetRootNode();
KFbxNode* lNode = NULL;
KFbxMesh* lMesh = NULL;
if(lRootNode)
{
if(lRootNode->GetNodeAttribute() != NULL)
{
for(int k = 0; k < lRootNode->GetNodeAttributeCount(); k++)
{
lMesh = (KFbxMesh*) lRootNode->GetNodeAttributeByIndex(k);
lMesh = lGConverter.TriangulateMesh(lMesh);

for(int i = 0; i < lMesh->GetControlPointsCount(); i++)
{
vertices.pos = lMesh->GetControlPointAt(i);
vertices.normal = //how to get normal???
vertices.tangent = //how to get tangent???
vertices.texC = //how to get texture coordinates???
}

for(int i = 0; i < lMesh->GetPolygonVertexCount(); i++)
{
indices.push_back(lMesh->GetPolygonVertices());
}
}
}

for(int i = 0; i < lRootNode->GetChildCount(); i++)
{
lNode = lRootNode->GetChild(i);

if(lNode->GetNodeAttribute() != NULL)
{
for(int k = 0; k < lNode->GetNodeAttributeCount(); k++)
{
lMesh = (KFbxMesh*) lNode->GetNodeAttributeByIndex(k);
lMesh = lGConverter.TriangulateMesh(lMesh);
vertices = new Vertex[lMesh->GetControlPointsCount()];

for(int i = 0; i < lMesh->GetControlPointsCount(); i++)
{
vertices.pos = lMesh->GetControlPointAt(i);
vertices.normal = //how to get normal???
vertices.tangent = //how to get tangent???
vertices.texC = //how to get texture coordinates???
}

for(int i = 0; i < lMesh->GetPolygonVertexCount(); i++)
{
indices.push_back(lMesh->GetPolygonVertices());
}
}
}
}
}

This topic is closed to new replies.

Advertisement