Animation / Wing Folding
-
Introduction
This tutorial will cover how to add simple rotating animations (parts that rotate) to ships. This is basically a collection of info, so a lot of credits go to
Mini_Me, BBalazs, Bejaymac and RimShotRequirements
First off, before we start, make sure your model’s parts that should get animated are all seperate groups (also export them as groups, so they are components within the .cmp).
Here already comes the tricky part that will save you trouble later on:
Animating parts always rotate around their 0,0,0 point in object space. That means, you will have to move the components in question to the center in such a way that it will rotate correctly. If the center of the model is 0,0,0 in object space, it will rotate around itself! Note that you can get away for certain animations without moving any group simply because of the nature of the animation. For example the X-Wing or B-Wing have wings that, in relation to the overall 0,0,0 point, should also rotate around that point. However, for this tutorial we will use the Eta-2 Jedi Fighter, where we definately have to move the components in order to get the animation right:
http://www.flserver.de/stuff/wingfolding_1.JPGBefore we move the animating groups, it might be wise at this point to measure angles to make life easier later on. There might be easier ways to measure an angle in Milkshape, but I just downloaded PicPick ( http://picpick.wiziple.net/download ) which has the awesome ability to measure an angle anywhere on the screen. So, I get angles of ~60° for the top wings, and ~70° for the bottom wings.
Now we move the animating groups:
http://www.flserver.de/stuff/wingfolding_6.JPGSince we will rotate around the z axis, its important we zero the wings on the x and y axis.
Now, you see the model is now pretty ugly. Dont worry, we will move the wings to their proper places in the .cmp!Also, make sure that all components have an component-attached, fitting hitbox, otherwise the hitbox will not move with the animation. I will not explain how to do this because honestly I simply dont really know. Watch the excellent other (video) tutorials about cmp file structure, cmp/sur splicing and hitboxing to get the idea.
Important: if you displaced your animating components in milkshape, you will have to do the same for their hitbox part!
Also, make sure that any hardpoints on moving parts are actually placed on the moving components, NOT on the root. Otherwise, your hardpoints will not move with your components.When we have made the ship meet the requirements above, we are ready to go. We’ll need the following tools:
- UTF Edit v1.003
- UTF Edit v1.004 (yes, we’ll need both)
- Your favourite hex editor
Lets get the bloddy wings to fold!
I’ll use the eta-2 Jedi Fighter.
All 4 wings are seperate, in the groups/components
z_eta-2_2 to z_eta-2_5
(check Milkshape screenshot above)The first and most important thing to do is messing with the cons_fix data. Hit up utf edit v1.4 and load the .cmp
Look at the fix data (right click -> “Edit Fix Data”):
http://www.flserver.de/stuff/wingfolding_2.JPGNow, for animations to work, all animating parts must not be “fixed” aka “Fix”, they need to be either “revolute” aka “Rev” which describes a rotation, or “Pris” which describes a translation (moving). For most of our animations we only need rotations, so I wont talk about translation-type animations here.
So, what we have to do here is delete all the moving parts from the Fix data, and add them to a Rev data node.
UTF edit v1.4 can not delete/add Fix/Rev/Pris data! So we have to do that manually, oh the joy!If you already made special Fix data origin/rotation/offset whatever adjustments, remember them! In most cases, they are all 0 and it has the standard rotation matrix!
Export the Cons/Fix node and use your favourite hex editor to delete the appropriate entries. In this case, its the first 4 entries:
http://www.flserver.de/stuff/wingfolding_3.JPGRe-import the fix-data and you are set.
Now we need to create a Cons/Rev data node. Create the node in utf edit v1.4 and export the data from any vanilla ship.
Now, if your vanilla ship has the same amount of animation parts that you need (in this case 4) it would be ideal and we can directly re-import, so we use the Rheinland Valkyre which has 4 rev data parts. (also note, in utf edit v1.4 you can directly copy the rev node, its sooo easy)
But if we would need more or less parts, we’d have to do some deleting/copying within the raw data. Note, we dont have to edit the actual data yet, since we can do all this in a very comfortable way within utf edit. Just make sure your number of rev data parts matches your needs.Now, in utf edit v1.4, edit all rev entries so they match their former fix data, in most cases like this:
http://www.flserver.de/stuff/wingfolding_4.JPGNote, we didnt edit the name (string)! Utf edit v1.4 cannot edit these names (strings)!
To edit those, save the cmp load it in utf edit v1.3
In utf edit v1.3, look at the bottom under “Custom Controls”, there are the buttons to edit the fix/rev/pris data.
Here we can now edit the names of the rev parts, name them just like they were named in the fix data.
Save the file and we can now again proceed in utf edit v1.4 (much more comfortable).Here comes the 2nd tricky part:
If you moved the animating groups to make them rotate correctly, just like we did in the beginning, we now have to use the “Origin” entries in the Rev node to move our wings to their proper places. If you didnt move the groups, skip this paragraph.
Use HardCMP and play with the excellent Hardpointing feature (CTRL+click when placing hardpoints automatically puts the hp on the model where the mouse is) to get a rough idea for coordinate values. This is a little trial and error until your parts match the model again. Also, if you didnt move the animating parts on the y-axis in Milkshape, you might want to ignore the z-axis in Hardcmp, since you only need to move the parts on the x and y axis.
For our eta-2 we found -2.626627, -0.382567, 0.000000 to be working, which we can then almost copy for all the other parts if we moved them in the same way (only changing the x-axis from -2.62662 to 2.62662).Now we get to the real stuff: the actual animation.
Note that at the bottom of the rev data parts, there is “Axis Rotate” and “Angle (Radians)”.
These two entries control the rotation axis and the maximum angle the part may rotate.
Note that all angles are always interpreted as radians.
1 radians = 57,2957795 degrees.
The rotation axis controls around which axis the part should rotate and in which direction.
We need it to rotate around the z-axis: 0, 0, 1 (or -1, we will trial and error here later to get the direction right).
The maximum angle is important, because your component does not exceed this angle ever in an animation. So set this to something higher than the angles you will use:
1.5 (= 85,94366925°, so its enough).Next in line: The Animation node.
Thank god this is the easiest part of the whole animation creation process.
For a start, you can either manually create all nodes (look for a template in any vanilla cmp file), or just copy one over from vanilla and then edit it appropriately.
This time, I just copy the Valkyre animation node and edit that:
http://www.flserver.de/stuff/wingfolding_5.JPGSince we have 4 wings, we have 4 joint maps. “Sc_extend wing” is the actual name of the animation and you are free to name it whatever you want.
Every joint map has a child and a parent name entry. Interpret the data as a string to modify it. The parent in most cases is the root, however this may be different on complex models with more components. The parent is always the static object; the animating object (aka the child) always rotates relative to the parent.
The header is a [3] float array and it tells the game which type of animation we want to use.
The value for rotating animations is:
0.000000
-1.000000
0.000000Frames is the next important node. Its also a float array and it controls the actual animation, like this:
0.000000 <- time 0:00
0.000000 <- angle 0 radians at 0:00
2.000000 <- time 0:02
1.178090 <- angle in radians at 2 seconds
10.000000
1.5707963 <- angle at 0:10 (90 degrees)I guess you get the idea.
Here we go, you should have everything to control the animation. What you have to do now is a lot of trial and error to get the animation right.
If you are smart you did measure angles in the beginning and you can now paste those in order to get a good start on the animation.
You control the direction of the rotation either within the frames data (which may be buggy when using negative values), or you simply alter the “Axis Rotate” data in the Rev node as explained above.
To test the animation, simply bind the animation to the cargo bay animation.
This is done in shiparch.ini with
“bay_door_anim = Sc_extend wing”
Now, if you jettison cargo, you should see your animation play.In the case of our eta-2 this looks like this:
http://www.youtube.com/watch?v=HSuMZCit_as
Awesome ;D
Quick Recap
Here is a quick overview over the animation process:
- make the ship meet the requirements, maybe move the animating groups so they’ll rotate correctly
- edit fix/rev data, maybe move the displaced components by editing rev data
- create and edit the animation node
- edit shiparch to bind the animation to bay doors and start trial and error process
As you see, it isnt that hard
-
Also, thanks for posting about Header and Frames, I will add it to the CMP editor tonight…
-
Nice one!  Now all we need is a clientside hook that calls it when the cruise engines are active.  And also one for the Cruiser forward guns recoil.  nudge nudge hint hint  ;D  Would it make a differance if i got down on my knees and begged??
-
Very nice tutorial w0dk4, takes alotta patience to piece it all together and explain it (which I obviously don’t have much of). Stoked to start seeing vids of people’s new creations
Remember peeps, you can use this for docking ring type stuff, constantly running station anis, constantly running engine rotation on ships, on and on.Just the Header section needs a teeny tweaking. It’s actually not one solid type of data like 3 floats, so UTF ed doesn’t show the correct values. Refer to LS’s new discovery of just what the data in it actually is:
@Lancer:
**Got some new info for the animators out there, all is not as it seems in the Animation nodes , W0dk4, you may want to update your tutorial. All of this information was obtained by building the editor and scripter for the Header and Frame nodes in br_01_avalon_cityscape.cmp and several others.
Header
4 bytes - ULONG - Frame Count
4 bytes - FLOAT - Frame Delay ( -1 = store timing in ‘Frames’, used for variable frame timing )
4 bytes - ULONG - TypeFrames
Total Entries depends on ‘Frame Delay’, below is a single entry from the ‘Frame Count’ list
Frame Delay = -1
4 bytes - FLOAT - seconds
4 bytes - FLOAT - angle in radiansFrame Delay not = -1
4 bytes - FLOAT - angle in radians**
so that’s:
unsigned long integer
float
unsigned long integer.If you do edit the Header in UTF, you must remember to: “interpret as INT” -> edit the 1st and 3rd entry.
“interpret as float” -> edit the middle entry