macroScript Mapper category:"Keffer Tools" tooltip:"Mapper" buttontext:"Mapper" ( global TotalPverts = 0, Uarray=#(), Varray=#(), Umultiplier = 0 Vmultiplier = 0 rollout Mapper "Apply Mapping" ( Group "Geometry Settings" ( radiobuttons geotype "geometry type" labels:#("Patch", "Mesh") default:1 columns:2 spinner HPatch "H edges" type:#integer range:[1,1000,1] align:#right spinner VPatch "V edges" type:#integer range:[1,1000,1] align:#right ) Group "Map Settings" ( spinner MChannel "Map Channel" type:#integer range:[1,100,1] width:100 align:#right ) Group "Tile Settings" ( radiobuttons maptype "Mapping Type" labels:#("Standard", "Noramalize") default:1 spinner UTile "U" type:#float scale:0.1 range:[0,100,1] width:50 align:#left across:2 --checkbox flipU "flip" align:#right spinner VTile "V" type:#float scale:0.1 range:[0,100,1] width: 50 align:#right --checkbox flipV "flip" align:#right ) Group "Offset Settings" ( spinner UOffset "U" type:#float scale:0.1 range:[0,100,0] width:50 align:#left across:2 spinner VOffset "V" type:#float scale:0.1 range:[0,100,0] width: 50 align:#left ) button MapPatch "Texture IT" width:120 height:20 button UndoMap "Undo" width:120 height:20 --button ReadIn "Read in UV's" width:120 height:20 button CheckUV "Check UV's" width:120 height:20 ----------------------------------------------------- ------------------------------------------------------ on Vpatch changed value do ( if $ != undefined do ( TotalPVerts = patch.getnumverts $ Hpatch.value = TotalPVerts / Vpatch.value ) ) ------------------------------------------------------ on Hpatch changed value do ( if $ != undefined do ( TotalPVerts = patch.getnumverts $ Vpatch.value = TotalPVerts / Hpatch.value ) ) ----------------------------------------------------- on readin pressed do ( if $ != undefined then ( MapPatch.enabled = true Uarray = #() Varray = #() NewUarray = #() NewVarray = #() TotalPatches = patch.getnumpatches $ TotalPVerts = patch.getnumverts $ for i = 1 to TotalPverts do --- store UV's ( Svert = patch.getmapvert $ 1 i append Uarray svert[1] append Varray svert[2] --append Warray svert[3] )--end for i if amax Uarray > 1 then ( UTile.value = (Uarray[2]) Hpatch.value = (amax Uarray / Uarray[2]) + 1 Vpatch.value = TotalPVerts/Hpatch.value VTile.value = Varray[(Hpatch.value + 1)] ) else ( UTile.value = (Uarray[2]) Hpatch.value = (amax Uarray / Uarray[2]) + 2 Vpatch.value = TotalPVerts/Hpatch.value VTile.value = Varray[(Hpatch.value + 1)] ) )-- end if undefined else ( MapPatch.enabled = false ) )--end on readin pressed ------------------------------------------------------ on MapPatch pressed do ( if $ != undefined do ( modPanel.addModToSelection (Uvwmap ()) ui:on $.modifiers[#UVW_Mapping].mapChannel = MChannel.value $.modifiers[#UVW_Mapping].maptype = 6 macros.run "Modifier Stack" "Convert_to_Patch" TotalPatches = patch.getnumpatches $ TotalPVerts = patch.getnumverts $ if TotalPatches < TotalPverts then ( Type = TotalPatches )--end if totalpatches else ( Type = TotalPverts )--end else for i = 1 to Type do ( patch.setmappatch $ MChannel.value i (patch.getmappatch $ 1 i)--detaches handles in uv map )--end for i modPanel.addModToSelection (Unwrap_UVW ()) ui:on modPanel.addModToSelection (Unwrap_UVW ()) ui:on macros.run "Modifier Stack" "Convert_to_Patch" patch.update $ for v = 0 to (TotalPVerts - hpatch.value) by hpatch.value do ( for u = 1 to hpatch.value do ( if maptype.state == 1 then ( patch.setmapvert $ MChannel.value (v + u) [(( u - 1)* Utile.value) / (hpatch.value - 1) + Uoffset.value, ((v/hpatch.value) * Vtile.value) / (vpatch.value - 1) + Voffset.value, 0] ) else ( patch.setmapvert $ MChannel.value (v + u) [(( u - 1)* Utile.value) + Uoffset.value, ((v/hpatch.value) * Vtile.value) + Voffset.value, 0] ) )--end for u )--end for v patch.update $ )--- end if undefined )--end on pressed MapPatch ----------------------------------------------------------------------- ----------------------------------------------------------------------- on UndoMap pressed do ( TotalPVerts = patch.getnumverts $ for x = 1 to TotalPverts do ( patch.setmapvert $ MChannel.value x [Uarray[x], Varray[x], 0] ) patch.update $ if amax Uarray > 1 then ( --UTile.value = (Uarray[2] - (amin Uarray)) UTile.value = (Uarray[2]) Hpatch.value = (amax Uarray / Uarray[2]) + 1 VTile.value = (amax Varray / (Hpatch.value - 1)) ) else ( --UTile.value = (Uarray[2] - (amin Uarray)) UTile.value = (Uarray[2]) Hpatch.value = (amax Uarray / Uarray[2]) + 2 VTile.value = (amax Varray / (Hpatch.value - 1)) ) ) -------------------------------------------------------------------------- -------------------------------------------------------------------------- on checkuv pressed do ( modPanel.addModToSelection (Unwrap_UVW ()) ui:on $.modifiers[#unwrap_uvw].unwrap.move () $.modifiers[#unwrap_uvw].unwrap.edit () $.modifiers[#unwrap_uvw].unwrap.fit () ) )--end of Mapper rollout ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ rollout Edit_Mapper "Edit UV's" ( Button Read_UV "Read in UV's" spinner EditChannel "Channel" type:#integer range:[1,99,1] width: 100 align:#cen Group "Edit Tiling" ( spinner EditUTile "U" type:#float scale:0.1 range:[0,100,1] width:50 align:#left across:2 spinner EditVTile "V" type:#float scale:0.1 range:[0,100,1] width: 50 align:#right button ChangeTile "change tiling" enabled:false ) Group "Offset" ( spinner EditUOffset "U" type:#float scale:0.1 range:[-100,100,0] width:50 align:#left across:2 spinner EditVOffset "V" type:#float scale:0.1 range:[-100,100,0] width: 50 align:#left button ChangeOffset "change offset" enabled:false ) Group "Flipping / Rotation" ( button FlipU "Flip U" across:2 enabled:false button FlipV "Flip V" enabled:false spinner EditURot "U rotation" type:#integer scale:90 range:[-180,180,0] width:100 align:#cen enabled:false spinner EditVRot "V rotation" type:#integer scale:90 range:[-180,180,0] width:100 align:#cen enabled:false ) Group "Copy/Paste" ( button copyUV "Copy" across: 2 enabled:false button pasteUV "Paste" enabled:false ) Group "overlaping UV's" ( button checkoverlap "check for overlaping UV's" spinner overlapUV "#'s overlap" type:#integer range:[0,1000,0] ) -------------------------------------------------------------------------------------------------------- on read_UV pressed do ( Uarray=#() Varray=#() if $ != undefined do ( TotalPatches = patch.getnumpatches $ TotalPVerts = patch.getnummapverts $ editchannel.value for i = 1 to TotalPverts do --- store UV's ( Svert = patch.getmapvert $ 1 i append Uarray svert[1] append Varray svert[2] )--end for i )--end if != startU = Uarray[1] endU = Uarray[2] startV = Varray[TotalPverts-1] endV = Varray[TotalPverts] EditUtile.enabled = true EditVtile.enabled = true EditUoffset.enabled = true EditVoffset.enabled = true FlipU.enabled = true FlipV.enabled = true EditUrot.enabled = true EditVrot.enabled = true copyUV.enabled = true pasteUV.enabled = true changetile.enabled = true changeoffset.enabled = true )--end read_UV pressed --------------------------------------------------------------------------------------------------------- on Changetile pressed do ( if $ != undefined do ( for CT = 1 to TotalPVerts do ( patch.setmapvert $ EditChannel.value CT [Uarray[CT] * EditUtile.value, Varray[CT] * EditVtile.value,0] ) patch.Update $ ) ) --------------------------------------------------------------------------------------------------------------------------------------------------- on ChangeOffset pressed do ( if $ != undefined do ( for CO = 1 to TotalPVerts do ( patch.setmapvert $ EditChannel.value CO [Uarray[CO] + EditUoffset.value, Varray[CO] + EditVOffset.value, 0] ) patch.Update $ ) ) -------------------------------------------------------------------------------------------------------------------- on copyUV pressed do ( selected = patch.getselectedpatch ) --------------------------------------------------------------------------------------------------------- )-- end of Edit_Mapper rollout MappingTools = newRolloutFloater "Mapping Tools" 160 460 addRollout Mapper MappingTools addRollout Edit_Mapper MappingTools rolledup:true )