| CreativeCOW Adobe After Effects Tutorial |
![]() |
![]() |
Chris Zwar Entertainment Media South Melbourne, AUSTRALIA ©2003 Chris Zwar and CreativeCOW.net. All rights reserved. |
Article Focus: This tutorial from Chris Zwar is a bit of a one trick pony, but it's a trick that's worth knowing. Cogs and gears are nice looking design elements and are popular in all sorts of backgrounds. If you do a search on the internet, it's easy to find a range of techniques for creating cogs in Photoshop and Illustrator, and Illustrator even comes with a few included. This is part four of a four part series. Next page you'll also find some extra tidbits. |
| Download Movie | Project files .sit | Project files: .zip |
In parts 1 3 of this tutorial series, we saw how we can construct cogs and gears in After Effects using the Path Text effect. Although there are a variety of methods of constructing cogs and gears, using the Path Text effect means that we can create cogs of different sizes which will animate together. Parts 1 3 were about the creation of the cogs; this tutorial is about the animation. More specifically, this tutorial is designed to make you start thinking about expressions, which are incredibly powerful but often overlooked. Expressions were added in version 5, but theyre not obvious - you wouldnt notice the addition of expressions unless you specifically went looking for them. And because they havent changed the way you have to use After Effects, many animators have continued to work exactly as they have for years, and not even had a go. Expressions are an alternative to keyframes instead of setting a definite number (for example, a rotation keyframe of 30 degrees), an expression is a formula or rule which calculates the value automatically. If youve used Excel then youll understand the difference between typing in an actual value, and having Excel calculate it for you with a formula. The aim of this tutorial is to make you appreciate how useful expressions can be, and by showing that something which appears quite complicated is actually simple when you go to do it yourself. Parts 1,2 & 3 of this series used the same After Effects project file but with Part 4, were beginning again from scratch.
Begin by opening a new Project, creating a new composition and importing the necessary files. There are a few image files well be using in the project, including the Worm Gear 1 second loop from tutorial 3, and a range of cogs which I created using the techniques in tutorial 2. You will need to complete Tutorial 3 and render the Worm gear movie. Also download the project files from above. I used the PAL defaults of 768 x 576, at 25 fps. Drag the Worm Gear loop into the timeline and use the loop function to extend the duration to 1 minute detailed in Part 3. ![]() In this case, the X position of the Worm Gear is 50. The first thing well add is the big cog we made in tutorial 2. Its been rendered out as a still image and named Cog 3 36 teeth. Drag it into the composition and position it so the teeth mesh nicely with the worm gear. I used the position values of 219, 127. ![]() Because the worm gear moves upwards, I made the teeth of the cog rest on top of the thread. If the worm gear moved in the opposite direction, I would have made the teeth of the cog rest against the bottom side of a thread. ![]() The idea is to make the Cog rotate as the Worm Gear turns. We could manually keyframe the rotation, but this is a good opportunity to demonstrate a simple expression. The rotation of the cog relates to the rotation of the worm gear. We can use an expression to calculate this for us, and this way well never have to change the settings if we extend the duration of the composition. Select the Cog layer, and press R to reveal the rotation settings. Click on rotation to select the property, and go to Add Expression, in the Animation menu. ![]() After Effects now turns the numbers red, and has added a line of text to the timeline. This line of text is our expression. At this stage, its saying that rotation = rotation. It might be zen, but its also a bit redundant. ![]() What were going to do is set up a rule which determines how the cog relates to the worm gear. We should probably start thinking about what this rule is going to be. The worm gear is an image of a worm gear turning the movie itself doesnt rotate or change position. So we will use the time of the movie as the basis for our expression. We designed the worm gear so that it revolves once per second. Each time it revolves, the teeth move up until after one second, they look like theyve moved up one whole tooth. All of this was done in Part 3. The point is that 1 second = 1 tooth. Our cog has 36 teeth again, we designed it this way in Part 2. So for our cog to do a complete revolution, the worm gear has to turn 36 times 1 revolution of the worm gear for every tooth on the cog. We can use this information to create a relationship between the time of the worm gear movie, and the rotation of the cog. We know that 36 revolutions of the worm gear equal 1 revolution of the cog. We know that 36 revolutions of the worm gear will take 36 seconds. We know that 1 revolution of the cog is 360 degrees. Therefore, our cog has to turn 10 degrees every second 360 degrees divided by 36 seconds. Thats what our expression will do- it will tell After Effects that for every second of the Worm Gear animation, the cog has to turn 10 degrees. Notice these three icons, because theyll become your new best friends: In simple terms, an expression is a formula. But formulas sound complicated and also imply lots of typing, and typing can be tedious. These icons are our saviours they are designed to let us build up expressions with the minimal amount of typing and hassle. Well get to the middle icon later, but for now well use the arrow. The arrow is the shortcut to a menu of common commands. Instead of having to learn complex programming terminology, all we have to do is click on the one we want from a list. Its really simple. In this case, were going to use the time command so click on the arrow to reveal all the options, and from the Global menu select time ![]() After Effects has now inserted the word time where it used to say rotation. ![]() You might be thinking that this is an anti-climax, because you could have typed the word time faster than it took to read that last section but trust me - not having to type in commands is great. Also, if you dont know the correct terminology for a command, you can usually guess by looking at the options. But lets get back to it. The time command works in seconds, and as we need our cog to turn 10 degrees every second, all we have to do is add a *10. Click in the text box and type *10. ![]() Click outside the box and youre done. Thats an expression. The rotation of the cog equals the time (in seconds) multiplied by 10. ![]() Try scrubbing in the timeline and youll notice that the cog now rotates in perfect synchronization with the worm gear. We dont have to think about it any more. Expressions really are simple, so lets set up another one. Drag the other cog the one with 12 teeth into the composition and place it at 383,64. At frame 0, the teeth should mesh nicely with the larger cog. ![]() Its obvious that the large cog will turn the smaller cog, so once again we can easily set up an expression to do this for us. Select the Cog layer with 12 teeth, and press R to reveal the rotation properties. Click on the word rotation to select it, and add expression just as we did earlier. ![]() This time, the rotation of our cog will be directly related to the rotation of the first cog, so adding the expression will be even easier. Remember our new best friends: The centre icon is the pick whip and allows us to click on anything we want to include in our expression. It saves us lots and lots of typing. All we have to do is click on the pick whip icon, and drag it to the rotation of our first cog. If you cant see the rotation of the 36-tooth cog, select the layer and press r so the rotation expression which we just typed is visible. You can drag the pick whip to either the word rotation or to the numbers, even though theyre red and say 0. Youll notice that when you drag the pick whip over the word rotation, After Effects draws a box around it, showing that youre selecting it. When you release the pick whip, After Effects adds the text to our new expression for us: It might look complicated, but remember we didnt have to type a letter. The text which After Effects has inserted is telling it where to find the rotation of the 36-tooth cog. From left to right, the text this_comp means that were looking as this composition (and not a pre-composition, for example). The layer(Cog 3 36 teeth.pct) is telling After Effects which layer were dealing with, and the rotation at the end is telling After Effects that were copying the rotation value. It might look like a jumble, but theres a simple underlying structure. Basically, this line of text is now an expression that makes the rotation of our 12 tooth cog equal that of the layer Cog3 36 teeth.pct. Because our first cog has 36 teeth, and this one only has 12, our 12 tooth cog should rotate 3 times as fast as the big cog (36 / 12 is 3) but in the opposite direction. To adjust our expression to do this automatically, all we have to do is click in the text box and add *-3. And there we have it our second expression. You can scrub in the timeline and youll see how the worm gear is turning the big cog, and the big cog is turning the smaller cog. All without keyframes. Lets do another one just for fun, to emphasise how simple it is. Drag the Cog 7 into the composition it has 16 teeth. Position it at 236,316. At frame 0, it will mesh with the 36 tooth cog nicely. ![]() Just as we did with our second cog, well add a simple expression so the large cog with 36 teeth will turn it. Because we want to link the two rotation properties, we need to be able to see both of them in the timeline. If you cant see the rotation of the 36 tooth cog (as in the screenshot above), select the 36 tooth cog layer and press r to reveal the rotation, then do the same for our new cog, with 16 teeth. This means the properties we want to link are visible. You should know the deal by now click on the word rotation for our 16 tooth cog, select add expression from the menu, then use the pick whip to drag a link to the 36 tooth cog. Notice that you can drag the pick whip to either the word rotation or to the red numbers they both work. ![]() The big cog has 36 teeth, and the smaller one has 16, so the ratio of turns will be 36:16. Do you know what 36 / 16 is? I wouldnt know without a calculator, but After Effects will figure it out. So click in the expression text and add *-(36/16). The minus sign makes the cog turn in the opposite direction. Wow. Now weve added three expressions. Have a quick scrub in the timeline to see how everything is coming along. If we dont slow down a bit we might turn into programmers. The pick whip lets us make simple expressions very easily. If you want, you can import the other cogs which Ive already made and have a ball creating your own drive trains, and use expressions to link them all together (I did, and Ive saved it as a separate project file.) Weve added three really simple expressions that arent complicated, were easy to do, and work really well. But you might be thinking that they werent really necessary. You could have added rotation keyframes just as easily, even though theyre not as flexible. So what well do now is use expressions to create a piece of animation which would be very, very difficult to animate manually and even if you did would be really difficult to adjust afterwards. Were going to add a piston to our composition, and have it linked to our 16 tooth cog in the centre. The expression will automatically calculate the position and rotation of the piston rod for us. ![]() Heres a sneak preview of what were about to do To keep things simple, well begin by using a white solid as the rod we can change it later. Add a new solid to the composition and call it Drive Rod 1. Make it 200 pixels wide and 6 pixels high. I made it white for visibility. ![]() In the timeline, set the anchor point to 0,3. We will be animating the rod from the left side, not the centre which is the default. ![]() The first thing well do is use an expression to set the position of the rod. We want the left side of the solid to be connected to the solid part of the 16 tooth cog. We begin as we did before press p to reveal the position properties, and click on the word position. Then add an expression. ![]() Our Drive Rod needs two values for its position an X value, or horizontal position, and a Y value, or vertical position. These positions will have a direct relationship to the number of degrees that the cog its attached to has turned - the relation of the position of the rod to the cog is determined by using trigonometry. This might sound scary, but its nothing more than we learned in high school and in actual fact, I just did a Google search for trigonometry and found the information which I needed. ![]() The rotation of the cog will determine the x& y position of the rod. I learned this on the internet, showing that its useful for more things than rude pictures. Remember our best friends? Were going to use the menu (the arrow on the right) to add the commands, so we dont have to type much. Youll be amazed at how easy it is to create an expression that looks complicated without even typing anything. The X position of the rod is related to the Cosine of the cogs rotation. I learned this on the Internet so it must be true. Click on the arrow to show all our commands, and under the JavaScript Math menu, choose the first one Math.cos(val). ![]() Notice how After Effects adds the command to our timeline. ![]() The word val is short for value, and this is where we put in the bit that relates to us. Highlight the word val, because were going to replace it. Now that its highlighted, we can use the pick whip to select what we want to replace it with we dont have to type anything. In this case, its the rotation of the 16 tooth cog. If you cant see the rotation value of the 16 tooth cog, youll need to select the Cog layer and press r. This will give you an error message because we havent finished our expression yet. But you can ignore it, because were coming right back to it. ![]() Drag the pick whip down to the rotation of the 16 tooth cog, and when you release it After Effects will insert the correct text into your expression for you. Theres one little catch. The JavaScript based commands work in Radians, while After Effects works in Degrees. In order for the Cosine command to work properly, we need to convert the degrees to radians first. But once again, we dont have to worry about the format of the command or even type anything just use the menu. If there isnt, you need an opening bracket after the s in Cos then position the cursor after the bracket, and select Degrees to Radians. ![]() After Effects has inserted the correct command for us. However, where it says degrees in brackets is where we want our rotation value, so move the text up as follows, and close the brackets at the end: ![]()
Select the Drive Rod layer and press r to reveal the rotation properties. Select the word rotation and add expression. You should be getting good at this by now.
Our completed expression
In part one, we look at the basic concept behind making cogs in After Effects, using the Path Text effect. This will demonstrate our trick in detail. In part two, we look at how we can extend this basic technique to produce more interesting looking cogs, using textures easily found on the internet. In part three, we extend the same techniques to construct a worm gear. And part four demonstrates how we can use simple expressions to create amazing animations using the parts we created in parts 1, 2 & 3. Part 4 Extras: From this basic overview, I created a more complete project with more cogs, and a few finishing touches. The project is called Part 4 Extras, and although it isnt a tutorial, there are a few notes about various refinements in it. --- Chris Zwar Please discuss this technique in the After Effects forum at Creativecow.net
|
Please visit our forums and view other articles at CreativeCOW.net if you found this page from a direct link.