- So in this example we've got our Height Controller object, which has a User Data slider. This User Data slider if you click and drag on it you notice it's controlling the Cube's overall Height and we're doing that through the use of Xpresso. So I'm going to double-click on that. And previously we made a layout for our Xpresso window, so I'm going to switch over to that now. And much like you can navigate inside the viewport with the one and two keys, if you hold down one, click and drag you can pan around, two, click and drag you can zoom in and out, you can use those same commands to navigate this Xpresso window.
So this little bit of Xpresso is what allows our Height Controller to drive the Size and Position of the cube. And you might be thinking why the Position of the cube? When we break it down you'll see here in a second. But basically this is what we're going to try and tackle. So I'm going to switch over to another open scene and to do that I'll hold down V on the keyboard and that'll open up a popup menu and there at the very bottom you'll see Projects and a list of all your open projects.
And we're going to rebuild that little bit of Xpresso. And the first part of that is adding a Null object, which we'll rename Height. And in the attribute manager you've got User Data right here, we're going to Add a User Data. By default it comes in with a generic data, we'll rename that Height. And the Interface is a Float right now, it's got these little two arrows. I prefer to use the Float Slider, just gets a little bit more screen real estate to set all this up.
And we're going to set this up to Meter, because we're dealing with distances. Now that we have this set up we want to link this slider to control the Cube's Size. Now you'll notice it's scaling from the center. We're going to address that here in a second, but we need to set up this first relationship. This Height controller, if you right-click on it, come over here to XPressions, there is something called Set Driver. Basically you're telling CINEMA to use this property, this User Data slider, to drive the Cube's Y position.
Come over here to the Y, right-click on that, come back over to XPressions, and Set Driven Absolute. Two things happen, it's going to make a new Xpresso node, and you'll notice here that there is a black triangle on the left side of this icon. That's telling you that this parameter is being driven by something else, it's getting input from some place else. To help visualize that, if you open up the Xpresso Editor you can kind of see what's going on. That original User Data slider is outputting, right? So you've got this little black triangle on the right side saying that it's outputting something.
It's outputting into this Range Mapper node, which we'll bypass for right now, but basically it's feeding into this Cube into the Object Size Y value. So that's using Set Driven keys to set up this Xpresso. But as we drive this Height value up and down you'll notice that it's scaling from the center. We want it to scale from the bottom. How do we do that? If you look at our Coordinates here, let's set this Height to something simple like 200.
Come over here to our Cube, we'll look at our position and our Object. And that 200, we're getting that value from the User Data slider, but now if we were to want this to grow from the bottom we need to raise this up looks like by 100. If we switch over to our side view by hitting F3 on the keyboard you'll see what's happening here. So it looks like this is exactly, the position of the Cube is exactly half the size of its height.
The position is where this axis lives. And that axis, because it's a CINEMA 4D parametric object, it's always going to sit scale from the center. We kind of need to cheat that to move this axis down to the bottom, so that we get this scaling from the bottom. How do we do that? Well that 200 value, we just need to divide that by 2, and feed that into here, into the Object's Y position. So we're going to use an Xpresso node for math. And under here, X-Pool, if it's not already open there's this little search feature here, and we're going to look for the math node.
We'll click and drag this guy out here. And we want to, again, take this Size Y at 200, which is coming from the Height controller, add that into the first value here. And if you click on this node you'll see that it's now getting the Input one from this Height controller and this Input 2 is a constant, whatever value we want here, we need to divide it by 2. So we'll add 2. And of course, change the Function from Add to Divide. This Math node now should be outputting half of our Height.
Half of our Height, 200, is 100. How can we check that? Come over here at type in result, and that Result node you can wire this up, it just visually shows you what's coming out of this port and that's 100, that's the correct value that we need to plug into the Cube's Y position. So the Cube Y, I'm going to take this value here from the Coordinates, drag it into the Input. I'm going to command double-click on the node and that will auto-resize that node to accommodate all the little text there, making it a little bit more legible for us to use.
And so this value needs to be tied together with this one here. And visually you don't see a change here, 'cause it's sitting on the exact same values, but now when we take our Height in the User Data it should scale from the bottom. So essentially Xpresso is a series of nodes that you can use to drive relationships from one value to another. In this case we used our User Data slider to affect both the Cube's Size and Position. And so we'll be using this same technique later on down the line in other videos.
Released
1/8/2016This course is a project-based learning experience that will introduce different tools and techniques for importing, styling, and manipulating chart data in C4D. Alan Demafiles shows how to drive relationships between spreadsheet data and geometry with set-driven XPresso keys, connect points with tracer objects, and animate charts with dynamic primitive objects. He also explains how to customize the look and behavior of your charts and graphs to fit the style of your company or your client's.
- Using XPresso to link data
- Importing spreadsheet data into CINEMA 4D
- Harnessing mograph effectors
- Connecting dots with tracer objects
- Adding text and x- and y-axes
- Creating pie charts and bar charts with CINEMA 4D
Share this video
Embed this video
Video: XPresso data linking