Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rollout SpringWeight "Spring weight tool" width:300 (
- button c_refresh "Refresh"
- dropdownList c_top_bone "Top bone"
- dropdownList c_bottom_bone "Bottom bone"
- editText c_sides "Sides"
- editText c_topVerticeId "Top vertice ID"
- editText c_bottomVerticeId "Bottom vertice ID"
- button c_start "Set weights"
- button c_cls "close"
- fn BlockUI = (
- c_top_bone.items = #()
- c_bottom_bone.items = #()
- c_top_bone.Enabled = false
- c_bottom_bone.Enabled = false
- c_start.Enabled = false
- c_sides.Enabled = false
- c_topVerticeId.Enabled = false
- c_bottomVerticeId.Enabled = false
- )
- fn UpdateUI = (
- global sk
- if($ == undefined or $.modifiers == undefined) then (
- Messagebox("Please select an object")
- BlockUI()
- ) else (
- if(ClassOf(sk = modpanel.getcurrentobject()) == Skin) then (
- global boneNames = for i=1 to (skinOps.GetNumberBones sk) collect (skinOps.GetBoneName sk i 0)
- c_top_bone.items = boneNames
- c_bottom_bone.items = boneNames
- if(skinOps.GetNumberBones sk >= 2) do (c_top_bone.selection = 2)
- c_top_bone.Enabled = true
- c_bottom_bone.Enabled = true
- c_start.Enabled = true
- c_sides.Enabled = true
- c_topVerticeId.Enabled = true
- c_bottomVerticeId.Enabled = true
- c_sides.text = "6"
- c_topVerticeId.text = "0"
- c_bottomVerticeId.text = (skinops.getnumbervertices(sk) - 1) as string
- ) else (
- Messagebox ("Please add and/or select the skin modifier from modifier list")
- BlockUI()
- )
- )
- )
- on c_cls pressed do (
- removeRollout(SpringWeight)
- DestroyDialog(SpringWeight)
- )
- on c_refresh pressed do (
- UpdateUI()
- )
- on SpringWeight open do (
- UpdateUI()
- )
- on c_start pressed do
- (
- if (sk == undefined or ClassOf(sk = modpanel.getcurrentobject()) != Skin) then (
- UpdateUI()
- ) else (
- if (c_sides.text == "") then (
- Messagebox("Enter number of sides!")
- ) else (
- local skinVerts = skinops.getnumbervertices(sk)
- local topVerticeId = c_topVerticeId.text as integer + 1
- local bottomVerticeId = c_bottomVerticeId.text as integer + 1
- local sides = c_sides.text as integer
- if (bottomVerticeId < topVerticeId) then (
- Messagebox("Not implemented!")
- throw "stop"
- )
- print("topVerticeId: " + (topVerticeId as string))
- print("bvid: " + (bottomVerticeId as string))
- print("sides: " + (sides as string))
- local totalVertices = 1 + bottomVerticeId - topVerticeId
- local steps = (totalVertices / sides) as integer - 1
- print("vnum: " + (totalVertices as string))
- print("steps: " + (steps as string))
- skinOps.SetVertexWeights sk topVerticeId c_top_bone.selection 1.0
- skinOps.SetVertexWeights sk topVerticeId c_bottom_bone.selection 0.0
- skinOps.SetVertexWeights sk bottomVerticeId c_top_bone.selection 0.0
- skinOps.SetVertexWeights sk bottomVerticeId c_bottom_bone.selection 1.0
- for i = 0 to steps do (
- local value = (i as float) / steps
- for j = 0 to sides - 1 do (
- local verticeId = topVerticeId + i*sides + j
- skinOps.SetVertexWeights sk verticeId c_top_bone.selection (1.0 - value)
- skinOps.SetVertexWeights sk verticeId c_bottom_bone.selection value
- )
- )
- print("OK")
- )
- )
- )
- )
- --addRollout SpringWeight
- try(destroyDialog SpringWeight)catch()
- createdialog SpringWeight
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement