// =========================================================================== // 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 // bulletRigidBody node. // proc updateConnectionUI(string $connections[], string $conInput) { if ($conInput == ""){ symbolButton -e -en 0 goToConnectedInput; text -e -en 0 inputName; } else { text -e -en 1 inputName; symbolButton -e -en 1 -c ("showEditor " + $conInput) goToConnectedInput; menuItem -e -l $connections[0] -c ("showEditor " + $conInput) goToConnectedMenuItem; } } global proc AEbulletInputMeshReplace ( string $attributeUIName, string $input ) { string $connections[] = `listConnections -p true $input`; string $conInput[]; tokenize($connections[0], ".", $conInput); text -e -l $attributeUIName inputName; textField -e -tx $conInput[0] //-cc ("setAttr -type \"string\" " + $input + " #1") inputConnected; updateConnectionUI($connections, $conInput[0]); } global proc AEbulletInputMeshNew ( string $attributeUIName, string $input ) { setUITemplate -pst attributeEditorTemplate; string $connections[] = `listConnections -p true $input`; string $conInput[]; tokenize($connections[0], ".", $conInput); rowLayout -nc 3;// -cat 3 both 0 -cal 3 center; text -l $attributeUIName inputName; textField -ed 0 -tx $conInput[0] //-cc ("setAttr -type \"string\" " + $input + " #1") inputConnected; symbolButton -i "inArrow.png" -c ("showEditor " + $conInput[0] ) goToConnectedInput; popupMenu -b 3 goToConnectedMenu; menuItem -l $connections[0] -c ("showEditor "+$conInput[0]) goToConnectedMenuItem; setParent -m ..; updateConnectionUI($connections, $conInput[0]); setUITemplate -ppt; } global proc int refitCollisionShape( string $nodeName ) { string $attr = $nodeName + ".inMesh"; string $inMesh[] = `listConnections -p false -sh true $attr`; $attr = $nodeName + ".inWorldMatrix"; string $inTransform[] = `listConnections -p false -sh true $attr`; python ("import maya.app.mayabullet.RigidBody as RigidBody; RigidBody.refitCollisionShape( \"" + $nodeName + "\",\"" + $inMesh[0] + "\",\"" + $inTransform[0] + "\" )"); // TODO: result 1 only if shape was refit. return 1; } global proc AErefitButtonNew(string $nodeNameExtra) { // $nodeNameExtra is the actual node name + "." $nodeName = substring($nodeNameExtra, 1, size($nodeNameExtra)-1); rowLayout -numberOfColumns 1 -columnAttach1 "left" -columnOffset1 144 -columnAlign1 "center"; button -label (uiRes("m_AEbulletRigidBodyShapeTemplate.kRefitCollisionShape")) -width 76 -command ("refitCollisionShape \"" + $nodeName + "\"") refitCollisionShapeButton; setParent ..; } global proc AErefitButtonReplace(string $nodeNameExtra) { // $nodeNameExtra is the actual node name + "." $nodeName = substring($nodeNameExtra, 1, size($nodeNameExtra)-1); button -edit -command ("refitCollisionShape \"" + $nodeName + "\"") refitCollisionShapeButton; } global proc callUpdateColliderUI( string $nodeName ) { python ("import maya.app.mayabullet.RigidBodyUI as RigidBodyUI; RigidBodyUI.updateColliderUI( \"" + $nodeName + "\" )"); } global proc callUpdateNeverSleep( string $nodeName ) { python ("import maya.app.mayabullet.RigidBodyUI as RigidBodyUI; RigidBodyUI.updateNeverSleepUI( \"" + $nodeName + "\" )"); } global proc AEbulletRigidBodyShapeTemplate ( string $nodeName ) { editorTemplate -beginScrollLayout; // == Add attrs == // RigidBody Properties editorTemplate -beginLayout (uiRes("m_AEbulletRigidBodyShapeTemplate.kRBProperties")) -collapse false; editorTemplate -addControl bodyType; editorTemplate -addControl neverSleeps callUpdateNeverSleep; editorTemplate -addControl mass; editorTemplate -addControl centerOfMass; editorTemplate -addControl linearDamping; editorTemplate -addControl angularDamping; editorTemplate -addControl friction; editorTemplate -addControl restitution; editorTemplate -endLayout; // Initial Conditions editorTemplate -beginLayout (uiRes("m_AEbulletRigidBodyShapeTemplate.kInitConditions")) -collapse true; editorTemplate -addControl initiallySleeping; editorTemplate -addControl initialVelocity; editorTemplate -addControl initialAngularVelocity; editorTemplate -addControl inWorldMatrix; editorTemplate -endLayout; // Forces/Impulses editorTemplate -beginLayout (uiRes("m_AEbulletRigidBodyShapeTemplate.kForces")) -collapse true; editorTemplate -addControl impulse; editorTemplate -addControl impulsePosition; editorTemplate -addControl torqueImpulse; editorTemplate -endLayout; // Collider Properties editorTemplate -beginLayout (uiRes("m_AEbulletRigidBodyShapeTemplate.kColliderProperties")) -collapse false; editorTemplate -addControl colliderShapeType callUpdateColliderUI; string $inputMesh = (uiRes("m_AEbulletRigidBodyShapeTemplate.kInputMesh")); editorTemplate -callCustom ("AEbulletInputMeshNew \"" + $inputMesh + "\"") ("AEbulletInputMeshReplace \"" + $inputMesh + "\"") "inMesh"; editorTemplate -addControl colliderShapeOffset; editorTemplate -ann (uiRes("m_AEbulletRigidBodyShapeTemplate.kColliderShapeMargin")) -addControl "colliderShapeMargin"; editorTemplate -addControl axis; editorTemplate -addControl length; editorTemplate -addControl radius; editorTemplate -addControl extents; editorTemplate -addControl autoFit callUpdateColliderUI; editorTemplate -callCustom ("AErefitButtonNew") ("AErefitButtonReplace") ""; editorTemplate -endLayout; // == Inherit == AEbulletShapeTemplate( $nodeName ); // System Properties editorTemplate -beginLayout (uiRes("m_AEbulletRigidBodyShapeTemplate.kDynanicsSystem")) -collapse true; string $solvedTranslate = (uiRes("m_AEbulletRigidBodyShapeTemplate.kSolvedTranslate")); string $solver = (uiRes("m_AEbulletRigidBodyShapeTemplate.kSolver")); editorTemplate -callCustom ("AEinputNew \"" + $solvedTranslate + "\"") ("AEinputReplace \"" + $solvedTranslate + "\"") "outSolvedWorldTranslate"; editorTemplate -callCustom ("AEinputNew \"" + $solver + "\"") ("AEinputReplace \"" + $solver + "\"") "solverInitialized"; editorTemplate -endLayout; // == Inherit == AEshapeTemplate( $nodeName ); // == Suppress == editorTemplate -suppress collisionFilterGroup; editorTemplate -suppress collisionFilterMask; // == Footer == editorTemplate -addExtraControls; editorTemplate -endScrollLayout; }