VOID ExportPath::Append( const ExportPath& OtherPath ) { // the other path can't be an absolute path assert( !OtherPath.IsAbsolutePath() ); // if we don't have a filename, just concatenate the strings if( !HasFileName() ) { strcat_s( m_strPath, (const CHAR*)OtherPath ); Initialize( NULL ); return; } // we have a filename, and we're appending a path. assume a directory append. // save the existing filename CHAR strFileName[MAX_PATH]; strcpy_s( strFileName, m_strFileName ); // trim off the filename *m_strFileName = '\0'; // append the other path strcat_s( m_strPath, (const CHAR*)OtherPath ); // if the other path has a filename, we'll use that if( OtherPath.HasFileName() ) { Initialize( NULL ); return; } // otherwise, use our filename strcat_s( m_strPath, strFileName ); // re-initialize all of our pointers Initialize( NULL ); }
VOID ExportPath::ChangeFileNameWithExtension( const ExportPath& OtherPath ) { ChangeFileNameWithExtension( (const CHAR*)OtherPath.GetFileName() ); }
HRESULT FBXImport::ImportFile( const CHAR* strFileName ) { assert( g_pSDKManager != nullptr ); assert( g_pImporter != nullptr ); assert( g_pFBXScene != nullptr ); assert( g_pScene != nullptr ); CHAR strTemp[200]; g_pScene->Information().ExporterName = g_strExporterName; INT iMajorVersion, iMinorVersion, iRevision; g_pSDKManager->GetFileFormatVersion( iMajorVersion, iMinorVersion, iRevision ); sprintf_s( strTemp, "FBX SDK %d.%d.%d", iMajorVersion, iMinorVersion, iRevision ); g_pScene->Information().DCCNameAndVersion = strTemp; ExportLog::LogMsg( 2, "Compiled against %s", strTemp ); ExportLog::LogMsg( 1, "Loading FBX file \"%s\"...", strFileName ); INT iFileFormat = -1; bool bResult = g_pImporter->Initialize( strFileName, iFileFormat, g_pSDKManager->GetIOSettings() ); if( !bResult ) { ExportLog::LogError( "Could not initialize FBX importer." ); return E_FAIL; } bResult = g_pImporter->Import( g_pFBXScene ); if( !bResult ) { ExportLog::LogError( "Could not load FBX file \"%s\".", strFileName ); return E_FAIL; } ExportLog::LogMsg( 1, "FBX file \"%s\" was successfully loaded.", strFileName ); g_pImporter->GetFileVersion( iMajorVersion, iMinorVersion, iRevision ); ExportLog::LogMsg( 2, "FBX file version: %d.%d.%d", iMajorVersion, iMinorVersion, iRevision ); ExportLog::LogMsg( 2, "Parsing scene." ); auto pTransformer = reinterpret_cast<FBXTransformer*>( g_pScene->GetDCCTransformer() ); pTransformer->Initialize( g_pFBXScene ); SetBindPose(); g_bBindPoseFixupRequired = false; assert( g_pFBXScene->GetRootNode() != nullptr ); XMMATRIX matIdentity = XMMatrixIdentity(); ParseNode( g_pFBXScene->GetRootNode(), g_pScene, matIdentity ); if( g_bBindPoseFixupRequired ) { ExportLog::LogMsg( 2, "Fixing up frames with updated bind pose." ); FixupNode( g_pScene, matIdentity ); } if( g_pScene->Settings().bExportAnimations ) { ParseAnimation( g_pFBXScene ); if( g_pScene->Settings().bRenameAnimationsToFileName ) { auto AnimName = g_CurrentOutputFileName.GetFileNameWithoutExtension(); size_t dwAnimCount = g_pScene->GetAnimationCount(); for( size_t i = 0; i < dwAnimCount; ++i ) { CHAR strCurrentAnimName[MAX_PATH]; if( i > 0 ) { sprintf_s( strCurrentAnimName, "%s%Iu", (const CHAR*)AnimName, i ); } else { strcpy_s( strCurrentAnimName, (const CHAR*)AnimName ); } ExportAnimation* pAnim = g_pScene->GetAnimation( i ); ExportLog::LogMsg( 4, "Renaming animation \"%s\" to \"%s\".", pAnim->GetName().SafeString(), strCurrentAnimName ); pAnim->SetName( strCurrentAnimName ); } } } return S_OK; }