3DI (Animation)

Binary formats and related hacking.

Moderator: Skyfaller

Post Reply
User avatar
quota4stupid
House Steiner Private First Class
House Steiner Private First Class
Posts: 81
Joined: Mon Dec 29, 2008 7:40 am
Location: Australia

3DI (Animation)

Post by quota4stupid » Sun Jun 21, 2009 10:00 am

After banging my head against a brick wall for the last month without getting anywhere, tonight I finally made some headway on the 3DI animation format. For anyone who's interested, here's what I've got so far:

[ Header ]
DWORD animTrackCount
DWORD framesPerTrack

This is then followed by animTrackCount Track records:

[ Track ]
DWORD id
DWORD type
DWORD values[framesPerTrack]

Finally, the file is terminated by a Flag Track:

[ Flag Track ]
DWORD values[2 x framesPerTrack]

Some notes:
  • The Track record id field ranges from 0 to animTrackCount-1 (Track records appear in ascending order).
  • The Track type field determines the transformation the track performs - the values are:
    • 0=Translate along X axis (track values are signed integer)
    • 1=Translate along Y axis (track values are signed integer)
    • 2=Translate along Z axis (track values are signed integer)
    • 3=Rotate around X axis (track values are 16:16 fixed point)
    • 4=Rotate around Y axis (track values are 16:16 fixed point)
    • 5=Rotate around Z axis (track values are 16:16 fixed point)
  • I'm still working on decoding the Flag Track values (currently trying to match up what's documented in MW2DOC.HTM in the Mercs tools directory with the file data). My best guess is that there are two consecutive DWORD values per frame, with the first specifying control codes and the second specifying their parameters.
This is all tied to the gamepiece BWD with the following:
  • The ANIM chunk identifies the 3DI file to use (WASM syntax example "animfile maddanim").
  • A series of TSK chunks tie objects in the gamepiece hierarchy to animation tracks (WASM syntax example "task animator 0 TW_HIPS;57,129,0" - connects track 0 to TW_HIPS).
For further details on gamepiece animation checkout MW2DOC.HTM (Appendix C) in the Mercs tools directory.
Last edited by quota4stupid on Wed Jun 24, 2009 9:46 pm, edited 1 time in total.

User avatar
Skyfaller
Clan 2nd MechWarrior
Clan 2nd MechWarrior
Posts: 991
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

Re: 3DI (Animation)

Post by Skyfaller » Sun Jun 21, 2009 11:13 am

quota4stupid wrote:After banging my head against a brick wall for the last month
Good work on the reengineering part, and I hope that headache is going to go away soon ;)
Download MechVM

If you have problems with MechVM, please attach the files MechVM.cfg and install-report.txt from the folder where MechVM installed your game.

User avatar
quota4stupid
House Steiner Private First Class
House Steiner Private First Class
Posts: 81
Joined: Mon Dec 29, 2008 7:40 am
Location: Australia

Re: 3DI (Animation)

Post by quota4stupid » Sun Jun 21, 2009 11:21 am

Skyfaller wrote:Good work on the reengineering part, and I hope that headache is going to go away soon ;)
You and me both :lol: And thankyou :-) I swear, the way it all fell together tonight was bloody magic :-D I picked the first two fields quickly when I first started looking at the files a month ago and then made no further headway - until tonight, when I decided to dump an entire file as a series of signed ints and then bam! I saw the pattern and it all fell into place :-) A truly satisfying evening :-)

Now if I can only figure out the flag track ;-)

User avatar
Col.Kell
House Steiner Archon
House Steiner Archon
Posts: 868
Joined: Sat Sep 27, 2008 7:44 am
Location: An Isolated Tennessee Valley.

Re: 3DI (Animation)

Post by Col.Kell » Sun Jun 21, 2009 10:18 pm

Excelent work! So this will mean if the 3DI files are modded then we'll have alternate mech animations? That would be nice for alternate mechs. :P
quota4stupid wrote:After banging my head against a brick wall for the last month
ehehe, not as bad as what I was doing in the weeks of my RWB campaign mod ;) hope you have better recovery than I :lol:
MechWarrior 2: 31stCC
Image

User avatar
quota4stupid
House Steiner Private First Class
House Steiner Private First Class
Posts: 81
Joined: Mon Dec 29, 2008 7:40 am
Location: Australia

Re: 3DI (Animation)

Post by quota4stupid » Mon Jun 22, 2009 12:16 am

Col.Kell wrote:Excelent work! So this will mean if the 3DI files are modded then we'll have alternate mech animations? That would be nice for alternate mechs. :P
Yeah, I thought you might see the potential in it. When I've got the flag track nutted out, I might knock together some basic tools for modifying the 3DI files :-)
Col.Kell wrote: ehehe, not as bad as what I was doing in the weeks of my RWB campaign mod ;) hope you have better recovery than I :lol:
Well like I said - when it all finally fell together it was fantastic, so I consider myself to be fully recovered :-D Although I'm bloody kicking myself that I didn't see the pattern sooner :-P

User avatar
quota4stupid
House Steiner Private First Class
House Steiner Private First Class
Posts: 81
Joined: Mon Dec 29, 2008 7:40 am
Location: Australia

Re: 3DI (Animation)

Post by quota4stupid » Mon Jun 22, 2009 3:41 am

Okey dokey, this is what I have on the flag track so far. There are 8 bytes per frame, arranged like so:

0x00000FFF 0xAA 0xBB 0xCC 0xDD (a little-endian 32-bit integer followed by four bytes), where:
  • 0x00000FFF is a set of control flags, described below.
  • 0xAA, 0xBB, 0xCC and 0xDD are parameter values (for the control flags that take parameters - if unused, these are set to -1)
The control flags are:
  • Bit 0: n# (#=0xAA)
  • Bit 1: a
  • Bit 2: b#### (#=0xAA, 0xBB, 0xCC and 0xDD - unused values are 0xff)
  • Bit 3: B
  • Bit 4: p
  • Bit 5: z
  • Bit 6: t# (#=B)
  • Bit 7: T# (#=B)
  • Bit 8: T!# (#=C)
  • Bit 9: f# (#=D)
  • Bit 10: !
  • Bit 11: s
So far, most of these flag values are just assumptions made by comparing 3DI hexdumps against the examples in MW2DOC.HTM Appendix C, except for the "s" flag which I have proved correct by testing in the sim. The values for "a" and "B" are consistent in the hexdumps with the MW2DOC description of their usage. The value I've assumed for "z" does not occur in any of the 31cc or Mercs 3DI files (which is consistent with MW2DOC, which says that flag isn't actually used by the sim).

With any luck I'll test all of the flags over the next couple of days, and should have more conclusive results to post :-)

User avatar
quota4stupid
House Steiner Private First Class
House Steiner Private First Class
Posts: 81
Joined: Mon Dec 29, 2008 7:40 am
Location: Australia

Re: 3DI (Animation)

Post by quota4stupid » Wed Jun 24, 2009 9:53 pm

I've been doing some testing today with the sim, and have updated my original post in this thread with the results. Specifically I've confirmed the interpretation of the track type values (0 to 5, other values appear to be ignored) and how they impact the interpretation of the track values (signed integer for types 0 to 2, 16:16 fixed point for 3 to 5).

Now it's on to testing the flag track values (I think these will be harder to experiment with)-: I've also decoded (partially or completely) some of the other less important formats (CPI, MGI, XXT, XYC, etc) and will post these in a separate thread soonish :-)

Post Reply