Notifications
Clear all
[Closed] Trting to update script with mousemove and docking
Mar 24, 2015 9:44 pm
Hi all, first post and all that so try and be gentle. I’m having trouble getting this script to update besed on any changed values. I was wondering whats the most logical way to go about this?
See script:
try (cui.UnRegisterDialogBar rolMainRR) catch()
try (destroyDialog rolMainRR) catch()
try (closerolloutfloater rolMainRR) catch()
global DialogIniFile = getDir #plugcfg + "/RegionRenderSettings.ini"
if renderSceneDialog.isOpen() == true do messagebox "The Render Dialog needs to close and say closed for any changes to take effect.
You don't really need it for test rendering anyway
If you open the render dialog and make changes, click the 'U!' button to update the UI." title:"RegionRender V2.0 by 3dwannab" beep:true
if renderSceneDialog.isOpen() == true do renderSceneDialog.close()
--------------------------------------------------------------------------------
rollout rolMainRR "RegionRender V2.0 by 3dwannab"
(
subRollout scriptBin width:252 height:300 pos:[-1,-1]
--------------------------------------------------------------------------------
rollout rolSub_1 "Settings"
(
checkbutton chk_region "Region" pos:[8,32] width:76 height:20 toolTip:"Toggle Region ON/OFF"
checkbutton chk_blowup "Blowup" pos:[8,52] width:76 height:20 toolTip:"Toggle Blowup ON/OFF"
checkbutton chk_displacement "Displace" pos:[84,32] width:72 height:20 toolTip:"Toggle Displacement ON/OFF
Helpful to speed up test renders when you're in an area where there is no displacement and don't need to parse the scene."
checkbutton chk_ibitmappager "" pos:[216,246] width:16 height:16
button btn_Render "RENDER" pos:[156,32] width:52 height:40 toolTip:"Start Render"
button btn_IRender "IR" pos:[208,32] width:24 height:40 toolTip:"Start Render"
spinner spn_output_width "" pos:[48,96] width:56 height:16 range:[2,32768,1] type:#integer scale:1 toolTip:"Output width (px)"
spinner spn_output_height "" pos:[136,96] width:56 height:16 range:[2,32768,1] type:#integer scale:1 toolTip:"Output height (px)"
spinner spn_giaa "" pos:[48,120] width:56 height:16 range:[1,1024,16] type:#integer scale:1 toolTip:"Sampling balance: GI/AA
The amount of GI samples per each Anti-Aliasing sample.
Higher values will increase sampling of Global Illumination, resulting in cleaner indirect lighting, glossy reflections, refractions and translucency. Lower values will increase sampling of Anti-Aliasing and therefore improve quality of fine geometry edges, Depth of Field, and Motion Blur.
Setting this value under 2 or above 64 is not recommended.
DEFAULT: 16"
spinner spn_lsm "" pos:[48,144] width:56 height:16 range:[0.0001,100,2] type:#float toolTip:"Sampling balance: Light samples multiplier
The amount of direct lights samples per each GI sample.
Increase this value in scenes where there is visible noise in the direct lighting. Default value of 2.0 works well in most cases.
DEFAULT: 2.0"
spinner spn_msi "" pos:[136,120] width:56 height:16 range:[0,1000,20] type:#float scale:0.01 toolTip:"Speed/Accuracy balance: Max sample intensity
The ratio between rendering performance and physical accuracy.
Lowering it will result in clamping of the reflection and refraction caustics brightness, significantly reducing noise at the expense of bias. Increasing this value will reduce amount of clamping but also increase amount of noise. Default value of 20 works well in most scenes.
Setting this value to 0 enables special unbiased mode where no clamping will occur. This mode will however often introduce fireflies that may never converge when using Progressive or Bucket render engine.
DEFAULT: 20.0"
spinner spn_mrd "" pos:[136,144] width:56 height:16 range:[1,100,25] type:#integer scale:10 toolTip:"Speed/Accuracy balance: Max ray depth
The maximum possible number of light bounces.
Lowering this value slightly improves performance, increasing it slightly improves accuracy. The change in Corona is however very small compared to other renderer's, so keeping the default value is advised.
DEFAULT: 25"
spinner spn_pass_limit "" pos:[136,168] width:56 height:16 range:[0,1000,0] type:#integer scale:5 toolTip:"The number of passes after which the rendering will stop. Each pass performs one anti-aliasing sample per pixel and a variable amount of secondary samples set by the GI/AA balance parameter.
DEFAULT 0 = Infinity"
spinner spn_render_time_limit "" pos:[48,168] width:56 height:16 range:[0,100000,0] type:#integer scale:5 -- toolTip:See Below
button btn_res_width_mul "x" pos:[8,72] width:76 height:16 toolTip:"Width resolution:
Left click: x 2
Right click: / 2"
button btn_res_height_mul "x" pos:[156,72] width:76 height:16 toolTip:"Height resolution:
Left click: x 2
Right click: / 2"
button btn_res_overall_mul "x" pos:[112,96] width:16 height:16 toolTip:"Overall resolution:
Left click: x 2
Right click: / 2"
button btn_about "?" pos:[8,246] width:16 height:16 toolTip:"About
"
button btn_vfb "VFB" pos:[84,72] width:36 height:16 toolTip:"Display the last rendered framebuffer. There has to be at least one previous render done in the current 3dsmax session for the button to work.
Left click: Open VFB
Right click: Close VFB"
button btn_matoverrideslotreset "MS" pos:[120,72] width:36 height:16 toolTip:"Left click: Reset material slots to Coronas.
Right click: Refresh all material slots. [SLOW]"
button btn_render_resume "Resume" pos:[84,52] width:72 height:20 toolTip:"Resume Last Render"
button btn_render_setup_dialog "S" pos:[112,120] width:16 height:16 toolTip:"Left click: Open Render Setup
Right click: Close Render Setup"
button btn_update_ui "U!" pos:[112,144] width:16 height:16 toolTip:"Click here to update UI from render dialog settings"
button btn_show_maps_in_viewport "M" pos:[112,168] width:16 height:16 toolTip:"Left click: Show Diffuse maps in viewport
Right click: Unshow Diffuse maps in viewport"
button btn_matoverrideslot "" pos:[112,192] width:16 height:16 toolTip:"Left click: Set material override mat.
Right click: Clear material override mat."
button btn_matoverrideexclude "+ / -" pos:[136,192] width:96 height:16 toolTip:"Left click: Add objects to material override exclude list
Right click: Remove objects to material override exclude list"
button btn_matoverrideexcludenumber "" pos:[8,208] width:224 height:16 enabled:false toolTip:"Shows the amount of excluded items"
label lb_output_width "W px:" pos:[8,96] width:32 height:16
label lb_output_height ":H px" pos:[200,96] width:32 height:16
label lbl_giaa "GI/AA:" pos:[8,120] width:32 height:16
label lbl_lsm "LSM:" pos:[8,144] width:32 height:16
label lbl_msi ":MSI" pos:[200,120] width:32 height:16
label lbl_mrd ":MRD" pos:[200,144] width:32 height:16
label lbl_pass_limit ":PLimit" pos:[196,168] width:32 height:16
label lbl_renderstamp "Render Stamp:" pos:[8,228] width:80 height:16
label lbl_mat_override "Mat Override:" pos:[8,192] width:76 height:16
label lbl_render_time_limit "TLimit:" pos:[8,168] width:32 height:16
checkbox chk_renderstamp_use_checkbox "" pos:[88,228] width:16 height:16 toolTip:"Use Render Stamp"
checkbox chk_override_mat_checkbox "" pos:[88,192] width:16 height:16 toolTip:"When checked, all scene materials will be overridden with a single specified material"
HyperLink scriptspotlink "by 3dwannab" pos:[34,250] width:180 height:16 address:"http://www.scriptspot.com/users/3dwannab" color:(color 200 0 255) hovercolor:(color 255 255 255) visitedcolor:(color 0 0 0)--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
fn UpDateScriptUI =(
if getRenderType() == #region then(
chk_region.state = on
)
else
chk_region.text = "Region OFF"
if getRenderType() == #region then(
chk_region.text = "Region ON"
)
else()
if EditRenderRegion.IsEditable == true and EditRenderRegion.IsEditing == false then(
EditRenderRegion.EditRegion()
)
if getRenderType() == #blowup then(
chk_blowup.state = on
)
else
chk_blowup.text = "Blowup OFF"
if getRenderType() == #blowup then(
chk_blowup.text = "Blowup ON"
)
else()
if IBitmapPager.enabled == true then(
chk_ibitmappager.text = "!"
chk_ibitmappager.state = on
chk_ibitmappager.tooltip = "IBitmapPager is turned on.
To speed up render times by 3-4, it is recommended to turn it off.
Max default = true
** FILE NEEDS RELOADING TO TAKE EFFECT"
)
else(
chk_ibitmappager.text = "☻"
chk_ibitmappager.tooltip = "IBitmapPager is turned off.
This is okay. Your render should be 3 to 4 times quicker because of this. ☻"
)
if renderDisplacements == true then(
chk_displacement.state = on
chk_displacement.text = "Displace ON"
)
else(
chk_displacement.text = "Displace OFF"
)
spn_output_width.value = renderWidth as integer
spn_output_height.value = renderHeight as integer
-- If Corona
if (matchPattern (renderers.current as string) pattern:"Corona*") then(
spn_giaa.value = renderers.current.shading_giToAaRatio
spn_lsm.value = renderers.current.lights_samplesMult
spn_msi.value = renderers.current.shading_maxSampleIntensity
spn_mrd.value = renderers.current.shading_maxRayDepth
spn_pass_limit.value = renderers.current.progressive_passLimit
spn_render_time_limit.value = renderers.current.progressive_timeLimit as integer / 60000
spn_render_time_limit.tooltip = "Time in [D.hh:mm:ss]
" as string + ((dotnetclass "TimeSpan").FromMilliseconds (renderers.current.progressive_timeLimit)).ToString() + "
The maximum time the rendering will be in minutes, use this in conjunction with passes, the first to hit will terminate the render" as string
chk_override_mat_checkbox.state = true
chk_override_mat_checkbox.state = true
chk_renderstamp_use_checkbox.state = true
chk_renderstamp_use_checkbox.state = true
if renderDisplacements == true then
chk_displacement.state = true
if renderers.current.mtlOverride == undefined then(
btn_matoverrideslot.text = "╳"
btn_matoverrideexcludenumber.text = renderers.current.overrideMtl_exclude.count as string + " Objects Excluded"
btn_matoverrideslot.tooltip = "No material override set"
)
else(
btn_matoverrideslot.text = "✔"
btn_matoverrideslot.tooltip = renderers.current.mtlOverride as string + "... is set as the default material.
Left click: Add objects to material override exclude list
Right click: Remove objects to material override exclude list"
btn_matoverrideexcludenumber.text = renderers.current.overrideMtl_exclude.count as string + " Objects Excluded"
btn_matoverrideexcludenumber.tooltip = renderers.current.overrideMtl_exclude.count as string + " Objects Excluded"
)
)
else(
spn_render_time_limit.enabled = false
spn_giaa.enabled = false
spn_lsm.enabled = false
spn_msi.enabled = false
spn_mrd.enabled = false
spn_pass_limit.enabled = false
chk_override_mat_checkbox.enabled = false
btn_matoverrideexclude.enabled = false
btn_matoverrideslot.enabled = false
)
-- If VRay
if (matchPattern (renderers.current as string) pattern:"V_Ray_*") then(
if renderers.current.system_frameStamp_on == true then
chk_renderstamp_use_checkbox.state = true
else()
if vr=renderers.current.options_displacement == true then(
chk_displacement.state = true
renderDisplacements = true
)
else(
chk_displacement.state = false
renderDisplacements = false
vr=renderers.current.options_displacement = false
)
)
)
on rolSub_1 open do(
UpDateScriptUI()
)
on rolMainRR mousemove pos do(
UpDateScriptUI()
)
on rolSub_1 rolledUp bState do(
if (bState == true) then(
UpDateScriptUI()
rolMainRR.height += rolSub_1.height
rolMainRR.height += 4
)
else(
UpDateScriptUI()
rolMainRR.height -= rolSub_1.height
rolMainRR.height -= 4
)
)
fn showDifMapsInVP mode =(
for o in (getclassinstances CoronaMtl) do(
try(showTextureMap o o.texmapDiffuse mode)catch()
)
)
--------------------------------------------------------------------------------- HELP WANTED ---------------------------------------------------------------------------------
dotNetControl obj_dd "System.Windows.Forms.ComboBox" pos:[8,8] width:224 height:22
-- When the ComboBox selection is changed change do something
fn dd_fill =
(
-- Collect the Cameras into an array
camArray = for i in cameras where superclassof i == Camera collect i.name
-- Clear the ComboBox list
obj_dd.items.clear()
-- Build a new ComboBox list using the view array
--obj_dd.items.addRange (#("Choose"))
--obj_dd.SelectedIndex = 1
obj_dd.items.addrange camArray
)
on drop_roll open do(
dd_fill()
UpDateScriptUI()
--Fill on open
)
on obj_dd DropDown do(
--Fill on expanding the list
dd_fill()
UpDateScriptUI()
)
on obj_dd SelectedIndexChanged do(
--Command to execute on selecting the entry
select (getNodeByName obj_dd.text)
viewport.setCamera (getNodeByName obj_dd.text)
UpDateScriptUI()
)
--------------------------------------------------------------------------------- HELP WANTED ---------------------------------------------------------------------------------
on btn_vfb rightclick do(
if not (matchPattern (renderers.current as string) pattern:"Corona*") then
messagebox "Only closes Coronas VFB" title:"RegionRender V2.0 by 3dwannab" beep:true
else
CoronaRenderer.CoronaFp.showVfb false
)
on spn_output_width changed val do(
renderWidth = spn_output_width.value
)
on spn_output_height changed val do(
renderHeight = spn_output_height.value
)
on btn_res_width_mul pressed do(
res_width_mul_NEW_VALUE = ((spn_output_width.value * 2) as integer)
spn_output_width.value = res_width_mul_NEW_VALUE
renderWidth = spn_output_width.value
)
on btn_res_width_mul rightclick do(
res_width_mul_NEW_VALUE = ((spn_output_width.value / 2) as integer)
spn_output_width.value = res_width_mul_NEW_VALUE
renderWidth = spn_output_width.value
)
on btn_res_height_mul pressed do(
res_height_mul_NEW_VALUE = ((spn_output_height.value * 2) as integer)
spn_output_height.value = res_height_mul_NEW_VALUE
renderHeight = spn_output_height.value
)
on btn_res_height_mul rightclick do(
res_height_mul_NEW_VALUE = ((spn_output_height.value / 2) as integer)
spn_output_height.value = res_height_mul_NEW_VALUE
renderHeight = spn_output_height.value
)
on btn_res_overall_mul pressed do(
res_overall_height_mul_NEW_VALUE = ((spn_output_height.value * 2) as integer)
spn_output_height.value = res_overall_height_mul_NEW_VALUE
res_overall_width_mul_NEW_VALUE = ((spn_output_width.value * 2) as integer)
spn_output_width.value = res_overall_width_mul_NEW_VALUE
renderWidth = spn_output_width.value
renderHeight = spn_output_height.value
)
on btn_res_overall_mul rightclick do(
res_overall_height_mul_NEW_VALUE = ((spn_output_height.value / 2) as integer)
spn_output_height.value = res_overall_height_mul_NEW_VALUE
res_overall_width_mul_NEW_VALUE = ((spn_output_width.value / 2) as integer)
spn_output_width.value = res_overall_width_mul_NEW_VALUE
renderWidth = spn_output_width.value
renderHeight = spn_output_height.value
)
on btn_Render pressed do(
if renderSceneDialog.isOpen() == true do renderSceneDialog.close()
renderWidth = spn_output_width.value
renderHeight = spn_output_height.value
gc() --Garbage Collection.
freescenebitmaps() --Cleans up in texture memory.
--clearUndoBuffer() Removes your Undos
max quick render
)
on btn_render_setup_dialog pressed do(
renderWidth = spn_output_width.value
renderHeight = spn_output_height.value
if renderSceneDialog.isOpen() == false do renderSceneDialog.open()
)
on btn_render_setup_dialog rightClick do(
if renderSceneDialog.isOpen() == true do renderSceneDialog.close()
)
on btn_update_ui pressed do(
if renderSceneDialog.isOpen() == true do renderSceneDialog.close()
UpDateScriptUI()
)
on btn_render_resume pressed do(
if not (matchPattern (renderers.current as string) pattern:"Corona*") then
messagebox "Resume Render only available in Corona!!
Get your act together son :P" title:"RegionRender V2.0 by 3dwannab" beep:true
else
renderWidth = spn_output_width.value
renderHeight = spn_output_height.value
CoronaRenderer.CoronaFp.resumeRender()
)
on spn_giaa changed val do(
renderers.current.shading_giToAaRatio = spn_giaa.value
)
on spn_mrd changed val do(
renderers.current.shading_maxRayDepth = spn_mrd.value
)
on spn_lsm changed val do(
renderers.current.lights_samplesMult = spn_lsm.value
)
on chk_override_mat_checkbox changed State do(
if not state then(
if (matchPattern (renderers.current as string) pattern:"V_Ray_*") then(
chk_override_mat_checkbox.state == false
renderers.current.options_overrideMtl_on = false
)
if (matchPattern (renderers.current as string) pattern:"Corona*") then(
chk_override_mat_checkbox.state == false
renderers.current.mtlOverride_enabled = false
)
)
else(
if (matchPattern (renderers.current as string) pattern:"V_Ray_*") then(
chk_override_mat_checkbox.state == true
renderers.current.options_overrideMtl_on = true
)
if (matchPattern (renderers.current as string) pattern:"Corona*") then(
chk_override_mat_checkbox.state == true
renderers.current.mtlOverride_enabled = true
)
)
)
on btn_matoverrideslot pressed do(
matoverrideslot = materialBrowseDlg #mats #instanceOnly
mtlBrowser.browseFrom #mtlLibrary
btn_matoverrideslot.text = "✔" as string
renderers.current.mtlOverride = matoverrideslot
btn_matoverrideslot.tooltip = renderers.current.mtlOverride as string + "... is set as the default material.
Left click: Add objects to material override exclude list
Right click: Remove objects to material override exclude list"
if renderers.current.mtlOverride == undefined then btn_matoverrideslot.text = "╳"
if renderers.current.mtlOverride == undefined then messagebox "No Override Material Set !" title:"RegionRender V2.0 by 3dwannab" beep:true
)
on btn_matoverrideslot rightclick do(
if renderers.current.mtlOverride == undefined then(
messagebox "Already cleared !" title:"RegionRender V2.0 by 3dwannab" beep:true
)
else(
renderers.current.mtlOverride = undefined
messagebox "Cleared override material !" title:"RegionRender V2.0 by 3dwannab" beep:true
btn_matoverrideslot.text = "╳"
btn_matoverrideslot.tooltip = "No material override set.
is set as the default material
Left click: Add objects to material override exclude list
Right click: Remove objects to material override exclude list"
)
)
on btn_matoverrideexclude pressed do(
for i in selection do appendifunique renderers.current.overrideMtl_exclude i
renderers.current.overrideMtl_exclude.count as string + " Objects Excluded"
btn_matoverrideexcludenumber.tooltip = renderers.current.overrideMtl_exclude.count as string + " Objects Excluded"
btn_matoverrideexcludenumber.text = renderers.current.overrideMtl_exclude.count as string + " Objects Excluded"
)
on btn_about pressed do(
messageBox "RegionRender V2.0 by 3dwannab
------------------------------------------------------------------------------------
Dev. by Stephen Sherry.
Visit: http://www.scriptspot.com/users/3dwannab.
Free for all use and / or modification.
If you modify the script, please mention my name, cheers. :)
------------------------------------------------------------------------------------
SUMMARY OF SCRIPT USAGE:
● Self explanatory (see tooltips, just hoover over buttons).
● There's right click functions, mainly the size of render output. Again FMI (see tooltips).
------------------------------------------------------------------------------------
NOTES:
● Some functions may not work for VRay. The buttons/spinners will be grayed out if so.
● Please enjoy this and always if you have any thing you want added, please contact me on my scriptspot page." title:"About RegionRender" beep:false
)
)
--------------------------------------------------------------------------------
on rolMainRR open do(
addSubRollout scriptBin rolSub_1
)
on rolMainRR moved pos do(
setIniSetting DialogIniFile "RegionRenderSettings" "Position" (pos as string)
tryDockState = try (cui.getDockState rolMainRR) catch ()
if tryDockState == undefined then theLastDockState = #cui_floatable else theLastDockState = tryDockState
setIniSetting DialogIniFile "RegionRenderSettings" "LastDockedState" (theLastDockState)
)
on rolMainRR close do(
try (cui.UnregisterDialogBar rolMainRR) catch()
tryDockState = try (cui.getDockState rolMainRR) catch ()
if tryDockState == undefined then theLastDockState = #cui_floatable else theLastDockState = tryDockState
setIniSetting DialogIniFile "RegionRenderSettings" "LastDockedState" (theLastDockState)
)
on rolMainRR mousemove pos do --lbuttondown
(
try (
UpDateScriptUI()
print "ss"
)
catch()
)
)
-- If floating settings
global DialogIniFile = getDir #plugcfg + "/RegionRenderSettings.ini"
DockedState = (getIniSetting DialogIniFile "RegionRenderSettings" "LastDockedState")
if ((DockedState == "cui_floatable") == true) then(
messagebox "Floating"
DialogPos = execute (getIniSetting DialogIniFile "RegionRenderSettings" "Position")
if DialogPos == undefined do DialogPos = [200,280]
if DialogPos == OK do DialogPos = [200,280]
createDialog rolMainRR 246 300 DialogPos.x DialogPos.y style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
cui.RegisterDialogBar rolMainRR style:#(#cui_dock_left, #cui_dock_right, #cui_floatable, #cui_handles)
--try (cui.UnRegisterDialogBar rolMainRR) catch()
)
-- If Docked settings
DialogIniFile = getDir #plugcfg + "/RegionRenderSettings.ini"
DockedState = (getIniSetting DialogIniFile "RegionRenderSettings" "LastDockedState")
if ((DockedState == "cui_dock_left") == true) then(
print "Left"
if DockedState == "cui_dock_left" do cui.DockDialogBar rolMainRR #cui_dock_left
createDialog rolMainRR 246 300 DialogPos.x DialogPos.y style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
cui.RegisterDialogBar rolMainRR style:#(#cui_dock_left, #cui_dock_right, #cui_floatable, #cui_handles)
)
DialogIniFile = getDir #plugcfg + "/RegionRenderSettings.ini"
DockedState = (getIniSetting DialogIniFile "RegionRenderSettings" "LastDockedState")
if ((DockedState == "cui_dock_right") == true) then(
print "Right"
if DockedState == "cui_dock_right" do cui.DockDialogBar rolMainRR #cui_dock_left
createDialog rolMainRR 246 300 DialogPos.x DialogPos.y style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
cui.RegisterDialogBar rolMainRR style:#(#cui_dock_left, #cui_dock_right, #cui_floatable, #cui_handles)
)
--try (cui.UnRegisterDialogBar rolMainRR) catch()
--try (destroyDialog rolMainRR) catch()
--try (closerolloutfloater rolMainRR) catch()
-- END OF CODE
The bit that should be of interest is :
on rolMainRR mousemove pos do(
UpDateScriptUI()
)
This is nested below the function. And it's not working. Any ideas? I'm past the maxscript help at this stage and need someones help. Thanks.
Another is the dockable window which I have getting save out to a .cfg file. I'm having trouble getting it to open as a docked window when it's in a docked state already. I was thinking of just adding buttons to the UI myself and use them to register and unregister the DialogBar. Again. Any ideas?