/**************************************************************************************** Copyright (C) 2014 Autodesk, Inc. All rights reserved. Use of this software is subject to the terms of the Autodesk license agreement provided at the time of installation or download, or which otherwise accompanies this software in either electronic or hard copy form. ****************************************************************************************/ #include "../Common/Common.h" #include //input file path char* sInputFile = ""; //output file path char* sOutputFile = ""; void ClearUV34(FbxMesh* pMesh); void RemoveColors(FbxMesh* pMesh); int main(int argc, char** argv) { if (argc != 3) { printf("参数格式不对"); return 0; } sInputFile = argv[1]; sOutputFile = argv[2]; //FBX SDK Default Manager FbxManager* lSdkManager = NULL; //Scene to load from file FbxScene* lScene = NULL; // Prepare the FBX SDK. InitializeSdkObjects(lSdkManager, lScene); // Load the scene. bool lResult = LoadScene(lSdkManager, lScene, sInputFile); if (lResult == false) { FBXSDK_printf("\n\nAn error occurred while loading the scene..."); } else { bool bSave = false; auto rootNode = lScene->GetRootNode(); for (int i = 0; i < rootNode->GetChildCount(true); i++) { auto lNodeOfInterest = rootNode->GetChild(i); if (lNodeOfInterest) { FbxMesh* lMeshOFInterest = lNodeOfInterest->GetMesh(); if (lMeshOFInterest) { bSave = true; std::cout << "mesh :" << lNodeOfInterest->GetNameOnly() << std::endl; //first,remove clr RemoveColors(lMeshOFInterest); //then, modify certain uv set and save it ClearUV34(lMeshOFInterest); } } } if (bSave) { // !< 根据设置转换为相应格式 //SaveScene(lSdkManager, lScene, sOutputFile); // !< 转为二进制文件 SaveScene(lSdkManager, lScene, sOutputFile, 0); } /* //Get the first node in the scene FbxNode* lNodeOfInterest = lScene->GetRootNode()->GetChild(0); if (lNodeOfInterest) { FbxMesh* lMeshOFInterest = lNodeOfInterest->GetMesh(); if (lMeshOFInterest) { FBXSDK_printf("current mesh node: %s\n", lMeshOFInterest->GetName()); //first,remove clr RemoveColors(lMeshOFInterest); //then, modify certain uv set and save it ClearUV34(lMeshOFInterest); //save the modified scene to file SaveScene(lSdkManager, lScene, sOutputFile); } } */ } // Destroy all objects created by the FBX SDK. DestroySdkObjects(lSdkManager, lResult); return 0; } void RemoveColors(FbxMesh* pMesh) { FbxGeometryElementVertexColor* lclrElenet = pMesh->GetElementVertexColor(); if (!lclrElenet) return; std::cout << "remove color" << std::endl; lclrElenet->GetDirectArray().Resize(0); lclrElenet->GetIndexArray().Resize(0); } void ClearUV34(FbxMesh* pMesh) { //iterating over all uv sets for (int lUVSetIndex = 0; lUVSetIndex < pMesh->GetElementUVCount(); lUVSetIndex++) { //get lUVSetIndex-th uv set FbxGeometryElementUV* lUVElement = pMesh->GetElementUV(lUVSetIndex); if (!lUVElement || lUVSetIndex < 2) continue; // only support mapping mode eByPolygonVertex and eByControlPoint if (lUVElement->GetMappingMode() != FbxGeometryElement::eByPolygonVertex && lUVElement->GetMappingMode() != FbxGeometryElement::eByControlPoint) return; //pMesh->RemoveElementUV(lUVElement); std::cout << "remove uv :" << (lUVSetIndex+1) << std::endl;; lUVElement->GetDirectArray().Resize(0); lUVElement->GetIndexArray().Resize(0); } }