# AE ENHANCERS

Expressions/Scripts/Presets
 It is currently Thu May 23, 2013 2:03 pm

 All times are UTC - 8 hours [ DST ]

 Page 1 of 1 [ 10 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Domino ExpressionPosted: Wed Aug 06, 2008 3:32 pm

Joined: Fri Dec 07, 2007 10:11 am
Posts: 128
Here is an expression I wrote that makes pictures drop like domino pieces falling on each other.
You should apply this expression to the xRotation property of a sequence of 3D layers (pictures) that are distributed in the Z-axis. The Anchor point of each layer should be at the bottom of the later.
The expression checks automatically the height of each picture and the distance between adjacent pictures to make the movement accurate and independent of the pictures' size and spacing. You can put as many pictures as you want.

Code:
pi = Math.PI;
D = length(transform.position,thisComp.layer(index+1).position);
H = thisLayer.height;
a1 = -Math.asin(D/H)*180/pi;
b = thisComp.layer(index+1).transform.xRotation;
a2 = b - Math.asin(D/H*Math.cos(b/180*pi))*180/pi;
T = 1;
t = time - index*T;
(t<=0) ? 0 : ( (t<=T) ? linear(t,0,T,0,a1) : a2)

For the last layer give the following, slightly different, expression:

Code:
T = 1;
t = time - index*T;
(t<=0) ? 0 : linear(t,0,2*T,0,-90)

The T variable controls the speed of the animation (this is the time one domino "piece" falls until it touches the next "piece").

I've attached a Project File that uses this expressions for a sequence of white solids, that are distributed in Z-depth (using a Position expression), and includes some lights and couple of cameras:
Camera 1: Shows the animation from a distance.
Camera 2: Uses an expression to move the camera and follow the domino movement.
Start with Camera 1 to see the behaviour, and then switch Camera 1 off to see the more interesting movement of Camera 2.
The lights also follow the domino movement using an expression.

You can use the Null 1 object to control the animation:
T - controls the speed of the animation
dt - controls the spacing between the pictures (don't put more than 1.18 or the pictures will be too far from one another to make a contact when they fall, and expression will go crazy...)

Attachment:
Domino Animation.zip [12.46 KiB]

Enjoy !
Koby.

Top

 Post subject: Re: Domino ExpressionPosted: Sat Aug 16, 2008 3:57 am

Joined: Fri Aug 15, 2008 6:14 am
Posts: 1
Thanks - this is great!
I tried using this with a few short video clips, and it throws a divide by zero error in line 6 - I have a LOT of stills, so this will be very useful, but... any ideas?

Top

 Post subject: Re: Domino ExpressionPosted: Sat Aug 16, 2008 8:44 am

Joined: Fri Dec 07, 2007 10:11 am
Posts: 128
My guess is that you have used images/clips with Height smaller than the distance between the images.
That would result in a divide by zero error, because the image's height must be higher than the distance to the next image in order to touch it when it falls, otherwise the expression formula would not have a solution and AE would result a divide by zero error...

The height of the images in my file is currently 900 pixels, and the current distance is 763 pixels.
If you used images/clips smaller than 763 in height, that would result in an error.
In order to change the distance between the images to fit your images/clips, change the value of the "dt" slider control in the NULL 1 object. I would start with dt=0.5, replace the pictures to your own pictures, and then increase the "dt" value to something you like (if you images are smaller than 382 pix in height, start with smaller dt).

p.s.: Once the divide by zero error occurs, AE won't recalculate again, even if you changed the "dt" value, until you click the (=) sign near the expression. You'll have to click each expression individualy, I don't know how to tell AE to recalculate all expressions again... That's why I would recomend to change the "dt" value, BEFORE you replace the pictures.

Hope that helps.

Top

 Post subject: Re: Domino ExpressionPosted: Wed Aug 20, 2008 2:35 am

Joined: Fri Dec 07, 2007 10:11 am
Posts: 128
Here is a modified expression for the domino effect, that solves the "divide by zero" error, in case the distance between pictures is bigger than images' height. In that case, the "domino pieces" would fall each one at it's own turn instead of trigerring the fall of each other, but this way it will not crash, so you would be able to change the distance between pictures without risking a "divide by zero" error.

Just replace the currect xRotation expression with this one (for all pictures, except for the last one):
Code:
pi = Math.PI;
D = length(transform.position,thisComp.layer(index+1).position);
H = thisLayer.height;
if (D<H){
a1 = -Math.asin(D/H)*180/pi;
b = thisComp.layer(index+1).transform.xRotation;
a2 = b - Math.asin(D/H*Math.cos(b/180*pi))*180/pi;
}else{
a1 = -90;
a2 = -90;
}
T = thisComp.layer("Null 1").effect("T")("Slider");
t = time - index*T;
(t<=0) ? 0 : ( (t<=T) ? linear(t,0,T,0,a1) : a2)

Koby.

Top

 Post subject: Re: Domino ExpressionPosted: Fri Aug 22, 2008 11:43 am

Joined: Thu Aug 21, 2008 8:41 am
Posts: 16
Koby>

Nice animation. I was looking for something like this some time ago for a tv spot, but very dificult to do by keyframes.
Let me ask you a question, using expressions, how can I have the same footage I replaced by the solid, at the front and at the back in every layer, like a mirror, in order to fly with a camera around the comp and get also image at the back, obtaining a good 3D realistic movement.

and again , nice work !!!!

Top

 Post subject: Re: Domino ExpressionPosted: Fri Aug 22, 2008 3:48 pm

Joined: Fri Dec 07, 2007 10:11 am
Posts: 128
ccf,
Just add a light source, lighting the back side of the images, and you will be able to see them from that side.

If you want that lights source just to light the back side of the images and not change the current shadows of the animation, turn off "Cast Shadows" for that light source.

Top

 Post subject: Re: Domino ExpressionPosted: Sat Aug 23, 2008 5:50 pm

Joined: Thu Aug 21, 2008 8:41 am
Posts: 16
Hi Koby:

Great idea !!!!!!!!!!! I will play with the composition and the new light , later I will let you know.

Top

 Post subject: Re: Domino ExpressionPosted: Wed Aug 27, 2008 4:59 pm

Joined: Thu Aug 21, 2008 8:41 am
Posts: 16
Koby:

I was playing with the light as an ambient, and I got wonderful results flying all over the composition.
That was the mirror effect I was looking for.

Bye bye

Top

 Post subject: Re: Domino ExpressionPosted: Thu Feb 12, 2009 7:22 am

Joined: Sun Apr 06, 2008 2:32 pm
Posts: 1
Location: South Florida
Koby,

Very nice animation.

The issue that I have is that I would like the last domino NOT to fall over, but rather stay standing.
Does your modified expression solve this issue?

And is the modified expression applied to only the last layer, or all the layers?

Thanks,
James Wicks

_________________
James Wicks
TV Producer
Jim Wicks Productions
http://www.jimwicks.com

Top

 Post subject: Re: Domino ExpressionPosted: Thu Mar 12, 2009 10:26 am

Joined: Fri Dec 07, 2007 10:11 am
Posts: 128
Hi James,

Thank you very much, I'm glad you've liked the animation

You'd better apply my modified expression to all layers except the last one (it prevents them from making an error, in case you enter wrong parameters in the sliders).

If you want to leave the last domino standing, just dissable the xRotation expression of the last domino layer (delete it or disable it at the (=) button),
and that's it !

Koby.

p.s.: Sorry for not answering sooner, I got married and went for a honeymoon, very far from home ...

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 10 posts ]

 All times are UTC - 8 hours [ DST ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ Announcements    Announcements Expressions    Expressions Library    Expressions Tutorials    Expression Discussion Scripts    General Scripts Library    Script Tutorials    Scripts Discussion    Script requests User Scripts    Paul Tuersley's Scripts    Impudent 1's Scripts Animation Presets    Animation presets Library