// Morph Diff 0.313 // 多段階モーフ作成支援。 モーフマップの差分量を取る。 @name "MorphDiff" @version 2.5 @warnings @script modeler @define DESCRIPT "Morph Diff" main { selmode(DIRECT); var SelPts = pointcount(); // 90/92/93 はpoint/poly countでUndoバッファを消費する @if version < 2.2 undo(); @end @if version > 2.7 undo(); @end if(!SelPts){ error("
Need Select Pts"); return; } var vmap = VMap(VMMORPH); if(vmap == nil){ error("
Not Found MORPH"); return; } var VMapNames; VMapNames += "--None--"; while(vmap && vmap.type == VMMORPH){ VMapNames += vmap.name; vmap = vmap.next(); } var SelMap[6]; var DstMap[5]; SelMap[] = 1; DstMap[] = 1; reqbegin(DESCRIPT); reqsize(460, 200); t0 = ctltext("","[ SRC map ] [ DEST map ]"); ctlposition( t0,135, 0); t1 = ctltext("","1st Morph"); ctlposition( t1, 4, 25); mp1 = ctlpopup("", 1, VMapNames); ctlposition(mp1, 55, 22, 200); t2 = ctltext("","2nd Morph"); ctlposition( t2, 4, 45); mp2 = ctlpopup("", 1, VMapNames); ctlposition(mp2, 55, 42, 200); ds2 = ctlpopup("", 1, VMapNames); ctlposition(ds2,252, 42, 200); t3 = ctltext("","3rd Morph"); ctlposition( t3, 4, 65); mp3 = ctlpopup("", 1, VMapNames); ctlposition(mp3, 55, 62, 200); ds3 = ctlpopup("", 1, VMapNames); ctlposition(ds3,252, 62, 200); t4 = ctltext("","4th Morph"); ctlposition( t4, 4, 85); mp4 = ctlpopup("", 1, VMapNames); ctlposition(mp4, 55, 82, 200); ds4 = ctlpopup("", 1, VMapNames); ctlposition(ds4,252, 82, 200); t5 = ctltext("","5th Morph"); ctlposition( t5, 4,105); mp5 = ctlpopup("", 1, VMapNames); ctlposition(mp5, 55,102, 200); ds5 = ctlpopup("", 1, VMapNames); ctlposition(ds5,252,102, 200); s0 = ctlsep(); ctlposition( s0, 2,127, 460); t6 = ctltext("","* Required 1st & 2nd SRC Morph maps."); ctlposition( t6, 4,131); t7 = ctltext("","* If DEST map is --None--, Overwrite SRC map."); ctlposition( t7, 4,145); return if !reqpost(); SelMap[1] = getvalue(mp1); SelMap[2] = getvalue(mp2); SelMap[3] = getvalue(mp3); SelMap[4] = getvalue(mp4); SelMap[5] = getvalue(mp5); DstMap[2] = getvalue(ds2); DstMap[3] = getvalue(ds3); DstMap[4] = getvalue(ds4); DstMap[5] = getvalue(ds5); reqend(); if((SelMap[1] == 1) || (SelMap[2] == 1)){ error("
Need 1st/2nd MAPs."); return; } var MapCnt; for(i = 3; i <= 6; i++){ if(SelMap[i] == 1){ MapCnt = i - 1; break; } } var Val[3]; var TmpVal; var ActFlag[SelPts]; ActFlag[] = 0; editbegin(); for(c = 1; c <= MapCnt; c++){ vmap = VMap(VMMORPH, VMapNames[SelMap[c]]); for(i = 1; i <= SelPts; i++){ if(vmap.isMapped(points[i])){ Val = vmap.getValue(points[i]); TmpVal[c][i][1] = Val[1]; TmpVal[c][i][2] = Val[2]; TmpVal[c][i][3] = Val[3]; }else{ TmpVal[c][i][1] = 0.0; TmpVal[c][i][2] = 0.0; TmpVal[c][i][3] = 0.0; ActFlag[i] += 1; } } } x = 1; for(c = 2; c <= MapCnt; c++){ if(DstMap[c] == 1) vmap = VMap(VMMORPH, VMapNames[SelMap[c]]); else vmap = VMap(VMMORPH, VMapNames[DstMap[c]]); for(i = 1; i <= SelPts; i++){ if(ActFlag[i] == MapCnt){ // SrcのMapを一切持たないがDestのMapがある場合0にする。Destも無いならスルー if(vmap.isMapped(points[i])) vmap.setValue(points[i], @0.0,0.0,0.0@); }else{ // 0であっても一つでもSrcのMapを持つなら通常通りの処理 Val[1] = TmpVal[c][i][1] - TmpVal[x][i][1]; Val[2] = TmpVal[c][i][2] - TmpVal[x][i][2]; Val[3] = TmpVal[c][i][3] - TmpVal[x][i][3]; vmap.setValue(points[i], Val); } } x++; } editend(); }