void DxStdMtl2::PatchInLightNodes() { for(int i = 0; i< sceneLights.Count(); i++) { int curLightIndex = -1; for(int j=0; j<elementContainer.NumberofElementsByType(EffectElements::kEleLight);j++) { LightElement * le = static_cast<LightElement*>(elementContainer.GetElementByType(j, EffectElements::kEleLight)); TSTR paramName = le->GetParameterName(); int actualLength = paramName.first('_'); for(int k=0; k<actualLength;k++) { if(isdigit(paramName[k])) { TSTR numChar = paramName.Substr(k,actualLength-k); int index = atoi(numChar.data()); if(index == i) { le->AddLight(sceneLights[i]->GetLightNode()); break; } } } } } }
PAVISTREAM GetAudioStream(TSTR name,TCHAR *dir) { HRESULT hr; PAVIFILE pfile; PAVISTREAM pstream = NULL; BOOL res = TRUE; #ifndef INTERIM_64_BIT // CCJ // RB 5/10/99: Reworked this a bit. Added the current scene dir as a possible search location. // Also now using SplitPathFile() instead of doing it by hand. hr = AVIFileOpen(&pfile,name,OF_READ,NULL); if (hr) { TSTR fileName, tryName; SplitPathFile(name, NULL, &fileName); // Try the given directory (which is the sound dir) tryName = TSTR(dir) + TSTR(_T("\\")) + fileName; hr = AVIFileOpen(&pfile,tryName,OF_READ,NULL); if (hr) { // Try the scene directory TSTR sceneName = GetCOREInterface()->GetCurFilePath(); TSTR scenePath; SplitPathFile(sceneName, &scenePath, NULL); tryName = scenePath + TSTR(_T("\\")) + fileName; hr = AVIFileOpen(&pfile,tryName,OF_READ,NULL); } #if 0 // Try the file in the given directory int i = name.Length()-1; while (i>0) { if (name[i]=='\\' || name[i]==':' || name[i]=='/') { i++; break; } i--; } if (name.Length()-i>0) { TSTR newname = TSTR(dir) + TSTR(_T("\\")) + name.Substr(i,name.Length()-i); hr = AVIFileOpen(&pfile,newname,OF_READ,NULL); } #endif } if (hr) return NULL; AVIFileGetStream(pfile,&pstream,streamtypeAUDIO,0); AVIFileRelease(pfile); if (!pstream) return NULL; // Verify it's PCM PCMWAVEFORMAT wf; LONG l = sizeof(wf); AVIStreamReadFormat(pstream,0,&wf,&l); if (!l) { AVIStreamRelease(pstream); return NULL; } if (wf.wf.wFormatTag != WAVE_FORMAT_PCM) { AVIStreamRelease(pstream); return NULL; } #endif // INTERIM_64_BIT return pstream; }
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; }