--- maxscript: unwrapUImode --- author: andrei kletskov (111) - http://andklv.narod.ru - andklv@mail.ru --- history: --- 2005 - v0.1 - initial version --- 22 march 2007 - v0.2 - new version for max8 -- this script is intended to help you with unwrapping routines -- it drives 3dsmax into UI mode that is more suitable for this task (in my opinion) -- the screen is divided into 2 parts. on the left is maximized uvwunwrap window -- on the right - your viewports. all toolbars are hidden. additional tools panel is displayed. -- this version of script was designed for 1600 screen resolution. you can cuztomize it for your resolution or needs. -- the position and size of UVWunwpar edit window is controlled via configuration file - \3dsmax_root\plugcfg\unwrapuvw.ini -- or via SAVE DEFAULT in unwrap window --- 22 january 2009 - v0.3 - complete rewrite of additional tools panel to cover all functions from the hidden main panel macroScript unwrapUImode_v03 category:"111" toolTip:"111_unwrapUImode_v03" silentErrors:TRUE ( --- start macroscript -------------------------------------------- script -------------------------------------------------------------------- tools_dialog_absolute_screen_position = [606,1095] ------ these are coorfinates of a smoll tools panel underlaying_toolbar_width = 798 ---- width of toolbar added to the left below unwrap window jjj ----- variable for exit button rollout cuv = undefined ---- current unwrap uvw modifier if roll_1 != undefined then jjj.end_mode.changed(false) --- checking rollout undefined else ( roll_1 = undefined -- underlaying tollbar at the left side of screen cur_so_level = undefined -- current sub object level uuu = undefined -- tools palette ----------------------- close button rollout ------------------------ rollout jjj "UV_edit_mode" ------ exit button rollout ( checkbutton end_mode "exit UV edit mode" checked:true height:25 width:100 pos:[0,0] on end_mode changed st do ( if st == false then ( -- cancelling expert mode cui.expertModeOff() --- destroing left toolbar if roll_1 != undefined then ( cui.UnRegisterDialogBar roll_1 destroyDialog roll_1 roll_1 = undefined ) --- closing CLOSE and TOOS dialog DestroyDialog jjj DestroyDialog uuu --- closing UVedit window subObjectLevel = 0 t = $ max select none select t subObjectLevel = cur_so_level ) ) on jjj close do jjj.end_mode.changed(false) ) --- end rollout jjj ------------------ starting script ------------------ if classof (modPanel.getCurrentObject()) == Unwrap_UVW then --- initial check ( ------------ getting unwrap uvw modifier to global cuv = modPanel.getCurrentObject() -- savind SO level cur_so_level = subObjectLevel --- entering expret mode cui.expertModeOn() ---- creating toolbar if roll_1 == undefined then ( rollout roll_1 "temp_screen_filler_toolbar" ( ) createDialog roll_1 width:underlaying_toolbar_width cui.RegisterDialogBar roll_1 style:#(#cui_dock_all,#cui_dock_left) cui.DockDialogBar roll_1 #cui_dock_left ) else ( cui.UnRegisterDialogBar roll_1 destroyDialog roll_1 roll_1 = undefined ) --- end creating toolbar --- opening uvedit window u = modPanel.getCurrentObject() subObjectLevel = 3 u.edit() u.setGridVisible false -- creating CLOSE button dialog CreateDialog jjj pos:[1495,-22] width:100 height:25 ----------------------------------------------------------- ------------------ creating TOOLS dialog -------------- ----------------------------------------------------------- fn tab_show_sel p = () fn tab_show_param p = () fn tab_show_qpm p = () fn tab_show_im p = () fn tab_show_pelt p = () fn tab_show_spline p = () rollout uuu "UV_tools" width:162 height:76 ( --- start tools dialog ------------------ tabs buttons ------------------- checkbutton btn_selection "s." toolTip:"selection tab" height:16 width:19 pos:[0,0] checkbutton btn_param "p." toolTip:"parameters tab" height:16 width:19 pos:[19,0] checkbutton btn_qpm "planar" toolTip:"quick planar map tab" height:16 width:38 pos:[38,0] checkbutton btn_im "inter." toolTip:"interactive mapping tab"height:16 width:38 pos:[76,0] checkbutton btn_pelt "pelt" toolTip:"pelt mapping tab"height:16 width:38 pos:[114,0] checkbutton btn_spline "spline" toolTip:"spline mapping tab"height:16 width:38 pos:[152,0] on btn_selection changed state do ( if state == on then ( tab_show_sel (true) tab_show_param (false) tab_show_qpm (false) tab_show_im (false) tab_show_pelt (false) tab_show_spline (false) ) else tab_show_sel (true) ) on btn_param changed state do ( if state == on then ( tab_show_sel (false) tab_show_param (true) tab_show_qpm (false) tab_show_im (false) tab_show_pelt (false) tab_show_spline (false) ) else tab_show_sel (true) ) on btn_qpm changed state do ( if state == on then ( tab_show_sel (false) tab_show_param (false) tab_show_qpm (true) tab_show_im (false) tab_show_pelt (false) tab_show_spline (false) ) else tab_show_qpm (true) ) on btn_im changed state do ( if state == on then ( tab_show_sel (false) tab_show_param (false) tab_show_qpm (false) tab_show_im (true) tab_show_pelt (false) tab_show_spline (false) ) else tab_show_im (true) ) on btn_pelt changed state do ( if state == on then ( tab_show_sel (false) tab_show_param (false) tab_show_qpm (false) tab_show_im (false) tab_show_spline (false) tab_show_pelt (true) ) else tab_show_pelt (true) ) on btn_spline changed state do ( if state == on then ( tab_show_sel (false) tab_show_param (false) tab_show_qpm (false) tab_show_im (false) tab_show_pelt (false) tab_show_spline (true) ) else tab_show_spline (true) ) -------------------- selection tab ---------------------- button b_sel_grow "+" pos:[1,18] width:16 height:16 ToolTip:"grow selection" button b_del_shrink "-" pos:[18,18] width:16 height:16 ToolTip:"shrink selection" button b_sel_ring "R" pos:[1,36] width:16 height:16 tooltip:"edge ring selection" button b_sel_loop "L" pos:[18,36] width:16 height:16 tooltip:"edge loop selection" checkbox chb_sel_ignore_bf "Ignore BF" pos:[38,18] checked:false checkbox chb_sel_by_element "By Element" checked:false pos:[38,36] checkbox chb_sel_planar_angle "Planar Angle" checked:false pos:[38,54] width:80 spinner s_sel_planar_angle "" pos:[120,54] width:50 range:[0,180,15] type:#float enabled:false button b_sel_matid "MatID" pos:[115,18] width:35 height:16 tooltip:"select MatID" spinner s_sel_matid "" pos:[150,18] width:40 type:#integer range:[1,255,1] button b_sel_sg "SG" pos:[115,36] width:35 height:16 tooltip:"select smoothing group" spinner s_sel_sg "" pos:[150,36] width:40 type:#integer range:[1,32,1] on b_sel_matid pressed do ( try (cuv.unwrap2.selectByMatID s_sel_matid.value) catch (messagebox"error!") ) on b_sel_sg pressed do ( try (cuv.unwrap2.selectBySG s_sel_sg.value) catch (messagebox"error!") ) on b_sel_grow pressed do ( try ( if subObjectLevel == 1 then cuv.unwrap5.expandGeomVertexSelection () if subObjectLevel == 2 then cuv.unwrap5.expandGeomEdgeSelection () if subObjectLevel == 3 then cuv.unwrap2.expandGeomFaceSelection () ) catch (messagebox"error!") ) on b_del_shrink pressed do ( try ( if subObjectLevel == 1 then cuv.unwrap5.contractGeomVertexSelection () if subObjectLevel == 2 then cuv.unwrap5.contractGeomEdgeSelection () if subObjectLevel == 3 then cuv.unwrap2.contractGeomFaceSelection () ) catch (messagebox"error!") ) on b_sel_ring pressed do ( try(cuv.unwrap5.geomEdgeRingSelection ()) catch(messagebox"error!") ) on b_sel_loop pressed do ( try(cuv.unwrap5.geomEdgeLoopSelection ()) catch(messagebox"error!") ) on chb_sel_ignore_bf changed state do ( try (cuv.unwrap2.setIgnoreBackFaceCull state) catch (messagebox"error!") ) on chb_sel_by_element changed state do ( try (cuv.unwrap2.setGeomSelectElementMode state) catch (messagebox"error!") ) on chb_sel_planar_angle changed state do ( s_sel_planar_angle.enabled = state try (cuv.unwrap2.setGeomPlanarThresholdMode state) catch (messagebox"error!") ) on s_sel_planar_angle changed val do ( try (cuv.unwrap2.setGeomPlanarThreshold val) catch (messagebox"error!") ) ------------------------ parameters tab ----------------- button b_param_reset "Reset UVWs" pos:[1,18] height:18 width:80 button b_param_save "Save..." pos: [1, 38] height:16 width:40 button b_param_load "Load..." pos: [41, 38] height:16 width:40 radiobuttons rb_param_channel "" labels:#("Map Chan.","Vertex Color Chan.") columns:1 default:1 pos:[84,18] spinner s_param_channel "" pos:[154,18] width:36 range:[1,99,1] type:#integer checkbox chb_param_seam "s" tooltip:"Show Seam" pos:[1,56] checked:false checkbox chb_param_mapseam "ms" tooltip:"Show Map Seam" pos:[30,56] checked:false checkbox chb_param_thickseam "thick" tooltip:"Thick Seam Display" pos:[69,56] checked:true checkbox chb_param_prevent "xr" tooltip:"Prevent Reflatenning" pos:[116,56] checked:false checkbox chb_param_normalize "nmlz" tooltip:"Normalize Map" pos:[150,56] checked:true on chb_param_prevent changed state do ( try (cuv.unwrap2.setPreventFlattening state) catch (messagebox"error!") ) on chb_param_normalize changed state do ( try (cuv.unwrap5.setNormalizeMap state) catch (messagebox"error!") ) on chb_param_seam changed state do ( try (cuv.unwrap5.setPeltAlwaysShowSeams state) catch (messagebox"error!") ) on chb_param_mapseam changed state do ( try (cuv.unwrap5.setShowMapSeams state) catch (messagebox"error!") ) on chb_param_thickseam changed state do ( try (cuv.unwrap4.setThickOpenEdges state) catch (messagebox"error!") ) on b_param_reset pressed do ( try (cuv.unwrap.reset ()) catch(messagebox"error!") ) on b_param_save pressed do ( try(cuv.unwrap.save ()) catch(messagebox"error!") ) on b_param_load pressed do ( try(cuv.unwrap.load ()) catch(messagebox"error!") ) on s_param_channel changed arg do ( try ( if arg == 1 then arg = 0 cuv.unwrap.setMapChannel arg ) catch(messagebox"error!") ) on rb_param_channel changed arg do ( try ( if arg == 2 then ( cuv.unwrap.setVC on ) else ( cuv.unwrap.setVC off ) ) catch (messagebox"error!") ) -------------------- quick planar mapping tab ---------------------- checkbox chbx_qpm_preview_gizmo "Preview Gizmo" pos:[90,18] checked:true radiobuttons rb_qpm "" labels:#("X", "Y", "Z", "Av.", "Sc.") default:4 columns:2 width:100 pos:[5, 20] button b_qpm_planar "Quick Planar Map" pos:[83,34] width:107 height:36 on chbx_qpm_preview_gizmo changed state do ( try (cuv.unwrap5.setQuickMapGizmoPreview state) catch (messagebox"error!") ) on rb_qpm changed state do ( if state == 5 then ( ) else ( try (cuv.unwrap.setProjectionType state) catch(messagebox"error!") ) ) on b_qpm_planar pressed do ( if rb_qpm.state == 5 then ( try ( cuv.unwrap5.mappingMode 1 cuv.unwrap5.setGizmoTM (inverse (viewport.GetTM())) cuv.unwrap5.mappingFit () cuv.unwrap5.mappingMode 0 ) catch (messagebox"error!") ) else ( try (cuv.unwrap5.quickPlanarMap ()) catch(messagebox"error!") ) ) --------------------- interactive mapping tab --------------- checkbutton cb_inter_planar "Planar" pos:[1,18] height:18 width:47 checkbutton cb_inter_cylindrical "Cylindrical" pos:[48,18] height:18 width:48 checkbutton cb_inter_spherical "Spherical" pos:[96,18] height:18 width:47 checkbutton cb_inter_box "Box" pos:[143,18] height:18 width:47 on cb_inter_planar changed state do ( cb_inter_cylindrical.checked = cb_inter_spherical.checked = cb_inter_box.checked = false try (if state == true then (cuv.unwrap5.mappingMode 1) else (cuv.unwrap5.mappingMode 0)) catch (messagebox"error!") ) on cb_inter_cylindrical changed state do ( cb_inter_planar.checked = cb_inter_spherical.checked = cb_inter_box.checked = false try (if state == true then (cuv.unwrap5.mappingMode 2) else (cuv.unwrap5.mappingMode 0)) catch (messagebox"error!") ) on cb_inter_spherical changed state do ( cb_inter_planar.checked = cb_inter_cylindrical.checked = cb_inter_box.checked = false try (if state == true then (cuv.unwrap5.mappingMode 3) else (cuv.unwrap5.mappingMode 0)) catch (messagebox"error!") ) on cb_inter_box changed state do ( cb_inter_planar.checked = cb_inter_cylindrical.checked = cb_inter_spherical.checked = false try (if state == true then (cuv.unwrap5.mappingMode 4) else (cuv.unwrap5.mappingMode 0)) catch (messagebox"error!") ) button cb_inter_alignx "X" pos:[1,39] height:16 width:47 button cb_inter_aligny "Y" pos:[48,39] height:16 width:48 button cb_inter_alignz "Z" pos:[96,39] height:16 width:47 button cb_inter_bestalign "Best" pos:[143,39] height:16 width:47 button cb_inter_fit "Fit" pos:[1,55] height:16 width:47 button cb_inter_alignv "View" pos:[48,55] height:16 width:48 button cb_inter_center "Center" pos:[96,55] height:16 width:47 button cb_inter_reset "Reset" pos:[143,55] height:16 width:47 on cb_inter_alignx pressed do try (cuv.unwrap5.mappingAlign 0) catch (messagebox"error!") on cb_inter_aligny pressed do try (cuv.unwrap5.mappingAlign 1) catch (messagebox"error!") on cb_inter_alignz pressed do try (cuv.unwrap5.mappingAlign 2) catch (messagebox"error!") on cb_inter_bestalign pressed do try (cuv.unwrap5.mappingAlign 3) catch (messagebox"error!") on cb_inter_fit pressed do try (cuv.unwrap5.mappingFit ()) catch (messagebox"error!") on cb_inter_center pressed do try (cuv.unwrap5.mappingCenter ()) catch (messagebox"error!") on cb_inter_reset pressed do try (cuv.unwrap5.mappingReset ()) catch (messagebox"error!") on cb_inter_alignv pressed do ( try ( cuv.unwrap5.setGizmoTM (inverse (viewport.GetTM())) cuv.unwrap5.mappingFit () ) catch (messagebox"error!") ) -------------------pelt mapping tab ---------------- button b_pelt_pelt "Pelt" pos:[130,19] width:60 height:50 checkbutton b_pelt_edit_seams "Edit Seams" height:14 width:122 pos:[5,16] checkbutton b_pelt_pp_seam "Point To Point Seam" height:14 width:122 pos:[5,30] button b_pelt_edge_seam "Edge Sel To Seams" height:14 width:122 pos:[5,44] button b_pelt_exp_face "Exp. Face Sel To Seams" height:14 width:122 pos:[5,58] on b_pelt_edit_seams changed state do ( b_pelt_pp_seam.checked = false try (cuv.unwrap5.setPeltPointToPointSeamsMode false) catch () try (cuv.unwrap5.setPeltEditSeamsMode state) catch (messagebox"error!") ) on b_pelt_pp_seam changed state do ( b_pelt_edit_seams.checked = false try (cuv.unwrap5.setPeltEditSeamsMode false) catch () try (cuv.unwrap5.setPeltPointToPointSeamsMode state) catch (messagebox"error!") ) on b_pelt_pelt pressed do ( try (cuv.unwrap5.mappingMode 5) catch (messagebox"error!") ) on b_pelt_edge_seam pressed do ( try(cuv.unwrap5.peltEdgeSelToSeam off) catch (messagebox"error!") ) on b_pelt_exp_face pressed do ( try (cuv.unwrap5.peltExpandSelectionToSeams ()) catch (messagebox"error!") ) ----------------------- spline mapping tab ------------------ button b_spline_spline "Spline" pos:[130,19] width:60 height:50 on b_spline_spline pressed do ( try (cuv.unwrap5.mappingMode 6) catch (messagebox"error!") ) ) --- end tools dialg ------------------------------ functions for hiding-showing buttons ------------- selection tab fn tab_show_sel p = ( uuu.btn_selection.checked = p uuu.b_sel_grow.visible = uuu.b_del_shrink.visible = uuu.b_sel_ring.visible = p uuu.b_sel_loop.visible = uuu.chb_sel_ignore_bf.visible = uuu.chb_sel_by_element.visible = p uuu.chb_sel_planar_angle.visible = uuu.s_sel_planar_angle.visible = uuu.b_sel_matid.visible = p uuu.s_sel_matid.visible = uuu.b_sel_sg.visible = uuu.s_sel_sg.visible = p ) ------------- parameters tab fn tab_show_param p = ( uuu.btn_param.checked = p uuu.b_param_reset.visible = uuu.b_param_save.visible = uuu.b_param_load.visible = p uuu.rb_param_channel.visible = uuu.s_param_channel.visible = uuu.chb_param_seam.visible = p uuu.chb_param_mapseam.visible = uuu.chb_param_thickseam.visible = uuu.chb_param_prevent.visible = p uuu.chb_param_normalize.visible = p ) -------------- quick planar map tab fn tab_show_qpm p = ( uuu.btn_qpm.checked = p uuu.chbx_qpm_preview_gizmo.visible = uuu.rb_qpm.visible = uuu.b_qpm_planar.visible = p ) -------------- interactive mapping tab fn tab_show_im p = ( uuu.btn_im.checked = p uuu.cb_inter_planar.visible = uuu.cb_inter_cylindrical.visible = uuu.cb_inter_spherical.visible = p uuu.cb_inter_box.visible = uuu.cb_inter_alignx.visible = uuu.cb_inter_aligny.visible = p uuu.cb_inter_alignz.visible = uuu.cb_inter_bestalign.visible = uuu.cb_inter_fit.visible = p uuu.cb_inter_alignv.visible = uuu.cb_inter_center.visible = uuu.cb_inter_reset.visible = p ) -------------- pelt mapping tab fn tab_show_pelt p = ( uuu.btn_pelt.checked = p uuu.b_pelt_pelt.visible = uuu.b_pelt_edit_seams.visible = uuu.b_pelt_pp_seam.visible = uuu.b_pelt_edge_seam.visible = uuu.b_pelt_exp_face.visible = p ) -------------- spline mapping tab fn tab_show_spline p = ( uuu.btn_spline.checked = p uuu.b_spline_spline.visible = uuu.b_pelt_edit_seams.visible = uuu.b_pelt_pp_seam.visible = uuu.b_pelt_edge_seam.visible = uuu.b_pelt_exp_face.visible = p ) ----------------- creating dialog CreateDialog uuu pos:tools_dialog_absolute_screen_position width:191 height:200 style:#(#style_border) tab_show_sel (false) tab_show_param (false) tab_show_qpm (true) tab_show_im (false) tab_show_pelt (false) tab_show_spline (false) uuu.chb_sel_ignore_bf.changed(false) try (uuu.s_param_channel.value = cuv.unwrap.getMapChannel() as integer) catch() uuu.chb_param_seam.changed (false) uuu.chb_param_mapseam.changed (false) ) ---- end initial check else messagebox "select unwrap UVW modifier in the stack!" ) --- end checking rollout undefined ) --- end macroscript