/* LookAt is a script for "aiming" objects at other objects via the Look-At controller. It is designed to work with multiple objects and can modify the Look-At settings as well as remove the controller, returning it to its original state.
Author: Chris Harvey */
--2011.7.14 盖天注解
try (cui.unregisterDialogBar Aim) catch() try (closeRolloutFloater Aim) catch()
rollout Look "LookAt Set-up" ( --有哟按教程 在这里打开 --这里的解释就是相当于加入控制器 加入约束 -- 快速的做约束是很好。 button HowTo_btn "Instructions" width:63 height:55 pos:[5,13] groupbox target_grp "Target Object" width:150 height:62 pos:[75,7] button Pick_btn "Pick" width:140 height:20 pos:[80,23] editText Pick_edt "" width:140 height:18 pos:[78,45] button Execute_btn "Add LookAt" width:210 height:25 pos:[10,75] button Remove_btn "Remove LookAt" width:210 height:25 pos:[10,103] button Off_btn "LookAt Off" width:103 height:21 pos:[10,130] button On_btn "LookAt On" width:103 height:21 pos:[117,130]
on HowTo_btn pressed do ( --点开之后的对话框 rollout rHOWpage "Aim Instructions" ( local htmlpath = getDir #scripts + "\\Harvey\\Help\\Aim_Help.html" local size = [700,1140] activeXControl name_ax "http:\\www.relic.com" width:(size.x-30) height:(size.y-45) align:#center on rHOWpage open do ( name_ax.Navigate2 htmlpath ) ) fHOWPage = newRolloutFloater "Aim Instructions" rHOWpage.size.x 800 addRollout rHOWPage fHOWPage rolledUp: false ) on Pick_btn pressed do ( global targetOBJ = pickobject() Pick_edt.text = targetOBJ.name ) on Execute_btn pressed do with undo label: "Look-At" on ( max motion mode
for foo in $ do ( foo.rotation.controller = rotation_list () ) for foo in $ do ( foo.rotation.controller.Available.controller = LookAt_Constraint () ) for foo in $ do ( foo.rotation.controller.LookAt_Constraint.controller.relative = on foo.rotation.controller.LookAt_Constraint.controller.viewline_length_abs = off foo.rotation.controller.LookAt_Constraint.controller.lookat_vector_length = 0 foo.rotation.controller.LookAt_Constraint.AppendTarget targetOBJ 50 ) for foo in $ do ( foo.rotation.controller.Available.controller = Euler_XYZ () ) for foo in $ do ( listctrl.setname foo.rotation.controller 1 "Base" listctrl.setname foo.rotation.controller 3 "Manual" ) undo off for foo in $ do ( foo.rotation.controller.setactive 3 )
max create mode ) on Remove_btn pressed do with undo label: "Remove LookAt" on ( for foo in $ do ( orig = copy foo.rotation.controller[1] foo.rotation.controller = orig ) ) on Off_btn pressed do with undo off ( for foo in $ do ( foo.rotation.controller.weight[2] = 0 ) ) on On_btn pressed do with undo off ( for foo in $ do ( foo.rotation.controller.weight[2] = 100 ) ) )
rollout AimModifier "Modify LookAt" ( --用图片做的按钮的背景 -- 还有就是用按钮做分割 效果也是很好。 ---这个相当于把注释越是的东西哪了出来 ---在ui上画的很长 做的很漂亮、 --我在分类上也是可是这样做的 --其实要是为了跟好卡 就做 imgTag 这个控件 group "Modifiy Aim" ( button Line_btn1 "" width:2 height:205 pos:[45,20] checkbutton rel_CHK "" width:35 height:12 pos:[7,175] --images:#(GetDir #maxroot + "\\scripts\\Harvey\\Icons\\CheckIcons.bmp", GetDir #maxroot + "\\scripts\\Harvey\\Icons\\CheckIcons.bmp", 3, 1, 3, 1, 3) checkbox Relative_chk "Keep Initial Offset" pos:[80,25] button Line_btn2 "" width:182 height:2 pos:[45,45] checkbutton look_CHK "" width:35 height:12 pos:[7,65] -- images:#(GetDir #maxroot + "\\scripts\\Harvey\\Icons\\CheckIcons.bmp", GetDir #maxroot + "\\scripts\\Harvey\\Icons\\CheckIcons.bmp", 3, 1, 3, 1, 3) radioButtons Look_rdo "Select LookAt Axis" pos:[70,55] labels:#("X", "Y", "Z") default: 3 checkbox Flip_chk "Flip" pos:[170,70] button Line_btn3 "" width:182 height:2 pos:[45,90] checkbutton Ucontrol_CHK "" width:35 height:12 pos:[7,110] -- images:#(GetDir #maxroot + "\\scripts\\Harvey\\Icons\\CheckIcons.bmp", GetDir #maxroot + "\\scripts\\Harvey\\Icons\\CheckIcons.bmp", 3, 1, 3, 1, 3) radioButtons Ucontrol_rdo "Upnode Control" pos:[70,100] labels:#("LookAt", "Axis Alignment") default: 2 button Line_btn4 "" width:182 height:2 pos:[45,135]
checkbutton Source_CHK "" width:35 height:12 pos:[7,155] --images:#(GetDir #maxroot + "\\scripts\\Harvey\\Icons\\CheckIcons.bmp", GetDir #maxroot + "\\scripts\\Harvey\\Icons\\CheckIcons.bmp", 3, 1, 3, 1, 3) radioButtons Source_rdo "Source Axis" pos:[70,145] labels:#("X", "Y", "Z") default: 2 checkbox FlipS_chk "Flip" pos:[170,160] button Line_btn5 "" width:182 height:2 pos:[45,180]
checkbutton Uaxis_CHK "" width:35 height:12 pos:[7,200] --images:#(GetDir #maxroot + "\\scripts\\Harvey\\Icons\\CheckIcons.bmp", GetDir #maxroot + "\\scripts\\Harvey\\Icons\\CheckIcons.bmp", 3, 1, 3, 1, 3) radioButtons Uaxis_rdo "Aligned to Upnode Axis" pos:[70,190] labels:#("X", "Y", "Z") default: 3 button Line_btn6 "" width:182 height:2 pos:[45,225] button None_btn "Check None" width:105 height:25 pos:[10,235] button All_btn "Check All" width:105 height:25 pos:[117,235] button Modify_btn "Modify Selected" width:212 height:25 pos:[10,265] ) on None_btn pressed do with undo off ( rel_CHK.state = false look_CHK.state = false Ucontrol_CHK.state = false Source_CHK.state = false Uaxis_CHK.state = false ) on All_btn pressed do with undo off ( rel_CHK.state = true look_CHK.state = true Ucontrol_CHK.state = true Source_CHK.state = true Uaxis_CHK.state = true ) on Modify_btn pressed do with undo label: "Modify Aim" on ( if rel_CHK.state == true then for foo in $ do ( foo.rotation.controller.LookAt_Constraint.controller.relative = Relative_chk.state ) if look_CHK.state == true then for foo in $ do ( foo.rotation.controller.LookAt_Constraint.controller.target_axis = ((Look_rdo.state as integer)-1) foo.rotation.controller.LookAt_Constraint.controller.target_axisFlip = Flip_chk.state ) if Ucontrol_CHK.state == true then for foo in $ do ( foo.rotation.controller.LookAt_Constraint.controller.upnode_ctrl = ((Ucontrol_rdo.state as integer)-1) ) if Source_CHK.state == true then for foo in $ do ( foo.rotation.controller.LookAt_Constraint.controller.StoUP_axis = ((Source_rdo.state as integer)-1) foo.rotation.controller.LookAt_Constraint.controller.StoUP_axisFlip = FlipS_chk.state ) if Uaxis_CHK.state == true then for foo in $ do ( foo.rotation.controller.LookAt_Constraint.controller.upnode_axis = ((Uaxis_rdo.state as integer)-1) ) ) )
Aim = NewRolloutFloater "Aim" 245 515 addRollout Look Aim addRollout AimModifier Aim