MW2 level import

MechVM - A MechWarrior 2 remake.

Moderator: Skyfaller

User avatar
Skyfaller
Clan 1st MechWarrior
Clan 1st MechWarrior
Posts: 1017
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

MW2 level import

Post by Skyfaller »

Skyfaller wrote: Developing an AI ... well, first I'd like to get the mechs walking in the original levels. In order to make modding the levels easier, I plan to export level descriptions as XML files that reference geometry in the PRJ (.WTB files). Once the mechs are walking and shooting, network and/or AI will have to be developed. While it seems easy to program a simple AI (come to a certain fighting distance with the opponent, then shoot until the mech runs hot or there is no more ammo), creating an AI that is interesting to fight is much more of a challenge.
Sir MMPD Radick wrote: Your assessment I believe to be correct.
You must get the basic movement code functional before you go any farther.. developing an ai without that is possible, but it would seem to me to be a frustrating way to go about it since you would not be able to see it in action visually.
The XML files for each level make sense as you already are exporting most things in that form anyway. It is better than writing a new scripting language for it that is for certain. Why double the work when you can use something premade and easily parseable?
I'm thinking (quite loudly) about how to describe the MW2 levels in XML files. Here's a list of possible approaches, with pros and cons:

I have tried converting some BWD files to XML, but the results need some brushing-up. ATM, it seems that I think I should pay attention to few tags: INCL, OBJ, REPR, ENDR, NAVP. INC includes other BWD files, OBJ includes geometry from the POLY directory. The REPR/ENDR tags seem relevant, too, because they group object parts into object groups, for example, destructible buildings. Perhaps it will be best to import the levels the same way I do it with the mechs: the objects inside REPR/ENDR tags are exported to XML files describing an object. I will need XML files how objects are exported, and further files that control how the exported objects must be assembled to form levels. Nav points could be imported in the same manner, but AI mech positions, goals and mission objectives should be hand-coded in XML. Minor variations might make the game more interesting.

+ Most flexible approach
+ (Relatively) Easy to produce mods by editing XML files or by editing 3D models exported in OBJ format
- Requires lots of code to export levels and load them later

Alternative: quota4stupid's documentation adds almost all the knowledge needed to load everything from the PRJ as needed. PRJ access would need to be sped up to be fast enough to handle this, or users will be bored to tears. This would lead to 100% conformity with the original game.

+ Less coding overhead
- Difficult to mod: any deviation from the original game requires developing much of the XML toolchain outlined above or altering the PRJ directly
- Requires optimization

I value the ability to mod the game over recreating the original game to the letter. The arguments above lead me to believe the XML toolchain for MW2 level import is the approach to pick here, but I'd welcome any arguments our readers might have. quota4stupid, do you see other tags worth preserving closely?

Texturing:
It might be possible to the x/y coordinates as texture coordinate for mountains as long as they are not too steep. This would allow texturing the MW2 DOS levels. When this does not work, we (I?) will need to edit things in a 3D suite, or we may have to live with the textures offered by the sim and objects in a single color.
User avatar
Sir MMPD Radick
Clan Nova Captain
Clan Nova Captain
Posts: 1625
Joined: Tue Jan 22, 2008 10:07 am

Re: MW2 level import

Post by Sir MMPD Radick »

I do not have much to add to this as it sounds like you have throughly thought this through.
The modding is indeed important, so between the two the answer is obvious.
- Requires lots of code to export levels and load them later
I would bet that this would change over time not to be as much with revisions.
James 3:5-10: My Reminder
And the tongue is a fire, a world of iniquity: so is the tongue among our members, that it defileth the whole body. Out of the same mouth proceedeth blessing and cursing. My brethren, these things ought not so to be.
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 level import

Post by quota4stupid »

Skyfaller wrote: PRJ access would need to be sped up to be fast enough to handle this, or users will be bored to tears. This would lead to 100% conformity with the original game.
Personally I was planning to take the lazy road and just memory-map the whole PRJ file ;-) As far as sim design goes, my intention is to work directly with the original files.
Skyfaller wrote: - Difficult to mod: any deviation from the original game requires developing much of the XML toolchain outlined above or altering the PRJ directly
I would be inclined to just use the existing tools (WASM, TAR, etc) and develop the ones that are missing (you've already got PRJPP for the project file, apart from that I guess the most significant tool missing would be one to import geometry into WTB format, etc). I would then say that if, for example, somebody wanted to go the full hog and develop a whole campaign with extra mechs and all the other trimmings, what you could do is have them bundle that as a separate PRJ. This would then be the primary PRJ for fetching resources, and the sim could fall back to the original PRJ file for any resources not contained in the primary (ie: the original mechs, textures, buildings, etc).
Skyfaller wrote: quota4stupid, do you see other tags worth preserving closely?
I'll get back to you on that one - I'm having a "can't see the forest for the trees" moment with all the different BWD chunks :-P In the next couple of days I'm going to get a nice big piece of paper and try to draw a diagram of how all the chunks relate to each other to give myself a clearer picture. What I will say now is that there's definately a lot of superfluous information in those chunks, definately a lot of stuff you could discard.
User avatar
Skyfaller
Clan 1st MechWarrior
Clan 1st MechWarrior
Posts: 1017
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

Re: MW2 level import

Post by Skyfaller »

Thanks for your opinions. Nice to see so much activity here today.

Processing the entire PRJ in memory is possible today. When I starting coding MechVM on a 512MB machine, less than two years ago, memory still was a bit too tight to use 60MB just for that, and undoubtedly, many people still don't have more memory. In MechVM, the class that handles file caching and the class that handle memory blocks have a similar interface. By creating a single super class for both, I could make it possible to flip between the methods of file caching and memory blocks. But there are easier methods to improve performance for now.

Creating WTB's was discussed here. I was able to produce a .WTB that MechVM displayed, but it was invisible in the MW2 sim after replacing another file with it. It is possible that the header information was incorrect.

For modding, I'd like to use totally new content without going through the pain of feeding it through the PRJ, and MW2's color index mode is very limiting when thinking of 24-bit textures. MechVM is able to load .OBJ files and .BMP textures, any additional information will be reflected in XML files. This also reduces the overhead of porting the MW3 levels to MechVM: the sim only needs to understand .OBJ, .BMP and .XML, once parsing works. Some day, I may add image compression using this library, but it's not important yet.
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 level import

Post by quota4stupid »

Skyfaller wrote: Processing the entire PRJ in memory is possible today. When I starting coding MechVM on a 512MB machine, less than two years ago, memory still was a bit too tight to use 60MB just for that, and undoubtedly, many people still don't have more memory. In MechVM, the class that handles file caching and the class that handle memory blocks have a similar interface. By creating a single super class for both, I could make it possible to flip between the methods of file caching and memory blocks. But there are easier methods to improve performance for now.
At this stage I wont be considering efficient memory consumption to be a priority (and since my PC has 2GB it's likely I wont at all). Having said that, Java being an OOP language and all, there's no real drama for me to initially write up the project access class using memory-mapping and then changing the implementation of that class to use something more memory-friendly later :-)
Skyfaller wrote: Creating WTB's was discussed here. I was able to produce a .WTB that MechVM displayed, but it was invisible in the MW2 sim after replacing another file with it. It is possible that the header information was incorrect.
Yeah, I'm in the same boat with the WTB format - haven't figured out most of the header yet. Might make that my mission for next week :-)
Skyfaller wrote: For modding, I'd like to use totally new content without going through the pain of feeding it through the PRJ, and MW2's color index mode is very limiting when thinking of 24-bit textures. MechVM is able to load .OBJ files and .BMP textures, any additional information will be reflected in XML files. This also reduces the overhead of porting the MW3 levels to MechVM: the sim only needs to understand .OBJ, .BMP and .XML, once parsing works. Some day, I may add image compression using this library, but it's not important yet.
Point taken. Since I'm not ready to start programming yet, I haven't given a lot of stuff like this much consideration yet (although I don't have to worry about also supporting MW3 ;-))
User avatar
Skyfaller
Clan 1st MechWarrior
Clan 1st MechWarrior
Posts: 1017
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

Re: MW2 level import

Post by Skyfaller »

Spent some time optimizing MW2.PRJ access yesterday evening. It took me all night to get MW2 mech importing down from 145s to 100s. Then I found one superfluous command. Eliminating that one cut the time for importing to 26s. An overall performance increase by factor 6 doesn't come along every day :)
User avatar
Sir MMPD Radick
Clan Nova Captain
Clan Nova Captain
Posts: 1625
Joined: Tue Jan 22, 2008 10:07 am

Re: MW2 level import

Post by Sir MMPD Radick »

nice job!
James 3:5-10: My Reminder
And the tongue is a fire, a world of iniquity: so is the tongue among our members, that it defileth the whole body. Out of the same mouth proceedeth blessing and cursing. My brethren, these things ought not so to be.
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 level import

Post by Col.Kell »

nice. :)
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 level import

Post by Skyfaller »

I think that MechVM will calculate lengths in meters internally. For display purposes, do you need to see measurements in miles or another unit?
User avatar
Sir MMPD Radick
Clan Nova Captain
Clan Nova Captain
Posts: 1625
Joined: Tue Jan 22, 2008 10:07 am

Re: MW2 level import

Post by Sir MMPD Radick »

I think meters is fine, mech2 is in meters anyway.
James 3:5-10: My Reminder
And the tongue is a fire, a world of iniquity: so is the tongue among our members, that it defileth the whole body. Out of the same mouth proceedeth blessing and cursing. My brethren, these things ought not so to be.
Post Reply