Continuing from last thread, here is another example of the same method translating objects using locators distance.
The creation of the spiral polyPlanes are preety straight forward. I used extruded curves to create the spiral. Then attach the polyPLane into the spiral curve with animation path. Then create the snapshots of the polyPlanes to "duplicate" those polyPlanes along the spiral curve.
I created simple mel to automate the setup of those locators to each polyPlanes. Here is the mel code :
string $tempObj[] = `ls -sl`;
string $ctrlLocs[] = `spaceLocator -n "ctrlLoc"`;
for ($i = 0; $i <>
{
//Create Locator & set translate xyz into obj cord
string $locs[] = `spaceLocator -n ("baseLoc_0" + $i)`;
string $pointCons[] = `pointConstraint -offset 0 0 0 -w 1 $tempObj[$i] $locs[0]`;
delete $pointCons[0];
//Create distance node
string $dist = `createNode distanceBetween`;
//Connect distance node two locator into distance node
connectAttr -f ($ctrlLocs[0] + ".translate") ($dist + ".point1");
connectAttr -f ($locs[0] + ".translate") ($dist + ".point2");
//Create multiplyDivide, plusMinusAverage, setRange & condition node
string $mDiv = `createNode multiplyDivide`;
string $plusMin = `createNode plusMinusAverage`;
string $range = `createNode setRange`;
string $cond = `createNode condition`;
//Connect distance into multi & cond
connectAttr -f ($dist + ".distance") ($mDiv + ".input1X");
connectAttr -f ($dist + ".distance") ($cond + ".firstTerm");
//Set value of multi, range & condition
setAttr ($mDiv + ".input1Y") 1;
setAttr ($mDiv + ".input2Y") 1;
setAttr ($range + ".maxX") 4;
setAttr ($range + ".oldMaxX") 1;
setAttr ($cond + ".operation") 4;
setAttr ($cond + ".secondTerm") 4;
setAttr ($plusMin + ".operation") 2;
setAttr ($mDiv + ".input2X") 4;
setAttr ($mDiv + ".operation") 2;
setAttr ($cond + ".colorIfFalseR") 0;
//Connect multi to plusMin
connectAttr -f ($mDiv + ".outputY") ($plusMin + ".input1D[0]");
connectAttr -f ($mDiv + ".outputX") ($plusMin + ".input1D[1]");
//Connect plusMin to range node
connectAttr -f ($plusMin + ".output1D") ($range + ".valueX");
//Connect range to cond
connectAttr -f ($range + ".outValueX") ($cond + ".colorIfTrueR");
//Connect cond to obj translate Y
connectAttr -f ($cond + ".outColorR") ($tempObj[$i] + ".ty");
}
The creation of the spiral polyPlanes are preety straight forward. I used extruded curves to create the spiral. Then attach the polyPLane into the spiral curve with animation path. Then create the snapshots of the polyPlanes to "duplicate" those polyPlanes along the spiral curve.
I created simple mel to automate the setup of those locators to each polyPlanes. Here is the mel code :
string $tempObj[] = `ls -sl`;
string $ctrlLocs[] = `spaceLocator -n "ctrlLoc"`;
for ($i = 0; $i <>
{
//Create Locator & set translate xyz into obj cord
string $locs[] = `spaceLocator -n ("baseLoc_0" + $i)`;
string $pointCons[] = `pointConstraint -offset 0 0 0 -w 1 $tempObj[$i] $locs[0]`;
delete $pointCons[0];
//Create distance node
string $dist = `createNode distanceBetween`;
//Connect distance node two locator into distance node
connectAttr -f ($ctrlLocs[0] + ".translate") ($dist + ".point1");
connectAttr -f ($locs[0] + ".translate") ($dist + ".point2");
//Create multiplyDivide, plusMinusAverage, setRange & condition node
string $mDiv = `createNode multiplyDivide`;
string $plusMin = `createNode plusMinusAverage`;
string $range = `createNode setRange`;
string $cond = `createNode condition`;
//Connect distance into multi & cond
connectAttr -f ($dist + ".distance") ($mDiv + ".input1X");
connectAttr -f ($dist + ".distance") ($cond + ".firstTerm");
//Set value of multi, range & condition
setAttr ($mDiv + ".input1Y") 1;
setAttr ($mDiv + ".input2Y") 1;
setAttr ($range + ".maxX") 4;
setAttr ($range + ".oldMaxX") 1;
setAttr ($cond + ".operation") 4;
setAttr ($cond + ".secondTerm") 4;
setAttr ($plusMin + ".operation") 2;
setAttr ($mDiv + ".input2X") 4;
setAttr ($mDiv + ".operation") 2;
setAttr ($cond + ".colorIfFalseR") 0;
//Connect multi to plusMin
connectAttr -f ($mDiv + ".outputY") ($plusMin + ".input1D[0]");
connectAttr -f ($mDiv + ".outputX") ($plusMin + ".input1D[1]");
//Connect plusMin to range node
connectAttr -f ($plusMin + ".output1D") ($range + ".valueX");
//Connect range to cond
connectAttr -f ($range + ".outValueX") ($cond + ".colorIfTrueR");
//Connect cond to obj translate Y
connectAttr -f ($cond + ".outColorR") ($tempObj[$i] + ".ty");
}
Komentar
Posting Komentar
Monggo komennya