// =========================================================================== // 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. // =========================================================================== proc int server(string $dName, string $sName) { //defineDataServer -d $dName -s $sName; return initDataServer($dName,$sName,"localhost", "", "",2); } proc attach1D( string $device, string $channel, float $scale, string $target, string $attribute) { string $axisName; $axisName = $channel; string $atrName = $target+"."+$attribute; attachDeviceAttr -d $device -ax $axisName $atrName; setAttrMapping -a -d $device -ax $axisName -at $attribute -s $scale; } proc string makeCylinder() { string $sarr[] = `cylinder -ax 0 1 0`; return $sarr[0]; } proc attachHands(string $device, string $hands[] ) { attach1D($device, "seconds", 1.0, $hands[0], "rz"); attach1D($device, "minutes", 1.0, $hands[1], "rz"); attach1D($device, "hours", 1.0, $hands[2], "rz"); } proc makeHands( string $dName, string $hands[] ) { // Second hand // $hands[0] = makeCylinder(); scale -a .1 6 .1 $hands[0]; $rp = $hands[0]+".rotatePivot"; select -r $rp; move -r 0 -6 0; select -r $hands[0]; move -r 0 6 0; select; // Minute hand // $hands[1] = makeCylinder(); scale -a .25 6 .25 $hands[1]; $rp = $hands[1]+".rotatePivot"; select -r $rp; move -r 0 -6 0; select -r $hands[1]; move -r 0 6 0; select; // Hour hand // $hands[2] = makeCylinder(); scale -a .5 4 .5 $hands[2]; $rp = $hands[2]+".rotatePivot"; select -r $rp; move -r 0 -4 0; select -r $hands[2]; move -r 0 4 0; select; attachHands($dName, $hands); } proc makeFace() { select; textCurves -s 8 -n "three" 3; select "three"; move -a 9.8615 -2.62462 0; select; textCurves -s 8 -n "six" 6; select "six"; move -a -2 -14.348 0; select; textCurves -s 8 -n "nine" 9; select "nine"; move -a -13.6563 -2.5 0; select; textCurves -s 8 -n "twelve" 12; select "twelve"; move -a -4.30736 9 0; select; sphere; select -tgl; } global proc string mayaClockDemo() { if (!`licenseCheck -m "edit" -typ "complete"`) { error((uiRes("m_mayaClockDemo.kNoLicense"))); } string $dName="clock"; string $sName="mayaClockServer"; if ( 0 != server($dName, $sName) ) { string $format = (uiRes("m_mayaClockDemo.kCouldNotLaunch")); string $errMsg = `format -stringArg $sName $format`; error $errMsg; return ""; } string $hands[3]; makeHands($dName, $hands); rename $hands[0] second_hand; rename $hands[1] minute_hand; rename $hands[2] hour_hand; //makeFace(); return $sName; }