modifying / adding-destroying rollouts?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
Old 02 February 2009   #1
modifying / adding-destroying rollouts?

hello there,

I'm coding a script to have a custom shader to export to my game and there's something I need to do but can't.

what I want is to be able to hide/show rollouts based on a dropdown box selection. I need to have different parameters depending on the shader type (very much like what happens if you change from Blinn to anything else in the shader type)
the problem is that since it's a material plugin it only expects Plugin clauses which prevents me from using if/else or addRollout/removeRollout to get this done.

I'm basing my script on this tutorial:

here's the code of the script:
--------------------------------------------------------- -- Plugin declaration plugin material Elium_Material name: "Elium Material" classID:#(0x82b4cdc2, 0x4f77873e) extends:Standard replaceUI:true ( -- Interface design params parameters main rollout:params ( -- Parameters definition and interface linking Shadertype type:#integer default:1 ui:eshad -- Interface action management --on Shadertype selected i do = eshad.items[i] on Shadertype set i do = i as string ) parameters main2 rollout:shaderparams ( -- Parameters definition and interface linking Color_Dif type:#color default:[128,128,128] ui:col_dif Color_Amb type:#color default:[0,0,0] ui:col_amb -- Interface action management on Color_Dif set val do delegate.diffuse = val on Color_Amb set val do delegate.selfIllumColor = val ) -- Rollout and buttons definition rollout params "Elium Material" ( group "General Settings" ( dropdownlist eshad "Shader" items:#("static", "static_spec", "tree") width:150 ) ) rollout shaderparams "Shader Parameters" ( group "Shader Parameters" ( colorpicker col_dif "Diffuse Color:" align:#left offset:[0,0] visible:true colorpicker col_amb "Ambient Color:" align:#left offset:[0,0] enabled:true ) ) -- Shader creation in the material editor on create do ( -- Shader type definition and parameters delegate.useSelfIllumColor = true delegate.filterMap = BitMapTexture() = "name" ) )

Old 02 February 2009   #2
you might be able to use subRollouts? can't say I've tried, but that should give you a control in which you can add/remove other rollouts. Won't fit exactly with the rest of the medit UI and workflow, but...

Otherwise, maybe you can just collapse/expand the rollouts as required and/or disable/enable the controls within (for c in <rollout>.controls do ( c.enabled = <boolean> -- make sure you don't enable controls that shouldn't be ))

Edit: sample code for the former... (ick)
global currentElium = undefined rollout roll_test "test" ( label lbl_test "test" button btn_test "press me to get current elium" on btn_test pressed do ( if (currentElium != undefined) do ( lbl_test.text = currentElium as string ) ) ) plugin material Elium_Material name: "Elium Material" classID:#(0x82b4cdc2, 0x4f77873e) extends:Standard replaceUI:true ( parameters main rollout:params ( ) rollout params "Elium Material" ( checkbutton ckb_showroll "show rollout" subrollout sub_rollouts "sub_rollouts" height:300 on params open do ( currentElium = this ) on params reload do ( currentElium = this ) on ckb_showroll changed state do ( if (state) then ( addSubRollout sub_rollouts roll_test ) else ( removeSubRollout sub_rollouts roll_test ) ) ) )

Edit2: And the latter
plugin material Elium_Material name: "Elium Material" classID:#(0x82b4cdc2, 0x4f77873e) extends:Standard replaceUI:true ( parameters main rollout:params ( ) rollout params "Elium Material" ( checkbutton ckb_showroll "show rollout" on ckb_showroll changed state do ( if (state) then ( this.roll_test.height = 300 this.roll_test.title = "Some other parameters" = true ) else ( = false this.roll_test.title = "-- disabled --" this.roll_test.height = 0 ) ) ) rollout roll_test "-- disabled --" rolledup:true height:0 ( label lbl_tadaa "ta-daaaaaa" on roll_test rolledup state do ( if ((state) AND (roll_test.title == "-- disabled --")) then ( = false ) ) ) )

Last edited by ZeBoxx2 : 02 February 2009 at 09:46 PM.
Old 02 February 2009   #3
hey thanks for the fast reply!

I tried the former but it didn't work because "parameters main2" requires that the rollout on which it will operate, already exists
so I tried the latter and that one did work. however instead of creating multiple rollouts and disabling them (and end up having 20 disabled rollouts) what I'm doing is have a single rollout and just edit the controls inside them, by enabling/disabling or hiding/showing those parameters

so in the end it really is exactly what I wanted, a different set of parameters based on the selection of the shader type rollout
thanks for your help, you really solved it
Old 02 February 2009   #4
cool - glad to be of assistance

as for the first one - correct.. that's why in the example it's a rollout defined outside of the scope of the scripted plugin. As a result, that rollout doesn't know what plugin instance it is used in, so there's a global variable that gets assigned the plugin instance, and that global variable is then referenced within that rollout. It's pretty messy
Old 02 February 2009   #5
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 08:56 PM.

Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.