PDA

View Full Version : Simple Madstate Tutorial (Now with source files!)


DeathWish
31st Jan 05, 9:00 AM
I got a PM from Sumillius asking for help with madstate anims. The following is the response I sent him, I figured it might be helpful to others as well.

This tutorial assumes you have Maya 3 with all the RDN Tools plugins fully installed. It also does not explain modeling, texturing, UV Mapping, creation of joints in maya, etc. It only explains animating for Homeworld 2.

Before beginning this tutorial you may find it useful to download MadstateTut.rar (http://www.slothworks.com/MadstateTut/MadstateTut.rar) and follow along step by step. This archive includes source files as well as compiled HW2 ready files.

To take a look at the finished product before beginning put the contents of the data folder in your %HW2_ROOT%/data directory. This replaces your Hiigaran Probe with an impromptu target drone inspired by the Kushan target drone from Homeworld 1. This is the ship we'll be animating in this tutorial. It's not pretty but it functions perfectly.

If you would like to take a look at the finished maya scene before you begin, take a look at hgn_probe_after.ma to get a good idea of what we're aiming for here today.

To follow along with this tutorial, open hgn_probe_before.ma

The process goes something along the lines of this:

Step 1: keyframe your animations; be sure to only move the joints, not the parts of the model. To achieve this place the parts of your model that you want to move below your joint on the hypergraph. Some general rules you'll want to follow:

* Joints should be placed at pivot points
* Parts that move along the same pivot should be on the same joint
* Always make frame 0 look like your idle or rest state because ships always spawn at frame 0. Always start your animations at frame 1 so they will not conflict with this idle state.
*Joints at frame 0 should have x,y, and z rotation of 0.0 and x,y, and z scale of 1.0 to avoid confusion later down the road. It is far easier to simply know that your rest state is at zero than it is to copy and paste every time you want to have a frame at the rest state. Along the same lines I find it helpful to have notepad open in another window so I can copy and paste translation, rotation, and scale values that I know I'll be using in other frames later on.
*Animations in HW2 run at 24 frames per second. If you want your animation to be 1 second long, make it 24 frames long.


Step 2: Keyframe your anim markers. You can create anim markers by clicking any empty area in the hypergraph with nothing selected then press <CTRL> + <G> to create a null marker, then click the matey button with that null marker selected. Create one keyframe with that marker selected at the BEGINNING and another at the END of EACH animation. This is imperative, you can have as many keyframes per animation as you like for the joints but only two for each marker, a beginning and an end. Be sure to name each of your markers the same as the states you plan on using. This is not necessary but it avoids confusion later on and animation is confusing enough as it is.

Step3: Export all to shipname.mad where shipname is the name of your ship.

Step4: Export all to shipname.hod where shipname is the name of your ship.

Step5: Create your shipname.madstate file, look at the vgr_probe.madstate and vgy_heavymissilefrigate.madstate files for good examples of syntax. Look at the Madstate documentation that comes with RDN Tools for a technical description that makes very little practical sense. In our case you may look at the hgn_probe.madstate that is packaged in this archive. It includes all the madstate syntax needed for this ship we've created.

Step6: Add your animations to the shipname.events file, this is necessary if you want sounds to accompany your animations. I'm not certain if it is necessary for the animation itself.

Well, if your file ended up looking like the hgn_probe_after.ma file, you'll be in good shape. Just test it and track down errors in the log file if there are any and you'll be animating in no time at all. Try tweaking these here and there. Try renaming things to other states in the documentation and trying them out. If you want a state that is entered by attacking though you'll probably want to add a weapon hardpoint.

If you have any questions feel free to post them here and I'll update this tutorial as I can.

Moderators please sticky this tutorial as the last two madstate tuts have vanished off the list of active threads. With a little time this will become the definitive madstate documentation. I'm willing to maintain it if someone will make sure it doesn't just disappear.

Fokker
31st Jan 05, 3:11 PM
Oh how we need search.

This topic's been covered relatively extensively.

If anybody else is doing advanced animaiton, let me know... seem to keep running into a few quirks, would like to be able to document the sources.

DeathWish
31st Jan 05, 3:16 PM
Sure, you can contact me via msn anytime if you need help. And yes, we need the search function back. For some reason both of our old madstate tuts are pushed off the active threads list due to lack of bumpage. Once I get pictures and an example maya scene uploaded I'll request this get stickied.

Edit: Oh yeah, I use google to search this forum when I want an old topic. Google seems able to get at the archives easier than I can by clicking around the site. This tut though was written from the top of my head, I'll refine it tonight.

Edit2: ok I've added sample files to the tut. Could someone sticky this so other people can find it months down the road?

evillejedi
1st Feb 05, 11:46 PM
I want to add that you should make sure that none of your joints in the rest state(frame 1) should have any rotation values (should all be 0) this will cause untold headaches if it is not done

DeathWish
2nd Feb 05, 8:14 AM
yeah, I made that mistake on my taiidan scout :-/ had to end up doing a lot of adjusting by hand and copy pasting values instead of approaching it mathmatically. In other words a lot of work and no noticeable difference to the casual player. I'll add that to the pointers in the tut.

evillejedi
2nd Feb 05, 10:39 AM
the other thing I would say is that if you have an animation that doesn't seem to update after weaking it, try deleting boh the hod and mad file and rexporting them clean, there seems to be some old data that get hung up in the file writing process for the mads

DeathWish
2nd Feb 05, 2:38 PM
Sumilius, Please rephrase your question a bit, I've no clue what you're talking about.

EJ, I've never noticed that personally but I wouldn't be suprised at all. Then again I'm always deleting folders and replacing them with new ones or with older backups. Bad files don't live long in my HW2 directory.

Sumillius
3rd Feb 05, 12:04 AM
Crap shouldn't write things at night...
Anyways here it comes again in a ,I hope , more sensebable way.

I told you about my problem that the lid of the box was openening a bit after the launch animation. You said it had something to do with misallignement of the marker/joint animations. Problem was i didn't put the idle frame in the beginning. In that other post i tried to point you on the fact that your probe model doesn't have this idle frame. Since i only used the model as refrence. But probably you don't need idle frames with normal animations... But You do need it with launch animations. Yesterday i noticed that line about idle frame at the start, which fixed my problem. But i can't recall it standing there one day before....

That's sorta what i wanted to say ... :)

DeathWish
3rd Feb 05, 1:43 AM
ah, but it DOES have an idle frame in the beginning, it's been there all along, look again and you will see :p the reference to it in the tut though wasn't added until after EJ pointed out that I hadn't mentioned it.

Sumillius
3rd Feb 05, 2:02 AM
It hasn't :P at least not at the beginning..... Behold THE TRUTH <ahum>


http://img.photobucket.com/albums/v244/Sumillius/timeslider.jpg


as you can see there is no idle frame at the beginning... Only in the middle (this is a timeslider view of all animated parts).

DeathWish
3rd Feb 05, 11:50 PM
yes but look the anim starts on frame 1, at frame 0 there is no keyframe. I misspoke earlier I guess. I'll change the references to say frame 0 instead.

evillejedi
3rd Feb 05, 11:57 PM
heh actually it seems to work best if you do start the first anim on frame 2, as in the literal frame 2. I had issues with my xwings code red until I changed this and moved the anims from 1-45 to 2-46 (they would sometimes cycle the anim and then revert to the rest state randomly during the anim)

DeathWish
4th Feb 05, 8:21 AM
Enterprise-E was having that problem with code red anims on the taiidan missile destroyer too. He said he'd also noticed it occasionally on the Vaygr Heavy Missile Frigate. I think I'll hereby label this a bug! ;) Shall I change the tutorial to reflect this?

Sumillius
5th Feb 05, 6:35 AM
Oki animations are piece of cake... :).
All animations are working fine as long as the custom animated ships are replacing excisiting ones. So Hgn_custom replaces the carrier.
But as soon as you put it in as a new ship in a new directory it won't run the animation. Any ideas about this problem ? I added the ship in the build.lua. Do i need to add something elsewhere or remove something elsewhere ?

DeathWish
5th Feb 05, 8:46 AM
look in your madstate file. It probably still says "HGN_PROBE" at the beginning of each anim. Change this to the exact ship name or it won't work. Other than that I'll take a look when I get home. All my taiidan animations are original ships that do not replace anything.

Burning_Terror
13th Aug 05, 3:50 PM
MadstateTut.rar link dosent work.