// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== global proc updateInteractiveShadingOptions(string $procArgs[]) { string $mode = ($procArgs[0]); string $editorVal = ($procArgs[1]); string $cmd = ""; int $isHighQualityMode = 0; if ($mode == uiRes("m_interactiveShadingOptions.kHighQualityRendering")) { $cmd = ("modelEditor -e -interactive -useInteractiveMode on -da smoothShaded -ubr 0 -urr 1 " + $editorVal); $isHighQualityMode = 1; } else if ($mode == uiRes("m_interactiveShadingOptions.kShaded")) $cmd = ("modelEditor -e -interactive -useInteractiveMode on -da smoothShaded -ubr 1 -urr 0 " + $editorVal); else if ($mode == uiRes("m_interactiveShadingOptions.kWireframe")) $cmd = ("modelEditor -e -interactive -useInteractiveMode on -da wireframe -ubr 0 -urr 0 " + $editorVal); else if ($mode == uiRes("m_interactiveShadingOptions.kBoundingBox")) $cmd = ("modelEditor -e -interactive -useInteractiveMode on -da boundingBox -ubr 0 -urr 0 " + $editorVal); else if ($mode == uiRes("m_interactiveShadingOptions.kPoints")) $cmd = ("modelEditor -e -interactive -useInteractiveMode on -da points -ubr 0 -urr 0 " + $editorVal); if (size($cmd)) evalEcho $cmd; else{ string $warningMsg = (uiRes("m_interactiveShadingOptions.kInvalidMode")); warning (`format -s $mode $warningMsg`); } // For interactive call we need to update the UI if (strcmp($procArgs[2], "true") == 0) updateHWRendererInteractiveSubOptions($editorVal, $isHighQualityMode); } global proc updateHWRendererInteractiveSubOptions(string $editor, int $isHighQualityMode) { // Toggle sub-options int $notHwRendererLowQualityMode = !$isHighQualityMode; disable -v $notHwRendererLowQualityMode ISO_smallObjCull; if ($isHighQualityMode) { int $val = `modelEditor -q -soc $editor`; if ($val) disable -v false ISO_SmallObjectThreshold; else disable -v true ISO_SmallObjectThreshold; } else disable -v true ISO_SmallObjectThreshold; disable -v $notHwRendererLowQualityMode ISO_Shadows; disable -v $notHwRendererLowQualityMode ISO_BackFaceCulling; } global proc interactiveShadingOptions(string $editorVal) { if (`window -exists interactiveShadingOptionsWin`) { deleteUI -wnd interactiveShadingOptionsWin; } string $cameraName = `modelEditor -q -cam $editorVal`; string $windowTitle = (uiRes("m_interactiveShadingOptions.kInteractiveShadingOptions")); window -title (`format -s $cameraName $windowTitle`) -menuBar false -rtf true interactiveShadingOptionsWin; setUITemplate -pushTemplate DefaultTemplate; string $parent = `columnLayout -adjustableColumn true`; // Main options global string $IOS_procArgs[]; $IOS_procArgs[0] = "undefined"; $IOS_procArgs[1] = $editorVal; $IOS_procArgs[2] = "true"; optionMenuGrp -label (uiRes("m_interactiveShadingOptions.kShadingMode")) -cc ("$IOS_procArgs[0] = `optionMenuGrp -query -value ISO_ModeMenu`; updateInteractiveShadingOptions($IOS_procArgs);" ) ISO_ModeMenu; menuItem -label (uiRes("m_interactiveShadingOptions.kHighQualityRendering")) /* 1 */ ISO_highQuaityRenderingMenuItem; menuItem -label (uiRes("m_interactiveShadingOptions.kShaded")) /* 2 */ ISO_shadedMenuItem; menuItem -label (uiRes("m_interactiveShadingOptions.kWireframe")) /* 3 */ ISO_wireframeMenuItem; menuItem -label (uiRes("m_interactiveShadingOptions.kBoundingBox")) /* 4 */ ISO_boundingBoxMenuItem; menuItem -label (uiRes("m_interactiveShadingOptions.kPoints")) /* 5 */ ISO_pointsMenuItem; setParent -menu ..; /// frameLayout -label (uiRes("m_interactiveShadingOptions.kHighQualityRenderingOptions")) -cl false -cll true; columnLayout; checkBoxGrp -label1 (uiRes("m_interactiveShadingOptions.kCullingThreshold")) -cc ("modelEditor -e -soc #1 " + $editorVal + "; disable -v (1-#1) ISO_SmallObjectThreshold") ISO_smallObjCull; int $val = `modelEditor -q -soc $editorVal`; int $doSmallObjectCull = $val; checkBoxGrp -e -value1 $val ISO_smallObjCull; floatSliderGrp -label (uiRes("m_interactiveShadingOptions.kViewSize")) -minValue 0.0 -maxValue 5.0 -fieldMinValue 0 -fieldMaxValue 5.0 -cc ("modelEditor -e -sot #1 " + $editorVal) ISO_SmallObjectThreshold; float $fval[] = `modelEditor -q -sot $editorVal`; floatSliderGrp -edit -value $fval[0] ISO_SmallObjectThreshold; checkBoxGrp -label1 (uiRes("m_interactiveShadingOptions.kDisableShadows")) -cc ("modelEditor -e -dis #1 " + $editorVal) ISO_Shadows; $val = `modelEditor -q -dis $editorVal`; checkBoxGrp -e -value1 $val ISO_Shadows; checkBoxGrp -label1 (uiRes("m_interactiveShadingOptions.kBackfaceCulling")) -cc ("modelEditor -e -ibc #1 " + $editorVal) ISO_BackFaceCulling; $val = `modelEditor -q -ibc $editorVal`; checkBoxGrp -e -value1 $val ISO_BackFaceCulling; setParent $parent; button -label (uiRes("m_interactiveShadingOptions.kClose")) -c "window -edit -visible false interactiveShadingOptionsWin" ISO_CloseButton; // Set the correct current interactive shading mode // int $hwRendererLowQualityMode = `modelEditor -q -urr $editorVal`; int $notHwRendererLowQualityMode = ! $hwRendererLowQualityMode; int $hwRenderDegradeToBaseRender = `modelEditor -q -ubr $editorVal`; int $useInteractiveMode = `modelEditor -q -useInteractiveMode $editorVal`; // Set the radio buttons to reflect which interactive // mode is selected // if ($hwRendererLowQualityMode) { optionMenuGrp -e -sl 1 ISO_ModeMenu; } else { if ($hwRenderDegradeToBaseRender) { optionMenuGrp -e -sl 2 ISO_ModeMenu; } else { string $interactiveShadeMode = `modelEditor -q -interactive -displayAppearance $editorVal`; switch($interactiveShadeMode){ case "wireframe": optionMenuGrp -e -sl 3 ISO_ModeMenu; break; case "boundingBox": optionMenuGrp -e -sl 4 ISO_ModeMenu; break; case "points": optionMenuGrp -e -sl 5 ISO_ModeMenu; break; } } } // Toggle sub-options if ($hwRendererLowQualityMode) { disable -v false ISO_smallObjCull; if ($doSmallObjectCull) disable -v false ISO_SmallObjectThreshold; else disable -v true ISO_SmallObjectThreshold; disable -v false ISO_Shadows; disable -v false ISO_BackFaceCulling; } else { disable -v true ISO_smallObjCull; disable -v true ISO_SmallObjectThreshold; disable -v true ISO_Shadows; disable -v true ISO_BackFaceCulling; } showWindow interactiveShadingOptionsWin; }