Here's how to use XPresso in Cinema 4D.
Ready to make your brain hurt a bit? Ok, so it won't be that bad. We're going to go through using XPresso step by step to build a clock rig that actually ticks on it's own in Cinema 4D. Now this may sound very specific, but by doing this exercise you'll be learning the foundations of how XPresso works that you can use to build your own custom tools to make you a faster MoGrapher.
Tutorial Full Transcript Below 👇:
[spooky pipe organ music]
Joey Korenman (00:18):
Hey there, Joey, here for school of motion in this lesson, we're going to take a look at some of the basics of espresso in cinema 4d espresso is a very powerful tool that may not be the easiest thing to wrap your brain around at first. But once you get in there and you start to understand how to hook everything up, you'll have a very powerful new skill at your disposal that you can use to unleash some real power in cinema 4d. Don't forget to sign up for a free student account so you can grab the project files from this lesson, as well as assets from any other lesson on the site. Now let's hop into cinema 4d and get going. So this is the finished version of the rig that I'm going to post on my website. Um, and if we click on the clock, uh, I basically have all the parts of the clock under this Knoll here, and I have made some user data controls for the clock.
Joey Korenman (01:13):
Um, and I'm going to show you guys how to do this in this tutorial. Um, but let's just see what the clock does. If I am going to make this a project, a thousand frames. So we have a little running time here and I'm just going to hit play and show you guys what happens. So the, uh, the second hand is ticking every second, it takes one more tick, uh, and you may barely be able to see that the minute hand is rotating slowly. Basically right now, this clock is running in real time. Uh, and there are no key frames here. This is all express. So, um, so if we click on the clock, we have some options here. Uh, we have the time multiplier, one equals real time. So right now this is set to one. This clock will literally keep time. If you, if you set it to the current time and you run cinema 4d for a long time, it will tell you the time.
Joey Korenman (02:01):
Uh, so I can't imagine any scenario where you would actually want that in a motion graphics piece. So let's, let's make that 100. All right. And now let's hit play again, and now it's going a hundred times real time. So now you can see the, uh, the minute hand is actually moving pretty quickly and the, our hands even starting to move. Um, and I've actually added some options here to, uh, get rid of the jumpiness, the, the ticking of the second hand. So you could have it be a little bit smoother. Um, and then I've even added a control to get rid of the visibility of the minute hand. Sorry, I have the second hand, um, in case you really want to crank up the speed here, let's say you needed some sort of, you know, time-lapse clock. I mean, you could, you can crank this number up besides you want.
Joey Korenman (02:49):
Um, and then there's some controls to set the starting hour, um, minute and seconds of the clock before it starts running. And then this spline down here, this is actually, if I set this back to one, um, this is actually the spline that controls the animation, uh, of the secondhand. So this, this motion where it kind of, you know, Springs forward and then jiggles a little bit, that's actually created by the spline. So, uh, express so is extremely powerful. It is, I think, far more powerful than expressions and after effects. Uh, and I'm going to show you guys how to build most of this rig, not all of it, cause it would take too long. Um, so I have a copy of this clock, uh, with all of the rigging and express and everything taken off of it. So first of all, if you've never used express, so let me try and explain, uh, what it is and how it works a little bit.
Joey Korenman (03:49):
Um, so express, so is sort of the, uh, cinema 4d version of expressions and cinema 4d has many, many ways to use, uh, code and, and sort of, you know, different ways besides key frames to animate things. Um, there's coffee, there's, there's now Python. Um, and, and then there's espresso, which is probably the simplest way, um, of sort of creating behaviors and, and things like that. So, um, in order to use express, so you need to put an espresso tag on an object in cinema. Now, one thing that, um, is very different about espresso, uh, as opposed to after effects, is that the express so itself, the, the nodes and behaviors you create, they don't actually have to be applied to the object that you want those behaviors to affect. What I mean by that is if I create a new Knoll and this is, this is pretty common, actually a lot of designers do this.
Joey Korenman (04:50):
You could just call this Knoll espresso and the smell doesn't do anything except hold an espresso tag. Um, so I'm gonna right, click it, go to cinema 4d tags and add this espresso tag. And the first thing that happens is this express. So editor pops up with nothing in it. Okay. So now we're ready to add some express up. So let me close this for a second. So I'm in within this express tag, um, I can actually affect any object that's in my scene anywhere. Um, and this can be handy if you wanted to create one master control for your whole scene and you had dozens of objects and they all needed to, to react to some, some controls that are manipulated within the espresso. Um, you could put the expressor tag here, just edited here, but actually control every object in your scene now, because my goal was to create a clock rig that you could just basically copy and paste this clock into your scene and use it.
Joey Korenman (05:53):
I actually want this tag on the clock. Uh, and the reason is, um, that way, if you just, you know, click on the clock and hit copy and paste, all of the espresso and control will come with it, if it was on this express. So no, you'd have to copy both of these. And that, that just seems kind of silly. So in this case, uh, it's better to have the tag right on the object. So now we have this tag, there's nothing in it now, what is this? It looks like graph paper. So the way express, uh, works, um, is very different than expressions and after effects, you don't generally type anything in, it's all done with nodes and you can see what those nodes are, uh, by right clicking in here. And if you go to new node, uh, there are some dropdown menus and you can actually just kind of drill down.
Joey Korenman (06:41):
And all of these things that it's showing me are nodes, you can add. Okay. And the nodes do basically the same things that you can do in after effects with expressions, they perform math. Um, they do conversions between different types of numbers. Um, they can store values. You can use them for if then behavior, you know, if, if this switches on, do this, if it's not do this, and there's a lot of, uh, I mean, you can obviously tell there's a lot of things you can do. There's also options in here in this script menu to actually create nodes where then you would go into, you would go into the note and you would type in some code and you can actually program and get some really, really complicated behavior with espresso. Um, there's also a whole section for thinking particles, uh, and that will be another tutorial for another time, because that is very deep topic.
Joey Korenman (07:34):
Um, but thinking particles actually are controlled entirely through espresso. Um, so, you know, getting the hang of express, so is, is really important to become a cinema 4d artist. Uh, you can do a lot of things without it, but again, it's just like expressions. It's going to make your life a lot easier. So the example of the clock, uh, let's get started here. So if you haven't watched the intro to after effects expressions, um, then I'll just do a quick recap. We basically use the technique of, um, of mapping the time of the composition, uh, to the rotation of the hour and minute hand of the clock. We're going to do the exact same thing here. Okay. So the first thing I'm going to do is, uh, I need a way of getting the time of this project and just like there's a time variable and after effects, there's a time node in cinema 48.
Joey Korenman (08:29):
So I'm going to right. Click new node and then, uh, in express so general way down here, there is a time node. Um, now there are many, many nodes and espresso and, uh, honestly the best way I've found to discover new ones and to, uh, kind of come up with ways of using them is to watch tutorials like this. And then, you know, just try and up with challenges for yourself, things that, um, are very tedious to do by key framing, but you, you suspect could be done with espresso and then go into the cinema 4d help, go to the express of section and try and read through these nodes. I mean, th they are called pretty intuitive things. Um, and so you, most of the time you can just kind of figure it out. So this time node here is going to return the time of the comp.
Joey Korenman (09:21):
Now, uh, you know, let's say we don't know that if this is going to give us seconds or frames, we don't know. Um, and, uh, let me just show you really fast when you click any node in the espresso editor, the properties for that node show up down here. So if there's options that you can change, they'll show up in this little area. Now this doesn't give us any options. So how do I know what this is actually, uh, spitting out? Um, we're going to grab another node, new note express so general. And the one we're looking for is result, um, result, uh, is all it does is basically show you the values that are coming out of other nodes. And this is a good time to explain why, what these nodes, uh, how they're sort of formatted. Um, so the left side of a node, the blue side is the input.
Joey Korenman (10:16):
So some nodes have inputs into them like this result node. Okay. It, it, it needs something inputted into this little blue.in order to work. This node only has an output. All it does is compute the time of the part of the project. And then it spits that value out of this red.here. Um, and in order to connect nodes together, uh, you click the output of one node and you get this little pick whip and you will drag it to the input of another node now express. So doesn't always update automatically. Sometimes you have to, uh, go backwards or forwards a frame. So I'm hitting GNF to go, uh, one frame forward, one frame back, and you can see now we're seeing the result from the time node. And it's clearly not in frames because we're at frame 11 and it's showing 0.4, five eight. But, um, this, uh, this project is most likely in 24 frames a second.
Joey Korenman (11:13):
So if we go to frame 24, we are now getting a one. Okay. So we now know the time node is giving us seconds not frames. And that's actually pretty useful if you're building a clock because you want that clock to run at a constant speed, regardless of the frame rate of your project. Um, so that's actually pretty useful. All right. So now what do we want to do with this value? Uh, we want to map that to the rotation, uh, of these hands. Um, so why don't we start with the, uh, the second hand and then we'll go to the minute hand the hour hand. All right. So in order to effect the second hand, which is this red hand, all the hands are overlapping right now, which is why it looks funny. Um, if you come into your object manager, uh, and you find the second hand, you can literally click and drag it into the espresso editor.
Joey Korenman (12:04):
And you'll see, now we have a node for the hand, so you can see the second hand right now. There's nothing, uh, there there's no values, there's nothing in here. Uh, we have to add everything manually that we want to control. Um, now, because we are, we want to tell the second hand, uh, what it's rotation should be specifically the bank rotation. You can see if I change it here, the second hand rotates around. Um, I want to, uh, I want to find the input for bank rotation here. Um, so again, inputs are on the left side here on the blue. So if you click this blue square, um, you have now some options and you can look through here and pick a million different things about the secondhand object that you can control with espresso. Um, and what we are going to look at is the coordinate coordinate section.
Joey Korenman (13:00):
Uh, and we're going to go down to rotation. And just so you know, the difference between global position global rotation and position rotation, uh, is that when the object is parented to something else, um, the global rotation and position will give you the, the actual position in your entire, you know, project in 3d space. Whereas the position in rotation will give you the, uh, the position rotation relative to its parent. Now this, um, it just so happens that the null clock, which, you know, is the parent of these minute, second, our hands, uh, it's in exactly the same position as all of these hands. So it's not really gonna make a difference in this case, if we use global or if we use just the standard position rotations. So I'm going to use rotation, uh, and I am going to go down to rotation that be for bank.
Joey Korenman (13:55):
And so now if I, um, move this result out of the way, so if I just take the output of the time node, pipe it to the input of the second hand into this rotation, B and I come over here and I hit play, it's going to play. All right. And, uh, you will notice, you know, that it's actually rotating, I mean, not super fast, but the faster than you might think, because you would assume that because over here in your attribute manager, if you click on the second hand, uh, the rotation bank parameter is set to 157 degrees. However we know, by looking at the express that the number actually getting piped into this is 2.75. So why is 2.75 seconds turning into 157 degrees? Well, that is because, uh, unfortunately, um, cause it just makes it a little more complicated, uh, even though you work in degrees, uh, when you're manually changing these values and espresso, uh, you're working in radians and, uh, basically, uh, uh, Radian is a method of talking about degrees using PI.
Joey Korenman (15:15):
So PI is 180 degrees. Two PI is 360 degrees. Um, fortunately you don't really have to worry about that. What you do need to do is convert these radians into degrees. Um, so you can, you, so you can work with them and it'll be a little easier. All right. Um, so what I want to do now is, um, create a control for this clock, um, to set the overall speed of the clock, um, because you know, what, if we want it to go faster or slower than the time note is actually animating. Um, so in order to create controls in cinema, you use user data. So if I click on this clock and I come down here, you can see right now we have no user data. We have basic coordinates and object tabs, and that's it. Uh, if we go to the user data menu right here and click add user data, we now have the manage user data window open up, and this is where we can create controls.
Joey Korenman (16:14):
And there's a lot of options how to do that. So the first thing you do is name the control. Um, so I thought about how I wanted to control this. And it seemed to me the easiest way to think about it would be how fast should our clock move relative to real time. So I'm going to call this the time multiplier. And then I gave myself a little hint saying one equals real time, so that if you want a clock that runs in real time, you would just set the value to one. So then if you look down below this, uh, it's asking for a data type. So you have a lot of different data types. Float is, um, probably the most common float is just means any number really. Um, and then the interface, you can have a float interface, which is essentially just a box like this, uh, where you can type in a number or use these little arrows.
Joey Korenman (17:09):
There's also a float slider, um, which gives you this nice little slider interface. Um, and I'm just going to use float for this. Um, and then what units do we want to use? Um, we're not working in percents here. We're going to use real numbers and your options are real percent degree in meter. Um, and we're just going to use a real number because, um, you know, we just want to type in a one or a two or a 100 or something like that. Um, so then what the step is, um, what increment do you want to move in? If I, if I click the edit arrow here, this upper, this down arrow, um, do I want it to go up by ones by tens or smaller? And I usually set this pretty small like 0.01, so I have more control over it. Um, and then there's options.
Joey Korenman (17:58):
If you want to limit the minimum and the maximum. Now I want to limit the minimum to a zero, but I want to, I don't want to limit the max. I want to make this clock go as fast as you could possibly want it to, and then you can set a default value. So default value will be one we hit. Okay. So now in our clock object, you have a user data tab with our data set up and you can see we have a slider. It, it will go down to zero and no further, it starts at one and it goes up and you can just scrub it up like this. You can hold shift and go quicker, or you can actually come in and type in a value. And now you can, uh, you can use this to start to control some of the espresso.
Joey Korenman (18:42):
So if we leave this at one for now, um, we'll, double-click the express a tag to bring this back up. So now we, uh, we need a way to get access to this user data. So the way you do that is we click and drag the entire clock, no into the express. So window and, uh, that user data we're going to use to basically multiply with the time. Um, so if we multiply one times time, then our secondhand will run in real time. Um, if we make it larger, it will go faster. So, uh, the user data is found in the outputs of the clock, uh, because it's a value that we're getting to use somewhere else. So if you click on this red box and you go all the way down to the bottom, you can actually see the user data for that object and there's our time multiplier.
Joey Korenman (19:34):
Okay. So, uh, so now we have two outputs time and the time multiplier from our user data. Um, and we want to multiply those two together to control the second hand. Alright, so now we need to think about, um, how fast that second hand, uh, needs to go each second. Okay. So that it's actually moving the correct distance in real time. Um, so here's where I had to think about this for a little bit. Uh, a circle again is 360 degrees. There are 60 seconds, uh, on the clock. So if you divide each, if you divide 360 by 60 seconds, that means each second is six degrees. Okay. So if, if this time multiplier is set to one, then I want six. I want this secondhand to move six degrees each second, and that will be real time. So, um, what I need to first do is multiply this time, multiplier times six, because I want to work in degrees when I'm creating this express.
Joey Korenman (20:46):
So it's going to make it easier for me to think and do the math I need to do. Um, so if I want to multiply this time, six, we're going to need to use a math node. So if we right click and do new node, uh, espresso calculate, this is where all of the, the math based nodes are. And you come down to math. So now you have a math node. All right. And the math node does addition, subtraction, multiplication, and division. And it has this other mode called modular, which is really interesting. Um, and, um, we're going to talk about modular a little bit later in the tutorial. So, um, I want to multiply these two numbers together. So if I click on the add node, um, and come down here to the attributes, I can change the function to multiply. All right. And then I can just drag the outputs of these two nodes to the inputs of this node.
Joey Korenman (21:43):
All right. Um, so now we're multiplying one times the time. Um, and actually before we do that, I want to convert this into, I want to multiply this by six so we can, um, so we can convert this into degrees that we're going to be using. So let me move this time out of the way for a second. So, um, if you have a math node, uh, and you only have one input and I want to multiply this input times six, you have two options. One is you can, uh, you can create a new node and in general you can find it, call it constant and they constant we'll just return any number you tell it. And that's all it does. Um, but you don't actually have to do that. You can click on the math node and go to parameter. And if you only have one of the inputs hooked up, then the other one can be typed in down here in the parameter.
Joey Korenman (22:39):
So I'm going to just going to type in six. So now the output of this is going to be whatever our time multiplier is times six. Okay. So right now it's six. So I want to convert that into, um, degrees. All right. Because I want to basically take the number of seconds that have elapsed. So at, at one second, I want that second hand to have moved six degrees and that's it. So, um, the first thing I need to do, because now we know this is expecting radians, but we're, we want to work in degrees because it's easier. Um, I'm going to convert the output of this into degrees. So the way we do that is, um, with a new node express. So calculate degree, and the degree node actually has two modes, radians, two degrees and degrees to radians. Okay. Um, so what we're going to have to end up doing is converting what we're, what we're working with here, which is going to be degrees.
Joey Korenman (23:43):
Um, and at the end, we're going to have to convert it to radians. Okay. Um, and I'm gonna use this result note to kind of check our math as we go along. Okay. So right now, um, we are multiplying our, um, we're multiplying our time multiplier times six. Um, so the result is six. Okay. So six degrees per second. Now we need to multiply this result times time. So I'm going to copy this node and a quick way to do it is to just hold command and drag it. Um, and so now I can connect the output of the time and the output of this multiply here, and let's look at the result of that. Okay. So now every second we are multiplying time six. Okay. So we're at 48 frames, which is two seconds. And this is 12. If I moved to 72 frames, this is now 18.
Joey Korenman (24:46):
Okay. So, uh, we are now successfully making this number go up by six every second. So now if we convert that a degree, cause this isn't degrees, if we convert that degree into radians. So again, here's the degree node it's set to right now, it's at radiance to degree, we want degree to radiant. So S 18 degrees convert that to radians and pump that into the rotation of the secondhand. Alright. So now let's hit play and see what happens. All right. So you can see it's moving one, one little tick every second, you know, one, 1002, 1003, 1000. So that is working exactly as we wanted and just to test, um, and make sure that this, uh, that our, our user data is working. We can now click on the clock, change this to 10. And so now it's moving 10 seconds every second. Okay.
Joey Korenman (25:46):
So now I've got the second hand wired up. It should be pretty easy to, um, to wire up the minute in the, our hands. Okay. So, um, what I'm going to do is, uh, I'm basically going to branch off, um, from, I'm going to branch off from this multiply node here. So if you think about, um, you know, the hand is moving six degrees every second in real time, if we're going in real time. Okay. So, um, you know, how many, how, how many times slower does the minute hand move than the second hand? Well, it moves 60 times slower, right? This has to move 360 degrees for this to move six degrees. Okay. So, um, what I want to do, um, is make a new multiply node down here. Okay. And, um, what I'm going to do is I'm going to take this, I'm going to take this multiply note here and let me get a result node because now as you can see, it can get pretty confusing.
Joey Korenman (26:59):
And, uh, I want to make sure I don't lead you guys down the wrong path. Okay. So this right here, uh, this is basically the degrees that are secondhand is moving. So if we divide that by 60, then that would be the number of degrees that the minute hand needs to move. Okay. So, um, so this multiply node can actually come over here. Um, and I generally try to organize things left to right in order, um, because you can see that this is already starting to get a little bit confusing. Um, and there's a few ways to organize yourself in, in express a one way, um, which might be wise right now is to, uh, get an espresso node in the general section called remark and all our remark does, uh, it lets you type in a comment in the M and the properties here, and you could just type in a second hand and it's just like a little sticky note for yourself.
Joey Korenman (28:00):
Uh, and then the other thing you could do is say, okay, which, um, which nodes are specifically for the secondhand, let's say these two are clearly for the second hand. So I'm going to label this remark and these two nodes, and I'm going to give them a different color. So all I did was click this title color box and made them all green. So it's just a little bit easier to see that way. Um, okay. So now, um, and one other thing you could do is come into the basic tab here and change the name of these express notes. So I could call this branch here. And so I'm kind of leaving myself a little hint. Um, you know, as I, as I get moving, um, I can click on these and see, okay, this is where I'm supposed to branch. You can also, um, create remarks and they only show up when you click on the node, but they can be helpful.
Joey Korenman (28:52):
All right. So, um, so now what we need to do is divide the result of this node here by 60. Um, so I'm going to take this math node and I'm going to change it from multiplied to divide. I'm going to take the input and connect it to the output of this. And then I don't need a second input. I can just come to parameter and type 60. So it's dividing the output of this by 60, and let's use the result node here to see, and it sure is sure is working. And now we need to, uh, do the exact same thing with the second hand, uh, that we do with the second hand, with the minute hand. So I'm actually going to copy this degree node here, because this is already set up to convert degrees to radians. Okay. And then I need to grab the men and hand, pull it down here and grab the rotation bank, pipe it in.
Joey Korenman (29:52):
And now the men in hand is wired up to all right. And you can see that as this makes a full revolution, the minute hand just moves one tick. Alright. So, um, so just using some simple math here, we've got second hand and we've got the men at hand all dialed in and I'm going to make these two, the minute hand in this degree. Now I'm going to make them different colors. And actually this is also part of the men in hand. Um, so I'm going to, uh, I'm going to make them all different color, make them a little wheat. Okay. So now the only one we have left is the, our hand. Um, and obviously that's going to work the same way. So, uh, let's pull the, our hand down here and let's grab the rotation bank. Let's copy this degree node and pipe that in.
Joey Korenman (30:47):
Um, all right. So if we, um, if we say that, you know, a minute hand moves 60 times slower than a second hand, then the hour hand clearly moves 60 times slower than the minute hand. So, um, really all we need to do is double up on this divide note here. So let's copy that and bring it over here. We'll spread these out a little bit, trying to create something that will make sense when I look at this later. Uh, so I'm going to take the output from this divide node, put it into this divide node and a, this divide is already set to divide by 60. So then we pipe output of that into this degrees to radians and into the hour hand. And let's change the color of these. Okay. Let's not do green because we've already done green. Cool. All right. So now let's check this. Um, if we run this clock, it's going to be almost impossible to see the hour hand move at this speed. So I'm going to type in 100. So now the second hand is moving. Um, you know, it's moving really, really fast. Uh, you can see the minute hand clearly moving, but, um, in 144 frame project, this minute hand only moves 10 minutes. So the hour hand still is not moving very fast. So why don't we change this to a thousand?
Joey Korenman (32:20):
Okay. All right. And you can see that this is not working right. Which means I've done my math wrong. Um, and the reason for that is because, um, it's late and I'm a little stupid. Um, yeah, this divide node should not be set to 60. Um, when a minute hand moves all the way around the clock, the hour hand does not move six degrees. The hour hand actually moves one 12th of the way around. So as the minute hand, uh, does a full circle, the hour hand does a one 12th of a circle. Um, so, uh, what really needs to do is divide instead of by 60, we need to divide by 12. Um, so now let's look at that. All right, so now we're at one o'clock, it goes all the way around, and we're almost there. Let me make this project longer. It's going to be hard to check our clock otherwise.
Joey Korenman (33:17):
All right. So we're at one o'clock, Manahan goes all the way around and we're at two o'clock now. All right. So now this clock is wired up to run forever all by itself. Um, that is the basics of, of espresso right there. Uh, you know, you, you pull objects from your object manager into the express. So, uh, you pick which inputs you want to work on, and then you can use other nodes and user controls that you make to, um, to affect things into, you know, create one control, do some math with it and, and work on three objects, you know, and make them all run at different speeds. Um, so if all you wanted to do was learn some basics of, of espresso, you should stop watching this tutorial right now, if you want to see a, a little bit of how you can do some advanced stuff and express.
Joey Korenman (34:10):
So, um, then keep watching, because when I'm going to attempt to do is recreate the rig that I created, and this was kind of tricky. I decided wouldn't it be cool if I could make the secondhand actually tick like a real clock? Um, and so I'm going to show you guys how I did that. Um, so the first thing you need to do is set this back the time multiplier back to one, and, um, let's go into the express and let's think about this for a second. So, um, when, uh, you know, right now the second hand moves at the right speed. Okay. Um, and I knew that, uh, it was, it was going to be tricky to get it to, to tick. So the first thing I wanted to do is figure out how can I make this not move smoothly around, but basically just jump, uh, one second, you know, just every second jump instantly to the next tick mark on the clock. Um, so I use the, um, I'm gonna, I'm going to pull up another result node here, so we can, we can monitor this as we go through it. Okay. So, um, we're going to be working on the second hand up here.
Joey Korenman (35:25):
Okay. So, um, right now, if you look at the, uh, the output of this multiply, now, this is telling us the degrees that the secondhand are moving. Okay. And I actually need is basically, uh, for this to stay zero all the way until we get to frame 24 and then become six instantly. Okay. So, um, what I basically needed was a way to round this number in increments of six. Now, there is no way to round a number in increments of six. You can round a number in increments of one. Um, so what I thought might work is if I take this number here, divide it by six. So now I'm working in increments of one, I round that number and then I multiply the result, time six, it might do what I wanted. Um, and, uh, I don't know. I wish I could explain, you know, why, like how I came up with that.
Joey Korenman (36:35):
I, I just basically bashed my head against my desk until it came out. And sometimes that's the only way I wish I had better news for you guys. Um, all right. So let's try that. So what we're gonna do is we're gonna create a new calculate math node. Alright. And we are going to set that to divide. All right. So we're going to pipe in the output of this and to the top, and then input two is going to be six. So we're dividing by six. So let's look at the result of that now. Okay. And just make sure it's doing what we think. Okay. So now it starts at zero at frame 24, instead of being six, it's now one at frame 48, instead of being 12. It's now two. Okay. Um, and you can see that now we've got, um, you know, in between one and two, you get all these decimal points.
Joey Korenman (37:31):
If we could round this number, basically chop those off. Uh, then we would have a number that's only changing every 24 frames. Um, so what I, what I was looking for, and I'd never used this before, but I was looking for a node that would round the number for me. And I, I maybe I didn't look hard enough, but I couldn't find an obvious one. But what I did find in this, uh, adapter section here is this universal node. And, uh, it takes an input and it spits out an output. And I thought, maybe this is what I'm looking for. And maybe this will convert whatever you put into it, into whatever the note is set to. So I changed the data type from real to integer. Uh, so that way, you know, integers don't have decimal points. Um, so let's pipe the output of this, into this universal adapter and then pipe that into the result.
Joey Korenman (38:31):
Let's check it. So we go to the beginning and we have zero, and then we get to frame 24 and it changes to one. And in between it stays put, so now every 24 frames, it switches. Um, so that made me very happy. I did a little dance and clap my hands. A couple of times, the next thing we need to do is take this and multiply it by six. So we divided by six, got rid of the decimals, multiply it back by six, to get back to our original number. And by doing that, we've basically cut out all those intermediate numbers. So we're going to make a new note express, so calculate math, and we want to, um, multiply this time. So we'll take the output of this universal adapter, pipe it into the input, set the other input to six. Okay. And, uh, so now let's look the result just to check, but I think this is going to work.
Joey Korenman (39:29):
So at frame zero, the result is zero. And as we scrub through, it stays zero until frame 24 and it jumps to six. So now every second we are jumping six degrees. It's exactly what we want. All right. So, um, what I'm going to do is take these two nodes here. All right. Now you can see that right now, the, the output, uh, way back here as being piped into this. Um, and so what's cool is we did all this extra work over here to try stuff out and see what the results going to be. However, we still have our original setup working, and that's one of the great things about express is that you can try different, different ideas and pipe things up, and then look at the result and see if it's working. And if it is, then you can just swap over and you've got a new setup.
Joey Korenman (40:22):
All right. So now let's play this and there you go. You see, now we have the second hand and it is ticking every second to another tick mark. Okay. Now that's pretty cool. And you could stop right there, but I wanted to figure out how do we get this to actually tick like a real clock? All right. So this is where I got a little bit fancy. Um, so I thought about what, what needs to happen in order to make the second hand tick? Well, basically what we've got now is, um, every second we're adding six to the number of degrees. Now in between those seconds, we need to slowly add between zero and six degrees and, uh, and basically cycle between zero and six degrees, um, and be able to control how fast we go from zero to six degrees. Okay. Um, and, uh, that, that probably made no sense when I just explained it, but, uh, watch what I'm talking about.
Joey Korenman (41:30):
So, um, what I want to is, uh, basically take the output of, of this here. Okay. And I want to look at that, the result of that. So right now, and actually what I'm going to do to make this a little bit easier. I'm going to keep this result note, I'm going to make a copy of it and I'm going to pipe into this. Okay. So, um, what you could see is that the output back here, this is before we did all this trickery to, to remove the in-between numbers, this is showing us the original number, right. And then when it gets to 12, boom, this one switches to 12 two. So what I realized was that if you took this number here and subtracted this number here, it would always give you the number of degrees in between the real value and the sort of, you know, staccato value.
Joey Korenman (42:28):
I'm not sure what you would call that syncopated, maybe. Um, and so that number that it would give you would basically cycle between zero and six and then it would loop over and over again. Okay. Um, and I said, well, what if I could take that looping zero to six, that, that we're getting by subtracting this result from this result and map that, uh, you know, in a way where we could control the speed of that number and then add, add the result back to this. Um, so again, I'm sure that made no sense, but let's, let's just do it and see what happens. Um, so what I need to do is create, uh, another math node to subtract this from this. Okay. Sorry, subtract this from this. So new node express, so calculate math. All right. And this is going to be a subtract node.
Joey Korenman (43:24):
So I want to subtract, I want to take this number and subtract this number. All right. Um, and now you can see, we're starting to get noodles all over the place, and sometimes that's not avoidable. Um, I could try to keep this a little, a little more manageable here, but I'm not going to worry about it for this in the rig that I actually posted. I cleaned it up a little bit. So let's look at the result of this and see what we're getting. Okay. Um, so you can see at a zero, both of these numbers are the same. So the result we're getting is zero, right. As we, um, increase in time and we get closer to one second, we approach six and then we jumped back to zero C. So we're just looping by subtracting the original number from this truncated number. Um, we're, we're going between zero and six over and over and over again.
Joey Korenman (44:20):
Um, so what can we do with that? Well, there is a very cool node in espresso. And if you use espresso a lot, you're going to use this over and over and over and over again, and called the range mapper. So if you go to calculate and find the range mapper, what the range mapper does, um, and there's an expression in after-effects very much like this, which I'll talk about in a later tutorial, um, what the range mapper does is it takes a number in the input and it outputs another number. And, uh, it gives you options how to map the input number to the output. So, for example, um, if you made a slider that went from zero to 100%, you could pipe that into the input here. And then the output could be set to go from 1 million to 2 million. So 0% would be 1 million, 100%.
Joey Korenman (45:11):
It would be 2 million. So it just, it takes a range of input numbers and it maps them to a range of output numbers. So what I want to do is map my zero to six here. So I'm going to, I'm going to pipe that into the input. I want to map this zero to six, to a different zero to six, and I'll show you exactly what I mean by that. I'm going to make another result node here, and I'm going to pipe it like this. And in the range map where you have to set a few things. So the type of data is real. That's correct. We're using real numbers. The input range and output range are user defined right now. Um, so if we go into parameter, the input lower and upper, um, we're looking for number zero to six, and we're outputting numbers zero to six.
Joey Korenman (46:00):
Okay. So by default, our input and our output are the same. So if I, if I step through this, you'll see these numbers are identical right now. Okay. Um, now, you know, just to show you guys an easy example of how this works, if I changed this output upper to 20, then now this number changes, and what it's doing is it's looking, uh, for number zero to six, and it's sort of spreading out zero to 20 along that range of zero to six. So it's just mapping a small range of numbers to a larger range of numbers. Now that's not what we want to do here. We actually want the same numbers to come out zero to six, but we want them to come out at a different speed. And one of the things, the range mapper lets you do is set up a spline here.
Joey Korenman (46:46):
Um, and the spline will control the rate at which the input becomes the output. So if I right click in here, uh, in this spline area and I go to spline presets linear, so a linear spline is the default. This just means there's a one-to-one relationship when the input is one, the output will be one. Okay. Um, so if we go back right here, um, the input of this range, mapper is five. The output is also five. If I go into the spline though, and I add a point here and I move this, you can see now the inputs five, but the output is 3.22. So w you know, but if we go to the ending, if we get towards end and we never actually hit six, because the number turns over, but you can see that it does start to accelerate and it gets closer and closer to the original numbers.
Joey Korenman (47:38):
So what we could do is use this, um, use this spline and basically draw a shape. That's going to, um, that's going to add on to our truncated, a number of degrees, a little bit of animation. Um, so if we look at this result, now this should be pretty interesting. So we have our range mapper here, and I've basically created a point in the middle and dragged it all the way to the bottom. And this is saying when the input is zero to probably all the way about four or five, the output is going to remain zero. And then at the very end, it's going to shoot up and we can go from zero to six really quickly. Okay. Um, and if we step through this frame by frame, you can see the results. Uh, the, the input of this range, mapper is 1.25. The output is still zero, and it's going to stay zero until we get very close to the end, and then it's going to shoot up really quickly. Um, so now we have this, this is basically the, the tick animation. Um, and this is the truncated, you know, degree that, that is basically just jumping six degrees. Every second. If we added this and this, then we would have a ticking animation. All right. So let me get rid of all these result nodes, because they're getting a little confusing. Um, let me add a new math node.
Joey Korenman (49:12):
Alright. And I'm gonna set it to add, it's already set to that. And all I need to do now is add this range mapper to this multiply nut. Okay. And now I'm going to disconnect these two nodes and move them away out here, um, and pipe the output into this, and let's have a look at what we have. Okay. So you can see now by adding the, the, uh, jerky movement with the sort of sped up only at the tail end of the animation, uh, you know, tic movement, we now have a ticking clock. Now, what, uh, what I thought was cool was that I could actually, um, you know, it's kind of a pain. If I want to change that spline to have to go in here, find the range map, or go to parameter and change the spline. Um, so I thought, wouldn't it be great if I could make a control right on this clock?
Joey Korenman (50:09):
And it turns out you can, if you go into user data and say, manage user data, since we already have some, you can just say manage, um, and you can see, we have our time multiplier here. Um, you can hit add data. All right. So we're going to call this, um, second and slime. Um, and actually, I want to, uh, I want to show you guys another cool feature. Um, before I do that, um, let's go back into user data, manage user data, um, because I knew I was going to have multiple controls for the secondhand, including whether it's visible or not, whether it ticks or not, um, you know, things like that. I wanted to, um, basically group all of those settings together. So you can actually add a group, um, and call that group whatever you want. You can call it second hand.
Joey Korenman (50:56):
And then in that group, you can add data and you can see there's a little arrow here. And now the data is underneath the second hand group. So we can just call this spline. The data type is going to be a spline and the default value. Um, I can right click in here and set the default to a linear spline hit. Okay. And so now in our user data, we have our time multiplier. We also have a little subsection here for secondhand that you can open up and see the spline. Um, so now, um, I can actually click on this range, mapper and click on this blue box, and you can add inputs to the range mapper. So you can actually add an input for the spline on that range mapper. Uh, and now this is where espresso can get a little confusing. So the, um, the user data I want to pipe into this is way over here on this clock, right?
Joey Korenman (51:52):
If I go way down here, user data, secondhand spline, that's what I want to pipe in. I don't really want a noodle going all the way across all these nodes. So in this case, I'm actually just going to drag another copy of my clock object, so I can, um, and you can have multiple copies of objects and express. So as long as you're not piping different values into the same inputs. So let's click on the output user data, secondhand spline, and there's a lot of options under splined, but we just want the base one spline. And I'm just going to connect the output of the spline to the input of the spline here. So now I can actually adjust the spline right here, right on the clock object. So if I add a point here and go like this, and, uh, and then what I did for the rig was I selected those two points, right?
Joey Korenman (52:41):
Clicked and set the point types to easy ease. And that way I get busy at handles. Um, and to make this even easier to edit, you can right click this and hit show in separate window. And now you can actually make this window bigger and, and drag around and make this spline, do whatever you want. Um, so if we play this, you can see now you've got a little bit more of a natural movement, and I actually added a few more points to this curve in the rig, um, so that I could get, I could get the, uh, I could get it to kind of overshoot, you know, and, and then kind of correct itself, you know, which is what it's kind of doing now. Um, so you can draw this spline any way you want. And that's how that, that second hand is going to animate.
Joey Korenman (53:32):
Woo. All right. Uh, another long tutorial. So, um, that is the basics of espresso. Um, there's some other things I did in my rig, but I think with what I've given you guys, um, you should be able to start playing around and figuring stuff out on your own. Um, again, I'm going to put that this whole clock rig up with a few more options and bells and whistles and, and, and some explanatory remarks, um, in the espresso manager, I'm going to put that [email protected] Um, and I hope this was helpful. Thank you guys. Uh, and I will see you next time. Thanks for watching. I hope you learned something new about cinema 4d that maybe you've never seen before. Of course, this lesson was just the very basics of what you can do with espresso, but hopefully now you'll be able to start tinkering with this very powerful node based system on your own to do some cool stuff in your own projects. If you have any questions or thoughts, let us know, and don't forget to sign up for a free student account to access the project files from the lesson that you just watched, plus a whole bunch of other amazing stuff. Thanks again. I'll see you next time.