Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
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.
Get unlimited access to all courses for just $25/month.Become a member
107 Video lessons · 34080 Viewers
94 Video lessons · 23788 Viewers
100 Video lessons · 4270 Viewers
83 Video lessons · 9306 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.
Your file was successfully uploaded.