Value* ExportCalMat_cf(Value** arg_list, int count) { int i = 0; TSTR fullpathfilename; check_arg_count(ExportCalMat, 2, count); type_check(arg_list[0], String, _T("[The first argument of ExportCalMat should be a string]")); type_check(arg_list[1], MAXMaterial , _T("[The 2nd argument of ExportCalMat should be a standard material]")); try { fullpathfilename = arg_list[0]->to_string(); StdMat* stdmat; if (fullpathfilename.Length() == 0) return new Integer(1); //Get material Value* val; val = arg_list[1]; if (! val)return new Integer(2); if (val->is_kind_of(class_tag(MAXMaterial)) ) { MtlBase* _mtl; _mtl = val->to_mtlbase(); if (! _mtl)return new Integer(3); stdmat = static_cast<StdMat*>(_mtl); } else { return new Integer(3); } if ( CMaxMaterialExport::ExportMaterialFromMaxscriptCall(fullpathfilename, stdmat) ) return new Integer(0); return new Integer(-1); } catch(...) { //MessageBox(NULL,"Exception catched in ExportCalMat C++ function","Error",MB_OK); return new Integer(-2); } }
void WeightTableWindow::PaintCellWeight(HDC hdc, int x, int y,int width, BOOL sel, BOOL centered, float value,BOOL indeterminant, BOOL locked, BOOL excluded) { HBRUSH textBackground; DWORD textColor; DWORD textBKColor; if (sel) { textBackground = GetSysColorBrush(COLOR_HIGHLIGHT); textColor = GetSysColor(COLOR_HIGHLIGHTTEXT) ; textBKColor = GetSysColor(COLOR_HIGHLIGHT) ; SelectObject(hdc, hFixedFontBold); } else { textBackground = ColorMan()->GetBrush(kWindow ); textColor = ColorMan()->GetColor(kWindowText ) ; textBKColor = ColorMan()->GetColor(kWindow ) ; SelectObject(hdc, hFixedFont); } SetTextColor(hdc, textColor); SelectObject(hdc, textBackground); SetBkColor(hdc, textBKColor); SelectObject(hdc,pBackPen); int offset = 0; TSTR weightStr; if (indeterminant) weightStr.printf("-"); else weightStr.printf("%0.3f",value); SIZE strSize; GetTextExtentPoint32(hdc, (LPCTSTR) weightStr, weightStr.Length(), (LPSIZE) &strSize ); int xPos; if (indeterminant) xPos = width/2 - strSize.cx/2; else xPos = 3; if (centered) { GetTextExtentPoint32(hdc, (LPCTSTR) weightStr, weightStr.Length(), (LPSIZE) &strSize ); xPos = width/2 - strSize.cx/2; } Rectangle(hdc, x, y,x+width+1,y+textHeight+1); TextOut(hdc, x+xPos,y+1,weightStr,weightStr.Length()); /* if ((locked) || (excluded)) { textBackground = ColorMan()->GetBrush(kWindow ); textColor = GetSysColor(COLOR_GRAYTEXT ) ; textBKColor = ColorMan()->GetColor(kWindow ) ; } */ if (this->GetShowExclusion()) { SelectObject(hdc,pBackPen); Rectangle(hdc, x+width-9, y,x+width+1,y+9+1); if (excluded) { SelectObject(hdc,pSelPen); MoveToEx(hdc,x+width-9, y, NULL); LineTo(hdc,x+width+1,y+9+1); MoveToEx(hdc,x+width, y, NULL); LineTo(hdc,x+width-9,y+9); } } if (GetShowLock()) { SelectObject(hdc,pBackPen); Rectangle(hdc, x+width-18, y,x+width-9+1,y+9+1); if (locked) { SelectObject(hdc,pSelPen); MoveToEx(hdc,x+width-16, y+2, NULL); LineTo(hdc,x+width-16,y+7); LineTo(hdc,x+width-11,y+7); } } }
HRESULT CreateShader(IDirect3DDevice8 *Device, TSTR File, const unsigned long* Decl, ShaderType Type, unsigned long* Handle) { HRESULT Hr; HANDLE hFile; unsigned long FileSize; unsigned long *Shader; TCHAR *FileName; D3DCAPS8 Caps; DWORD Usage = 0; Hr = S_OK; if(!File.Length()) { Handle = 0; return(S_OK); } FileName = FindFile(File); if(Device && FileName) { Device->GetDeviceCaps(&Caps); // for those mad Laptop users if(Caps.DeviceType == D3DDEVTYPE_REF) { Usage = D3DUSAGE_SOFTWAREPROCESSING; } hFile = CreateFile(FileName,GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL); if(hFile == INVALID_HANDLE_VALUE) { return(E_FAIL); } FileSize = GetFileSize(hFile,NULL); Shader = (unsigned long*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,FileSize); if(!Shader) { return(E_FAIL); } ReadFile(hFile,(void*)Shader,FileSize,&FileSize,NULL); CloseHandle(hFile); if(Type == SHADER_VERTEXSHADER) { if(FAILED(Hr = Device->CreateVertexShader(Decl,Shader,Handle,Usage))) { return(Hr); } } else { if(FAILED(Hr = Device->CreatePixelShader(Shader,Handle))) { return(Hr); } } HeapFree(GetProcessHeap(),0,(void *)Shader); } else { return(E_FAIL); } return(Hr); }
// Handle WM_COMMAND messages separately void AudioP3Dlg::WMCommand(int id, int notify, HWND hCtrl) { int mmerr; AudioP3Control* af = (AudioP3Control *)GetWindowLongPtr(hWnd, DWLP_USER); switch (id) { case IDC_AUDAMP_ABSOLUTE: cont->absolute = IsDlgButtonChecked(hWnd,id); Change(); break; case IDC_QUICKDRAW: cont->quickdraw = IsDlgButtonChecked(hWnd,id); Change(); break; case IDC_AUDAMP_RECDEVICE: if (notify == CBN_SELCHANGE) { int devIdx = SendMessage(GetDlgItem(hWnd, IDC_AUDAMP_RECDEVICE), CB_GETCURSEL, 0, 0); cont->rtwave->SetDevice(devIdx); Change(); } break; case IDC_AUDAMP_RECENABLE: cont->enableRuntime = IsDlgButtonChecked(hWnd,id); // Startup or terminate runtime recording if (cont->enableRuntime) { if ((mmerr = cont->rtwave->StartRecording()) == 0) { EnableWindow(GetDlgItem(hWnd, IDC_AUDAMP_RECDEVICE), 0); } else { CheckDlgButton(hWnd, id, 0); MessageBox(hWnd, GetString(IDS_CJ_DEVICE_BUSY), GetString(IDS_CJ_PROGNAME), MB_OK); } } else { cont->rtwave->StopRecording(); EnableWindow(GetDlgItem(hWnd, IDC_AUDAMP_RECDEVICE), 1); } // Here we are just telling trackview to repaint its hierarchy. // We haven't actually changed anything, but the switch from file to record // will cause a change in TrackView line height - and we need to tell that // to TrackView cont->NotifyDependents(FOREVER,PART_ALL,REFMSG_SUBANIM_STRUCTURE_CHANGED); Change(); break; case IDC_BTN_BROWSE: { // Changed to open in the directory of the file. //CJ TSTR dir = cont->szFilename; if (dir.Length() == 0) { // Use sound dir if no file. dir = TSTR(ip->GetDir(APP_SOUND_DIR)); } else { int lc = dir.last((int)'\\'); if (lc == -1) { lc = dir.last((int)'/'); } if (lc != -1) { dir[lc] = '\0'; } } // Brings up file dialog box with sound "preview". GetSoundFileName(hCtrl, cont->szFilename, dir); if (!cont->szFilename.isNull()) { cont->wave->InitOpen(cont->szFilename); SendMessage(GetDlgItem(hWnd, IDC_AUDAMP_FILENAME), WM_SETTEXT, 0, (LPARAM)((char *)cont->szFilename)); EnableChannelUI(cont->wave->GetNumChannels() == 2); } Change(); } break; case IDC_BTN_REMOVESOUND: cont->wave->FreeSample(); cont->szFilename = ""; SendMessage(GetDlgItem(hWnd, IDC_AUDAMP_FILENAME), WM_SETTEXT, 0, (LPARAM)""); EnableChannelUI(FALSE); Change(); break; case IDC_AUDAMP_LEFT: cont->channel = 0; Change(); break; case IDC_AUDAMP_RIGHT: cont->channel = 1; Change(); break; case IDC_AUDAMP_MIX: cont->channel = 2; Change(); break; case IDC_ABOUT: ShowAbout(hWnd); break; case IDC_CLOSE: DestroyWindow(hWnd); 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; }
HRESULT CreateShaderVertex(IDirect3DDevice9 *Device, TSTR File,LPDIRECT3DVERTEXDECLARATION9 * vdecl, LPDIRECT3DVERTEXSHADER9 *Handle) { HRESULT Hr; HANDLE hFile; unsigned long FileSize; unsigned long *Shader; TCHAR *FileName; D3DCAPS9 Caps; DWORD Usage = 0; Hr = S_OK; D3DVERTEXELEMENT9 test[] = { { 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, { 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 }, { 0, 24, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 1 }, { 0, 36, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }, { 0, 44, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 }, { 0, 52, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 2 }, { 0, 60, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 3 }, D3DDECL_END() }; Hr = Device->CreateVertexDeclaration(test, vdecl); if (FAILED(Hr)) { return Hr; } if(!File.Length()) { Handle = 0; return(S_OK); } FileName = FindFile(File); if(Device && FileName) { Device->GetDeviceCaps(&Caps); // for those mad Laptop users if(Caps.DeviceType == D3DDEVTYPE_REF) { Usage = D3DUSAGE_SOFTWAREPROCESSING; } hFile = CreateFile(FileName,GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL); if(hFile == INVALID_HANDLE_VALUE) { return(E_FAIL); } FileSize = GetFileSize(hFile,NULL); Shader = (unsigned long*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,FileSize); if(!Shader) { return(E_FAIL); } ReadFile(hFile,(void*)Shader,FileSize,&FileSize,NULL); CloseHandle(hFile); if(FAILED(Hr = Device->CreateVertexShader(Shader, Handle))) { return(Hr); } HeapFree(GetProcessHeap(),0,(void *)Shader); } else { return(E_FAIL); } return(Hr); }