|
|
|
HOW TO ANIMATE A SCENERY OBJECT– PART 1 Copyright © 2004 Paul DeVerter A Port City Car Co. Project DOWNLOADS REQUIRED FOR THIS TUTORIAL: Rot.zip Several .rot files to add to your Abacus\TSModeler\Resources Folder. TutStatE.zip A completed Tutorial Stationary Steam Engine for you to compare to what you have done, or to place in any route you may desire. It includes the s, sd, ace, and a text file. SEE ALSO:
This advanced level tutorial is for Train Sim Modeler, which contains little help on animation. If you follow this tutorial, you will build an animated scenery object. After you have decided what you are going to do, you need to make sure you follow several rules.
A Stationary Steam Engine project.
This model has rotating, rotating and sliding, and simple sliding parts. To learn what to do, the size is not important, just whatever looks reasonable. And use gaudy and multiple colors, so you can send pictures to friends and ask for advice, and identify parts by color as well as your nomenclature.
Part HierarchyLets talk for a bit about naming hierarchy. In order to set things into MSTS, TSM wants you to have a parent part, and a bunch of dependents. The part that goes on the ground is the one at the origin. If you pick something above that physically for the origin, the part object will sink into the ground when you try to place it in Route Editor. We have already placed the Base at the origin, and adjusted its axis so that it will be sunk into the ground about half way. What is confusing in reading about bogies, and wheels is that the frame of an engine or car is the parent, and the bogies are dependent, and the wheels are sub dependents. So how do we set up an animated object that has a Flywheel, a Connecting Rod, a Crosshead, and a Piston Rod, each connected to the next, yet each independently animated? The answer is trial and error, and here is my solution after facing flying parts.
Part NamesAnd as mentioned earlier, you can choose any names you wish for animated parts in scenery objects, and that seems to work fine. This is not true for Pickup Objects, and for these you need to read the MSTS Technical Documents in your CD’s.
Adding AnimationBack to No animation. To add animation, you need to go to Project Preferences in the File menu. Here you will need to choose Anim Scenery, which is TSM’s name for a Complex Shape in the scenery department. Also pick a long name and a short name for the project. Notice the Box Animation Frames down toward the bottom. Until you chose Anim Scenery it showed a grayed out (0), and the line says: (Last animation frame will be one less than this value). If we are going to have 8 animation frames, then we need to stick in 9. But later, when we are setting up the frames, the numbering scheme starts with 0 and goes to 8. 0 through 8 frames = 9, which is somehow inconsistent with the last animation frame being one less than 9. However, the 0 frame and the end frame are identical, which I am told causes the animation to loop into a repetitive string. But logic aside, if you are going to have 8 frames, put in 9; and if you are going to have 16, put in 17. There is no need to use a bunch of un-necessary animation, and TSM and MSTS seem to fill in the gaps, and it really looks lifelike and smooth. If you were doing a Water Tank spout, you would use only 3 frames; 0 and 2 being the same, and being the initial up position, and 1 being the down position. Yet when played in the Sim, all looks well and works slowly. And we haven’t really gotten to frames yet anyway. But we will very shortly.
But suppose something goes wrong (and it nearly always does) and the Flywheel doesn’t want to follow your instructions, and goes off on a spin of its own, as here. What to do?
For example, look at Frame 3, and you will see 180 in the X axis, and there should be only a 0 there. Further, the Z progression in degrees is not correct, because of the jump from 90 (or 89) to 314. So, you have two choices. You can delete all the data for all Frames by clicking the Clear button, which is worth a try, and doing the exercise over again. Or, you can correct the erroneous Frames. Since you already know how to start the animation over again, let’s try the correction route.
Why do these things happen? Why does it sometimes rain? I think that TSM gets loaded down with data, and can’t make the computations correctly. It has also been my experience that you must progress through the animation data input in numerical order, at least for rotation items. But sometimes not. It may also help to close other Programs that may be open, and also to save, and perhaps close and reopen the TSM file fairly regularly. Anyway, you know how to fix it, so do it now. Proper data is shown below.
This what the corrected Rotation Keys data for the Flywheel should look like after you are done editing all of the entries:
In this image you can clearly see the data for each of the 8 Frames, and also discern the three parameters. I see there is still a slight error in Frame 1, and you can fix it if you wish. Now, again run the Ami button slider, and see if everything rotates properly. To digress even further, I think the clue to all rotation key data in TSM is to save after each entry is made. I have prepared correct .rot files for each axis, and have still had problems making the rotation keys data stick when animating parts. The only way I can make TSM behave is to enter one or two keys worth of data, and then save the whole file, before entering any further data. I have prepared several .rot files for you, one in each of the three axes, and some going clockwise and some counterclockwise. I have finally been able to animate three wheels, one in each of the three axes, and have all 3 rotate properly, in various directions, at the same time. These .rot files are in attachments to this tutorial. The structure is that the first letter is the axis of rotation, the second is the number of frames, and the third is either clockwise or counterclockwise, e.g. x8cw.rot. You may place these files in your TSM Folder Abacus\TSModeler\Resources and use them for further projects that involve rotation. Simply use the Load button to bring them up. You should also either remove the .rot file that came with TSM, or else correct it so that Frame 0 and Frame 8 are identical, which means change the 360 in Frame 8 to a 0. Let us now construct and animate the Connecting Rod. Using the Box tool, lets make a Rod that is 5 feet in width, 0.3 deep, and 0.3 high. The first thing to do is move the axis from the center to left end where it will mate with the Crankpin. So, activate the Move tool, constrain Y and Z, and hold down SHIFT while you move the part axis to the end. After you have shifted the axis to the left end in the front view, look at the side view, and move the Rod out so it clears the Flywheel. Now, back to the front view, constrain just Z, and move the Rod with its shifted axis over the Crankpin. Then use the Rotate tool, constrain Z, and rotate the right end so that it rests on the grid line that goes through the horizontal center of the Flywheel. Change the name in F2 from tube to Connecting Rod, and change the parent to Base. It looks like this:
We will use the horizontal grid line for placing the right end of the Rod, and the Crankpin for the left end as we proceed with animation. Since the entire project is animated scenery in Part Properties, we need to do nothing further, except to use the Ani button and Animate Part pane to set the motion. The position shown will be the initial and last positions, which will handle Frames 0 and 8, just as in the case of the Flywheel. The only difference is that we will need to click both the Set Rotation and Set Motion buttons for each frame. So, make sure the Rod is selected, and push the Ani button, and see that the Connecting Rod and Flywheel are in the above positions in Frame 0. If not, make adjustments. Then click both the Set Rotation and Set Motion buttons. Next, move the Slider to the far right, to Frame 8 and do the same things. Then go back to Frame 0 and press F2 and then the Animation button, and look at the data. The Frames for the two Keys should be the same. If not, straighten it out now, as explained for the Flywheel. Now we will go on to the setting for Frame 1, which should follow intuitively from the prior instructions. But if not, you should move the Slider in the Animate Part pane to Frame 1. Then, using the Move tool, and constraining Z, move the axis of the Rod to the center of the Crankpin. Then using the Rotate tool, and again constraining Z, rotate the Rod till the right end is centered on the grid line of the center of the Flywheel, and then click Set Motion and Set Rotation. Do this all the way through Frame 7, as you have already done Frame 8. Now you can check your work, as you have done before for the Flywheel, by clicking the Ani button, and moving the Slider back and forth. And problem solving is identical as before. If there are any, look for abnormalities in the Part Animation pane. The illustration below is Frame 7 of the Connecting Rod. It shows how the Rod has been manipulated to place the left end over the Crankpin of the Flywheel, and the right end in line with the horizontal axis of the center of the Flywheel, on the grid line. When in place the Set Motion and Set Rotation buttons are both clicked.
Now we move on to the next part in the chain, the Crosshead. This is a simple block in this tutorial, and I include a simple removable Pin in the center, just to help line up the parts. This part only slides linearly back and forth along the X axis, so we will only be using the Set Motion button, as there is no rotation of the Crosshead. Again go to the Box tool, and pick a shape that is 1 foot wide, 1 foot high, and 0.8 deep. Manipulate the Crosshead until it is centered on the horizontal grid line from the center of the Flywheel, in both the Front and Side views. Then add a simple Crosshead Pin in the Z axis in the middle of the Crosshead, such as a tube of 0.1 Radius, 0.9 Length, closed at both ends, and structured along the Z axis. After it is placed, as with the Crankpin, it needs to be joined to the moving part, so follow the same selection and joining process, with the Crosshead being selected last. Also go to F2, Part Properties, and change the name of the box to Crosshead, with the Part Parent being Base. Now is the time to animate the Crosshead. So, once again select the Crosshead, and note that you will constrain it in both the Y and Z axes, because it only moves back and forth along the X axis. After it is properly placed for the initial starting position, which is Frame 0, you will need to only click the Set Motion button. And as before, you will move the Slider to the Frame 8 position, and after making certain everything is in the proper position, you will click the Set Motion button again.
Here we have the Crosshead with fused Crosshead Pin in Frame 4. So far as the Crosshead is concerned, it is in the same position in Frames 0, 8, and 4. The other Frames will require sliding the Crosshead back and forth along the X axis only, so attend to these animation details. Note that the Crosshead is in the same position in Frames 1 and 3, and likewise in Frames 5 and 7. I have had no difficulty in using the Set Motion button in no particular order. When you are done, move the Animation Part Frame back to 0, and get out on Ani. Then check your work as before by going to F2, Animation Button, and looking over the Part Animation pane to see that the Motion Keys and Rotation Keys data looks correct. Again you should see nothing changing in the Y and Z axes for each Frame, and if you have inadvertently made an entry or two in the Rotation Keys for the Crosshead, simply Clear that area of data. The last part to animate is the Piston Rod. So, go to the Tube tool, and lets pick a Radius of 0.1, and a length of 3 feet, with the Rod being open at both ends, and having 4 or 6 points and only 1 section. Structure it along the X axis, as that is where it slides back and forth. Place it along the same grid line as the horizontal center of the Flywheel, and Crosshead. It will be placed slightly inset into the Crosshead so that there is no need for a left poly or texture, and the right end will be hidden in the Cylinder, so it also needs no poly or texture. Check Polygon Smoothing to make it round, name it Piston Rod, and its parent will also be the Base.
Now you will animate the Piston Rod, in an identical manner to the Crosshead, as all it does is slide back and forth, linearly on the X axis. You will only be using the Set Motion button. Now it is time to make the remaining static, un-animated parts of the Stationary Engine. These are pretty simple, just to save time, and finish up your project. Probably the easy thing to make is the Cylinder. So use the Tube tool, and make one with a Radius of 1.25, Length of 3 feet, closed on both ends, 8 or 10 points, and 1 section, formed along the X axis. Using your Ani button, see where the Crosshead is in its extreme right position, which should be Frame 6. Put the left end of the cylinder a couple if inches from there, with the central axis of the Cylinder being concentric with the Piston Rod. Sometimes the Cylinder will jump around as the animation is cycled, so just get a general location for it, and then make the final placement after you are out of the animation mode.
Name it Cylinder, and use the Base as the Parent. Check Polygon Smoothing. This is generally what it should look like in the perspective view, in Frame 6. Next up are the Upper and Lower Slides for the Crosshead, and a Support for the Cylinder. For the Upper Slide, go to the Box tool, and create a Slide that is 3.2 wide, 0.3 high, and 1 deep. Then use the Move tool to place it above the Crosshead, and slightly sunken into the Cylinder head. It should be centered above the Piston Rod.
After it is in place, go to F2 and name it Slide, Upper and make its part parent Base. Now for the Lower Slide, we will copy and paste. So, while the Upper Slide is selected, got to the Edit menu, and click Copy. Then click Paste. The new part is covering up the earlier one, so use the Move tool, constrain X and Z, and move the pasted Slide down in the Y axis until it is placed under the Crosshead. Rename it Slide, Lower, and make parent Base. The final part is a Support for the Cylinder. Again, use the Box tool, and create a Support that is 2 wide, 1.3 or so deep, and 2 high. Center it under the Cylinder, so that it is buried in both the Base and the Cylinder, and name it Support, with Base as parent. Now you are done making parts, and it is time to begin cleaning up the parts so that we can texture the Stationary Engine. Here you will see why we have buried certain parts within other parts. The answer is so that we can avoid having to texture things we can not see. And it we can not see a surface, we can probably just eliminate the surface in
order to reduce the number of polys in the Object, and thus reduce the load on the Sim engine, to ultimately speed up the frame rate. So, go through the parts, one by one, and check in F2 to make certain that each part has a name, and a parent, except the Base. Then look at each part to see if there are any surfaces that will not be seen, and can thus be eliminated. So, lets start with the Base. Select the Base, and go into poly mode, and change the view to Outline, as opposed to Solid. Then use the N key to cycle through all the polys to determine if any will be hidden. And you will find that the bottom of the
Base is pointing into the ground when in the Sim, and thus will never be seen. So, with that normal or poly highlighted, as above, it can be eliminated, simply by hitting Delete. The same can be done for many of the other parts, such as the bottom of the Stand, the ends of the Slides that are buried in the Cylinder, and both the top and bottom of the Support. Also the right end of the Connecting Rod is buried in the Crosshead. And if you wish, you can eliminate the Crankpin polys and the Crosshead Pin polys, as well. If you leave them in, remove the poly on the end of the Crankpin that is buried inside the Flywheel. However, if you eliminate one poly too many, it is difficult to get it back, so exercise caution. TexturingThere are really no secrets in texturing this simple model, and rather than write an article on that subject, I simply refer you to the manual that comes with TSM. I created a simple set of color blocks in a 256 x 256 bmp, with the thought being that some vivid colors would make explaining, and asking questions a whole lot simpler. So here is what the bmp looks like, and you can make your own.
Once you have finished texturing, then go to the Polygon Menu, and click on Find Untextured Polygons. With any luck, you will get this pane.
So, all is well, and it is now time to stick it into a Route, and see what it looks like. If you did have untextured polygons, just follow the instructions in the pane, and you will be lead to the offending parts, and even polys, which you must then texture. You must fill in the blanks for Create a Train Simulator Object, found in the Edit menu. TSM will do the necessary, and even prepare a ref file entry for you. I picked a new Class, called Animated. The Filename comes from the Project Properties pane, which we filled out much earlier. But, if you failed to do so, you can do it now. My ref file entry came out like this: Static ( Class ( Animated ) Filename ( StatStmEng.s ) Align ( None ) Description ( Stationary_Steam_Engine ) ) in the ref file of the Route I sent it to, namely FirstRoute. Notice the name of the s file. TSM takes the Filename entry, which is the short name in Project Properties, and adds an s. The sd file name is the same. The ace file takes its name from the bmp file that you use to texture. So, choose a name you can live with when you pick the one for your bmp. There is a way to change the bmp file name, but that is another story. The Description entry comes from the long name that you placed in the Project Properties pane earlier. TSM automatically added the underlines between each word when it creates the ref file. I don’t know if there is any way to add sound to the Object.
Now go ahead and create the model in MSTS, and then move on to Route Editor to set the model on the terrain. The only trick here is to get the Engine animation to work. All you need to do, after rotating and setting the height, is press F2 and while the object is in wire frame mode, right click. The Properties pane comes up with two tabs at the top. Pick the one that says “cont.” and check the box “Animate this object”. Then, go to F2 and click the Object, and the animation should start. Then save your way out of Route
Editor in the usual way. Now, you can go to the regular Train Simulator and drive by and enjoy your new Stationary Engine. And you will see it is really spinning. Animation SpeedAs you have seen, the animation is much too fast. The Flywheel is going around and around way too often. So, the problem is how to slow it down? And the answer is to adjust a parameter in the s file. Apparently the speed of rotation is set up automatically in MSTS, and you are not given an opportunity to select what you would like. From what I have read, the initial speed is set at a parameter of 30. I can not tell if this is RPM or Feet per Second, but nonetheless, it can be changed. If you un-compress the s file, you will find a line that is styled animation and the parameters are ( x 30. The x apparently means the number of animation frames. In our case we have used an animation of 9 which really means 8, so the line reads: animation ( 8 30. OK, the first number we have already set with the number of animation frames, and the second has to do with speed. I counted the revolutions per minute and 30 seems to be about twice as fast as I would like, and when I changed the line to read: animation ( 8 15 the rotation speed was much more reasonable, and close to 112 rpm. So, we need to un-compress the s file. To do this, use Shape File Manager. After it is uncompressed, you need to search for “animation” in the s file, and that is where you will find the line that states: animation ( 8 30, way down at the bottom. In WordPad, change this line so that it reads: animation ( 8 15 . Here is what the lines look like in the s file, before you have made the change:
Now recompress the s file, and substitute this new s file for what was previously in the Route file of the Sim. I have found no need to delete the prior s file in the Route, simply overwrite the existing one with the revised one. By doing this, you will reduce the rotation speed to approximately 112 RPM, which is a reasonable speed for a Stationary Steam Engine. You can try other numbers for other speeds. DocumentationOne of the things I always do, when making a new object for MSTS, is to document what files were made, and where the object was placed. The easiest way to do this is to save a copy of the Conversion.txt file (CnvReport.txt), generated by TSM, in the same place you keep the project file. It is found in the Abacus\TSModeler Folder. I then add to the Conversion file a copy of the pertinent part of the Reference file, and also document the location that I put the object. Then place it in your Project Folder. Now, I have to admit that I changed the long and short files names before I created the object to Tutorial Steam Engine and TutStatEng. So, I ended up with something like this: TutStatEng.txt Tutorial Stationary Steam Engine March 29, 2004 Conversion Report: TSM.s - TrainSim shape file TSM_ascii.s - ascii version of shape file TSM.sd - TrainSim shape definition file Converted texture: C:\PROGRA~1\MI9A48~1\TRAINS~1\utils\makeace "C:\Projects\trainsim\Animation\SteamEngine.bmp" "SteamEngine.ace" -dxt SteamEngine.ace Texture copied to C:\PROGRA~1\MI9A48~1\TRAINS~1\Routes\FirstRoute\Textures\SteamEngine.ace Converted TSM.s to binary file TSDSb.s TSMb.s - Binary version of shape file Copied TSMb.s to C:\PROGRA~1\MI9A48~1\TRAINS~1\Routes\FirstRoute\Shapes\TutStatEng.s Copied TSM.sd to C:\PROGRA~1\MI9A48~1\TRAINS~1\Routes\FirstRoute\Shapes\TutStatEng.sd Added object reference to FirstRoute.ref Object added to FirstRoute at Long. -0.20041 Lat. 51.60137 Reference file data in FirstRoute.ref: Static ( Class ( Animated ) Filename ( TutStatEng.s ) Align ( None ) Description ( Tutorial_Steam_Engine ) ) This will give you the basic facts to help generate a readme file for others to use. And it will also provide you a record of the name of the ace, s, and sd files, and where they were placed. When you build several objects, you soon forget exactly what the names were, where they are located, and even what class they are in. ImprovementsHere is what the Stationary Steam Engine looks like, when you are all done.
You are now on your own, but here are some things that you might consider as betterments. The Flywheel truly looks like an octagon, and if you were to check the box in Part Properties for Polygon Smoothing, that would help a little. But if would help even more if you were to use 16 points, instead of 8. You do not need to use 16 frames for the rotation, however. The direction of rotation of the Flywheel is currently clockwise, because that is the direction of the individual animation frames. If you wish it to rotate counterclockwise, I believe you will have to rebuild the whole animation from the beginning of the Flywheel. The colors are terrible, but your children will love them. A Crankshaft or Flywheel shaft could easily be added and extended out the back side of the Flywheel, and be connected to all sorts of machinery, like a dynamo or pump. ConclusionYou have learned how to make a simple piece of rotating machinery. You have learned how to make animated parts that rotate, slide, and both rotate and slide. And you have learned how and where to troubleshoot things that go wrong with animation. So enjoy your engine, and go on to bigger and better projects. Paul DeVerter, a/k/a CMO, paul@paradesquare.ca
|