Friday 22 November 2013

Week_8  Controllers and Constraints

 




A controller is a program module that manages animation
A constraint is a type of controller in which one object is controlling another.


Using bouncing sphere is a simple way to test it, bounce a ball.
1_create a sphere in the perspective view, currently there's no animation here because the default controller for an object transform such as position is something called a Bezier Float controller, and that's what gives us the ability to animate tangent handles and adjust the shape of a curve and adjust the keyframe interpolation, so that's a default type of controller is Bezier Float.

2_There are lots of types of controllers and many different things can be done.
with the ball selected, go to the Graph Editors > Track View - Curve Editor, scrolling down in the list here highlighted the Z-Position. If I want to assign a controller, I can go up to the Controller menu and choose Assign, and I have got a list of the valid controllers for that particular animation channel or track, and you will see Bezier Float is active.

Choose a different controller.

3_Try the Waveform Float. Play this back and see that it’s an oscillating motion. It is actually procedural animation. This is moving up and down according to a sign wave. Going back into the Track Editor, with the Properties page for this Waveform controller, and try out different types of waveforms like the Half Sign, which is basically creating a parabolic bouncing shape, and with things like the Period. That's the duration of one cycle, you can make that longer so it has fewer bounces.

4_If you wanted this to actually just bounce on the floor and land at exactly a Z value of zero. Maximize this window with Alt+W, get a little bit closer in. On frame 0, where the waveform is at its lowest. Going back to the Track view, and I've got the ability to manually adjust an offset.

5_Organize the view a bit better. At frame 0 you can set this manual amount, just scrolling that up until it's just touching the floor, and you can also see that the waveform is moving too, so when you adjust this, the waveform is moving in the Graph Editor too, in the Curve Editor. Play that back and it is an infinitely bouncing ball motion.
Go back into the controller properties, and right-click on the name of the track and then choose Properties, and it will take you back in, and here you can do things like change the Period. So there are lots of different types of controllers. The default is the so-called Bezier Float.
6_There are many to choose from, and they need playing around with. Things like have the motion of objects be driven by the volume of an audio file can be done. So controllers are very powerful. To go back to a standard way of animating,
Controller > Assign and switch this Z-Position back to Bezier Float, and now it’s back to creating standard keyframes in the normal way.

Applying path constraints
========================
A constraint is a type of controller in which one object controls another object, or one entity controls another entity. So constraints are very powerful.
One of the most common ones is a Path constraint where you can attach an object to a Spline Curve and have it animate down that path.

Here we will make a simple turntable animation. It's a very common thing that modelers need to do so they can show off their work. So with the robo_arm create a circle that's going to be the path and then a camera to attach to the path.













1_In the Create panel>Shapes, make a circle. With snap to the grid on, position the cursor right at the origin so that the circle is right there centered on the model, and if I am not sure whether it is or not, I can always go into the Move tool and right-click on that and make sure, okay, the circle is at an absolute position of 0, 0, 0. 

2_Create a target camera, in the Perspective view, click and drag, and place that target at the origin once again 0,0,0
Make the front viewport the camera viewport, and I can hit F3 as well so I can see shading. It isn’t attached to the path yet. I'm going to attach the camera to the path using the Path constraint. Constraints work by selecting the object that you wish to constrain first. I want to select the camera and constrain it to this path.

3_With the camera selected, open the Animation menu set and the category for Constraints, choose Path Constraint. Then click spline curve, the cursor changes to a different icon. So click on that and now you'll see the camera is attached to the path, and you rewind and play that back, you'll see the camera is orbiting around the object.

Checking in the Camera viewport, you see a turntable movement. All you need to do now is move that path and possibly move the target as well.


4_With the circular path, just move it upward. The camera is constrained to the path. Also you want to move the camera target up to, in Ortho View, grab that target and move that up. And also probably want to change the field-of-view, Go into the Camera View, right-click on that and use Field-Of-View control to zoom out a little bit, and play back, we have a turntable animation.

Path constraints are good for this sort of thing. So the camera is just spinning around and around and around. Because this is a procedural circle, I can actually go to the Modify panel and select my Select Object tool, grab the circle, and I can change the radius too. So maybe move the camera further out and then use the Field-Of-View tool. Once again going back to the camera.

Zooming in a little bit, remembering that you always want to have Safeframes enabled. Shift+F to visualize my Safeframes and frame that up and play it back. Maybe zoom back out again, and I've got a Path constraint, and it's working great. If I want to change the speed of the motion, all you have to do is select the constrained object, so in this case it's the camera. Select that camera, and you'll see there's a keyframe here and here, and this is distance along the path in percentages.

So this is 0% along the path at Frame 0 and 100% along the path at Frame 100. So if I wanted this to go more slowly, I go to my Time Configuration, increase the number of frames, let's say 300 frames, which is 10 seconds, say OK, and just move this second keyframe down to the end. So it will be 100% along the path at Frame 300. Going back and playing that back, and now I've got a nice slow turntable. So that's just one simple example of the utility of using constraints. 



The circle could be a collapsed editable spline shape. Draw out a similar size circle, collapse to an editable spline. Check out the vertex numbers and add a few more vertices. Move some of the vertices vertically and perhaps alter the circle to something you might prefer as a path. Break the other path link and link the target to the new path.










Assigning a link constraint
==========================

To move an object as part of the operation of the movement of a hierarchy it is necessary to add a link constraint at the points you wish the hierarchy to take charge and relinquish control. The following shows this:

 




To move an object, we will use a link constraint.  Above the cylinder will be constrained by the floor.

The purpose of a link constraint is to enable you to transfer a parent-child link from one object to another over the course of an animation. 

In other words, if you have a character or, in this case a robot, that needs to pick something up and carry it and then set it down or maybe pass it off to someone/thing else. If you need to do that, then you have to use a link constraint, because you cannot use a standard link to do that. Standard linking-up is permanent.
If you linked the cylinder to the robot wrist, that would be permanent through the entire animation and it would be nearly impossible to animate the wrist and the cylinder separately in order to get a realistic motion.

So, when you want to have something pick something up and then throw it or drop it or pass it off, you're going to have to use a link constraint in order to transfer that parent to another parent.

Start this off. Start on frame 0, what you want to do at first is to constrain this cylinder to the room/floor.

1_This should be link-constraining to an immobile object, usually, the ground or the room or something that's not animated. So, select the cylinder, go up to Animation menu, looking for Constraints > Link Constraint. Select that. As soon as you do that, you'll notice that the Command panel is changed and I'm now looking at the Motion panel.

2_But in any event, you are ready to select the object you will constrain to the room. So click on that. Now a Link constraint has being created. The first target has been assigned. So, 3ds Max has opened the Motion panel automatically.

3_Within that, you will see parameters for the selected object. So, for example, what controller I have assigned and so on. You'll see here now it's constrained to the room currently. So as I play my animation currently, I've done the whole animation in advance, but it's not selecting anything.

Using the Motion panel

We have got some animation, here, and we've constrained the cylinder to the room on Frame 1, and you'll see actually if the cylinder is selected we've actually got a keyframe there. That's an indication that there is some data in that frame. And what that is actually is a target for the Link constraint, and you can see that in the Motion panel. In the Motion panel and I've got the Link Parameters rollout visible. So what you need is go forward to the point in time where we want the robot arm to actually pick up the cylinder.

1_Get in a little bit closer. So sometime after the claws dip to their minimum, but before it starts moving up, you want to transfer the link to the wrist, instead of the floor or the room. So here I am.


2_Here its on 2 minutes 22 frames. In the Motion panel click to Add Link and then you want to click on the robot's wrist and transfer the linkage to that object and that's happening on frame 92 as  can be seen here.

3_All right, rewind this and play this back. So it's actually connected. Now it's staying connected. That's fine. And when I want it to drop, I'll transfer the linkage back to the room. So get in a little bit closer on that.




4_So when do I want it to drop? Right after those claws start to open. So right around seven seconds and four frames. I've got Add Link still active here, and I'll just click on the room and I just transfer the linkage back to the room. So now when I play this further, it's no longer linked to the arm during that period of time after Frame 229. So rewind and play this back, and see what happens.

No comments:

Post a Comment