|
||
|
| Tutorial 8: An Animated Australian Windmill: Part 2 Animation Animation In Part 1 we constructed the windmill model. In Part 2 we will animate the model. The windmill will have the mill rotating slowly, and the vane and mill will oscillate laterally in the wind. This will need two distinct animation motions created in gmax. First make sure the System units are Metric as mentioned earlier, for animation to work correctly in Trainz. Animation can be rotation and translation only scalar (change of size of an object) is not supported by the export plugin. The steps we will do are:
Alignment There were a number of different parts that make up the tower, mill and other objects. Decide which will be animated, and attach as many as you can into one object This will simplify the number of objects you are dealing with, and make the connection to helpers easier. For example, I suggest five final objects:
Place all the objects as you want them at the start of the animation. If you decide to change this initial placement later after adding animation, it can be a problem correcting the animation.
These steps are important to set up the animation correctly aligned. If not aligned, the animation may appear correct in gmax, but the objects will be scattered across the landscape in Trainz. You do not have to align the helpers, if they were placed in top view, they will be aligned automatically. Notice how all the axes in the screenshot below are aligned. Click on the Effect Pivot Only button to turn it off.
Helpers These are the dummies that are animated (note they are not the same as the point placed for the smoke attachment earlier). They are linked together to follow the animations of each other. You do not animate the objects themselves. Objects are linked to the helpers, and therefore follow the helper animation. All helpers are placed in Top View. The main helper is usually called b.r.base or b.r.main and is placed on the origin. Notice the special notation that Trainz recognises, the b.r. must precede all helper point names.
Select the helper just made, and move it to the origin (0,0,0) - remember you can right click on the co-ordinate arrows at the bottom of the screen. This is the main helper. EVERYTHING must be linked to a helper or it will now show in Trainz. Note:
I like to set the centres of rotation (centroid) for the mill and for the oscillating head, and then place helpers at these locations, easier to use co-ordinates rounded off (8.6 instead of 8.592). Select the mill object, and the centroid is at X= 0, Y= -0.6, Z= 10.8. This is at the centre of the mill and is a suitable rotation point. In top view draw a helper anywhere, name it b.r.mill and move it to these co-ordinates (you could also clone the b.r.main helper and rename the clone, instead of drawing a new helper). For the oscillator on top of the tower, the centroid reads X= 0, Y= 0, Z= 10.6. This is a suitable point for the horizontal rotation. If the centroid were offset from the object centre, you would use the Hierachy menu and the Affect Pivot Only to move it to a suitable position. Again in top view, draw a helper anywhere, name it b.r.oscillator and move it to these co-ordinates. You should now have three small boxes as helpers, in the correct locations for animation.
Linking Helpers and Objects The b.r.mill is to be linked to the b.r.oscillator which in turn is to be linked to b.r.main.
The helpers are now linked correctly, and we can link the objects to those helpers.
Repeat this linking process for the mill, linking it to the b.r.mill, and then link the oscillating_head to the b.r.oscillator. Press the H key to display the select menu again, and click on the Display Subtree button to show the linking tree of the helpers and objects see below.
Notice that you do not have to link the a.water0 attachment point to a helper for it to work in Trainz. However, if you do want to have an attachment point move with a helper, you have to use a special notation refer to the Content Creators Guide 2006 pages 363 and 381 for assistance. Remember to always click the Arrow key to turn off the linking process when finished, or you will only see the linking menu not the select menu. Animating the Model We can now animate the mill and oscillator. Now the mill head will swing slowly back and forth, and the mill blades will rotate a number of revolutions during that time. We can vary the final speed in the config.txt file with the animation-loop-speed tag, but in gmax we will select an animation of 300 frames at 30 frames per second, this would give an oscillating time of 10 seconds. Let us decide that the mill blades will rotate 3 times over the 300 frames (every 100 frames). The animation must always return to the start position at the end of the cycle. You should select carefully which animation should be done first, an animation is easiest if done in one plane at a time, that is, all the rotations of the mill blades should be entered for the full 300 frames before starting to oscillate the head. If the oscillations were done first, the mill blade would be rotating about a constantly changing axis, and near impossible to animate correctly. Find the animation settings box at the bottom of the screen, step 1 below.
Important: You will notice the large Animate button on the bottom menu. This must be clicked red to record any animation of the helpers. If you move an object or a helper without this button being active (red) the animation will not be recorded, and the axis alignment could be destroyed. Animating the Mill There are a number of different tools in gmax to set up animation. This is one sequence:
Click the angle snap toggle
The wheel should now rotate 360 degrees anticlockwise over 100 frames. Repeat these same steps at key frame 200 and 300, see steps 1 to 5 above but type in 200 and 300 to go to those key frames. You can now turn off the red Animate button, and play the animation from frame 0. Because the mill blades are linked to the helper, they will follow the animation we have set for the helper. It should be smooth but if it is not, that would not be abnormal for a windmill. To smooth an animation you can insert extra intermediate key frames, or experiment with the tension values (25 to 50). These tighten up the rotation through the key frames, so it doesn't drift as much. Oscillating the Head The head of the windmill will oscillate in the wind, but it should not be regular, and should pause in some positions until the wind changes. Make a random animation but return to the start position after 300 frames. Plan the animation before starting. The mill is connected to the oscillator helper, so it will swing with the oscillator, following the helpers. Let the head swing as follows:
Animate the oscillator helper using the following steps, it is similar to how we animated the mill blades. Look at the top view and as before,
Here are the first four key frame setting displays from the steps above:
Note:
Repeat the above steps for the remaining key positions, here are the setting displays:
The oscillations sometimes look like they are on rubber bands, a bit sloppy, especially if they are large movements over short time frames, they can overshoot the required positions. For the mill this makes the movement more natural and fluid. You can vary the tension in the Key Info box. The curved graph gives loose control at 25 and changes to the pointed curve (tighter control) at 50. Select any number in between these values to experiment. When you use translation in animation (linear movement say), there are different controls on how the movement passes through the key frame points.
The animation should be working correctly, if not you may have to delete some of the key frames, or even unlink helpers or objects, or delete the helpers and start again in extreme cases. If when you get the animation into Trainz, it is scattered across the landscape, the axis alignment was incorrect at the start of the animation setup. If any of the objects fail to appear in Trainz, it is likely you have forgotten to link all objects to a helper, or the linking is broken. These are the keys for unlinking or deleting a key frame:
Linear Animation - Lifting the Rod To be complete, we really should introduce some linear animation, the vertical lift rod that raises the water is operated on a crank from the mill and goes up and down. The rod itself would be hard to see, so lets make a rusty coupler in the length of rod, so that will be obvious when it moves up and down. We have however attached the rod to the water pipe earlier and made it a stationary object attached to b.r.main. It is easy to separate it, and then attach it to a new helper that goes up and down. Select the water_pipe object then:
We need to make a rusty coupler as part of the rod, about 6 metres above the ground, so we can actually see the animation action of the rod. Construct a small cylinder with a diameter a little larger than the rod, texture and map it rust, then attach it to the rod as one object.
Animating the Rod and Coupler In top view construct a helper b.r.rod near the centre of the rod (about 6m up from the ground), link the b.r.rod to the b.r.main, then link the rod itself to the b.r.rod, similar to previous linking steps. Because the rod was part of the water_pipe, and has not been rotated during the detaching process, its axis will be aligned to the World axis already. The mill rotates three times over the 300 frames, and the rod goes down and up for each rotation. Consider the position of the b.r.rod to be at the top of the stroke, and it will move down 0.3m, then back up over 100 frames, this will be repeated three times for the full animation cycle. To animate the rod helper, make sure the animation is at frame zero (in entry box at the bottom of the screen), and make sure the Animate button is clicked to make it red:
To move the helper and therefore the rod, we will have key frames at every 50 frames, the heights alternate from 6.0m to 5.7m and back again. Setting these frames and heights is quite easy, and we will use the bottom frame and height entry boxes this time instead of the animate menu down the side of the screen.
The action of typing in a new dimension sets the key frame, with a value of 5.7m and you will see the helper move down 0.3 metres.
Now the rod has completed one of the three cycles and it is back at the top of its travel. Repeat the above steps for frames at 150, 200, 250 and 300 with the 5.7 or 6.0m heights entered correctly. Click the Animate button to turn it off and run the animation from the buttons at the bottom of the screen. The animation should look smooth and the rusty coupler should travel up and down with the lift rod. Adjusting Linear Animation Smoothmess and Performance The rod should not move up and down in a linear motion, as it is driven by a crank on the mill. It should slow down as it approaches the top or bottom of the motion. Looking at the animation just created it seems to do this. The way an animation tracks through a key frame was discussed earlier, as an elastic band, accelerating into or out of the frame, or sharp changes of direction. These properties are set by the animation controllers, you will have noticed the graphical diagram in the Key Info box of the Animate menu.
The one shown is the default value and gives a smooth flow through the key frame. This is usually satisfactory for most of your animation. However, if you move a helper and hence an object over large distances and short time frames, then alter the trajectory sharply, the animation can wander all over the place, or overshoot. Right click on one of the graphs above, and you can see the other options to alter the behaviour into and out of each key frame, you should refer to the Help file for an understanding of each option. Exporting the Model Make a temporary directory to export the model, for later import into Trainz. Export the model as mill.im from the file export menu (File .. Export .. mill.im .. Save).
Exporting the Textures To export the textures used on the model use the Resource Collector option.
All the textures used should now be found in the same folder as the mill.im model. Verify that the textures match the texture.txt file names, delete any texture files that are not required.
After many exports, when the model is finished, you should delete all the texture.txt and the texture files, and export and gather for a final time you may have changed your textures during the model development, and have obsolete textures left in the directory. Exporting the Animation Open the File ..Export box and export the animation as anim.kin. A dialogue box will open asking how many animation frames to export, click ok to export the full 300 frames.
The Config.txt File For the correct config.txt file see the downloadable model for this tutorial. A typical file for the windmill will look like this:
You should only use a vanilla text editor such as Notepad to create config.txt files, MS Word is not suitable, the quote character for example, is not the correct quote " code recognised by Trainz. The important parts for the mill model in the mesh table are:
Comments I hope you can find something useful in the tutorial.
Making the Model The construction of the windmill is covered in Part 1 of the tutorial, click this link: Part 1 Ian Manion (Vulcan) May 2008 The full tutorial is available for download as a pdf: Animated Windmill The model files (gmax and ingame files) are also available for download: Model Files Amendment Notes and Comments
18/05/08 Initial issue. |
|