// =========================================================================== // 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: 2003 // // Description: // Routine to make dynamic curves from passed nurbs curve array. // global proc attachCurvesToHairSystem( string $hsys, string $curves[], int $lockEnds ) { int $numCurves = size( $curves ); if( $numCurves < 1 ){ return; } string $groupNames[] = getHairSystemGroups( $hsys, true ); string $parent = ""; int $endIndex[] = {0}; int $i, $j, $k, $l; for( $i = 0; $i < size($curves); $i++ ){ string $curve = $curves[$i]; // Determine if the curve is a COS or just a regular curve. // This is cloned from "convertCurvesToStrokes.mel" int $COS = 0; string $relatives[] = `listRelatives -ap -p $curve`; for ($j = 0; $j < size( $relatives ); $j++) { string $testMe = $relatives[$j]; if (`nodeType $testMe` == "transform") { string $testList[] = `listRelatives -ap -p $testMe`; for ($k = 0; $k < size( $testList ); $k++) { string $subTest = $testList[$k]; if (`nodeType $subTest` == "curveVarGroup") { string $testList2[] = `listRelatives -ap -p $subTest`; for ($l = 0; $l < size( $testList2 ); $l++) { if (`nodeType $testList2[$l]` == "nurbsSurface") { $COS = 1; $parent = $testList2[$l]; $j = size( $relatives ); $k = size( $testList ); $l = size( $testList2 ); } } } else { if (`nodeType $testList[$k]` == "nurbsSurface") { $COS = 1; $parent = $testList[$k]; $j = size( $relatives); $k = size( $testList ); } } } } else if (`nodeType $testMe` == "nurbsSurface") { $parent = $testMe; $COS = 1; $j = size( $relatives); } } if ( $COS == 1 ) { // the name in $curves is something like nurbsPlane->curve1: this // has illegal characters for a name so we use the default naming // string $cFS = `createNode "curveFromSurfaceCoS" -name ($curves[$i] + "cFS")`; string $cFS = `createNode "curveFromSurfaceCoS"`; // Do we need to check the index of the WS connections? connectAttr ($curve + ".ws[0]") ($cFS + ".curveOnSurface"); connectAttr ($parent + ".ws[0]") ($cFS + ".inputSurface"); $curve = $cFS; } string $surf = ""; // no surface to attach to int $doRest = false; string $hname = createHairCurveNode($hsys, $surf, 0.0, 0.0, 0, true, true, $doRest, false, $curve, 1.0, $endIndex, $groupNames[0], $groupNames[1], 1); if( $lockEnds && size( $hname ) > 0 ){ setAttr ( $hname + ".pointLock" ) 3; setAttr ( $hname + ".restPose" ) 1; } } }