top of page
Writer's pictureRiptcage

Q2WF Model Extraction for a Modern Game Environment

The MD2 File Format

The MD2 file format is the second model format in the Quake series. Quake 1's model format was the MDL acronym. Why didn't they name it MDL2? Because a 3 letter max file extension was the established standard back before windows 95 due to limitations. Ha!


Important knowledge about the MD2 when extracting data

  • MD2 files are stored in PAK files, which is an archive of files with preserved file paths

  • The texture paths are referenced in the MD2, because textures are separate .PCX formatted files.

  • While the texture path is referenced, the MD2 stores the textures width/height so we can determine proper UV scale.

  • Each model is mostly in their own folder, with an associated skin.pcx and a tris.md2 file

  • Each vert stores a light normal index that maps to a hard coded normal value in the C code.

  • The MD2 stores animation frames where each frame contains a separate mesh, with verts in different positions.

  • There is a translation and scale value per frame, which must be applied to all vertices on that frames mesh.


Developing a Q2.Model.Export Workflow


This python command line interface will;

  • Recursively find all PAK files within -q2_dir. Includes models and textures in "<q2_dir >/wf/models" as well.

  • Uses a heavily modified version of VGIO to read MD2 and associated PCX files from PAK files

  • Converts MD2 to FBX with each frame by frame vertex animated mesh named according to it's "animation track"

  • Converts PCX to PNG with the embedded palette, using the Python Imaging Library

  • Saves them in the output path within their respective model paths from the PAK file


A mesh for every animated frame

MD2 models contain a list of frames, where each frame represents a snapshot of animation for the set of verts that make up the model. See example with a version of the Q2WF Sniper Rifle


The quake 2 engine takes each meshes verts per frame and does a linear interpolation of 2 to 3 frames to create a smooth animation between each. This is essentially a built in morph target or blend shape system for all assets within the quake 2 engine. See video below that demonstrates automating each mesh frame into a 3 frame interpolated blend shape animation.



The vert count per mesh is the same per frame and that's what allows the interpolated verts to work. The downside of this technique in Quake 2's case is that each vert positioning is never truly consistent and much more so then Quake 1 due to the MD2 feature of a separate scale and translation difference per frame. This means we get noticeable wobbly vert animation or more commonly known as vert swimming.


Quake 2 gets away with this somewhat on weapons by pausing the animations over a series of frames for each type of weapon used for the idle animation, but take a look at the machine gun weapon model and it's idle animation. Slowed down to 15FPS, the vert swimming becomes much more obvious.



At 30FPS, it's still noticeable.. but not as much. Playing 20+ years ago, I rarely even noticed this fundamental yet interesting flaw.


Vertex Animation to Skeletal Animation

Modern game engines like Unity and Unreal support morph targets(Roblox does not), but for the more common use case of weapon animation in a modern FPS, animation is typically driven by skeletal bones where the mesh is skinned to these bones. How can we approach automating animated mesh sequences to a skinned model with skeletal bone transformations? Two words, Skinning Decomposition. Thanks to EA and the open source development of Dem Bones, we can do just that.


There are two approaches to using Dem Bones from Maya.

  1. Use the dembones command line interface and provide a cached alembic file and an fbx of the mesh at rest pose.

  2. Compile maya-dem-bones for your version of Maya and use the exposed python binding that has access to the skinning decomposition libraries and convert it directly in Maya. It's pretty simple to compile, assuming you have visual studio community edition with cmake. If anyone is interested in a walk through, jus ask! It takes minutes.

In the end, you can choose number of bones to use where it will attempt to auto skin on those bones. From my experience, if you were to be converting a cloth animated mesh sequence to a skinned animated bone transformation, choosing number of bones and trial & error until you get a good result is the path forward.

However, for something like hand movement, maneuvering multiple objects, my recommendation is to evaluate the animated mesh and determine where the bones should be placed for the best mesh deformation. Think about what is moving and how it should move when the bone rotates and position the bone with the X axis going down the invisible chain. In this case, there is no bone chain and that's because with the use of dem bones, it is best not to use bone chains.


Important to note

While the breakdown above highlights high level steps, there are many in between modifications required to ensure the mesh is merged by UV shell and cleaned up. Which often times resulted in remodeling portions of the frame by frame mesh due to collapsed faces with zero area, in which tools have been written to support these tedious workflows so that they look and work authentic to quake 2 weapons factory.


What's Next in Quake 2 Weapons Factory Roblox?

The past month, a lot of work was done solidifying many of the tools and processes shown above with detailed documentation, so that anyone could run through the process for the rest of the weapons much quicker then the marine weapons. The issue was that they were previously just undocumented processes with python scripts that I essentially hadn't touched in months and forgot what to do. So i had to reverse engineer what each approach was, and ensure I documented it for the future of WFR. Other then that, December was filled with long work days(not WFR), personal vacations and family visits. All of which included a much needed break and celebration from all the work that's been done so far this year.

As we close through the Holiday, I've been working through the roadmap and determined what it looks like to release WFR by the end of the year. In short, I've decided to officially state the first release to be on March 5th, and there is still a lot of tasks to take care of even after I get all the weapons working for the first 3 classes.


Here's what that looks like:

  • Sniper Weapons and Special - December

  • Gunner Weapons and Special - December

  • Player Movement and Details Polish - January

  • Roblox Lobby Experience - 1st half February

  • First User Experience -  2nd half February

  • WFR First Release - March 5th


With that said, I am also rolling with the decision for users to play WFR as their Roblox Avatars where they become each class and where the outfit, which will support the R15 rig on 3 mesh options.

  • Roblox Blocky

  • 2012 Roblox Style

  • 2016 Roblox Boy

This brings a Roblox avatar twist to Weapons Factory, that I think Roblox Players will enjoy more then playing a random hero character they don't care about. What's better then to become the class!

I've always said EOY 2023 in hopes to hit that goal, but I'd prefer to release a more polished game end of Q1 2024.

See you in the new year!

For those interested, these references really help to understand the Md2 format





Recent Posts

See All

Comments


bottom of page