// =========================================================================== // 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: 20 Feb 2002 // // Description: // Make Collide // global proc doMakeCollideFluid( int $version, string $args[] ) { if(( $version < 1 ) || ( size( $args ) < 1 )) { error(uiRes("m_doAppendHairCache.kIncorrectVersion")); return; } int $tess = $args[0]; string $selected[] = `ls -sl`; // Handle the case where the xform nodes are selected. string $nurbs[] = `listRelatives -ni -s -type "nurbsSurface" $selected`; string $meshs[] = `listRelatives -ni -s -type "mesh" $selected`; string $fluids[] = `listRelatives -type "fluidShape" -type "fluidTexture3D" -type "fluidTexture2D" $selected`; // Handle the case where the shape nodes are selected. string $select; for( $select in $selected ) { if( `nodeType $select` == "nurbsSurface" ) $nurbs[size($nurbs)] = $select; if( `nodeType $select` == "mesh" ) $meshs[size($meshs)] = $select; if( `nodeType $select` == "fluidShape" ) $fluids[size($fluids)] = $select; } if( size($nurbs) + size($meshs) == 0 ) { error ((uiRes("m_doMakeCollideFluid.kSelectNurbsOrMesh"))); return; } if( size($fluids) == 0 ) { error((uiRes("m_doMakeCollideFluid.kSelectFluid"))); return; } string $cmd; string $geometry; string $fluid; string $fmt = (uiRes("m_doMakeCollideFluid.kAlreadyColliding")); for($geometry in $nurbs) { for($fluid in $fluids) { if(`collision -q $geometry $fluid`) { warning(`format -s $geometry -s $fluid $fmt`); continue; } $cmd = "createNode geoConnector;"; string $geo = evalEcho($cmd); setAttr ($geo + ".tessellationFactor") $tess; $cmd = "connectAttr " + $geometry + ".message " + $geo + ".owner;"; evalEcho($cmd); $cmd = "connectAttr " + $geometry + ".worldMatrix[0] " + $geo + ".worldMatrix;"; evalEcho($cmd); $cmd = "connectAttr " + $geometry + ".local " + $geo + ".localGeometry;"; evalEcho($cmd); $cmd = "connectAttr -na " + $geo + ".resilience " + $fluid + ".collisionResilience;"; evalEcho($cmd); $cmd = "connectAttr -na " + $geo + ".friction " + $fluid + ".collisionFriction;"; evalEcho($cmd); $cmd = "connectAttr -na " + $geo + ".sweptGeometry " + $fluid + ".collisionGeometry;"; evalEcho($cmd); $cmd = "connectAttr time1.outTime " + $geo + ".currentTime;"; evalEcho($cmd); } } for($geometry in $meshs) { for($fluid in $fluids) { if(`collision -q $geometry $fluid`) { warning(`format -s $geometry -s $fluid $fmt`); continue; } $cmd = "createNode geoConnector;"; string $geo = evalEcho($cmd); setAttr ($geo + ".tessellationFactor") $tess; $cmd = "connectAttr " + $geometry + ".message " + $geo + ".owner;"; evalEcho($cmd); $cmd = "connectAttr " + $geometry + ".worldMatrix[0] " + $geo + ".worldMatrix;"; evalEcho($cmd); $cmd = "connectAttr " + $geometry + ".outMesh " + $geo + ".localGeometry;"; evalEcho($cmd); $cmd = "connectAttr -na " + $geo + ".resilience " + $fluid + ".collisionResilience;"; evalEcho($cmd); $cmd = "connectAttr -na " + $geo + ".friction " + $fluid + ".collisionFriction;"; evalEcho($cmd); $cmd = "connectAttr -na " + $geo + ".sweptGeometry " + $fluid + ".collisionGeometry;"; evalEcho($cmd); $cmd = "connectAttr time1.outTime " + $geo + ".currentTime;"; evalEcho($cmd); } } }