Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Introducing Xpresso

From: CINEMA 4D Essentials 8: Character Rigging and Xpresso

Video: Introducing Xpresso

Have you ever been interested in learning scripting, but have been afraid of all that code? Do you like the pick whips in After Effects for linking layers and parameters? Well, if you answered yes to those questions, then you're going to love XPresso. XPresso is about establishing relationships between objects or parameters. To illustrate that, let's create a very simple relationship here. I'm going to add a cube to a scene and move it on its negative X axis, and let's add a pyramid to the scene. What I want to be able to do is to have this pyramid drive the rotation of this cube.

Introducing Xpresso

Have you ever been interested in learning scripting, but have been afraid of all that code? Do you like the pick whips in After Effects for linking layers and parameters? Well, if you answered yes to those questions, then you're going to love XPresso. XPresso is about establishing relationships between objects or parameters. To illustrate that, let's create a very simple relationship here. I'm going to add a cube to a scene and move it on its negative X axis, and let's add a pyramid to the scene. What I want to be able to do is to have this pyramid drive the rotation of this cube.

The first step in our process for creating the relationship with XPresso is to add an XPresso tag. Let's right-click on the pyramid and go to CINEMA 4D tags, and then XPresso. When I let go, I get an XPresso Editor that pops up here, and then I also have this little XPresso tag on my object. It's good form to put the XPresso tag on the objects that you're going to be controlling. In theory though, XPresso tags can exist just about any place in your scene. Now I'm going to bring the XPresso Editor down just a bit, and let's actually make the window smaller so we can see the whole thing and bring it down right here.

Now what I want to be able to do is drive the rotation of the cube with the rotation of the pyramid. Now what I need to do is to get my nodes for each of these objects here in the X group window. So let's take the pyramid and drag it over here and I get this little rounded rectangle, and let's drag the cube and drag it in. Now I get a rounded rectangle for that. Now these are called nodes. And if I expand the node outward a little bit, and I'll do that for each of them, the size doesn't really matter. It's just a question of being able to read the contents of the node.

Now you may have noticed that there is colors here in the XPresso Editor window and those colors are very important. The node system in XPresso is designed around the idea of inflows and outflows. On the left-hand side is blue, and those are inflows. On the right-hand side is red, and those are outflows. If I click on each of these colors you see I get properties, and these properties will change based on which side you click on, but also want type of object it is or node that you're using. This node, when I select it, has its own set of parameters, and for a basic object operator node, the only real parameter I can change is the reference.

This tells me what object in the system it's referencing. So I want to establish a link between the rotation of the pyramid and the rotation of the cube. So let's go to the Pyramid and do Coordinates > Global Rotation > Global Rotation-H. That's around the Y axis. Let's enlarge the node just a little bit. Now what we can do to establish our link is take the outflow from this Global Rotation-H and link it to the inflow of the Global Rotation-H on the cubes. So when I click on this little circle here, and that represents the outflow for that parameter, and let's drag it across the blue.

When I let go I get a list, and I can go down to Coordinates, and then go to Global Rotation > Global Rotation-H. So I've just linked Global Rotation to Global Rotation. Now you can link a lot of different things together, but there's always problems with the format of the information coming out. Rotation and rotation are expressed in the same way with degrees. If I were trying to link rotation to position that would be more problematic and I'd need to interpret that data with a node in the middle here. For now though, let's see what's happened. It looks like, visually, nothing's happened in the window.

So if we go to the Pyramid and go to the Coordinate properties, if I scrub the Rotation-H you'll see that both objects now turn, so the rotation on the pyramid is driving the rotation on the cube. And you can have more than one element linked together inside the node. What I can do is go to the Pyramid, and let's add in Global Position-Y. If I click on that and go to Coordinates and do Global Position-Y, I want to link this Global Position-Y to the Global Position-Y of the Cube. What I want to have happen is I'd like for the Cube to always remain 10 units above the Pyramid.

No matter where it is in space I never want it to be able to come down below the Pyramid. I'll start off by going to the Cube and adding in, under Coordinates, Global Position-Y. Now if I were to just simply drag across Global Position-Y to Global Position-Y, it's going to look like nothing happened. That's because the cube and the pyramid are already on the same Y level. But you'll notice though, if I select the cube, I can no longer drag it up. It's locked. I can move it on X and Z, but I can't move it on Y, Cmd+Z or Ctrl+Z. That's because the position Y is being controlled by this linkage here.

So what we want to do is to have this always be above the pyramid. So let's disable that, and we're going to introduce a new node in the middle here. Let's right-click in the XPresso window and go to New Node, and then XPresso, and then Calculate. All of these other menus that you see here are all about other elements that you can create within XPresso. You can create XPresso Hair nodes, MoGraph nodes, and Dynamics and Thinking Particles nodes. These are the general XPresso nodes, and I'm going to go to the Calculate function and add in a little bit of math.

Now don't be scared, I stink at math, but this is going to be really easy to understand. And this math node has its own set of properties over here in the Attribute Manager. Now let's give ourselves a little bit more room to work. I'm going to use the 2 key on the keyboard and drag out just a bit. You notice as I zoom in and zoom out that the XPresso window zooms in with me. If I hold on the 1 key I can pan around the XPresso window. Now you look at the parameters for this Math Add Node, you'll see that we have a data type. These will be real numbers, and we can do a different type of math function.

Add, Subtract, Multiply, Divide, and then something called Modulo. We're going to use a simple Math Add function, and these are the two values that we're going to add together: input one and input two. Input one is going to come from the Pyramid. We're going to take the Global Position-Y and drag that into this input field right here. When I make that connection it looks like nothing has happened. That's because this Math Add Node doesn't do anything until you send the output from it to another object. So what we want to do is to send the output from this Math Add Node into the Global Position-Y of the cube.

When we do this, nothing happens. That's because in the Math Add Node, all we're adding is zero. So let's add some values here. The original position of the Pyramid is currently Y on zero-axis. So if we add 100 to the position of the cube in the Math Add Node, if we go in here and type in 100, you'll see that the cube has jumped 100 units up. That doesn't seem exciting until you go and start moving the Pyramid around. No matter where I move the pyramid, it's always going to say 100 units higher than the location of this axis.

So if I make that say 300, then the cube will jump up here. And you can see as I move that around, no matter where I move it, it stays that way, and you can still move on X and Y, and you also still have the linkage for the rotation. Let's back out here just a bit so you can see everything going on. The Y position on the cube is still locked and I can't move it up and down, but I can still move it left and right on X and Z. So this is just literally touching the tip of the XPresso iceberg.

Just keep in mind that XPresso is a scripting language. It can be as complicated as you want to make it. If you're a programmer and you love writing code, the XPresso Editor is going to be your best friend. But if you're not comfortable writing code, then you can still do a lot of really interesting things with XPresso. Now, I'm not a code writer. So in this chapter I'm going to be focusing on things that I know non-code writers are going to find useful.

Show transcript

This video is part of

Image for CINEMA 4D Essentials 8: Character Rigging and Xpresso
CINEMA 4D Essentials 8: Character Rigging and Xpresso

12 video lessons · 4051 viewers

Rob Garrott
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed CINEMA 4D Essentials 8: Character Rigging and Xpresso.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.