// =========================================================================== // 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. // =========================================================================== // // // Creation Date: Jun 2014 // // // Procedure Name: // DynNClothMenu // // Description: // Create the DYNAMICS->nCloth // // Input Arguments: // parent to parent the menu to. // // Return Value: // None. // global proc DynCreateNPaintPropertiesMenu( string $parent, string $useThisMesh, int $whichMenu ) // // Build the paint nCloth submenu // // If $whichMenu == 0, paint by vertex map. // If $whichMenu == 1, paint by texture map. // If $whichMenu == 2, convert current texture map to vertex map // If $whichMenu == 3, convert current vertex map to texture map // { string $meshParam = $useThisMesh; if( $useThisMesh == "" ){ $meshParam = "\"\""; } setParent -menu $parent; menuItem -divider true -dividerLabel (uiRes("m_DynClothMenu.kDynamicProp")); // To add another paintable attribute, add the appropriate entries to the // following tables // int $numCommon = 6; // Number of common attributes (to cloth & to a passive // collision object) at the start of these tables. string $attrs[] = { "bounce", "collideStrength", "fieldMagnitude", "friction", "stickiness", "thickness", "tangentialDrag", "bend", "bendAngleDropoff", "compression", "damp", "deform", "drag", "inputAttract", "lift", "mass", "restLengthScale", "restitutionAngle", "rigidity", "stretch", "wrinkle" }; string $maplabels[] = { "PBoM", //bounce "PCsM", //collide str "PFMM", //field magnitude "PFM", //friction "PStM", //stickiness "PTM", //thickness "PTDM", //tangent drag "PBeM", //bend "PBaM", //bend angle drop off "PCM", //compression "PDaM", //damp "PDV", //deformability "PDRM", //drag "PIAM", //input attract "PLFM", //lift "PMM", //mass "PRLM", //rest length scae "PRaM", //restitution angle "PRM", //rigidity "PSM", //stretch "PWM" //wrinkle }; string $vertexlabels[] = { "PVBo", //bounce "CPCs", //collide str "PVFM", //field magnitude "PVF", //friction "PVSt", //stickiness "PVT", //thickness "PVTD", //tangent drag "PVBe", //bend "PVBa", //bend angle drop off "PVC", //compression "PVDa", //damp "PVD", //deformability "PVDR", //drag "PVIA", //input attract "PVLF", //lift "PVM", //mass "PVRL", //rest length "PVRa", //restitution angle "PVR", //rigidity "PVS", //stretch "PVW" //wrinkle }; string $labels[] = { (uiRes("m_DynClothMenu.kBounceMap")) , (uiRes("m_DynClothMenu.kCollideStrengthMap")) , (uiRes("m_DynClothMenu.kFieldMagnitudeMap")) , (uiRes("m_DynClothMenu.kFrictionMap")) , (uiRes("m_DynClothMenu.kStickinessMap")) , (uiRes("m_DynClothMenu.kThicknessMap")) , (uiRes("m_DynClothMenu.kTangentialMap")), (uiRes("m_DynClothMenu.kBendMap")) , (uiRes("m_DynClothMenu.kBendAngleDropoffMap")) , (uiRes("m_DynClothMenu.kCompressionMap")) , (uiRes("m_DynClothMenu.kDampMap")) , (uiRes("m_DynClothMenu.kDeformMap")) , (uiRes("m_DynClothMenu.kDragMap")), (uiRes("m_DynClothMenu.kInputAttractMap")), (uiRes("m_DynClothMenu.kLiftMap")), (uiRes("m_DynClothMenu.kMassMap")) , (uiRes("m_DynClothMenu.kRestLengthScaleMap")), (uiRes("m_DynClothMenu.kRestitutionAngleMap")) , (uiRes("m_DynClothMenu.kRigidityMap")) , (uiRes("m_DynClothMenu.kStretchMap")) , (uiRes("m_DynClothMenu.kWrinkleMap")) }; string $annots[]; if ($whichMenu < 2) { $annots = { (uiRes("m_DynClothMenu.kBounceMapAnnot")) , (uiRes("m_DynClothMenu.kCollideStrengthMapAnnot")) , (uiRes("m_DynClothMenu.kFieldMagnitudeMapAnnot")) , (uiRes("m_DynClothMenu.kFrictionMapAnnot")) , (uiRes("m_DynClothMenu.kStickinessMapAnnot")) , (uiRes("m_DynClothMenu.kThicknessMapAnnot")) , (uiRes("m_DynClothMenu.kTangentialDragMapAnnot")), (uiRes("m_DynClothMenu.kBendMapAnnot")) , (uiRes("m_DynClothMenu.kBendAngleDropoffMapAnnot")) , (uiRes("m_DynClothMenu.kCompressionMapAnnot")) , (uiRes("m_DynClothMenu.kDampMapAnnot")) , (uiRes("m_DynClothMenu.kDeformMapAnnot")) , (uiRes("m_DynClothMenu.kDragMapAnnot")) , (uiRes("m_DynClothMenu.kInputAttractMapAnnot")), (uiRes("m_DynClothMenu.kLiftMapAnnot")) , (uiRes("m_DynClothMenu.kMassMapAnnot")) , (uiRes("m_DynClothMenu.kRestLengthScaleMapAnnot")), (uiRes("m_DynClothMenu.kRestitutionAngleMapAnnot")) , (uiRes("m_DynClothMenu.kRigidityMapAnnot")) , (uiRes("m_DynClothMenu.kStretchMapAnnot")) , (uiRes("m_DynClothMenu.kWrinkleMapAnnot")) }; } else if($whichMenu == 2 ){ $annots = { (uiRes("m_DynClothMenu.kBounceConvertAnnot")) , (uiRes("m_DynClothMenu.kCollideStrengthConvertAnnot")), (uiRes("m_DynClothMenu.kFieldMagnitudeConvertAnnot")) , (uiRes("m_DynClothMenu.kFrictionConvertAnnot")) , (uiRes("m_DynClothMenu.kStickinessConvertAnnot")) , (uiRes("m_DynClothMenu.kThicknessConvertAnnot")), (uiRes("m_DynClothMenu.kTangentialDragConvertAnnot")), (uiRes("m_DynClothMenu.kBendConvertAnnot")) , (uiRes("m_DynClothMenu.kBendAngleDropoffConvertAnnot")) , (uiRes("m_DynClothMenu.kCompressionConvertAnnot")) , (uiRes("m_DynClothMenu.kDampConvertAnnot")) , (uiRes("m_DynClothMenu.kDeformConvertAnnot")) , (uiRes("m_DynClothMenu.kDragConvertAnnot")) , (uiRes("m_DynClothMenu.kInputAttractConvertAnnot")), (uiRes("m_DynClothMenu.kLiftConvertAnnot")) , (uiRes("m_DynClothMenu.kMassConvertAnnot")) , (uiRes("m_DynClothMenu.kRestLengthScaleConvertAnnot")), (uiRes("m_DynClothMenu.kRestitutionAngleConvertAnnot")) , (uiRes("m_DynClothMenu.kRigidityConvertAnnot")) , (uiRes("m_DynClothMenu.kStretchConvertAnnot")) , (uiRes("m_DynClothMenu.kWrinkleConvertAnnot")) }; } else { $annots = { (uiRes("m_DynClothMenu.kBounceConvertVertAnnot")) , (uiRes("m_DynClothMenu.kCollideStrengthConvertVertAnnot")), (uiRes("m_DynClothMenu.kFieldMagnitudeConvertVertAnnot")) , (uiRes("m_DynClothMenu.kFrictionConvertVertAnnot")) , (uiRes("m_DynClothMenu.kStickinessConvertVertAnnot")) , (uiRes("m_DynClothMenu.kThicknessConvertVertAnnot")), (uiRes("m_DynClothMenu.kTangentialDragConvertVertAnnot")), (uiRes("m_DynClothMenu.kBendConvertVertAnnot")) , (uiRes("m_DynClothMenu.kBendAngleDropoffConvertVertAnnot")) , (uiRes("m_DynClothMenu.kCompressionConvertVertAnnot")) , (uiRes("m_DynClothMenu.kDampConvertVertAnnot")) , (uiRes("m_DynClothMenu.kDeformConvertVertAnnot")) , (uiRes("m_DynClothMenu.kDragConvertVertAnnot")) , (uiRes("m_DynClothMenu.kInputAttractConverVertAnnot")), (uiRes("m_DynClothMenu.kLiftConvertVertAnnot")) , (uiRes("m_DynClothMenu.kMassConvertVertAnnot")) , (uiRes("m_DynClothMenu.kRestLengthScaleConvertVertAnnot")), (uiRes("m_DynClothMenu.kRestitutionAngleConvertVertAnnot")) , (uiRes("m_DynClothMenu.kRigidityConverVertAnnot")) , (uiRes("m_DynClothMenu.kStretchConvertVertAnnot")) , (uiRes("m_DynClothMenu.kWrinkleConvertVertAnnot")) }; } string $optAnnots[] = { (uiRes("m_DynClothMenu.kBounceMapOptionAnnot")), (uiRes("m_DynClothMenu.kCollideStrengthMapOptionAnnot")), (uiRes("m_DynClothMenu.kFieldMagnitudeMapOptionAnnot")), (uiRes("m_DynClothMenu.kFrictionMapOptionAnnot")), (uiRes("m_DynClothMenu.kStickinessMapOptionAnnot")), (uiRes("m_DynClothMenu.kThicknessMapOptionAnnot")), (uiRes("m_DynClothMenu.kTangentialDragMapOptionAnnot")), (uiRes("m_DynClothMenu.kBendMapOptionAnnot")), (uiRes("m_DynClothMenu.kBendAngleDropoffMapOptionAnnot")), (uiRes("m_DynClothMenu.kCompressionMapOptionAnnot")), (uiRes("m_DynClothMenu.kDampMapOptionAnnot")), (uiRes("m_DynClothMenu.kDeformabilityMapOptionAnnot")), (uiRes("m_DynClothMenu.kDragMapOptionAnnot")), (uiRes("m_DynClothMenu.kInputAttractMapOptionAnnot")), (uiRes("m_DynClothMenu.kLiftMapOptionAnnot")), (uiRes("m_DynClothMenu.kMassMapOptionAnnot")), (uiRes("m_DynClothMenu.kRestLengthScaleMapOptionAnnot")), (uiRes("m_DynClothMenu.kRestitutionAngleMapOptionAnnot")), (uiRes("m_DynClothMenu.kRigidityMapOptionAnnot")), (uiRes("m_DynClothMenu.kStretchMapOptionAnnot")), (uiRes("m_DynClothMenu.kWrinkleMapOptionAnnot")) }; // Loop through the tables and build the menu // int $index = 0; int $numAttrs = size($attrs); while( $index < $numAttrs ){ // specify the attribute name to be displayed in 3dPaint as second // parameter to paintNClothTexture if( $index == $numCommon ){ menuItem -divider true -dividerLabel (uiRes("m_DynClothMenu.kPhysicalProp")); } string $attrName = $attrs[$index] + "Map"; string $attrLabel = $labels[$index]; string $baseAttr = $attrs[$index]; string $setMapTypeCmd = ("setNClothMapType(\""+$baseAttr+"\"," + $meshParam + ","); string $attrCmd, $optCmd; switch ($whichMenu) { case 0: { // paint vertex map $setMapTypeCmd += "1)"; $attrCmd = ($setMapTypeCmd+"; artAttrNClothToolScript 4 "+$baseAttr); $optCmd = ($setMapTypeCmd+"; artAttrNClothToolScript 3 "+$baseAttr); } break; case 1: { // paint texture $setMapTypeCmd += "2)"; $attrCmd = ($setMapTypeCmd+"; paintNClothTexture " + $attrName + " \"" + $attrLabel + "\" " + ($index < $numCommon ) + " 0" + $meshParam ); $optCmd = ($setMapTypeCmd+"; paintNClothTexture " + $attrName + " \"" + $attrLabel + "\" " + ($index < $numCommon ) + " 1" + $meshParam ); } break; case 2: { // convert texture map to vertex map $attrCmd = ("nClothTextureMapToVtxMap " + $attrName + " " + $meshParam); } break; case 3: { // convert vertex map to texture map $attrCmd = ("nClothVtxMapToTextureMap 1 { \"" + $attrName + "\", \""+ $attrs[$index] + "\", \""+ ($index < $numCommon ) + "\", "+ $meshParam + " }"); } break; } if ($whichMenu == 0) { menuItem -label $labels[$index] -annotation $annots[$index] -image "nClothPaintPerVertex.png" -imageOverlayLabel $vertexlabels[$index] -enable true -command $attrCmd; menuItem -optionBox true -annotation $optAnnots[$index] -image "nClothPaintPerVertex.png" -imageOverlayLabel $vertexlabels[$index] -enable true -command $optCmd; } else if ($whichMenu == 1) { menuItem -label $labels[$index] -annotation $annots[$index] -image "nClothPaintMap.png" -imageOverlayLabel $maplabels[$index] -enable true -command $attrCmd; menuItem -optionBox true -annotation $optAnnots[$index] -image "nClothPaintMap.png" -imageOverlayLabel $maplabels[$index] -enable true -command $optCmd; } else { menuItem -label $labels[$index] -annotation $annots[$index] -enable true -command $attrCmd; } $index++; } setParent -menu ..; } global proc DynCreateConvertOutputMenu( string $parent ) // // Build the convert output Submenu { setParent -menu $parent; menuItem -rtc "nClothLocalToWorld" convertLocalToWorldItem; menuItem -rtc "nClothWorldToLocal" convertWorldToLocalItem; setParent -m ..; } global proc DynCreateRestShapeMenu( string $parent ) // // Build the Submenu { setParent -menu $parent; menuItem -rtc "nClothRestToInputStart" restToInputStartItem; menuItem -rtc "nClothRestToInput" restToInputItem; menuItem -rtc "nClothRestToMesh" restToMeshItem; setParent -menu ..; } global proc DynClothMenu( string $parent ) { setParent -menu $parent; if( `menu -query -numberOfItems $parent` != 0 ) { // // Menu is built already - just return // return; } menuItem -divider true -dividerLabel (uiRes("m_DynClothMenu.kNClothCreate")); menuItem -rtc "nClothMakeCollide" -dmc "performMakeCollideNCloth 2" -ddc "nClothMakeCollideOptions" nClothCreatePassiveItem; menuItem -optionBox true -rtc "nClothMakeCollideOptions"; menuItem -rtc "nClothCreate" -dmc "performCreateNCloth 2" -ddc "nClothCreateOptions" nClothCreateItem; menuItem -optionBox true -rtc "nClothCreateOptions"; menuItem -rtc "nucleusGetnClothExample"; menuItem -divider true -dividerLabel (uiRes("m_DynClothMenu.kNClothEdit")); menuItem -rtc "nClothDeleteHistory"; menuItem -optionBox true -rtc "nClothDeleteHistoryOpt"; menuItem -rtc "nClothDisplayCurrentMesh" displayCurrentMeshItem; menuItem -rtc "nClothDisplayInputMesh" displayInputMeshItem; menuItem -rtc "nClothRemove" -dmc "performRemoveNCloth 2 \"selected\"" nClothRemoveItem; menuItem -divider true -dividerLabel (uiRes("m_DynClothMenu.kNClothProperties")); string $convertOutputItem = `menuItem -label (uiRes("m_DynClothMenu.kNClothConvertOutput")) -annotation (uiRes("m_DynClothMenu.kNClothConvertOutputAnnot")) -subMenu true -tearOff true -allowOptionBoxes false nClothConvertOutputItem`; DynCreateConvertOutputMenu $convertOutputItem; string $restShapeItem = `menuItem -label (uiRes("m_DynClothMenu.kNClothRestShape")) -annotation (uiRes("m_DynClothMenu.kNClothRestShapeAnnot")) -subMenu true -tearOff true -allowOptionBoxes true nucleusRestShapeItem`; DynCreateRestShapeMenu $restShapeItem; menuItem -divider true -dividerLabel (uiRes("m_DynClothMenu.kNClothMaps")); string $paintTextureItem = `menuItem -label (uiRes("m_DynClothMenu.kPaintPropByTexture")) -annotation (uiRes("m_DynClothMenu.kPaintPropByTextureAnnot")) -subMenu true -tearOff true -allowOptionBoxes true nClothPaintPropTextureItem`; DynCreateNPaintPropertiesMenu $paintTextureItem "" 1; string $paintVtxMapItem = `menuItem -label (uiRes("m_DynClothMenu.kPaintPropByVertex")) -annotation (uiRes("m_DynClothMenu.kPaintPropByVertexAnnot")) -subMenu true -tearOff true -allowOptionBoxes true nClothPaintPropVertexItem`; DynCreateNPaintPropertiesMenu $paintVtxMapItem "" 0; string $convertTxToVtxItem = `menuItem -label (uiRes("m_DynClothMenu.kConvertTextureMap")) -annotation (uiRes("m_DynClothMenu.kConvertTextureMapAnnot")) -subMenu true -tearOff true -allowOptionBoxes true nClothConvertTextureItem`; DynCreateNPaintPropertiesMenu $convertTxToVtxItem "" 2; string $convertVtxToTxItem = `menuItem -label (uiRes("m_DynClothMenu.kConvertVtxMap")) -annotation (uiRes("m_DynClothMenu.kConvertVtxMapAnnot")) -subMenu true -tearOff true -allowOptionBoxes true nClothConvertVtxItem`; DynCreateNPaintPropertiesMenu $convertVtxToTxItem "" 3; setParent -m ..; }