Previous Section: View Animation

AnimMate Track Animation

AnimMate contains a specialized tool for animating vehicles such as tanks and bulldozers which have articulated tracks. In this section, you will use AnimMate to add an articulated track to a tank model, and then animate the tank.

If you are editing the moss.g database, from the last section, exit MGED. For this section, you will need a simple tank model, which is also included with the BRL-CAD distribution. If the BRL-CAD source is located in the "/cadsrc" directory, then you should execute the following commands to get a copy of the tank model and open it with MGED:

%> asc2g < /cadsrc/db/ktank.asc > anim_tank.g
%> mged anim_tank.g
Bring up AnimMate's main menu with the command:
mged> animmate

Preparing the Model

Before proceeding, there are a few changes that must be applied to the geometry file to make it animation-ready. The names of the wheels must be changed to share a common base name, with indexes from zero to six. A prototype track pad must be created, and sixty copies of the pad must be made for the left and right tracks. Save the following file as track.txt, and then run it using the command:
mged> source track.txt

track.txt

#TRACK.TXT - command to prepare for ktank track animation
units mm

#create new names for the left wheels
g lw.0 r37
g lw.1 r32
g lw.2 r33
g lw.3 r34
g lw.4 r35
g lw.5 r36
g lw.6 r38

#create new names for the right wheels
g rw.0 r44
g rw.1 r39
g rw.2 r40
g rw.3 r41
g rw.4 r42
g rw.5 r43
g rw.6 r45

#create new parent group for the wheels
for {set i 0} { $i < 7 } { incr i} {
	g anim_wheels lw.$i rw.$i
}

#create the prototype track pad solid
in pad_proto.s arb8 \
112	-125.2	0	\
112	125.2	0	\
112	125.2	25.4	\
112	-125.2	25.4	\
-112	-165.1	0	\
-112	165.1	0	\
-112	165.1	25.4	\
-112	-165.1	25.4	\

#make the prototype track pad region
r pad_proto u pad_proto.s

#make sixty pads for the left track, and sixty for the right
for {set i 0} { $i < 60} { incr i} {
	i pad_proto rpad.$i
	i pad_proto lpad.$i
	g pads lpad.$i rpad.$i
}

#create an animation-ready tank
g anim_tank hull turret anim_wheels pads

Note that the file changed the editing units to mm. It is best to work in these base units during track animation.

You should see a trapezoidal shape in the MGED display. This is the pad prototype, named "pad_proto". Display the entire tank with the command:

mged> B anim_tank
Look at the tank from an ae 35,25 view.

Use the "l" command to look at the contents of anim_tank and its children. Notice that although anim_tank/pads contains 120 pad objects, the display seems to show only one, at the origin. This is because all 120 pads are identical copies of the pad prototype. The next step is to use AnimMate to put the pads around the wheels of the model.

Creating the Track

In order for AnimMate to do track animation, it must know the position and size of the wheels defining the track. You need to make a wheel specification table and place this information into a table editor. The first three columns of the wheel spec table specify the positions of the wheel centers, and the fourth column specifies the wheel radii. The wheels must be listed in clockwise order as seen from the right, starting at the top front of the vehicle and ending at the top back wheel.

There are many different methods of obtaining the wheel spec table. For example, you might center the display on each wheel in turn, and store the points in an animation curve. You could then put the curve in a table editor, remove the time column, and add the radius column. For now, you can just use the two wheel specification files provided here.

left_wheels.txt

2997.19995117 1231.90002441 -609.599975586 279.4
1854.19995117 1231.89997864 -1168.40002441 381
939.799987793 1231.89997864 -1168.40002441 381
25.3999996185 1231.89997864 -1168.40002441 381
-889 1231.89997864 -1168.40002441 381
-1803.40002441 1231.89997864 -1168.40002441 381
-2844.80004883 1231.90005493 -685.799987793 330.2

right_wheels.txt

2997.19995117 -1231.90002441 -609.599975586 279.4
1854.19995117 -1231.89997864 -1168.40002441 381
939.799987793 -1231.89997864 -1168.40002441 381
25.3999996185 -1231.89997864 -1168.40002441 381
-889 -1231.89997864 -1168.40002441 381
-1803.40002441 -1231.89997864 -1168.40002441 381
-2844.80004883 -1231.90005493 -685.799987793 330.2
From the AnimMate main menu, open two table editors with the New Editor option in the TABLE EDITOR menu. Read left_wheels.txt into text editor 0 by pressing the Read button, selecting from File, and entering the file name in the input-request window that pops up. Then read right_wheels.txt into text editor 1 in the same way.

Go back to AnimMate's main menu and choose Articulated Track from the CREATE SCRIPT menu. This creates the track animation window. Before using this window to produce animation scripts for the track, you will use it to put the pads around the wheels in the model.

At the bottom of the window, enable the Create geometry file from frame button. In the Output file entry box, type left.tcl. Leave the Vehicle path from table entry box blank for the time being, and in the Wheel specs from table entry box, type 0 for table editor 0. Leave the wheel base name blank, since you don't need to change the positions of the wheels in the model. Enter pads/lpad. (including the ".") for the Pad base name. AnimMate will obtain the names of all the left pads by adding integer indexes to this string. For the Number of pads, enter 60.

The next line of the track animation window allows you to specify the track length. When Minimize track length is specified, the resulting track is wrapped tightly around the wheels. Select Elastic track length. With this option, you specify the track length. Any extra length is taken up by a drooping catenary arc between wheel zero and wheel (n-1). (This is why wheel zero is always the top front and wheel (n-1) is always the top back wheel.) If the track length you specify is too short, the elastic track will be stretched to fit. Press the Get track length from wheel specs button. The value 13908.27 should appear. This is the minimum track length needed to fit around the wheels listed in the wheel spec table. In order to give the track a slight droop, modify the track length entry box to read 13925.

The vehicle is centered more or less at the origin, and has no yaw, pitch, or roll, so you may leave the next two lines blank or zero-filled. Double-check that the Create geometry file from frame button is enabled, and that the corresponding entry box reads 0, and then press OK to create left.tcl. The newly created file consists of a series of "arced" commands like the following:

arced pads/lpad.0 matrix rarc 0.9908975556 0 -0.1346181052 2959.587653 0 1 0 1231.900024 0.1346181052 0 0.9908975556 -332.7431985 0 0 0 1
arced pads/lpad.1 matrix rarc 0.7676558998 0 0.6408622469 3176.256863 0 1 0 1231.900024 -0.6408622469 0 0.7676558998 -395.1169172 0 0 0 1
arced pads/lpad.2 matrix rarc 0.0445116452 0 0.9990088655 3276.323028 0 1 0 1231.900024 -0.9990088655 0 0.0445116452 -597.1634219 0 0 0 1
arced pads/lpad.3 matrix rarc -0.7076188871 0 0.7065943041 3194.6224 0 1 0 1231.900024 -0.7065943041 0 -0.7076188871 -807.3086927 0 0 0 1
arced pads/lpad.4 matrix rarc -0.8604415104 0 0.5095492196 2999.9788 0 1 0 1231.900024 -0.5095492196 0 -0.8604415104 -932.6713713 0 0 0 1
Source this file in MGED and view the results by re-displaying the tank:
mged> source left.tcl
mged> e anim_tank

Sixty track pads should appear around the left wheels of the tank. Viewed from the side, the track has a slight droop between the two top wheels.

Now, repeat the process for the right wheels. Change the name of the output file to right.tcl, change the wheel spec table to 1, for table editor 1, and change the pad base name to pads/rpad.. Press the OK button once again, then execute the commands:

mged> source right.tcl
mged> e anim_tank
The right track also appears.

Animating the Track

AnimMate animates articulated tracks such as the two you created earlier, by producing an animation script which moves the pads and rotates the wheels. At this point, you have already provided most of the information needed for such an animation, but AnimMate still needs to know how far the pads should be rolled around the wheels in each frame. This information can be specified directly, or can be inferred from the path of the vehicle of which the track is a part.

To directly specify the distance the track should be rolled in each frame, you would need to create an animation table consisting of a time column and a distance column. In the distance column, you would specify the total distance the track should be rolled in each frame. You would enter the identifier of the animation table next to the label Vehicle path from table, and select the Distance option just below that label.

Specifying the vehicle path

More often, you know the path that a vehicle will take, and you want the track to appear to be driving the vehicle. This is the method you will use in this tutorial. You will need to create an animation table specifying the position of the vehicle in each frame.

To do this, go to AnimMate's main menu and click on Curve Editor. Click on the Current curve button and select Rename curve from the posted menu. In the input-request window that appears, type path as the new name for the curve. Go to a top view, and use the ADD button, as explained in a previous section of the tutorial, to create a three-node animation curve which is less than half the length of the tank. (A short path is best for demonstrating the motion of the pads). Press Spline Interpolate to create an interpolation curve called "spl_path". (Note: all of the curves drawn by AnimMate appear white in this model, because the coloring is done by region ident codes, rather than material properties of the objects. See the MGED edcolor command for more information.)

Animating the vehicle

Before creating the track scripts, you should make sure that you are happy with the path that the vehicle will take. Open a new table editor, and read the contents of the "spl_path" curve into the editor by clicking on from curve spl_path from the Read menu. Go back to the main menu, click on CREATE SCRIPT and then select Object from the posted menu to pop up the object animation window.

Fill in tank.script next to the Output file label. Select table editor from the Source option menu, and fill in the identifier of the table editor containing the contents of "spl_path". For the Object name, put /anim_tank. Make sure that the Object center and Object yaw,pitch,roll entries are set to 0 0 0, and select Automatic steering from the Orientation control section. Now press OK to create tank.script. Show the script by clicking on Show Script and pressing OK on the show script window. The center of the tank should slide along the path specified by "spl_path".

If the preview is too agonizing slow on your display, you might want to go back to the curve editor, reduce the number of frames per second, and then redo everything from the spline interpolation step. When developing animations, it is sometimes a good idea to work at a lower frame rate during the early stages, and then go back and redo the interpolations at a higher rate when you're sure you've got it right.

Creating the track scripts

The next step is to animate the track so that the tank rolls instead of sliding. Go back to the track animation window, and type left.script as the output file. Next to the Vehicle path from table label, fill in the integer identifier of the table editor which contains the tank's path. Since the vehicle path table contains the position of the tank but not the orientation, select the Position checkbutton on the next line. Next to the Wheel specs from table entry box, enter 0 for table editor 0 (if that is still the table editor which lists the left wheel positions).

For the wheel Wheel base name, type anim_wheels/lw. (don't forget the ".") in the entry box. The output script will rotate the wheels as the pads move around them, although the rotation won't be visible since the wheels are simply cylinders. If the wheel base name is omitted, then no animation commands are created for the wheels.

Fill in all of the other entries as you did when creating the left track model: enter pads/lpad. next to Pad base name, 60 next to Number of pads, 13925 next to Elastic track length, 0 0 0 next to Vehicle center and Vehicle yaw,pitch,roll. Disable the Create geometry file from frame check button, so that the output file will be an animation script. Finally press OK to create the file left.script.

Pop up the show scripts window and press the Restore button to put the tank back in its modeled position. Orient the display to a nice 35,25 view of the left track, and then press Show to show left.script. You should see the left track moving around the left wheels, although the tank itself doesn't move. To get the full animation, you will need to combine the track animation scripts with the vehicle animation script (tank.script in this case).

It may appear to you that the left track stops and moves backwards during the animation. There are two possible explanations for this behavior. One is that the left track may need to turn backwards while the right track is turning forward, if the tank's movement contains a very sharp left turn. The other possibility is that although the track is actually moving forward, it appears to be rolling backward due to a strobing effect. This is the same effect which causes wagon wheels to appear to turn backwards in movies. When the track is moving slowly, each pad moves slightly ahead of its previous position between frames. However, if the track is moving faster, then each pad might move to just behind the position that pad it follows was in during the previous frame. Since the pads are identical, your eye thinks that the other pad moved backward. Strobing problems can be avoided by selecting the Enable Anti-Strobing checkbutton. When the track is moving fast enough to cause strobing effects, this option adds random jitter to the track movement, creating motion blur instead of strobing.

Before combining scripts, create an animation script for the right track. Change the Output file to right.script, and change the Wheel specs from table to 1. Change the wheel base name to anim_wheels/rw., change the pad base name to pads/rpad., and press OK to create right.script.

From the main menu, select COMBINE SCRIPTS to pop up the script-combining window. From the list of files on the right side of the window, select tank.script, left.script, and right.script. This should make those three names appear in the list on the left side. Next to the Create script label, enter all.script, then press OK to create all.script. When you show all.script, the tank, pad, and wheel animation should be combined in such a way that the track appears to be driving the tank. In particular, the pads which touch the ground should remain still as the tank rolls over them.

The track animation window is built on top of the anim_track routine. This routine has some additional features not accessible through AnimMate, such as the ability to animate vehicles with dynamic suspensions.


Next Section: Conclusion

Previous Section: View Animation

Index