int TrianExporter::DoExport( const TCHAR * name, ExpInterface *ei, Interface *i, BOOL suppressPrompts, DWORD options ) { //Open the file to export to. m_of.open( name ); //Create an Error procedure. MyErrorProc pErrorProc; SetErrorCallBack( &pErrorProc ); //Get the game interface m_pIGame = GetIGameInterface(); //Start the progress bar. i->ProgressStart( _T( "Exporting to .trian file..." ), TRUE, fn, NULL ); //Set up the conversion manager. IGameConversionManager * cm = GetConversionManager(); //Set up the whacky coordinate system that 3DS Max uses. UserCoord whacky = { 1, //Right-Handed. 1, //X Axis goes right. 4, //Y Axis goes in. 3, //Z Axis goes down. 0, //U Tex Axis is left. 1 //V Tex Axis is down. }; cm->SetUserCoordSystem( whacky ); //Set the coordinate system. cm->SetCoordSystem( IGameConversionManager::IGAME_MAX ); //Initialize the game scene. m_pIGame->InitialiseIGame( options & SCENE_EXPORT_SELECTED ); //Go through all the nodes of the scene and export only the Game Meshes. for( int l = 0; l < m_pIGame->GetTopLevelNodeCount(); l++ ) { //Get the current Game node. IGameNode * node = m_pIGame->GetTopLevelNode( l ); //Check for selected state. if( node->IsTarget() ) continue; ExportNodeInfo( node ); } //End the progress bar. i->ProgressEnd(); //Release the scene. m_pIGame->ReleaseIGame(); m_pIGame = 0; //Close the output stream. m_of.close(); return TRUE; }
int Unreal3DExport::DoExport( const TCHAR *name, ExpInterface *ei, Interface *i, BOOL suppressPrompts, DWORD options ) { int Result = FALSE; // Set a global prompt display switch bShowPrompts = suppressPrompts ? false : true; bExportSelected = (options & SCENE_EXPORT_SELECTED) ? true : false; // Get file names SplitFilename(TSTR(name), &FilePath, &FileName, &FileExt); if( MatchPattern(FileName,TSTR(_T("*_d")),TRUE) || MatchPattern(FileName,TSTR(_T("*_a")),TRUE) ) { FileName = FileName.Substr(0,FileName.length()-2); } ModelFileName = FilePath + _T("\\") + FileName + TSTR(_T("_d")) + FileExt; AnimFileName = FilePath + _T("\\") + FileName + TSTR(_T("_a")) + FileExt; ScriptFileName = FilePath + _T("\\") + FileName + TSTR(_T("_rc.uc")); // Open Log fLog = _tfopen(FilePath + _T("\\") + FileName + _T(".log") ,_T("wb")); // Init pInt = GetCOREInterface(); pInt->ProgressStart( GetString(IDS_INFO_INIT), TRUE, fn, this); Progress += U3D_PROGRESS_INIT; try { MyErrorProc pErrorProc; SetErrorCallBack(&pErrorProc); ReadConfig(); //if(bShowPrompts) /*DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_PANEL), GetActiveWindow(), Unreal3DExportOptionsDlgProc, (LPARAM)this);*/ //if(showPrompts) { // Prompt the user with our dialogbox, and get all the options. if(!DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_PANEL), GetActiveWindow(), Unreal3DExportOptionsDlgProc, (LPARAM)this)) { throw CancelException(); } } // Enumerate interesting nodes Init(); // Fetch data from nodes GetTris(); GetAnim(); // Prepare data for writing Prepare(); // Write to files WriteScript(); WriteModel(); WriteTracking(); // Show optional summary ShowSummary(); WriteConfig(); Result = IMPEXP_SUCCESS; } catch( CancelException& ) { Result = IMPEXP_CANCEL; } catch( MAXException& e ) { if( bShowPrompts && !e.message.isNull() ) { MaxMsgBox(pInt->GetMAXHWnd(),e.message,ShortDesc(),MB_OK|MB_ICONERROR); } Result = IMPEXP_FAIL; } // Release scene if( pScene != NULL ) { pScene->ReleaseIGame(); pScene = NULL; } // Close files fclosen(fMesh); fclosen(fAnim); fclosen(fLog); fclosen(fScript); // Return to MAX pInt->ProgressEnd(); return Result; }