// =========================================================================== // 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. // =========================================================================== // // Description: // Define the appearance of the attribute editor for the bulletSolver node. // global int $gAEcollisionFilterNumReserved = 5; global proc AEcollisionFilterValueChanged(string $attrName, string $control, int $idx) { // query the value from the text field $value = `textField -query -text $control`; // query the attribute value string $allFilterNames[] = getAttr($attrName); // if textField different from attribute value then change if ($allFilterNames[$idx]!=$value) { $allFilterNames[$idx]=$value; string $sSet = stringArrayToString({"setAttr", $attrName, "-type stringArray", size($allFilterNames), ("\"" + stringArrayToString($allFilterNames, "\" \"") + "\"") }, " "); evalEcho $sSet; // force rigid body and soft body AE's to replace current filter names refresh -f; } } proc newFilterControl(string $attrName, string $filterName, int $index, string $control) { global int $gAEcollisionFilterNumReserved; global string $gAEcollisionFiltersControls[]; rowColumnLayout -numberOfColumns 1 -columnWidth 1 150 -columnAlign 1 "left" $control; $gAEcollisionFiltersControls[size($gAEcollisionFiltersControls)] = $control; $control = "collisionFilterCL_Label" + $index; textField -text $filterName -editable ($index>$gAEcollisionFilterNumReserved) -changeCommand (stringArrayToString({"AEcollisionFilterValueChanged", $attrName, $control, $index }, " ")) $control; setParent ..; } global proc AEcollisionFiltersNew(string $attrName) { // Register a script job to delete all of the control UI in the case of a file -new. scriptJob -e "deleteAll" AEcollisionFiltersDeleteControls; setUITemplate -pst attributeEditorTemplate; columnLayout "collisionFiltersColumn"; // Get all of the collision filters. string $allFilterNames[] = getAttr($attrName); // Iterate over them and fill in the UI int $i; for ($i=0; $i < size($allFilterNames); $i++) { string $rcName = "collisionFilterRC_Label" + $i; newFilterControl( $attrName, $allFilterNames[$i], $i, $rcName ); } setParent ..; setUITemplate -ppt; } global proc AEcollisionFiltersReplace(string $attrName) { global string $gAEcollisionFiltersControls[]; setUITemplate -pst attributeEditorTemplate; setParent "collisionFiltersColumn"; // Get all of the collision filters. string $allFilterNames[] = getAttr($attrName); // Iterate over them. For each one found, // fill in the UI for the associated multi attribute. int $i; for ($i=0; $i < size($allFilterNames); $i++) { // If the UI doesn't exist create it. Otherwise, use // the existing UI. string $rcName = "collisionFilterRC_Label" + $i; if (!`control -exists $rcName`) { newFilterControl( $attrName, $allFilterNames[$i], $i, $rcName ); } else { control -e -visible true $rcName; } } setParent ..; setUITemplate -ppt; } global proc AEcollisionFiltersDeleteControls () // // Description: // This procedure deletes all of the UI controls build for the collisionFilters attribute. // The procedure is called from a script job when a file -new is performed. // { global string $gAEcollisionFiltersControls[]; string $c; for ($c in $gAEcollisionFiltersControls) catch( deleteUI($c) ); clear($gAEcollisionFiltersControls); } global proc callUpdateUseMayaFields( string $nodeName ) { /* Called when the attribute editor UI for the solver needs to be updated to reflect the latest attribute values. Enables and disables controls. */ $useMayaFields = getAttr($nodeName+".useMayaFields"); editorTemplate -dimControl $nodeName "gravity" $useMayaFields; editorTemplate -dimControl $nodeName "windMagnitude" $useMayaFields; editorTemplate -dimControl $nodeName "windDirection" $useMayaFields; } global proc AEsolverDisplayOptionsNew( string $attrName ) { python ("import maya.app.mayabullet.SolverUI as SolverUI; SolverUI.AEOptions( \"" + $attrName + "\", SolverUI.solverDisplayOptionsMap, replace=False )"); } global proc AEsolverDisplayOptionsReplace( string $attrName ) { python ("import maya.app.mayabullet.SolverUI as SolverUI; SolverUI.AEOptions( \"" + $attrName + "\", SolverUI.solverDisplayOptionsMap, replace=True )"); } global proc AEbulletSolverShapeTemplate ( string $nodeName ) { editorTemplate -beginScrollLayout; // Add editorTemplate -beginLayout (uiRes("m_AEbulletSolverShapeTemplate.kSolverProperties")) -collapse false; editorTemplate -ann (uiRes("m_AEbulletSolverShapeTemplate.kEnableSimulation")) -addControl enableSimulation; editorTemplate -ann (uiRes("m_AEbulletSolverShapeTemplate.kStartTime")) -addControl startTime; editorTemplate -ann (uiRes("m_AEbulletSolverShapeTemplate.kSplitImpulse")) -addControl splitImpulse; editorTemplate -ann (uiRes("m_AEbulletSolverShapeTemplate.kSolverAcceleration")) -addControl solverAcceleration; editorTemplate -ann (uiRes("m_AEbulletSolverShapeTemplate.kInternalFixedFrameRate")) -addControl internalFixedFrameRate; editorTemplate -ann (uiRes("m_AEbulletSolverShapeTemplate.kMaxNumIterations")) -addControl maxNumIterations; editorTemplate -ann (uiRes("m_AEbulletSolverShapeTemplate.kGroundPlane")) -addControl groundPlane; editorTemplate -endLayout; editorTemplate -beginLayout (uiRes("m_AEbulletSolverShapeTemplate.kBasicFields")) -collapse false; editorTemplate -addControl useMayaFields callUpdateUseMayaFields; editorTemplate -addControl gravity; editorTemplate -addControl windMagnitude; editorTemplate -addControl windDirection; editorTemplate -endLayout; // Simulation Display editorTemplate -beginLayout (uiRes("m_AEbulletSolverShapeTemplate.kSolverDisplay")) -collapse false; editorTemplate -callCustom AEsolverDisplayOptionsNew AEsolverDisplayOptionsReplace solverDisplayOptions; editorTemplate -endLayout; // Collision Filters editorTemplate -beginLayout (uiRes("m_AEbulletSolverShapeTemplate.kCollisionFilters")) -collapse true; editorTemplate -callCustom AEcollisionFiltersNew AEcollisionFiltersReplace collisionFilters; editorTemplate -endLayout; // Suppress editorTemplate -suppress debugDraw; editorTemplate -suppress solverDisplayOptions; editorTemplate -suppress rigidBodies; editorTemplate -suppress softBodies; editorTemplate -suppress softConstraints; editorTemplate -suppress rigidBodyConstraints; editorTemplate -suppress collisionFilters; // Inherit attrs AEshapeTemplate( $nodeName ); //AEdependNodeTemplate $nodeName; // For a DGNode // Suppress attrs // == Footer == editorTemplate -addExtraControls; editorTemplate -endScrollLayout; }