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

Linking objects to points with Xpresso

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

Video: Linking objects to points with Xpresso

The scripting language and nodes in XPresso allow you to control objects, but they also allow you to control the components that make up objects. What we're going to do is link the position of a point on a spline to the position of a sphere. It's an important idea that introduces you to the concept of a point index. In this scene, I have a very simple hierarchy for a spline wrap and a matrix object, and I built a hierarchy similar to this in the module on MoGraph. So if you're unfamiliar with this setup, you can take a look at that, and you'll see this exact same rig, except that I've made a train.

Linking objects to points with Xpresso

The scripting language and nodes in XPresso allow you to control objects, but they also allow you to control the components that make up objects. What we're going to do is link the position of a point on a spline to the position of a sphere. It's an important idea that introduces you to the concept of a point index. In this scene, I have a very simple hierarchy for a spline wrap and a matrix object, and I built a hierarchy similar to this in the module on MoGraph. So if you're unfamiliar with this setup, you can take a look at that, and you'll see this exact same rig, except that I've made a train.

But in this case, I've got a little train of spheres, and if I go to my spline wrap, you can see that if I adjust the Offset, the matrix object will move along the spline. Now you may have noticed that the spheres are not moving to the position of the matrix object right away, and that's because of the way the Object Manager evaluates the objects in the scene. So the fix for that is to hit the letter A on the keyboard, and that will cause everything to refresh for you. So let's rewind that back to 0, and then hit A on the keyboard to get it to redraw the frame again.

So what I want to be able to do is take one of the points on the spline, and link it to the position of this sphere. Now the point that I want to link is the point that's right about here. If I click on the spline, this spline is set up as something called a cubic, which is a little bit like a hybrid between a Bezier spline and a B-Spline. If I go into Point Mode, you can see that I've got points on that spline and that the curvature of the spline passes through each of those points. That is the point that I want to link to the position of this large sphere.

So wherever this big sphere goes, the point on that spline will follow it. Any object that's made up of points, edges, and polygons in CINEMA 4D has something called a Point Index Value. To see that Point Index Value, first you need to select the object. So I'm going to click on the spline. And underneath the Structure Manager, the Structure Manager shows you the composition of that object, and the Structure Manager is just a spreadsheet of numbers. And those numbers all represent the locations of the points on this spline. You can see on this spreadsheet, one of the points is highlighted, and that's number 2, and that is this point right here.

If I click on one of these other numbers, you can see that I'm actually selecting points. So this is a great way to figure out which point you're trying to find. This point number 2 here is the point that I want to manipulate. So I need to remember that number. That's index value 2. The index always starts off at 0 and then it counts forward from there. So I want to address point number 2 on this spline. Let's go back to the Object Manager, and we're going to introduce an XPresso tag to the scene, and because the tag is going to be modifying the spline, I'm going to right-click and put the tag onto the spline.

So let's right-click, and go to CINEMA 4D tags, and down at the bottom is XPresso. When I do that, the XPresso Editor pops up, and we're going to drag in the spline. And let's make the XPresso window just a little bit smaller, so we can see everything here, and drag that down. I'll hold down 1 on the keyboard to navigate. Now we also want to add in this big sphere, and we'll drag this over here. So the position on the big sphere is going to drive the position of that single point on the spline. So first, we have to find out where that point is, and there's a special node for that.

Let's right-click any place in the XGroup window that's not on a node, and go to New Node, XPresso, and under General, we're going to grab the Point node. The Point node has some properties associated with it. Most importantly, it's got an Object field, and then Point Index, and then it's got Point Count and Point Position. Now if you wanted to find out the exact number of points in an object, then you could send this information out of this node, and that would work for you great. But what we care about right now is the Point Index. This point position is the outflow for the point position.

That would be if we wanted to drive the position of the sphere with this point. But we're going to do the reverse of that. So we want to have the inflow position over here. So let's click on the blue side, and go to Point Position. That adds a third item over here. What we want to do is to feed the object information from this spline object into the object field here. This yellow band indicates that the node is miscalculating and it's miscalculating because it doesn't have an object to calculate with. So let's go to the spline and drag it up here just above that node, and send the object information from the spline object out to the inflow of this node here.

Let's drag that over here just like that, and take that object and go right like that. So now you can see that the yellow has gone away, and that's because the Point node is calculating the information correctly. Now if you click on the Point node and you look at the Attribute Manager, you can see that there's a Point Index field. Right now, the Point Index is set to modify point 0. And if you remember from the Structure Manager, we want to modify point 2. So let's put in a 2 there. And when we do that, the point position is set to 0, 0, 0.

It's moved our spline point from where it was to 0, 0, 0. So Index Point 2 is now moved to the world. What we need to do next is feed some information into this point position, and to do that, we need to have the big sphere. And so the big sphere, we want to use the position information here to drive this point position here. Click on the outflows and go to Coordinates, and then do Global Position for the big sphere, and then send this Global Position information into the point position here.

When we do that, now we have this point stuck to the location of that sphere. Now this point over here moved when we first added the Point null. That's because it took point 0 and moved it to 0, 0, 0. So let's take this point and move it back over here, and then hit the letter A on the keyboard to get the frame to redraw correctly. Now if I go to point number 2 on the spline, and I try and drag up and down, you'll see that I can't, nothing happens. That's because the position of that point is being driven by the sphere. If I take the big sphere and drag it up and down, you see that the spline changes shape based on the position of that sphere.

This technique is incredibly useful for a wide variety of applications. In this case, by linking that point on the spline to the sphere, that gives us a handle that we can actually animate for the spline itself. Rather than trying to animate an individual point, link the point to another object to animate that. It gives you much more control.

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 · 4062 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.