PDA

View Full Version : Animation incrementation


nelsig
12-17-2004, 07:41 PM
Does someone help me ? I try to create a hudge advertising panel sliced in small rotating blades. So can be 2 or 3 different visuals displayed on the same board ! When the blades rotate it reveals the second visual.

I have a lot of incremented blades in my scene (disp_001, disp_002, disp_003,
etc.) and I want to have a script or expression to key frame only the disp_001.ry and the rest of the blades form a wave to the new goal rotation.

But the problem I don't know anything about mel and expressions :banghead:

Thanks a lot for your Greaaat Help !

Nicolas Elsig

nelsig
12-18-2004, 03:04 PM
Ok ... I started learning C today keeping in mind to find a solution to my problem and to try to understand mel scripting basis

I did a very simple "app" that do what I want, here is the code

#include <stdio.h>

int main (int argc, const char * argv[]) {
// disp_N.ry test in C
int n , p;
printf("disp_001.ry : ");
scanf("%d", &n);
printf("Increment disp_002.ry : ");
scanf("%d", &p);
do
{ printf("%d\n", n=n+p);
}
while (n != 90);
printf("90 atteint");
}

but now the problem if I apply this to an expression, the disp_002.ry value become 90, but what I want is that the value increments during I play the animation

Dirk Bialluch
12-18-2004, 05:06 PM
Hope I understood your problem right. The following expression will rotate a definable number of objects called obj2, obj3, ... based on the (keyframed or whatever) y rotation of obj1. The delay value specifies the amount of frames to wait until the next blade starts rotating.


string $objName = "obj"; // blade base name
int $numObj = 10; // number of blades
float $delay = 3.0; // time delay

// iterate through blades, animation is taken from very first blade "obj1"
for( $cnt = 1; $cnt < $numObj; $cnt++ )
{
setAttr ( $objName + ( $cnt + 1 ) + ".ry" ) `getAttr -t ( frame - $delay * $cnt ) ( $objName + "1.ry" )`;
}


Cheers,
Dirk

nelsig
12-18-2004, 07:18 PM
Thank you so much ! it works great and exactly as I desired

:bounce:

Nicool
12-25-2004, 01:57 AM
Dirk solution is cool :thumbsup: Here is another solution for this kind of application. Do not use -time flag of getAttr. This expression gives not the same result. b object tends to follow a (Dirk's solution have the have b to follow a exact path).


// Parameters

string $master = "a";
string $follower = "b";
float $delay = 2;
string $evaluatedAttr[] = {"tx", "ty", "tz"};


// Process

for($attr in $evaluatedAttr) {

float $masterAttrValue = `getAttr ($master+"."+$attr)`;
float $followerAttrValue = `getAttr ($follower+"."+$attr)`;
float $value = (($masterAttrValue - $followerAttrValue)/$delay);
setAttr ($follower+"."+$attr) $value;
}




This expression is like US Football or Rugby (even wide life hunting). A good workflow would be to replace $delay by an animatable attribute (e.g. addAttr on b). Then reduce delay value during the time. At the end, acceleration, b will have joined a (even though a is moving).

Hope it helps even after you got the solution :wip:

- Nico

CGTalk Moderation
01-20-2006, 04:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.