ScriptSpot

Forum topic · General Scripting

Controlling Morphs with spinners

By A_Mc · 2010-04-21

Description

Hi

I'm totally new to MaxScript and have been trying to work my way through the tutorials in the help files and playing around with them as I go. The Morph Controller is quite an interesting one as I'm doing a set of morph targets for some animation that I have to do and I thought using that in a UI would be awesome, however the slider/progress bar is a bit rubbish at being exact and so I've been trying to change this to a spinner but having no luck with it... does anyone have any ideas?

Thanks

Here's the tutorial code


macroscript MorpherFloater category:"HowTo"

(

global mf_float, mf_morpher_mod

on isEnabled return

selection.count == 1 and (try($.morpher)catch(undefined)) != undefined

on execute do

(

mf_morpher_mod = $.modifiers[#morpher]

used_channels = #()

txt ="rollout mf_main \"Morpher Floater\" (\n"

for i = 1 to 100 do

(

if WM3_MC_HasData mf_morpher_mod i then

(

append used_channels i

txt +="progressbar mf_slider_"+ i as string

txt +=" value:"+ (WM3_MC_GetValue mf_morpher_mod i) as string

txt +=" width:150 height:18 across:2 align:#left\n"

txt +="edittext mf_label_"+i as string

txt +=" align:#right text:\""+i as string+": "

txt +=(WM3_MC_GetName mf_morpher_mod i) +"\"\n"

txt +="on mf_slider_"+i as string+" clicked val do (\n"

txt +="WM3_MC_SetValue mf_morpher_mod "

txt += i as string+" (val as float) \n"

txt +="SliderTime +=0)\n"

)

)--end i loop

txt +=")\n"

createDialog (execute txt) 340 (used_channels.count*24)

txt ="fn mf_update_slider = (\n"

for i in used_channels do

(

txt +="mf_main.mf_slider_"+i as string

txt +=".value = WM3_MC_GetValue mf_morpher_mod "+i as string+" \n"

)--end i loop

txt +=")\n"

global mf_update_slider = execute txt

registertimecallback mf_update_slider

deleteAllChangeHandlers id:#morpher_floater

when parameters mf_morpher_mod changes \

HandleAt:#RedrawViews \

id:#morpher_floater do mf_update_slider()

)--end if

)--end script

Comments (2)

A_Mc · 2010-04-22

As it turns out the spinner is actually connected to the morph targets, however only one way i.e. when the morpher value is changed in the toolbar it changes the values in the script UI, however when the spinners in the script UI are moved the morpher isn't affected in the slightest...

If there is any other info I need to supply let me know

Cheers

A_Mc · 2010-04-21

I have managed to replace the bars with spinners, literally changing the progress bar part to spinner, but this breaks the control connection to the morpher. If possible i'd like the ability to update the spinner, as the slider does when the animation bar is scrubbed

Cheers