hto
02-02-2006, 09:31 PM
Hi,
I'm doing a script that get Keyframes from a curve (clusters), Randomize and Set newKeyframes. I animate one curve, but the new ones I want to be automatically.
This curves flying around an arm. so I need a little bit of collision detection. one of the problems that I have. is I can't make my script dynamic. what I meand I need to give all the names of the clusters,
string $clusterOrder[11] = {"curve4", "cluster11Handle1", "cluster10Handle1", "cluster9Handle1", "cluster8Handle1", "cluster7Handle1", "cluster6Handle1", "cluster5Handle1", "cluster4Handle1", "cluster3Handle1", "cluster2Handle1", "cluster1Handle1"};
but I would like the program take it automatically.
$clusterOrder = `ls -type clusterHandle`;
But this is not working properly.
This is the script that I'm working so far.
// Get the Keyframes, Randomize and Set newKeyframes.
//------------------------------------------ Variables------------------------------------------------------------------
int $t=0;
//string $clusterOrder[11] = {"curve4", "cluster11Handle1", "cluster10Handle1", "cluster9Handle1", "cluster8Handle1", "cluster7Handle1", "cluster6Handle1", "cluster5Handle1", "cluster4Handle1", "cluster3Handle1", "cluster2Handle1", "cluster1Handle1"};
string $clusterOrder[];
float $random, $imp;
//----------------------------------------------------------------------------
//Put all the clusters in a list
$clusterOrder = `ls -type clusterHandle`;
//Calculate how many keys exist in the clusters
// Set keys position.
for ($i = 0; $i < size($clusterOrder); $i++) {
//print ($i +"\n");
float $keyCount=`keyframe -q -kc ($clusterOrder[$i] + ".tx")`;
for($k=0; $k<$keyCount; $k++) {
$random=`rand -1 2`;
keyframe -e -at tx -in $k -vc $random $clusterOrder[$i];
float $imp = `getAttr ($clusterOrder[$i] + ".tx")`;
//print ($imp);
}
float $keyCount=`keyframe -q -kc ($clusterOrder[$i] + ".ty")`;
for($k=0; $k<$keyCount; $k++) {
$random=`rand -1 2`;
keyframe -e -at ty -in $k -vc $random $clusterOrder[$i];
float $imp = `getAttr ($clusterOrder[$i] + ".ty")`;
//print ($imp);
}
float $keyCount=`keyframe -q -kc ($clusterOrder[$i] + ".tz")`;
for($k=0; $k<$keyCount; $k++) {
$random=`rand 0 3`;
keyframe -e -at tz -in $k -vc $random $clusterOrder[$i];
float $imp = `getAttr ($clusterOrder[$i] + ".tz")`;
// print ($imp);
}
}
Thanks for your help.
I'm doing a script that get Keyframes from a curve (clusters), Randomize and Set newKeyframes. I animate one curve, but the new ones I want to be automatically.
This curves flying around an arm. so I need a little bit of collision detection. one of the problems that I have. is I can't make my script dynamic. what I meand I need to give all the names of the clusters,
string $clusterOrder[11] = {"curve4", "cluster11Handle1", "cluster10Handle1", "cluster9Handle1", "cluster8Handle1", "cluster7Handle1", "cluster6Handle1", "cluster5Handle1", "cluster4Handle1", "cluster3Handle1", "cluster2Handle1", "cluster1Handle1"};
but I would like the program take it automatically.
$clusterOrder = `ls -type clusterHandle`;
But this is not working properly.
This is the script that I'm working so far.
// Get the Keyframes, Randomize and Set newKeyframes.
//------------------------------------------ Variables------------------------------------------------------------------
int $t=0;
//string $clusterOrder[11] = {"curve4", "cluster11Handle1", "cluster10Handle1", "cluster9Handle1", "cluster8Handle1", "cluster7Handle1", "cluster6Handle1", "cluster5Handle1", "cluster4Handle1", "cluster3Handle1", "cluster2Handle1", "cluster1Handle1"};
string $clusterOrder[];
float $random, $imp;
//----------------------------------------------------------------------------
//Put all the clusters in a list
$clusterOrder = `ls -type clusterHandle`;
//Calculate how many keys exist in the clusters
// Set keys position.
for ($i = 0; $i < size($clusterOrder); $i++) {
//print ($i +"\n");
float $keyCount=`keyframe -q -kc ($clusterOrder[$i] + ".tx")`;
for($k=0; $k<$keyCount; $k++) {
$random=`rand -1 2`;
keyframe -e -at tx -in $k -vc $random $clusterOrder[$i];
float $imp = `getAttr ($clusterOrder[$i] + ".tx")`;
//print ($imp);
}
float $keyCount=`keyframe -q -kc ($clusterOrder[$i] + ".ty")`;
for($k=0; $k<$keyCount; $k++) {
$random=`rand -1 2`;
keyframe -e -at ty -in $k -vc $random $clusterOrder[$i];
float $imp = `getAttr ($clusterOrder[$i] + ".ty")`;
//print ($imp);
}
float $keyCount=`keyframe -q -kc ($clusterOrder[$i] + ".tz")`;
for($k=0; $k<$keyCount; $k++) {
$random=`rand 0 3`;
keyframe -e -at tz -in $k -vc $random $clusterOrder[$i];
float $imp = `getAttr ($clusterOrder[$i] + ".tz")`;
// print ($imp);
}
}
Thanks for your help.
