// =========================================================================== // 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 changeNParticleInput( string $nParticle, string $attr, int $newVal) { if( !objExists($nParticle) ){ return; } string $ramp, $pp; int $isVector = false; if( $attr == "radiusScaleInput" ){ $ramp = "internalRadiusRamp"; $pp = "radiusPP"; } else if( $attr == "massScaleInput" ) { $ramp = "internalMassRamp"; $pp = "mass"; } else if( $attr == "frictionScaleInput" ) { $ramp = "internalFrictionRamp"; $pp = "frictionScalePP"; } else if( $attr == "stickinessScaleInput" ) { $ramp = "internalStickinessRamp"; $pp = "stickinessScalePP"; } else if( $attr == "collideStrengthScaleInput" ) { $ramp = "internalCollideStrengthRamp"; $pp = "collideStrengthPP"; } else if( $attr == "bounceScaleInput" ) { $ramp = "internalBounceRamp"; $pp = "bounceScalePP"; } else if( $attr == "viscosityScaleInput" ) { $ramp = "internalViscosityRamp"; $pp = "viscosityScalePP"; } else if( $attr == "surfaceTensionScaleInput" ) { $ramp = "internalSurfaceTensionRamp"; $pp = "surfaceTensionScalePP"; } else if( $attr == "pointFieldScaleInput" ) { $ramp = "internalFieldScaleRamp"; $pp = "pointFieldScalePP"; } else if( $attr == "opacityScaleInput" ) { $ramp = "internalOpacityRamp"; $pp = "opacityPP"; } else if( $attr == "incandescenceInput" ) { $isVector = true; $ramp = "internalIncandescenceRamp"; $pp = "incandescencePP"; } else if ($attr == "colorInput") { $isVector = true; $ramp = "internalColorRamp"; $pp = "rgbPP"; } else { return; } string $source = ($nParticle + "." + $ramp); string $dest = ($nParticle + "." + $pp); if( $newVal == 0 ){ // destroy connections if( $pp == "mass" ){ // can only disconnect mass as it is not a dynamic attr if( isConnected( $source, $dest ) ){ disconnectAttr $source $dest; } } else { if( objExists( $dest ) ){ deleteAttr $dest; } $dest = $dest + "0"; if( objExists( $dest ) ){ deleteAttr $dest; } } } else { if( !objExists( $dest ) ){ if( $isVector ){ addAttr -ln $pp -dt vectorArray $nParticle; } else { addAttr -ln $pp -dt doubleArray $nParticle; } } if( !isConnected( $source, $dest ) ){ connectAttr -f $source $dest; } $dest += "0"; if( !objExists( $dest ) ){ $pp += "0"; if( $isVector ){ addAttr -ln $pp -dt vectorArray $nParticle; } else { addAttr -ln $pp -dt doubleArray $nParticle; } } } }