HRESULT CStaticMesh::Initalize(const char * szFilePath, const char * szFileName) { m_eDrawType = DRAW_VERTEX; FbxManager* pFBXManager = FbxManager::Create(); FbxIOSettings* pIOsettings = FbxIOSettings::Create(pFBXManager, IOSROOT); pFBXManager->SetIOSettings(pIOsettings); FbxScene* pFBXScene = FbxScene::Create(pFBXManager, ""); FbxImporter* pImporter = FbxImporter::Create(pFBXManager, ""); if (FAILED(Load_StaticMesh(szFilePath, szFileName, pFBXManager, pIOsettings, pFBXScene, pImporter))) return E_FAIL; CMesh::CreateRasterizerState(); //Init_Shader(); pFBXScene->Destroy(); pImporter->Destroy(); pIOsettings->Destroy(); pFBXManager->Destroy(); return S_OK; }
void MyGameFbxSceneLoader::loadSceneFromFbx( MyGameScene::MyGameSceneManager* sceneMgr, const string& fileName, MyGameSceneNode* node, vector<MyGameSceneEntity*>& entityList ) { FbxManager* fbxMgr= FbxManager::Create(); FbxIOSettings* fbxIO = FbxIOSettings::Create( fbxMgr, IOSROOT ); fbxMgr->SetIOSettings( fbxIO ); FbxScene* fbxScene = FbxScene::Create( fbxMgr, "test" ); FbxImporter* importer = FbxImporter::Create( fbxMgr, "" ); importer->Initialize( fileName.c_str(), -1, fbxMgr->GetIOSettings() ); importer->Import( fbxScene ); fbxIO->Destroy(); FbxNode* rootNode = fbxScene->GetRootNode(); FbxGeometryConverter converter( fbxMgr ); converter.TriangulateInPlace( rootNode ); getNodeFromFbxNode( sceneMgr, rootNode, node, entityList ); rootNode->Destroy(); fbxScene->Destroy(); fbxMgr->Destroy(); }
int main(int argc, char** argv) { #if _WIN32 char current_path[MAX_PATH + 1]; GetDirectoryName(current_path, argv[0]); SetCurrentDirectoryA(current_path); #endif FBX2MDL::FBXImporter importer; FBX2MDL::FBXExporter exporter; FbxManager* sdkManager = FbxManager::Create(); FbxIOSettings* ios = FbxIOSettings::Create(sdkManager, IOSROOT); sdkManager->SetIOSettings(ios); fbxsdk_2015_1::FbxImporter* fbxImporter = fbxsdk_2015_1::FbxImporter::Create(sdkManager, ""); if (!fbxImporter->Initialize("box3.fbx", -1, sdkManager->GetIOSettings())) { printf("Call to FbxImporter::Initialize() failed.\n"); printf("Error returned: %s\n\n", fbxImporter->GetStatus().GetErrorString()); system("PAUSE"); exit(-1); } FbxScene* fbxScene = FbxScene::Create(sdkManager, "myScene"); fbxImporter->Import(fbxScene); auto scene = importer.LoadScene(fbxScene, sdkManager); auto writer = exporter.Export(scene); fbxScene->Destroy(); fbxImporter->Destroy(); sdkManager->Destroy(); writer->WriteOut("box2.mdl"); auto buf = writer->Get(); auto buf_ = std::vector<uint8_t>(); for (size_t i = 0; i < buf.size(); i++) { auto b = ((uint8_t*) buf.data())[i]; buf_.push_back(b); } ace::Model_IO model_io; model_io.Load(buf_, ace::ToAString("./").c_str()); /* MDLExporter *exporter = new MDLExporter("Data/Model/AnimationTest.fbx", "Data/Model/AnimationTest.mdl"); exporter->Convert(); delete exporter; */ return 0; }
// FBXデータから頂点データにコンバート // ※パスは「/」でしか通らない //const char* filename = "../datas/box.fbx"; bool LoadFBXConvertToVertexData(const char* filename, VertexDataArray& outVertexData) { //============================================================================== // FBXオブジェクト初期化 //============================================================================== // FBXマネージャー作成 FbxManager* pFBXManager = FbxManager::Create(); // シーン作成 FbxScene* pScene = FbxScene::Create(pFBXManager, ""); // FBXのIO設定オブジェクト作成 FbxIOSettings *pIO = FbxIOSettings::Create(pFBXManager, IOSROOT); pFBXManager->SetIOSettings(pIO); // インポートオブジェクト作成 FbxImporter* pImporter = FbxImporter::Create(pFBXManager, ""); // ファイルインポート if(pImporter->Initialize(filename, -1, pFBXManager->GetIOSettings()) == false) { return false; } // シーンへインポート if(pImporter->Import(pScene) == false) { return false; } // ※この時点でインポートオブジェクトはいらない pImporter->Destroy(); //============================================================================== // FBXオブジェクトの処理 //============================================================================== // シーンのものすべてを三角化 FbxGeometryConverter geometryConverte(pFBXManager); geometryConverte.Triangulate(pScene, true); // メッシュ情報処理 GetMeshData(pScene->GetRootNode(), outVertexData); //============================================================================== // FBXオブジェクト色々破棄 //============================================================================== pIO->Destroy(); pScene->Destroy(); pFBXManager->Destroy(); getchar(); return true; }
int main(int argc, char** argv) { if(argc!=3) { printf("引数が足りません。\n"); return -1; } const char* importPath = argv[1]; const char* exportPath = argv[2]; FBX2MDL::FBXImporter importer; FBX2MDL::FBXExporter exporter; FbxManager* sdkManager = FbxManager::Create(); FbxIOSettings* ios = FbxIOSettings::Create(sdkManager, IOSROOT); sdkManager->SetIOSettings(ios); fbxsdk_2015_1::FbxImporter* fbxImporter = fbxsdk_2015_1::FbxImporter::Create(sdkManager, ""); if (!fbxImporter->Initialize(importPath, -1, sdkManager->GetIOSettings())) { printf("Call to FbxImporter::Initialize() failed.\n"); printf("Error returned: %s\n\n", fbxImporter->GetStatus().GetErrorString()); system("PAUSE"); exit(-1); } FbxScene* fbxScene = FbxScene::Create(sdkManager, "myScene"); fbxImporter->Import(fbxScene); auto scene = importer.LoadScene(fbxScene, sdkManager); auto writer = exporter.Export(scene); fbxScene->Destroy(); fbxImporter->Destroy(); sdkManager->Destroy(); writer->WriteOut(exportPath); return 0; }
~ScopedScene(){ if (scene){ scene->Destroy(true); } }
int main(int argc, char **argv) { #ifndef _DEBUG if (argc != 2) { printf("invalid arg"); return 0; } const char* filename = argv[1]; #else const char* filename = "*****@*****.**"; #endif output.open("output.txt", ios::out | ios::trunc); output2.open("output2.txt", ios::out | ios::trunc); output3.open("output3.txt", ios::out | ios::trunc); if (!output.is_open()) { exit(1); } FbxManager* fm = FbxManager::Create(); FbxIOSettings *ios = FbxIOSettings::Create(fm, IOSROOT); //ios->SetBoolProp(EXP_FBX_ANIMATION, false); ios->SetIntProp(EXP_FBX_COMPRESS_LEVEL, 9); ios->SetAllObjectFlags(true); fm->SetIOSettings(ios); FbxImporter* importer = FbxImporter::Create(fm, ""); if (!importer->Initialize(filename, -1, fm->GetIOSettings())) { printf("error returned : %s\n", importer->GetStatus().GetErrorString()); exit(-1); } FbxScene* scene = FbxScene::Create(fm, "myscene"); importer->Import(scene); importer->Destroy(); output << "some\n"; output << "charcnt : " << scene->GetCharacterCount() << endl << "node cnt : " << scene->GetNodeCount() << endl; int animstackcnt = scene->GetSrcObjectCount<FbxAnimStack>(); output << "animstackcnt : " << animstackcnt << endl; output << "------------" << endl; vector<FbxNode*> removableNodes; for (int i = 0; i < scene->GetNodeCount(); i++) { FbxNode* node = scene->GetNode(i); output << "scene's node " << i << " : " << node->GetName() << ", childcnt : " << node->GetChildCount(); if (node->GetNodeAttribute()) { output <<", att type : " << node->GetNodeAttribute()->GetAttributeType(); if (node->GetNodeAttribute()->GetAttributeType() == FbxNodeAttribute::EType::eMesh) { FbxMesh* mesh = node->GetMesh(); output << ", mem usage : " << mesh->MemoryUsage() << ", deformer cnt : " << mesh->GetDeformerCount(FbxDeformer::EDeformerType::eSkin) << endl; collapseMesh(mesh); FbxSkin* skin = (FbxSkin*) (mesh->GetDeformer(0, FbxDeformer::EDeformerType::eSkin)); if (skin) { for (int cli = 0; cli < skin->GetClusterCount(); cli++) { FbxCluster* cluster = skin->GetCluster(cli); output << "\tcluster no." << cli << " has " << cluster->GetControlPointIndicesCount() << " connected verts" << endl; if (cluster->GetControlPointIndicesCount() == 0) removableNodes.push_back( cluster->GetLink() ); //cluster-> //skin->RemoveCluster(cluster);효과없음 } } if (mesh->IsTriangleMesh()) { output << "\tit's triangle mesh" << endl; } //mesh->RemoveDeformer(0);효과없음 } else output << endl; } else { output << ", att type : none" << endl; } } for (int rni = 0; rni < removableNodes.size(); rni++) { FbxNode* rnd = removableNodes[rni]; if (rnd && rnd->GetNodeAttribute()->GetAttributeType() == FbxNodeAttribute::EType::eSkeleton) { output3 << rnd->GetName() << " node with no vert attached's curve : " << rnd->GetSrcObjectCount<FbxAnimCurve>() << "," << rnd->GetSrcObjectCount<FbxAnimCurveNode>() << endl; } } output << "-----------animinfo" << endl; int cubic = 0, linear = 0, cons = 0; for (int si = 0; si < animstackcnt; si++) { FbxAnimStack* stack = scene->GetSrcObject<FbxAnimStack>(si); for (int i = 0; i < stack->GetMemberCount<FbxAnimLayer>(); i++) { FbxAnimLayer* layer = stack->GetMember<FbxAnimLayer>(i); int curvenodecnt = layer->GetMemberCount<FbxAnimCurveNode>(); int compositcnt = 0; for (int j = 0; j < curvenodecnt; j++) { FbxAnimCurveNode* cnode = layer->GetMember<FbxAnimCurveNode>(j); compositcnt += (cnode->IsComposite() ? 1 : 0); } output << "\tanimstack's layer " << i << " : " << layer->GetName() << ", curve node cnt : " << curvenodecnt << ", composit node cnt : " << compositcnt << endl; vector<FbxAnimCurveNode*> nodes2del; for (int j = 0; j < curvenodecnt; j++) { FbxAnimCurveNode* cnode = layer->GetMember<FbxAnimCurveNode>(j); output << "\t\tcurvenode " << j << " channel cnt : " << cnode->GetChannelsCount() << ", dst obj cnt " << cnode->GetDstObjectCount() << "("; for (int dsti = 0; dsti < cnode->GetDstObjectCount(); dsti++) { output << "," << cnode->GetDstObject(dsti)->GetName(); if (cnode->GetDstObject(dsti)->GetSrcObjectCount() > 0) output << "<" << cnode->GetDstObject(dsti)->GetSrcObjectCount<FbxSkeleton>() << ">"; } output << ")"; FbxTimeSpan interval; if (cnode->GetAnimationInterval(interval)) { output << ", start : " << interval.GetStart().GetTimeString() << ", end : " << interval.GetStop().GetTimeString() << endl; } else { nodes2del.push_back(cnode); output << ", no interval" << endl; } for (int chi = 0; chi < cnode->GetChannelsCount(); chi++) { int curvecnt = cnode->GetCurveCount(chi); output << "\t\t\tchannel." << chi << " curvecnt : " << curvecnt << endl; for (int ci = 0; ci < curvecnt; ci++) { FbxAnimCurve* curve = cnode->GetCurve(chi, ci); int keycnt = curve->KeyGetCount(); output << "\t\t\t\tcurve no." << ci << " : key count : " << keycnt; output2 << "curve " << ci << endl; vector<int> keys2Remove; for (int cki = 0; cki < keycnt; cki++) { FbxAnimCurveKey prevkey, currkey, nextkey; if (cki == 0 || cki == keycnt - 1) continue; currkey = curve->KeyGet(cki); prevkey = curve->KeyGet(cki-1); nextkey = curve->KeyGet(cki + 1); bool keepit = true; output2 << ci << "-" << cki; // keepit = keepTestHorizon(curve, prevkey, currkey, nextkey); // if (keepit) // keepit = slopkeepTest(curve, prevkey, currkey, nextkey); if (!keepit) { if (!(currkey.GetInterpolation() == FbxAnimCurveDef::EInterpolationType::eInterpolationConstant && nextkey.GetInterpolation() != FbxAnimCurveDef::EInterpolationType::eInterpolationConstant)) keys2Remove.push_back(cki); } } for (int kri = keys2Remove.size() - 1; kri >= 0; kri--) { //curve->KeyRemove(keys2Remove[kri]); } output2 << endl; //output << ", cubic:linear:const : " << cubic << ":" << linear << ":" << cons << endl; if (keys2Remove.size() > 0) output << ", " << keys2Remove.size() << " keys removed"; keycnt = curve->KeyGetCount(); } } } //이부분은 별로 효과없음 /* for (int di = 0; di < nodes2del.size(); di++) { layer->RemoveMember(nodes2del[di]); } */ } } output << "cubic:linear:const " << cubic << ":" << linear << ":" << cons << endl; FbxExporter* exporter = FbxExporter::Create(fm, ""); const char* outFBXName = "after.fbx"; bool exportstatus = exporter->Initialize(outFBXName, -1, fm->GetIOSettings()); if (exportstatus == false) { puts("err export fail"); } exporter->Export(scene); exporter->Destroy(); scene->Destroy(); ios->Destroy(); fm->Destroy(); output.close(); output2.close(); output3.close(); return 0; }
/***************************************************************** * LoadLevel() Returns the only instance of the MessageManager * * Ins: szFilePath * * Outs: None * * Returns: bool * * Mod. Date: 09/02/2015 * Mod. Initials: NH *****************************************************************/ bool CLevelLoader::LoadLevel(string file_name) { #pragma region FBX initialize // Get an FBX manager FbxManager* manager = FbxManager::Create(); if (manager == 0) { return false; } // Create IO settings FbxIOSettings* io_settings = FbxIOSettings::Create(manager, IOSROOT); if (io_settings == 0) { manager->Destroy(); return false; } manager->SetIOSettings(io_settings); // Create importer FbxImporter* importer = FbxImporter::Create(manager, ""); if (importer == 0) { io_settings->Destroy(); manager->Destroy(); return false; } // Initialize importer if (importer->Initialize(file_name.c_str(), -1, io_settings) == false) { io_settings->Destroy(); manager->Destroy(); importer->Destroy(); return false; } // Create a scene FbxScene* scene = FbxScene::Create(manager, "myScene"); if (scene == 0) { io_settings->Destroy(); manager->Destroy(); importer->Destroy(); return false; } // Load the scene with contents from the file if (importer->Import(scene) == false) { io_settings->Destroy(); manager->Destroy(); importer->Destroy(); scene->Destroy(); return false; } // No longer need the importer // Traverse the scene FbxNode* root_node = scene->GetRootNode(); if (ProcessLevelNode(root_node, m_cvMeshes) == false) { importer->Destroy(); io_settings->Destroy(); root_node->Destroy(); scene->Destroy(); manager->Destroy(); return false; } importer->Destroy(); io_settings->Destroy(); root_node->Destroy(); scene->Destroy(); manager->Destroy(); #pragma endregion #pragma region Exit Door Objects srand((unsigned int)(CURRENT_TIME())); unsigned int ExitDoorIndex = rand() % 4; //for (unsigned int i = 0; i < m_cvExitDoorMeshes.size(); i++) //{ // m_cvExitDoorMeshes[i].ConvertVertices(); // m_cvExitTeleporterMeshes[i].ConvertVertices(); // if (i == ExitDoorIndex) // { // //this is the exit door // m_cpTheExitDoor = new CExitDoorObject("ExitDoor"); // m_cpTheExitDoor->AddCollider(new CCollider(true, Bounds::AABB, m_cvExitDoorMeshes[i].GetVertices())); // m_cpTheExitDoor->SetRenderMesh(new CRenderMesh(&m_cvExitDoorMeshes[i], GRAPHICS->GetVertexShader(), GRAPHICS->GetPixelShader(), nullptr, nullptr, nullptr, L"../Game/Assets/Art/2D/Textures/Door.dds")); // m_cpEnvironmentObjects.push_back(m_cpTheExitDoor); // m_cpObjectManager->AddObject(m_cpTheExitDoor, CObjectManager::eObjectType::Dynamic); // //set up teleporter // m_cpTheExitTeleporter = new CWaypointObject("ExitTeleporter"); // m_cpTheExitTeleporter->SetPosition(GetAABBCentroid(m_cvExitTeleporterMeshes[i].GetVertices())); // continue; // } // //thse are not exit doors anymore. now they are standard walls // CWallObject* newWall = new CWallObject("Wall"); // newWall->AddCollider(new CCollider(false, Bounds::AABB, m_cvExitDoorMeshes[i].GetVertices())); // newWall->SetRenderMesh(new CRenderMesh(&m_cvExitDoorMeshes[i], GRAPHICS->GetVertexShader(), GRAPHICS->GetPixelShader(), nullptr, nullptr, nullptr, L"../Game/Assets/Art/2D/Textures/Maze_Wall.dds")); // m_cpEnvironmentObjects.push_back(newWall); // m_cpObjectManager->AddObject(newWall, CObjectManager::eObjectType::Static); //} #pragma endregion CNavGraphManager::GetReference().AddNavGraph("MinotaurNavGraph", m_cpMinotaurNavGraph); return true; }
int main() { // ※パスは「/」でしか通らない const char* filename = "../datas/box.fbx"; //============================================================================== // FBXオブジェクト初期化 //============================================================================== // FBXマネージャー作成 FbxManager* pFBXManager = FbxManager::Create(); // シーン作成 FbxScene* pScene = FbxScene::Create(pFBXManager, ""); // FBXのIO設定オブジェクト作成 FbxIOSettings *pIO = FbxIOSettings::Create(pFBXManager, IOSROOT); pFBXManager->SetIOSettings(pIO); // インポートオブジェクト作成 FbxImporter* pImporter = FbxImporter::Create(pFBXManager, ""); // ファイルインポート if(pImporter->Initialize(filename, -1, pFBXManager->GetIOSettings()) == false) { printf("FBXファイルインポートエラー\n"); printf("エラー内容: %s\n\n", pImporter->GetStatus().GetErrorString()); return 1; } // シーンへインポート if(pImporter->Import(pScene) == false) { printf("FBXシーンインポートエラー\n"); printf("エラー内容: %s\n\n", pImporter->GetStatus().GetErrorString()); return 1; } // ※この時点でインポートオブジェクトはいらない pImporter->Destroy(); //============================================================================== // FBXオブジェクトの処理 //============================================================================== // ノードを表示してみる traverseScene(pScene->GetRootNode()); // シーンのものすべてを三角化 FbxGeometryConverter geometryConverte(pFBXManager); geometryConverte.Triangulate(pScene, true); // メッシュ情報処理 GetMeshData(pScene->GetRootNode()); //============================================================================== // FBXオブジェクト色々破棄 //============================================================================== pIO->Destroy(); pScene->Destroy(); pFBXManager->Destroy(); printf("全処理終了\n"); getchar(); return 0; }
void Run(CommandMap & commands){ FbxScene * scene = nullptr; try{ auto & fbx = FBX::GetInstance(); // IMPORT cout << "Importing..." << std::endl; auto input = commands.find(kInputCommand); scene = fbx.Import(input->second.front()); //EXECUTION //if (commands.find(kTriangulateCommand) != commands.end()){ cout << "Triangulating (this could take a couple of minutes)..." << std::endl; fbx.Triangulate(*scene); //} CommandMap::iterator cmd; if (commands.find(kRemap) != commands.end()){ cout << "Re-mapping mesh attributes..." << std::endl; fbx.RemapAttributes(*scene); } if ((cmd = commands.find(kExtension)) != commands.end()){ cout << "Normalizing texture paths..." << std::endl; fbx.NormalizeTexturePaths(*scene, input->second.front(), cmd->second.size() <= 0 ? "" : cmd->second.front()); } // EXPORT cout << "Exporting to FBX..." << std::endl; auto output = commands.find(kOutputCommand); fbx.Export(*scene, output->second.front()); // YAY! cout << "Done!" << std::endl; } catch (std::exception & e){ //Darn... cout << e.what() << std::endl; } //Cleanup if (scene != nullptr){ scene->Destroy(); } }
void GeometryLoaderDX11::loadFBXFile( std::string szFilename, std::vector<GeometryPtr>& vGeomVector, std::vector<std::string>& vNames ) { FileSystem fs; szFilename = fs.GetModelsFolderS() + szFilename; pFBXManager = FbxManager::Create(); if( !pFBXManager ) Log::Get().Write( L"CGeometryLoader11.cpp: Error creating FBX Manager!" ); FbxIOSettings* pIOS = FbxIOSettings::Create( pFBXManager, IOSROOT ); pFBXManager->SetIOSettings( pIOS ); FbxString lPath = FbxGetApplicationDirectory(); pFBXManager->LoadPluginsDirectory( lPath.Buffer() ); FbxScene* pScene = FbxScene::Create( pFBXManager, "" ); int /*nFileMajor,*/ nFileMinor, nFileRevision; int nSDKMajor, nSDKMinor, nSDKRevision; int i, /*nAnimationStack,*/ lFileFormat; // bool bStatus; // char szPassword[1024]; FbxManager::GetFileFormatVersion( nSDKMajor, nSDKMinor, nSDKRevision ); FbxImporter* pImporter = FbxImporter::Create( pFBXManager, "" ); if (!pFBXManager->GetIOPluginRegistry()->DetectReaderFileFormat(szFilename.c_str(), lFileFormat) ) { // Unrecognizable file format. Try to fall back to FbxImporter::eFBX_BINARY lFileFormat = pFBXManager->GetIOPluginRegistry()->FindReaderIDByDescription( "FBX binary (*.fbx)" );; } bool ImportStatus = pImporter->Initialize( szFilename.c_str(), lFileFormat, pFBXManager->GetIOSettings() ); pImporter->GetFileVersion( nFileMinor, nFileMinor, nFileRevision ); if( !ImportStatus ) { Log::Get().Write( L"CGeometryLoader11.cpp: FbxImporter Initialize failed!" ); return; } ImportStatus = pImporter->Import( pScene ); if( !ImportStatus ) { Log::Get().Write( L"CGeometryLoader11.cpp: FbxImporter failed to import the file to the scene!" ); return; } FbxAxisSystem SceneAxisSystem = pScene->GetGlobalSettings().GetAxisSystem(); FbxAxisSystem AxisSystem( FbxAxisSystem::eYAxis, FbxAxisSystem::eParityOdd, FbxAxisSystem::eLeftHanded ); if( SceneAxisSystem != AxisSystem ) { AxisSystem.ConvertScene( pScene ); } //FbxSystemUnit SceneSystemUnit = pScene->GetGlobalSettings().GetSystemUnit(); //if( SceneSystemUnit.GetScaleFactor() != 1.0f ) // FbxSystemUnit::cm.ConvertScene( pScene ); FBXTriangulateRecursive( pScene->GetRootNode() ); FbxArray<FbxMesh*> vMeshs; FBXFillMeshArray( pScene, vMeshs ); unsigned short usVertexCount = 0; unsigned short usTriangleCount = 0; unsigned short usGroupCount = 0; unsigned short usMaterialCount = 0; unsigned short usIndicesCount = 0; for( i = 0; i < vMeshs.GetCount(); i++ ) { Log::Get().Write( L"CGeometryLoader11.cpp: Loading File!" ); std::string name = vMeshs[i]->GetNode()->GetName(); vNames.push_back( name ); usVertexCount = vMeshs[i]->GetControlPointsCount(); if( usVertexCount == 0 ) continue; usTriangleCount = vMeshs[i]->GetPolygonVertexCount() / 3; usIndicesCount = vMeshs[i]->GetPolygonVertexCount(); VertexElementDX11* pPositions = new VertexElementDX11( 3, usTriangleCount * 3 ); pPositions->m_SemanticName = VertexElementDX11::PositionSemantic; pPositions->m_uiSemanticIndex = 0; pPositions->m_Format = DXGI_FORMAT_R32G32B32_FLOAT; pPositions->m_uiInputSlot = 0; pPositions->m_uiAlignedByteOffset = 0; pPositions->m_InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; pPositions->m_uiInstanceDataStepRate = 0; VertexElementDX11* pTexCoords = new VertexElementDX11( 2, usTriangleCount * 3 ); pTexCoords->m_SemanticName = VertexElementDX11::TexCoordSemantic; pTexCoords->m_uiSemanticIndex = 0; pTexCoords->m_Format = DXGI_FORMAT_R32G32_FLOAT; pTexCoords->m_uiInputSlot = 0; pTexCoords->m_uiAlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT; pTexCoords->m_InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; pTexCoords->m_uiInstanceDataStepRate = 0; VertexElementDX11* pNormals = new VertexElementDX11( 3, usTriangleCount * 3 ); pNormals->m_SemanticName = VertexElementDX11::NormalSemantic; pNormals->m_uiSemanticIndex = 0; pNormals->m_Format = DXGI_FORMAT_R32G32B32_FLOAT; pNormals->m_uiInputSlot = 0; pNormals->m_uiAlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT; pNormals->m_InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; pNormals->m_uiInstanceDataStepRate = 0; Vector3f* pPos = pPositions->Get3f(0); Vector3f* pNorm = pNormals->Get3f(0); Vector2f* pTex = pTexCoords->Get2f(0); FbxVector4* pFBXVerts = new FbxVector4[usVertexCount]; memcpy( pFBXVerts, vMeshs[i]->GetControlPoints(), usVertexCount * sizeof(FbxVector4)); TriangleIndices face; GeometryPtr pGeomPointer( new GeometryDX11() ); for( int j = 0; j < usTriangleCount; j++ ) { int nIndex = 0; FbxVector4 FBXNorm( 0, 0, 0, 0 ); FbxVector2 FBXUV( 0, 0 ); face.P1() = nIndex = vMeshs[i]->GetPolygonVertex( j, 0 ); pPos[nIndex].x = (float)pFBXVerts[ nIndex ][0]; pPos[nIndex].y = (float)pFBXVerts[ nIndex ][1]; pPos[nIndex].z = (float)pFBXVerts[ nIndex ][2]; vMeshs[i]->GetPolygonVertexNormal( j, 0, FBXNorm ); pNorm[nIndex].x = (float)FBXNorm[0]; pNorm[nIndex].y = (float)FBXNorm[1]; pNorm[nIndex].z = (float)FBXNorm[2]; vMeshs[i]->GetPolygonVertexUV( j, 0, "map1", FBXUV ); pTex[nIndex].x = (float)FBXUV[0]; pTex[nIndex].y = (float)FBXUV[1]; face.P2() = nIndex = vMeshs[i]->GetPolygonVertex( j, 1 ); pPos[nIndex].x = (float)pFBXVerts[ nIndex ][0]; pPos[nIndex].y = (float)pFBXVerts[ nIndex ][1]; pPos[nIndex].z = (float)pFBXVerts[ nIndex ][2]; vMeshs[i]->GetPolygonVertexNormal( j, 1, FBXNorm ); pNorm[nIndex].x = (float)FBXNorm[0]; pNorm[nIndex].y = (float)FBXNorm[1]; pNorm[nIndex].z = (float)FBXNorm[2]; vMeshs[i]->GetPolygonVertexUV( j, 1, "map1", FBXUV ); pTex[nIndex].x = (float)FBXUV[0]; pTex[nIndex].y = (float)FBXUV[1]; face.P3() = nIndex = vMeshs[i]->GetPolygonVertex( j, 2 ); pPos[nIndex].x = (float)pFBXVerts[ nIndex ][0]; pPos[nIndex].y = (float)pFBXVerts[ nIndex ][1]; pPos[nIndex].z = (float)pFBXVerts[ nIndex ][2]; vMeshs[i]->GetPolygonVertexNormal( j, 2, FBXNorm ); pNorm[nIndex].x = (float)FBXNorm[0]; pNorm[nIndex].y = (float)FBXNorm[1]; pNorm[nIndex].z = (float)FBXNorm[2]; vMeshs[i]->GetPolygonVertexUV( j, 2, "map1", FBXUV ); pTex[nIndex].x = (float)FBXUV[0]; pTex[nIndex].y = (float)FBXUV[1]; pGeomPointer->AddFace( face ); } for( int j = 0; j < usVertexCount; j++ ) { pNorm[j].Normalize(); } pGeomPointer->AddElement( pPositions ); pGeomPointer->AddElement( pNormals ); pGeomPointer->AddElement( pTexCoords ); delete[] pFBXVerts; vGeomVector.push_back( pGeomPointer ); vMeshs[i]->Destroy(); vMeshs[i] = NULL; } pImporter->Destroy(); pImporter = NULL; pScene->Destroy(); pScene = NULL; pIOS->Destroy(); pIOS = NULL; pFBXManager->Destroy(); pFBXManager = NULL; }