morpher floater with rollouts

Greetings, I’ve been trying to do something that should be simple but as with any code it can turn into more than what you expected. Anyway in the maxscript help file there is a great example of how to use progressbars to control the morpher. However I’d like to just use part of the code but I’m having some troubles. The examples uses progress bars and I’d like to use sliders instead and got that working. The problem I’m having is in making it in a floating UI with rollouts. Right now its stuck in a floater UI with no rollouts.

I really just want the code the says “read the modifier with the morpher & build a slider with that” on a rollout in a floating UI.

Anyway in case someone has thoughts here’s the code so far:

(

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 +="slider 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+” changed 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*40)

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

Thanks....

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jdigital's picture

Thanks so much for helping.

Thanks so much for helping. This works wells now.

Thanks for your time!

KaSa's picture

I think I got it. At least

I think I got it. At least it's doing what I think you want. Replace the line:
createDialog (execute txt) 340 (used_channels.count*40)

with this:
new_floater = newrolloutfloater "Morpher Sliders" 340 ((used_channels.count*40) + 40)
addrollout (execute txt) new_floater

If this is the behavior you want, you don't need to declare a global for new_floater at the top.

jdigital's picture

Thanks your replies are

Thanks your replies are helpful. I know that adding the 2 lines of code at the end of a script will create the rollout.

The problem I'm having is once the rollout & floater is created it's "Blank". The slider with the morpher isn't added.

I see your comment about adding it Gloabal so the txt will have access to it. I just gave that a try and didn't seem to work. I'm guessing its becasue I'm not doing it correctly.

So at the top of the script I added this:

global mf_float, mf_morpher_mod, newRolloutFloater

Then at the bottom I added this:

new_floater = newRolloutFloater "Morpher Sliders" 200 200
addRollout mf_main new_floater

Again this is just to test so the names and stuff isn't great. I just copied it from your last post.

When I run the script I get a floater with the slider and then a blank floater with the "rollout". Its close but something is just out of place.

I appreaicate all your help.

Thanks

KaSa's picture

In your globals, change

In your globals, change newRolloutFloater to new_floater. Without looking at the whole thing, it's hard to know what else could be happening. It should be pretty close to working, though.

KaSa's picture

You can create a rollout

You can create a rollout floater, and then use addrollout to add the rollout to the floater. The usual usage is something like:

new_floater = newRolloutFloater "Morpher Sliders" 200 200
addRollout mf_main new_floater

Those two lines are usually at the bottom of the script, after the rollout has been defined. For multiple rollouts, just use addRollout for each one of them.

If you want to have the generated script (txt) add the rollout to a floater that already exists, then you would have to define new_rollout as a global so txt will have access to it.

Or, if you want a UI that has other elements besides rollouts, then you can create another rollout that has a subrollout, and add mf_main to that using addsubrollout.

I hope that helps.

jdigital's picture

thanks for the reply glad

thanks for the reply glad somoene was looking at my post. Yes it does work if you select an object with the morpher applied.

However, the "Dialog" that's created is not a rollout panel. Its a modless dialog thats created on the fly.

I'm looking to have the code work in a floating window with a rollout. That way I can make several rollouts to break up the different morph areas and such.

I hope this makes sense. Maybe its not possible I don't know.

thanks

KaSa's picture

It works for me. Do you have

It works for me. Do you have morph targets assigned in the modifier? The script is looking for used channels, so if there are no targets assigned it will have nothing to loop through, and create a script with no sliders.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.