// UVSymmetric 0.461 // 最初に選択した頂点のUV値を中心軸とし、2-3、4-5・・・と線対称にする。 @name "UVSynmmetric" @version 2.5 @warnings @script modeler @define DESCRIPT "UVSynmmetric" var VMapNames; main { selmode(DIRECT); var SelPts = pointcount(); if((SelPts > 0)&&(SelPts < 3)){ error("
Need 3 Pts or More"); return; } var RecentMap = recall("RecentMap", "--None--"); var ListIdx = checkUVMap(RecentMap); if(!SelPts){ selUVMap(ListIdx); return; } if(!ListIdx){ if(!(ListIdx = selUVMap(ListIdx))) return; } var vmap = VMap(VMTEXTURE, VMapNames[ListIdx]); editbegin(); if(!vmap.isMapped(points[1])){ editend(); error("
not mapped UVs. on 1st Pts."); return; } var LastPnt, DiffX; var SrcUV[2], DstUV[2], CenterUV[2]; CenterUV = vmap.getValue(points[1]); var ErrFlag = 1; var p = 2; // 基準点の分を引く x = (SelPts - 1) >> 1; // 対の数分ループ、内で2ポイント分処理 // setValue内でpoints[p++]とするとNG。 LS2.5のバグ for(i = 1; i <= x; i++){ if(vmap.isMapped(points[p])){ SrcUV = vmap.getValue(points[p]); p++; DiffX = SrcUV[1] - CenterUV[1]; if(DiffX != 0.0) DstUV[1] = CenterUV[1] - DiffX; else DstUV[1] = CenterUV[1]; DstUV[2] = SrcUV[2]; vmap.setValue(points[p], DstUV); p++; }else{ // UVが無い場合、そのIDを記録。頂点カウントも進める LastPnt[ErrFlag] = points[p]; ErrFlag++; p++; // 対になる頂点も記録。カウントも進める LastPnt[ErrFlag] = points[p]; ErrFlag++; p++; } } LastPnt[ErrFlag] = points[SelPts]; editend(); selmode(USER); selpoint(CLEAR); // 端数、または、非マップ頂点があったら if(!(SelPts % 2) || ErrFlag >= 2){ info("
Fraction or Non Assign Points."); selpoint(SET, POINTID, LastPnt); } } // ----------------------- selUVMap: ListIdx { if(!ListIdx) ListIdx = 1; reqbegin(DESCRIPT); reqsize(190,60); c1 = ctlpopup("", ListIdx, VMapNames); ctlposition(c1, 4, 3, 175); return(false) if !reqpost(); i = getvalue(c1); reqend(); store("RecentMap", VMapNames[i]); info("
Set [ ",VMapNames[i]," ]"); return(i); } checkUVMap: RecentMap { var vmap = VMap(VMTEXTURE); if(vmap == nil){ error("
Not Found UV Map"); return; } VMapNames = nil; while(vmap && vmap.type == VMTEXTURE){ VMapNames += vmap.name; vmap = vmap.next(); } var MapCnt = VMapNames.size(); var ListIdx = 0; for(i = 1; i <= MapCnt; i++){ if(RecentMap == VMapNames[i]){ ListIdx = i; break; } } return(ListIdx); }