void plPassAnimDlgProc::Update(TimeValue t, Interval& valid, IParamMap2* pmap) { /* plAnimStealthNode *testStealth = (plAnimStealthNode *)pmap->GetParamBlock()->GetINode( (ParamID)kPBAnimTESTING ); if( testStealth != nil ) { IParamBlock2 *pb = testStealth->GetParamBlockByID( plAnimStealthNode::kBlockPB ); if( pb && pb->GetMap() && pb->GetMap()->GetUserDlgProc() ) pb->GetMap()->GetUserDlgProc()->Update( t, valid, pmap ); } */ HWND hWnd = pmap->GetHWnd(); IParamBlock2 *pb = pmap->GetParamBlock(); plAnimComponentProc::SetBoxToAgeGlobal(GetDlgItem(hWnd, IDC_MTL_GLOBAL_NAME), pb->GetStr(ParamID(kPBAnimGlobalName))); }
AWDBlock * MaxAWDExporter::ExportCameraAndTextureExporter(INode * node, double * mtxData, AWDSceneBlock * parent, BlockSettings * blockSettings) { awd_float64 * transform_mtx_camera = (double *)malloc(12*sizeof(awd_float64)); awd_float64 store1 = mtxData[3]; awd_float64 store2 = mtxData[4]; awd_float64 store3 = mtxData[5]; transform_mtx_camera[0] = mtxData[0]; transform_mtx_camera[1] = mtxData[1]; transform_mtx_camera[2] = mtxData[2]; transform_mtx_camera[3] = mtxData[6]; transform_mtx_camera[4] = mtxData[7]; transform_mtx_camera[5] = mtxData[8]; transform_mtx_camera[6] = store1*-1; transform_mtx_camera[7] = store2*-1; transform_mtx_camera[8] = store3*-1; transform_mtx_camera[9] = mtxData[9]; transform_mtx_camera[10] = mtxData[10]; transform_mtx_camera[11] = mtxData[11]; Object *obj; obj = node->GetObjectRef(); SClass_ID sid=obj->SuperClassID(); getBaseObjectAndID( obj, sid ); CameraObject *camObject= (CameraObject *) obj; double fov=camObject->GetFOV(0); bool isOrtho=camObject->IsOrtho(); double clipNear=camObject->GetClipDist(0,CAM_HITHER_CLIP); double clipFar=camObject->GetClipDist(0,CAM_YON_CLIP); char * camName_ptr=W2A(node->GetName()); AWD_lens_type camType=AWD_LENS_PERSPECTIVE; if (isOrtho) camType=AWD_LENS_ORTHO; AWDCamera * awdCamera = new AWDCamera(camName_ptr, strlen(camName_ptr), camType, transform_mtx_camera); AWDTextureProjector * textureProjector= new AWDTextureProjector(camName_ptr, strlen(camName_ptr), mtxData); AWDBitmapTexture * projectionTexture = NULL; free(camName_ptr); if(!isOrtho){ //double aspectRatio=maxInterface->GetRendApect(); double aspectRatio=1/double(maxInterface->GetRendImageAspect()); double horizontalFOV=double(fov* (double(double(180)/(double(3.14159265358979323846))))); double verticalFOV=horizontalFOV * double(aspectRatio); awdCamera->set_lens_fov(verticalFOV); } awdCamera->set_lens_near(clipNear * blockSettings->get_scale()); awdCamera->set_lens_far(clipFar * blockSettings->get_scale()); bool exportCamera=true; bool exportTextureProjector=false; BaseObject* node_bo = (BaseObject*)node->GetObjectRef(); IDerivedObject* node_der = NULL; char * settingsNodeID_ptr=NULL; if((node_bo->SuperClassID() == GEN_DERIVOB_CLASS_ID) || (node_bo->SuperClassID() == WSM_DERIVOB_CLASS_ID) || (node_bo->SuperClassID() == DERIVOB_CLASS_ID )) { node_der = ( IDerivedObject* ) node->GetObjectRef(); if (node_der!=NULL){ int nMods = node_der->NumModifiers(); for (int m = 0; m<nMods; m++){ Modifier* node_mod = node_der->GetModifier(m); if (node_mod->IsEnabled()){ MSTR className; node_mod->GetClassName(className); char * className_ptr=W2A(className); if (ATTREQ(className_ptr,"AWDCamera")){ IParamBlock2* pb = GetParamBlock2ByName((ReferenceMaker*)node_mod, "main"); if(pb!=NULL){ int numBlockparams=pb->NumParams(); int p=0; for (p=0; p<numBlockparams; p++) { ParamID pid = pb->IndextoID(p); ParamDef def = pb->GetParamDef(pid); ParamType2 paramtype = pb->GetParameterType(pid); char * paramName=W2A(def.int_name); if (paramtype==TYPE_STRING) { if (ATTREQ(paramName, "thisAWDID")) settingsNodeID_ptr = W2A(pb->GetStr(pid)); } if (paramtype==TYPE_BOOL){ if (ATTREQ(paramName, "exportCamera")) exportCamera = (0 != pb->GetInt(pid)); if (ATTREQ(paramName, "exportTextureProjector")) exportTextureProjector = (0 != pb->GetInt(pid)); } free(paramName); } } if(exportCamera){ AWD_lens_type lens_type = AWD_LENS_PERSPECTIVE; int lensType=1; int projectionHeight=1; int offcenterX_pos=1; int offcenterX_neg=1; int offcenterY_pos=1; int offcenterY_neg=1; IParamBlock2* pb = GetParamBlock2ByName((ReferenceMaker*)node_mod, "camera_params"); if(pb!=NULL){ int numBlockparams=pb->NumParams(); int p=0; for (p=0; p<numBlockparams; p++) { ParamID pid = pb->IndextoID(p); ParamDef def = pb->GetParamDef(pid); ParamType2 paramtype = pb->GetParameterType(pid); char * paramName=W2A(def.int_name); if (paramtype==TYPE_INT){ if (ATTREQ(paramName, "lensType")) lensType = pb->GetInt(pid); if (ATTREQ(paramName, "projectionHeight")) projectionHeight = pb->GetInt(pid); if (ATTREQ(paramName, "offcenterX_pos")) offcenterX_pos = pb->GetInt(pid); if (ATTREQ(paramName, "offcenterX_neg")) offcenterX_neg = pb->GetInt(pid); if (ATTREQ(paramName, "offcenterY_pos")) offcenterY_pos = pb->GetInt(pid); if (ATTREQ(paramName, "offcenterY_neg")) offcenterY_neg = pb->GetInt(pid); } free(paramName); } if(lensType==2){ lens_type=AWD_LENS_ORTHO; awdCamera->set_lens_proj_height(projectionHeight); } else if (lensType==3){ lens_type=AWD_LENS_ORTHOOFFCENTER; awdCamera->set_lens_offset(offcenterX_pos, offcenterX_neg, offcenterY_neg, offcenterY_pos ); } awdCamera->set_lens_type(lens_type); } } if(exportTextureProjector){ IParamBlock2* pb = GetParamBlock2ByName((ReferenceMaker*)node_mod, "texture_projector_params"); if(pb!=NULL){ int numBlockparams=pb->NumParams(); int p=0; for (p=0; p<numBlockparams; p++) { ParamID pid = pb->IndextoID(p); ParamDef def = pb->GetParamDef(pid); ParamType2 paramtype = pb->GetParameterType(pid); char * paramName=W2A(def.int_name); if (paramtype==TYPE_TEXMAP){ if (ATTREQ(paramName,"projectionTexture") ){ Texmap *projectionTexmap = pb->GetTexmap(pid); if (projectionTexmap != NULL && projectionTexmap->ClassID() == Class_ID(BMTEX_CLASS_ID, 0)) { projectionTexture=ExportBitmapTexture((BitmapTex *)projectionTexmap, NULL, UNDEFINEDTEXTYPE, FORTEXTUREPROJECTOR); if (projectionTexture!=NULL) textureProjector->set_texture(projectionTexture); else{ textureProjector->make_invalide(); exportTextureProjector=false; } } } } if (paramtype==TYPE_FLOAT){ if (ATTREQ(paramName, "aspect_ratio")) textureProjector->set_aspect_ratio(pb->GetFloat(pid)); } free(paramName); } } else{ textureProjector->make_invalide(); exportTextureProjector=false; } } } free(className_ptr); } } } } else{ } if(exportCamera){ if (parent) { parent->add_child(awdCamera); } else { awd->add_scene_block(awdCamera); } } else{ delete awdCamera; } if(exportTextureProjector){ textureProjectorCache->Set(settingsNodeID_ptr, textureProjector); if (parent) { parent->add_child(textureProjector); } else { awd->add_scene_block(textureProjector); } if(projectionTexture!=NULL) awd->add_texture(projectionTexture); } else{ delete textureProjector; if(projectionTexture!=NULL) delete projectionTexture; } if(settingsNodeID_ptr!=NULL) free(settingsNodeID_ptr); if((exportCamera)&&(!exportTextureProjector)) return awdCamera; else if((!exportCamera)&&(exportTextureProjector)&&(textureProjector!=NULL)) return textureProjector; else if((exportCamera)&&(exportTextureProjector)) return awdCamera; return NULL; }
void plResponderWaitProc::LoadPoint(bool force) { int who = fWaitPB->GetInt(kWaitWho); const char *point = fWaitPB->GetStr(kWaitPoint); if (point && *point == '\0') point = nil; CheckRadioButton(fhDlg, IDC_RADIO_FINISH, IDC_RADIO_POINT, point || force ? IDC_RADIO_POINT : IDC_RADIO_FINISH); BOOL enableAll = (who != -1); EnableWindow(GetDlgItem(fhDlg, IDC_RADIO_FINISH), enableAll); EnableWindow(GetDlgItem(fhDlg, IDC_RADIO_POINT), enableAll); BOOL enablePoint = ((point != nil) || force) && enableAll; EnableWindow(GetDlgItem(fhDlg, IDC_WAIT_POINT), enablePoint); ComboBox_ResetContent(GetDlgItem(fhDlg, IDC_WAIT_POINT)); if (enableAll) { IParamBlock2 *pb = (IParamBlock2*)fStatePB->GetReferenceTarget(kStateCmdParams, 0, who); plResponderCmd *cmd = plResponderCmd::Find(pb); // KLUDGE - stupid one-shot needs editable box if (cmd == &(plResponderCmdOneShot::Instance())) { ShowWindow(GetDlgItem(fhDlg, IDC_WAIT_POINT), SW_HIDE); HWND hEdit = GetDlgItem(fhDlg, IDC_MARKER_EDIT); ShowWindow(hEdit, SW_SHOW); ICustEdit *custEdit = GetICustEdit(hEdit); custEdit->SetText(point ? (char*)point : ""); } else { ShowWindow(GetDlgItem(fhDlg, IDC_WAIT_POINT), SW_SHOW); HWND hEdit = GetDlgItem(fhDlg, IDC_MARKER_EDIT); ShowWindow(hEdit, SW_HIDE); plResponderCmd::WaitPoints waitPoints; cmd->GetWaitPoints(pb, waitPoints); HWND hCombo = GetDlgItem(fhDlg, IDC_WAIT_POINT); ComboBox_ResetContent(hCombo); if (waitPoints.size() == 0) { EnableWindow(GetDlgItem(fhDlg, IDC_RADIO_POINT), FALSE); EnableWindow(GetDlgItem(fhDlg, IDC_WAIT_POINT), FALSE); } else { for (int i = 0; i < waitPoints.size(); i++) { const char *marker = waitPoints[i].c_str(); int idx = ComboBox_AddString(hCombo, marker); if (point && !strcmp(point, marker)) ComboBox_SetCurSel(hCombo, idx); } } } } }
BOOL plResponderProc::DlgProc(TimeValue t, IParamMap2 *pm, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { static UINT dragListMsg = 0; if (dragListMsg != 0 && msg == dragListMsg) if (DragListProc(hWnd, (DRAGLISTINFO*)lParam)) return TRUE; switch (msg) { case WM_INITDIALOG: { if (!fhMenu) ICreateMenu(); fhDlg = hWnd; fhList = GetDlgItem(fhDlg, IDC_CMD_LIST); fCurState = 0; fCmdIdx = -1; fPB = pm->GetParamBlock(); fComp = (plResponderComponent*)fPB->GetOwner(); fComp->IFixOldPB(); LoadState(); // Make it so the user can drag commands to different positions dragListMsg = RegisterWindowMessage(DRAGLISTMSGSTRING); MakeDragList(GetDlgItem(hWnd, IDC_CMD_LIST)); // Setup the State Name combo HWND hStateName = GetDlgItem(hWnd, IDC_STATE_COMBO); ComboBox_LimitText(hStateName, 256); // I give up, Windows doesn't want to tell me the real font size #if 0//def CUSTOM_DRAW // TEMP HDC hDC = GetDC(hStateName); HFONT sysFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); HFONT oldFont = SelectFont(hDC, sysFont); TEXTMETRIC tm; GetTextMetrics(hDC, &tm); ComboBox_SetItemHeight(hStateName, 0, tm.tmHeight+2); DeleteFont(SelectFont(hDC, oldFont)); ReleaseDC(hStateName, hDC); #endif // Add the commands int idx = ComboBox_AddString(hStateName, "Add State"); ComboBox_SetItemData(hStateName, idx, kStateAdd); idx = ComboBox_AddString(hStateName, "Remove Current State"); ComboBox_SetItemData(hStateName, idx, kStateRemove); idx = ComboBox_AddString(hStateName, "Set Current as Default"); ComboBox_SetItemData(hStateName, idx, kStateDefault); idx = ComboBox_AddString(hStateName, "Copy Current State"); ComboBox_SetItemData(hStateName, idx, kStateCopy); HWND hSwitchCombo = GetDlgItem(hWnd, IDC_SWITCH_COMBO); int numStates = fPB->Count(kResponderStateName); for (int i = 0; i < numStates; i++) { const char *stateName = fPB->GetStr(kResponderStateName, 0, i); char buf[128]; if (!stateName || *stateName == '\0') { sprintf(buf, "State %d", i+1); stateName = buf; } ComboBox_InsertString(hStateName, i, stateName); ComboBox_AddString(hSwitchCombo, stateName); } ComboBox_SetCurSel(hStateName, fCurState); ComboBox_SetCurSel(hSwitchCombo, fStatePB->GetInt(kStateCmdSwitch)); } return TRUE; #ifdef CUSTOM_DRAW case WM_DRAWITEM: if (wParam == IDC_STATE_COMBO) { IDrawComboItem((DRAWITEMSTRUCT*)lParam); return TRUE; } break; #endif case WM_SETCURSOR: { if (HIWORD(lParam) == WM_RBUTTONDOWN && HWND(wParam) == GetDlgItem(hWnd, IDC_CMD_LIST)) { ICmdRightClick(HWND(wParam)); return TRUE; } } break; case WM_COMMAND: if (HIWORD(wParam) == BN_CLICKED) { if (LOWORD(wParam) == IDC_ADD_ACTIVATOR) { // Adding an activator. Set it and refresh the UI to show it in our list. plPick::Activator(fPB, kResponderActivators, false); pm->Invalidate(kResponderActivators); return TRUE; } else if (LOWORD(wParam) == IDC_ADD_CMD) { AddCommand(); return TRUE; } // Remove the currently selected condition else if (LOWORD(wParam) == IDC_REMOVE_CMD) { RemoveCurCommand(); return TRUE; } } else if (HIWORD(wParam) == LBN_SELCHANGE && LOWORD(wParam) == IDC_CMD_LIST) { ICreateCmdRollups(); return TRUE; } else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_SWITCH_COMBO) { int sel = ComboBox_GetCurSel((HWND)lParam); if (sel != CB_ERR) fStatePB->SetValue(kStateCmdSwitch, 0, sel); } else if (LOWORD(wParam) == IDC_STATE_COMBO) { HWND hCombo = (HWND)lParam; int code = HIWORD(wParam); // Disable accelerators when the combo has focus, so that new names can be typed in if (code == CBN_SETFOCUS) { plMaxAccelerators::Disable(); return TRUE; } else if (code == CBN_KILLFOCUS) { plMaxAccelerators::Enable(); return TRUE; } // State name changed, save it in the PB else if (code == CBN_EDITCHANGE) { char buf[256]; ComboBox_GetText(hCombo, buf, sizeof(buf)); const char *curName = fPB->GetStr(kResponderStateName, 0, fCurState); if (!curName || strcmp(buf, curName)) { HWND hSwitch = GetDlgItem(hWnd, IDC_SWITCH_COMBO); int sel = ComboBox_GetCurSel(hSwitch); ComboBox_DeleteString(hSwitch, fCurState); ComboBox_InsertString(hSwitch, fCurState, buf); ComboBox_SetCurSel(hSwitch, sel); fPB->SetValue(kResponderStateName, 0, buf, fCurState); ComboBox_DeleteString(hCombo, fCurState); ComboBox_InsertString(hCombo, fCurState, buf); // ComboBox_SetCurSel(hCombo, fCurState); } return TRUE; } else if (code == CBN_SELCHANGE) { int sel = ComboBox_GetCurSel(hCombo); int type = ComboBox_GetItemData(hCombo, sel); if (type == kStateAdd) { IParamBlock2 *pb = CreateParameterBlock2(&gStateBlock, nil); fCurState = AddState(pb); fCmdIdx = -1; } else if (type == kStateRemove) { int count = fPB->Count(kResponderState); // Don't let the user remove the last state if (count == 1) { hsMessageBox("You must have at least one state.", "Error", hsMessageBoxNormal); ComboBox_SetCurSel(hCombo, fCurState); return TRUE; } // Verify that the user really wants to delete the state else { int ret = hsMessageBox("Are you sure you want to remove this state?", "Verify Remove", hsMessageBoxYesNo); if (ret == hsMBoxNo) { ComboBox_SetCurSel(hCombo, fCurState); return TRUE; } } fPB->Delete(kResponderState, fCurState, 1); fPB->Delete(kResponderStateName, fCurState, 1); ComboBox_DeleteString(hCombo, fCurState); ComboBox_SetCurSel(hCombo, 0); HWND hSwitch = GetDlgItem(hWnd, IDC_SWITCH_COMBO); ComboBox_DeleteString(hSwitch, fCurState); // If the deleted state was the default, set the default to the first int defState = fPB->GetInt(kResponderStateDef); if (fCurState == defState) fPB->SetValue(kResponderStateDef, 0, 0); else if (fCurState < defState) fPB->SetValue(kResponderStateDef, 0, defState-1); // Patch up the switch commands for (int i = fCurState; i < fPB->Count(kResponderState); i++) { IParamBlock2 *pb = (IParamBlock2*)fPB->GetReferenceTarget(kResponderState, 0, i); int switchState = pb->GetInt(kStateCmdSwitch); // TODO: might want to warn about this if (switchState == fCurState) pb->SetValue(kStateCmdSwitch, 0, 0); else if (switchState > fCurState) pb->SetValue(kStateCmdSwitch, 0, switchState-1); } fCurState = 0; fCmdIdx = -1; } else if (type == kStateDefault) { // Set the current state as the default fPB->SetValue(kResponderStateDef, 0, fCurState); ComboBox_SetCurSel(hCombo, fCurState); } else if (type == kStateCopy) { // Clone the state PB IParamBlock2 *origPB = (IParamBlock2*)fPB->GetReferenceTarget(kResponderState, 0, fCurState); IParamBlock2 *copyPB = (IParamBlock2*)origPB->Clone(gMyRemapDir); fCurState = AddState(copyPB); fCmdIdx = -1; } else { fCurState = sel; fCmdIdx = -1; } LoadState(); return TRUE; } } } return FALSE; }
BOOL plPassAnimDlgProc::DlgProc(TimeValue t, IParamMap2 *pMap, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { if( fCurrParamMap != pMap ) { if( fCurrParamMap != nil ) { plPassMtlBase *mtl = (plPassMtlBase *)( fCurrParamMap->GetParamBlock()->GetOwner() ); mtl->UnregisterChangeCallback( this ); } fCurrParamMap = pMap; if( fCurrParamMap != nil ) { plPassMtlBase *mtl = (plPassMtlBase *)( fCurrParamMap->GetParamBlock()->GetOwner() ); mtl->RegisterChangeCallback( this ); } } IParamBlock2 *pb = pMap->GetParamBlock(); plPassMtlBase *mtl = (plPassMtlBase*)pb->GetOwner(); HWND gWnd = GetDlgItem(hWnd, IDC_MTL_GLOBAL_NAME); char buff[512]; switch (msg) { case WM_DESTROY: if( fCurrParamMap != nil ) { plPassMtlBase *mtl = (plPassMtlBase *)( fCurrParamMap->GetParamBlock()->GetOwner() ); mtl->RegisterChangeCallback( this ); fCurrParamMap = nil; } break; case WM_INITDIALOG: { fhWnd = hWnd; fCurrStealth = nil; IInitControls(mtl, pb); plAnimComponentProc::FillAgeGlobalComboBox(gWnd, pb->GetStr(ParamID(kPBAnimGlobalName))); plAnimComponentProc::SetBoxToAgeGlobal(gWnd, pb->GetStr(ParamID(kPBAnimGlobalName))); IEnableGlobal(hWnd, pb->GetInt( (ParamID)kPBAnimUseGlobal ) ); bool stopPoints = false; if( DoesHaveStopPoints( pb->GetOwner() ) ) { stopPoints = true; break; } IEnableEaseStopPoints( pMap, stopPoints ); } return TRUE; case WM_COMMAND: // Anim name selection changed if (LOWORD(wParam) == IDC_NAMES && HIWORD(wParam) == CBN_SELCHANGE) { IUpdateSegmentSel( pMap ); return TRUE; } // Refresh clicked else if (LOWORD(wParam) == IDC_REFRESH_ANIMS && HIWORD(wParam) == BN_CLICKED) { IInitControls(mtl, pb); return TRUE; } else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_MTL_GLOBAL_NAME) { ComboBox_GetLBText(gWnd, ComboBox_GetCurSel(gWnd), buff); pb->SetValue(ParamID(kPBAnimGlobalName), 0, _T(buff)); } else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_MTL_USE_GLOBAL) { IEnableGlobal(hWnd, pb->GetInt( (ParamID)kPBAnimUseGlobal ) ); } break; } return FALSE; }
bool HoudiniEngineMesh::UpdateParameters(TimeValue t) { bool need_cook = false; if ( assetId >= 0 ) { hapi::Asset asset(assetId); if (asset.isValid()) { INode* node = this->GetINode(); if (node) { MSTR pname; int subs = node->NumSubs(); for (int i = 0; i < subs; ++i) { pname = node->SubAnimName(i); Animatable* anim = node->SubAnim(i); if (anim) { int blocks = anim->NumParamBlocks(); for (int block = 0; block < blocks; ++block) { IParamBlock2 *pblock = anim->GetParamBlock(block); if (pblock) { TSTR pbname = pblock->GetLocalName(); int nNumParams = pblock->NumParams(); ParamID id; std::map<std::string, hapi::Parm> params = asset.parmMap(); for (int i = 0; i < nNumParams; i++) { id = pblock->IndextoID(i); MSTR pname = pblock->GetLocalName(id); std::string hname = CStr::FromMSTR(pblock->GetLocalName(id)).data(); int index = (int)(hname[hname.size() - 1] - '0'); hname.pop_back(); if (std::string("__he_input") == hname) { // input node INode* inputnode = pblock->GetINode(id, t); if (inputnode) { need_cook = SetInputNode(index, inputnode) || need_cook; } } else { // parameters if (params.find(hname) != params.end()) { hapi::Parm parm = params[hname]; if (HAPI_ParmInfo_IsInt(&parm.info())) { int value = pblock->GetInt(id, t); if (value != parm.getIntValue(index)) { parm.setIntValue(index, value); need_cook = true; } } else if (HAPI_ParmInfo_IsFloat(&parm.info())) { float value = pblock->GetFloat(id, t); if (value != parm.getFloatValue(index)) { parm.setFloatValue(index, value); need_cook = true; } } else if (HAPI_ParmInfo_IsString(&parm.info())) { std::string value = CStr::FromMSTR(pblock->GetStr(id, t)); if (value != parm.getStringValue(index)) { parm.setStringValue(index, value.c_str()); need_cook = true; } } } } } } } } } } } } return need_cook; }
void plAnimComponentProc::Update( TimeValue t, Interval &valid, IParamMap2 *pmap ) { HWND hWnd = pmap->GetHWnd(); IParamBlock2 *pb = pmap->GetParamBlock(); SetBoxToAgeGlobal(GetDlgItem(hWnd, IDC_ANIM_GLOBAL_LIST), pb->GetStr(ParamID(kAnimGlobalName))); }
void HwShaderExporter::exportEffectParameters ( StdMat2* material ) { COLLADASW::StreamWriter* streamWriter = &mDocumentExporter->getStreamWriter(); IParamBlock2 * pblock = material->GetParamBlock ( 0 ); int parameterCount = pblock->NumParams(); for ( int i = 0; i < parameterCount; i++ ) { ParamID parameterID = pblock->IndextoID( i ); ParamType2 parameterType = pblock->GetParameterType( parameterID ); ParamDef parameterDef = pblock->GetParamDef( parameterID ); const TCHAR* paramName = parameterDef.int_name; switch ( parameterType ) { case TYPE_FLOAT: { COLLADASW::NewParam<> newParam ( streamWriter ); newParam.setParamType ( COLLADASW::ValueType::FLOAT ); int numOfValues = 1; float paramValue = pblock->GetFloat( parameterID ); exportParam ( paramName, &newParam, ¶mValue, numOfValues ); break; } case TYPE_INT: { COLLADASW::NewParam<> newParam ( streamWriter ); newParam.setParamType ( COLLADASW::ValueType::INT ); int numOfValues = 1; int paramValue = pblock->GetInt( parameterID ); exportParam ( paramName, &newParam, ¶mValue, numOfValues ); break; } case TYPE_RGBA: case TYPE_FRGBA: { COLLADASW::NewParam<> newParam ( streamWriter ); newParam.setParamType ( COLLADASW::ValueType::FLOAT4 ); int numOfValues = 4; AColor paramPoint3Value = pblock->GetAColor( parameterID ); float* paramValue = (float*)paramPoint3Value; exportParam ( paramName, &newParam, paramValue, numOfValues ); break; } case TYPE_POINT3: { COLLADASW::NewParam<> newParam ( streamWriter ); newParam.setParamType ( COLLADASW::ValueType::FLOAT3 ); int numOfValues = 3; Point3 paramPoint3Value = pblock->GetPoint3( parameterID ); float* paramValue = (float*)paramPoint3Value; exportParam ( paramName, &newParam, paramValue, numOfValues ); break; } case TYPE_BOOL: { COLLADASW::NewParam<> newParam ( streamWriter ); newParam.setParamType ( COLLADASW::ValueType::BOOL ); int numOfValues = 1; /*bool*/ int paramValue = pblock->GetInt( parameterID ); exportParam ( paramName, &newParam, ¶mValue, numOfValues ); break; } //TYPE_ANGLE //TYPE_PCNT_FRAC //TYPE_WORLD case TYPE_STRING: { COLLADASW::NewParam<> newParam ( streamWriter ); const MCHAR * paramValue = pblock->GetStr( parameterID ); exportParam ( paramName, &newParam, paramValue ); break; } //TYPE_FILENAME //TYPE_HSV //TYPE_COLOR_CHANNEL //TYPE_TIMEVALUE //TYPE_RADIOBTN_INDEX //TYPE_MTL //TYPE_TEXMAP case TYPE_BITMAP: { PBBitmap * bitmap = pblock->GetBitmap( parameterID ); exportSampler ( paramName, bitmap ); break; } //TYPE_INODE //TYPE_REFTARG //TYPE_INDEX //TYPE_MATRIX3 //TYPE_PBLOCK2 case TYPE_POINT4: { COLLADASW::NewParam<> newParam ( streamWriter ); newParam.setParamType ( COLLADASW::ValueType::FLOAT4 ); int numOfValues = 4; Point4 paramPoint3Value = pblock->GetPoint4( parameterID ); float* paramValue = (float*)paramPoint3Value; exportParam ( paramName, &newParam, paramValue, numOfValues ); break; } default: { //:TODO: warning (file and/or popup) GetCOREInterface()->Log()->LogEntry( SYSLOG_WARN, DISPLAY_DIALOG, _M( "Parameter export problem" ),_M( "Unsupported parameter type (%i) for parameter %s\n" ), parameterType, paramName ); } } } }
void MaxAWDExporter::ExportUserAttributes(Animatable *obj, AWDAttrElement *elem) { if (!opts->ExportAttributes()) return; ICustAttribContainer *attributes = obj->GetCustAttribContainer(); if (attributes) { int a=0; int numAttribs=0; numAttribs = attributes->GetNumCustAttribs(); for (a=0; a<numAttribs; a++) { int k=0; CustAttrib *attr = attributes->GetCustAttrib(a); for (k=0; k<attr->NumParamBlocks(); k++) { int p=0; IParamBlock2 *block = attr->GetParamBlock(k); if (block!=NULL){ char * blockName_ptr=W2A(block->GetLocalName()); if (ATTREQ(blockName_ptr,"AWDObjectSettingsParams") ){ } // the next three should not occur yet, as we do not read Custom-properties on materials yet else if (ATTREQ(blockName_ptr,"AWD_MaterialSettingsparams") ){ } else if (ATTREQ(blockName_ptr,"AWD_EffectMethodsparams") ){ } else if (ATTREQ(blockName_ptr,"AWDShadingParams") ){ } else{ for (p=0; p<block->NumParams(); p++) { ParamID pid = block->IndextoID(p); Color col; AColor acol; Interval valid = FOREVER; awd_uint16 len = 0; AWD_field_type type = AWD_FIELD_FLOAT32; AWD_field_ptr ptr; ptr.v = NULL; switch (block->GetParameterType(pid)) { case TYPE_ANGLE: case TYPE_PCNT_FRAC: case TYPE_WORLD: case TYPE_FLOAT: type = AWD_FIELD_FLOAT64; len = sizeof(awd_float64); ptr.v = malloc(len); *ptr.f64 = block->GetFloat(pid); break; case TYPE_TIMEVALUE: case TYPE_INT: type = AWD_FIELD_INT32; len = sizeof(awd_int32); ptr.v = malloc(len); *ptr.i32 = block->GetInt(pid); break; case TYPE_BOOL: type = AWD_FIELD_BOOL; len = sizeof(awd_bool); ptr.v = malloc(len); *ptr.b = (0 != block->GetInt(pid)); break; case TYPE_FILENAME: case TYPE_STRING: type = AWD_FIELD_STRING; ptr.str = (char*)block->GetStr(pid); len = strlen(ptr.str); break; case TYPE_RGBA: type = AWD_FIELD_COLOR; len = sizeof(awd_color); col = block->GetColor(pid); ptr.v = malloc(len); *ptr.col = awdutil_float_color(col.r, col.g, col.b, 1.0); break; case TYPE_FRGBA: type = AWD_FIELD_COLOR; len = sizeof(awd_color); acol = block->GetAColor(pid); ptr.v = malloc(len); *ptr.col = awdutil_float_color(acol.r, acol.g, acol.b, acol.a); break; } if (ptr.v != NULL) { ParamDef def = block->GetParamDef(pid); if (ns == NULL) { // Namespace has not yet been created; ns is a class // variable that will be created only once and then // reused for all user attributes. char * ns_ptr=opts->AttributeNamespace();//dont free, as this will get freed in the opts delete ns = new AWDNamespace(ns_ptr, strlen(ns_ptr)); awd->add_namespace(ns); } char * thisName=W2A(def.int_name); elem->set_attr(ns, thisName, strlen(thisName)+1, ptr, len, type); free(thisName); } } } free(blockName_ptr); } } } } }
void SaveMetaData(INode* node, AlembicObject* object) { if (object == NULL) { return; } if (object->GetNumSamples() > 0) { return; } Modifier* pMod = FindModifier(node, Class_ID(0xd81fc3e, 0x1e4eacf5)); bool bReadCustAttribs = false; if (!pMod) { pMod = FindModifier(node, "Metadata"); bReadCustAttribs = true; } if (!pMod) { return; } std::vector<std::string> metaData; if (bReadCustAttribs) { ICustAttribContainer* cont = pMod->GetCustAttribContainer(); if (!cont) { return; } for (int i = 0; i < cont->GetNumCustAttribs(); i++) { CustAttrib* ca = cont->GetCustAttrib(i); std::string name = EC_MCHAR_to_UTF8(ca->GetName()); IParamBlock2* pblock = ca->GetParamBlockByID(0); if (pblock) { int nNumParams = pblock->NumParams(); for (int i = 0; i < nNumParams; i++) { ParamID id = pblock->IndextoID(i); // MSTR name = pblock->GetLocalName(id, 0); MSTR value = pblock->GetStr(id, 0); metaData.push_back(EC_MSTR_to_UTF8(value)); } } } } else { IParamBlock2* pblock = pMod->GetParamBlockByID(0); if (pblock && pblock->NumParams() == 1) { ParamID id = pblock->IndextoID(0); MSTR name = pblock->GetLocalName(id, 0); int nSize = pblock->Count(id); for (int i = 0; i < nSize; i++) { MSTR value = pblock->GetStr(id, 0, i); metaData.push_back(EC_MSTR_to_UTF8(value)); } } } if (metaData.size() > 0) { Abc::OStringArrayProperty metaDataProperty = Abc::OStringArrayProperty( object->GetCompound(), ".metadata", object->GetCompound().getMetaData(), object->GetCurrentJob()->GetAnimatedTs()); Abc::StringArraySample metaDataSample(&metaData.front(), metaData.size()); metaDataProperty.set(metaDataSample); } }