MW2 textures

Binary formats and related hacking.

Moderator: Skyfaller

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: MW2 textures

Post by Col.Kell »

Okay then. :)
MechWarrior 2: 31stCC
Image
User avatar
Skyfaller
Clan 1st MechWarrior
Clan 1st MechWarrior
Posts: 1017
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

Re: MW2 textures

Post by Skyfaller »

The file v1mistwr is referenced from MW2_MAP1.BWD at offset 1054. There is one BMPJ and one BMID tag following it. In MechVM, use the palette Cind_da.COL for displaying v1mistwr.XEL. v1mistwr is displayed as file #714, and the offset to edit in MW2.PRJ (DOS-english) is 17508092. Changing the file name v1mistwr to v1_vents has no effect, but as Kell reported, changing the number preceeding it does. The following BMPJ tag seems to assign ID #019Eh to this texture, displayed as 9E 01 due to Intel byte ordering (usually called little endian).

Now, looking at TW1_Head.WTB, a hex editor shows 7 occurences of that number, all of them in the vertices block. These appear to be special vertices that contain texture information. The texture IDs show up as the third coordinate in these vertices, and the final two WORDs may contain the texture coordinates. Now, all we need to find out is how normal vertices select texture coordinate vertices.
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: MW2 textures

Post by Col.Kell »

Changing the file name v1mistwr to v1_vents has no effect, but as Kell reported, changing the number preceeding it does.
I just want to comment, this applies to everything in the PRJ. BWDs, WTBs, XELs, etc.

Only with the exception of the sound files within the SCN1 files, which are somehow able to activate themselves upon their cue in-game. Even without the tags. :?
But say you have an instance of, say... GENE001S, and there is a tag that comes with it, you change the tag and the name. But if you don't want any sound at all, just fill the sound name and it's tag full of FF's.
v1mistwr is displayed as file #714, and the offset to edit in MW2.PRJ is 17508092.
*kell slaps himself on the forehead*
Did my hex editor overlook the hex translation of 714 in the Timber Wolf head???
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: MW2 textures

Post by quota4stupid »

For the record I don't have the Titanium Trilogy or any of the 3D accelerated versions of MW2, and since Mercs is the only one with partially documented development tools, I'm focusing on decoding the files from the original Mercs.

For curiosity sake, I compiled a summary of the IDs and associated comments from DEM1MAP1.WLD (http://users.tpg.com.au/nkjd245/mw2/idlist.txt). Interestingly, the comments in the original file (not included in my summary) also include a number which is always 256 less than the BMID value next to it. Checking this against the WTB files (I used the TimbreWolf too :-)) shows that the first byte in each poly record (+256) matches a BMID value from DEM1MAP1.WLD that is linked to mech camo/insignia textures. For example, many of the mech body polys start with value 0 - add 256 and check DEM1MAP1.WLD and this is described as "light grey metal mech plate" (one of the camo textures). Two other WTB files that define squares (I forget the exact names off the top of my head, but they have "DEC" in the name) have polys starting with 63 - add 256 gives you BMID 319, which in DEM1MAP1.WLD is described as "FedCom" (insignia texture).

As per one of my previous posts re: CAMO & STAR tags, I'm pretty sure these values may then be offset to change camo/insignia (note that the camo/insignia above represent the base for each - ie: if you check the CAMO values in the mission builder FAQ, number 0 is "Plain steel panels" and the first alliance defined in xxxxSCN1.WLD files is always FedCom).

If I get some time after work tonight, I hope to try to knock together a quick Java program to test this theory. I hope :-)
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: MW2 textures

Post by Col.Kell »

Hope it goes well. I can only program BASIC, I couldn't handle Java or C++ if my life depended on it. ;)
MechWarrior 2: 31stCC
Image
User avatar
Skyfaller
Clan 1st MechWarrior
Clan 1st MechWarrior
Posts: 1017
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

Re: MW2 textures

Post by Skyfaller »

Col.Kell wrote:Hope it goes well. I can only program BASIC, I couldn't handle Java or C++ if my life depended on it. ;)
If you can program BASIC, you can learn to program C. It's mostly only a different notation, it's worth learning. It may mean a better life for you and your family someday, at least more freedom in job choice. Don't be afraid, Yes, You Can Learn to Program in C.
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: MW2 textures

Post by quota4stupid »

My current theory/understanding of the vertex & poly records in the WTB files:

[ Vertex ]
0 - 3 : X
4 - 7 : Y
8 - 11 : Z
12 - 13 : TX
14 - 15 : TY

[ Poly ]
0 : Texture ID (see below)
1 : Control value/flags?
2 - 3 : No. of vertex indices that follow.
4 + : Series of indices into the vertex array (0 = 1st vertex in array)

The texture ID + 256 = a BMID value in a previously loaded xxxxMAP1.BWD file. I believe byte 1 of the poly record is some sort of control value/flags although I dunno the exact interpretation yet. I base this on the fact that:
* Most regular mech polys seems to have a value of 0x64 or 0x6C here.
* By contrast, the DUMMY.WTB (which I don't think is meant to be rendered) has a value of 0x10.
* The windshield WTB (ie: TW1WINSH.WTB for TimbreWolf) uses 0x47, which I assume instructs the sim to use flat color instead of texture.
* The decal WTBs (ie: TW1DECLR & TW1DECLL for TimbreWolf) uses 0x7C, which I think tells the sim to make a color in the texture transparent (0xFF I think).
Last edited by quota4stupid on Fri Jan 23, 2009 2:43 am, edited 1 time in total.
User avatar
Skyfaller
Clan 1st MechWarrior
Clan 1st MechWarrior
Posts: 1017
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

Re: MW2 textures

Post by Skyfaller »

I think we're getting close to a solution here. Thanks quota4stupid!
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: MW2 textures

Post by Col.Kell »

Geat job, quota! :)
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: MW2 textures

Post by quota4stupid »

Thankyou :-)

I've tried testing the above theory, but unfortunately while I can successfully load & decode the data from file, my OpenGL skills are pretty poor so I haven't been able to properly render it yet :-P (Side note: for me, this MW2 project is meant to be a combo of reverse engineering something for the first time AND learning to use OpenGL properly... I'm definately doing better with the former than the later ;-)) I think to properly test this theory I might follow Col Kells lead and go to town on the project file with a hex editor when I've got some time :-D

Btw, one thing I did find with my Java-ing was that while the mission builder FAQ describes the MW2_MAP[1-3].BWD files as being "defaults", I'm not sure that's entirely true. Initially I tried loading only them and then loading TIMBRWLF.BWD and got a whole bunch of unresolved texture ID values. After that I tried also loading a random MAP file (BET1MAP1.BWD I think off the top of my head) and it was all good. **shrugs** The quest continues! ;-)
Post Reply