## Path Animations

In the Getting Started tutorial, you animated a sphere that moved roughly in a circle - this demonstrated how to create a choreography based on keying an object's position at various times. As you may have noticed, to refine the movement to be circular, you had to make adjustments to the animation curves in the choreography editor. Although this method is fine for certain types of movement, Realsoft 3D provides other options. One of these options is to animate an object along a path, hence the term, path animation.

This tutorial explores some of the ways you can create path animations, which includes attaching an object to a two dimensional object such as a line or a three dimensional object such as a surface.

Tutorial level: Medium

Example project: 'tutorprojects\animation\paths\moving sphere'

Remember the animation of a sphere traveling in a circle you created in the Getting Started with Animation tutorial? Now let's do that same animation using a path.

First, set up your environment. Then create an analytic sphere in the upper left corner of the view, followed by a NURBS circle centered approximately at the view's midpoint with a diameter of about 3/4 of the view's size.

Select the sphere and then the circular curve (the order is important), and then choose Tools/Lattice Mapping/Create Path Animation from the main menu (or, if you are using the startup environment, open the Lattice Mapping tab, and click the Path button. This presents a control bar with the path tool's options.

Note It is important that you select the objects in the specified order. If you select the objects in reversed order, you would get a curve moving along the surface of the sphere.

Options for the Path tool

For this first attempt, use the default settings, so just click Accept. Now play the animation and note what is occurring. First, the sphere follows a circular path based on its initial position and its offset from the path curve. Second, the sphere rotates about the center point of the circle as if there were an invisible rod connecting the center of the circle to the center of the sphere. To contrast this rotation, double click the sphere object to open the property window, go to the Map tab and uncheck the Rotation attribute, then replay the animation.

### Object on an open path

Tutorial level: Medium

Tutorial project: 'tutorprojects\animation\path\morphing path'

Making an object follow a path defined by an open curve is essentially the same as using a closed curve. Once again, the initial positions of the two objects, in relation to each other, determines the actual movement (that is, if you are using the Translate option).

 Set up a sphere and a curve as shown in the image, and use Lattice Mapping/Path with the default options, and then play the animation. A sphere and an open NURBS curve as the path

Now edit the NURBS curve, maybe straightening out the dip near the middle, and then play the animation. Try just moving points first, then edit the curve by also removing points. Next, add some new points to the curve, and reshape it again. Note that when you make these changes, the sphere speeds up and slows down as it traverses the path. This is based on the spacing of the curve points: the greater the distance between points, the faster the object moves along that line segment. No matter what type of editing you perform on the line, the object remains correctly attached to the path.

Now try editing the path curve while in animation recording mode. Select the curve and enter Edit mode. Set the time slider to frame 0 and activate animation recording. Move to frame 30 and point edit the curve. Move to frame 60 and adjust the curve some more. Continue editing the curve at frame 90, then deactivate animation recording. You now have a sphere that moves along a morphing path.

### Unattaching an object from a path

As you may guess at this point there are quite a number of ways, based on the relative position between the object and the path, that you can set up a path animation. So what if you attach an object to a path, and you do not like the result? You can easily unattach an object from a path with the Unmap tool.

Select the object and then the path. Then, from the Lattice Mapping tab, click the Unmap button. The object and the path are no longer attached. You can now modify the positions of either object and connect the two again.

Note You can also access the Unmap function from the main menu, Tools/Lattice Mapping/Unmap Objects.

### A swimming fish

This example demonstrates how to create swimming fishes, wriggling snakes and other effects where the motion path should not only transform the object to be animated but also deform it.

 1. Create a fish by using NURBS or subdivision tools. The only requirement for the fish is that it contains a sufficient number of points so that the curve can deform it. 2. Create a NURBS curve representing the path.
 3. Select the 'fish' and the 'path' (in this order). Then click the Path tool. This time set the Target option to Points and click Accept. Select Target=Points A freeform fish and a NURBS curve

Play the animation and the fish wriggles along the path. Keep this project open for use in the next section.

### Reconnecting an object to a different path

Tutorial level: Medium

Tutorial project: 'tutorprojects\animation\path\swimmingfish'

 The fish moving along a skeleton The Lattice Mapping/Reconnect tool allows you to exchange one path for another. Using the swimming fish project from the previous section, add a skeleton object to use as the path for the swimming fish. Select the fish and then the skeleton, and then activate the Reconnect tool. Click Accept and the fish jumps to the skeleton. Move the time slider and the fish moves along the skeleton.

Example project: 'tutorprojects/animation/paths/fish on a skeleton'

### Mapping specific points to a path

Tutorial level: Medium

Tutorial project: 'tutorprojects\animation\path\ik_path'

So far we have dealt with mapping entire objects to paths, but what if you only want a part of an object to move along a path, for instance, the end joint of an arm. For this you set the Path tool to use the Selected Points value for the Target option.

 For example, you can use a NURBS curve to control the path of a joint of a skeleton: 1. Create a skeleton and a NURBS curve defining a path for a joint of the skeleton. 2. Multi select the skeleton and the path (in this order) and enter the Edit mode. Now, select the end point of the skeleton by clicking it. 3. Activate the Path tool and set Target to Selected Points. Click Accept. The last joint of a skeleton attached to a NURBS curve using the path tool and the Selected Points option

You have now attached the joint to the path. Play with the time slider and see how the joint follows the path. Note that the skeleton uses inverse kinematics to follow the path, which is what you might have already expected.

### Timing

In the previous tutorials we have used two key frames to set up path animations. In the first frame the object is at the start of the curve and in the last frame the object is located at the tail of the curve. The intermediate positions are interpolated for us by the animation system.

The speed at which the object travels between the two ends of the path depends on the properties of the path. Depending on the point density and parametrization of the path, the object may accelerate and decelerate while it moves along the path.

You can control the default speed and timing very easily by adding new key frames. This tutorial explains how to do that.

Tutorial project: 'tutorprojects\animation\path\moving and rotating cube'

 1. Set the frame count to 200. Create an analytic cube and a NURBS curve to define a motion for it. 2. Select the cube and then the NURBS path. Apply the pull down menu Animation/Path/Move. Play the animation to verify that the cube travels to the end of the path during the playback. A cube follows a path

Let's change the motion so that the cube reaches the end point of the path at the frame 100 and then travels back to the start of the path.

3. Open the choreography window (pull down menu Animation/Choreographs..). Go to the Properties tab. Open the sub structure of the 'cube:init0' choreography. Open also the structure of the path choreography. Select the attribute LatticeTranslate. The curve graph at the right side of the choreography window now shows a linearly ascending red curve. The green and blue curves have a constant zero value.

 4. Click in the middle of the red curve and move the inserted point up to level y=1.0. 5. Move the end point of the red curve down to zero level. Play the animation. The cube travels to the end of the path, slowly decelerates and then travels back. Deceleration at the end point is a result of the round curve shape. If you change the curve type to polyline, direction changes without deceleration. Note that the red curve defines the position along the path. You can also create some key frames to the green and blue curves to temporarily displace the cube from the path. A lattice translation curve, which makes the cube to return to the start point of its path

In addition to translation, you can naturally control how the cube rotates in the path object's space. For example, to make the cube rotate while it moves on the curve:

 6. Go to the Animateable Attributes tab on the choreography window. Select the path choreography. 7. Find and select LatticeRotate from the attribute list. Check Animated option for it. 8. Go to the Properties tab. Select the new LatticeRotate attribute under the path choreography. The curve graph shows no curve at this point. Select Create predefined curve/45 degree curve from the popup menu of the curve graph. Make Lattice Rotation animated
 9. Select Set Minimum and maximum values from the popup menu. Set Max Y = 360 degrees, check rescale and hit OK. 10. Move the end point of red curve and blue curve down to zero level. The green curve will grow from zero to 360 degrees, meaning that the cube will make exactly one full revolution around the path during its travel. Play the animation. The cube moves and rotates in the parameter space of the curve. Lattice Rotation curves

### Deformation paths

Let's assume we want to create a 'flying carpet' animation. This can be done by using a NURBS mesh as a path.

Tutorial level: Medium

Tutorial project: 'tutorprojects\animation\paths\mesh path'

 A red 'carpet' mesh on a blue 'path' mesh. 1. Create a carpet (say a NURBS mesh consisting of 5 x 5 control points). 2. Create a bigger NURBS mesh consisting of 20 x 5 control points. This mesh represents the path of the carpet. We want the carpet to move on the surface of this mesh.
 3. Select the 'carpet' and 'path' meshes, activate the Path tool, set the Target option to Point and click Accept. If you now move the time slider, you can see how the carpet moves along the blue mesh. 4. Modify the path mesh so that it contains bumps here and there. Play the animation to see how the carpet moves along the curved path mesh. The carpet follows a curved path mesh
Camera following a NURBS stripe

Note A NURBS mesh as a camera path allows very good banking control.

Tutorial project: 'tutorprojects\animation\path\camera moving along a NURBS stripe'

### Mapping objects to curved paths

Tutorial level: Medium

Tutorial project: 'tutorprojects\animation\path\map to curved path'

Let's assume we have a very curved surface which we need to use as a motion path for an object. For example, we need to move a mesh on the surface of a NURBS head.

There are two problems. First, we need to deform the mesh to match the surface of the head at a certain area. If the head is very curved, this is not a trivial job. We could use collision detection or some other tools but if we have a very curved object containing tentacles and holes, matching the mesh on the path mesh can be very time consuming job.

The second problem is that lattice mapping to very curved lattice objects is not always reliable and points can get mapped to wrong lattice coordinates.

The Reconnect tool solves this problem. You can first map the object to a planar mesh to define appropriate lattice coordinates. You can even animate the object on that well behaving planar lattice object. Then, use the Reconnect tool to swap the path object to the final curved surface.

Let's see how this works.

1. Create a NURBS mesh consisting of 12x12 control points and an analytic rectangle on which we will animate the mesh. Then map the NURBS mesh to the rectangle exactly the same way as we mapped the NURBS carpet to the path mesh in the previous example.

 A red mesh moving on the surface of a head If you now play the animation, the mesh moves along the analytic rectangle. 2. Activate animation recording mode. Modify the mesh at suitable frames using move, rotate, etc. tools to create some key frames. 3. Load in the actual object you want to be used as a motion path (for example, 'models\nurbs\simple head'). If you use File/Load, remember to uncheck Replace, otherwise you will loose the project! 4. Select the mesh and the NURBS head and activate the Reconnect tool. Click Accept and the mesh jumps on the surface of the NURBS mesh! Now that the mesh follows the shape of the NURBS head precisely, you can add some further key frames, fine tune motions, etc. without any problems.

### Multiple motion paths

Tutorial level: Medium

Example project: 'tutorprojects\animation\path\multiple paths'

The lattice mapping system allows you to map an object to multiple lattice objects. For example, you can control the head of a mesh using one skeleton and its tail using another skeleton. Similarly, you can animate an object using several paths.

As an example, we will define an animation where the camera position follows a smooth path, but the aim point follows another polygonal path:

 1. Create a camera and a smooth NURBS curve representing a motion path for the camera position. 2. This time we don't map the entire camera on the path but its position handle! So, enter the Edit mode and select the position handle of the camera. Multi select the camera and the NURBS path (again in this order). 3. Activate the Path tool and set Target to Selected Points. Then click Accept. We have now mapped one point of the camera object to a motion path. 4. Create a polygonal NURBS curve representing a motion path for the aim point and map the aim point handle to it exactly the same way as you mapped the camera position. Map the camera position handle to a NURBS curve

That's all. Play the animation and see how the aim point moves along one path while the position of the camera follows another path.