For decompiling FLEXES and getting them into 3DS Max ready format:
- Create a dmx_<CLASSNAME>.lua file with the following:Load("PATH_TO_STEAM/ACCOUNT_NAME/sourcesdk_content/tf/modelsrc/player/CLASS_NAME/decomp/flexes/CLASS_NAME_morphs_high.dmx")
Save("PATH_TO_STEAM/ACCOUNT_NAME/sourcesdk_content/tf/modelsrc/player/CLASS_NAME/decomp/flexes/CLASS_NAME/hwm/.obj")
Load("PATH_TO_STEAM/ACCOUNT_NAME/sourcesdk_content/tf/modelsrc/player/CLASS_NAME/decomp/flexes/CLASS_NAME_morphs_low.dmx")
Save("PATH_TO_STEAM/ACCOUNT_NAME/sourcesdk_content/tf/modelsrc/player/CLASS_NAME/decomp/flexes/CLASS_NAME/.obj")
This assumes your directory structure is set up like so:/decomp/CLASS_NAME/ <-- core directory for your decompiled smd
/decomp/CLASS_NAME/flexes <-- your starting dmx files will go here
/decomp/CLASS_NAME/flexes/CLASS_NAME <-- flexes will go here
/decomp/CLASS_NAME/flexes/CLASS_NAME/hwm <-- SFM high morph flexes will go here - Place this in steam\steamapps\ACCOUNT_NAME\sourcesdk\bin\orangebox\bin
- Make sure the above folder structure exists!
- Make sure the vs.lua file is blank; create a vs.lua file if one does not exist
- Make sure you're using the dmx files (NOT the dmx.smd files) located in \sourcesdk_content f\modelsrc\player\CLASS_NAME\parts\dmx
- SHIFT + RIGHT CLICK on bin\orangebox\bin, choose 'open command window here'
- Type in the following and wait a few moments: dmxedit dmx_<CLASSNAME>.lua
- Flex files should be in their respective folder
- Make sure the files are there. You can safely ignore errors about a library failing to load, but if you see SteamStartup failed, you'll need to restart steam and try again.
- GOTCHAS: If you get the error 'AppFramework : Unable to load module p4lib.dll!' make sure you're using the right dmx files. Alternately, try running dmxedit with -nop4 (tools mode) enabled., or simply click and drag the .lua file onto the dmxedit executable.
- Next, delete all 'mixed' flexes by searching in Explorer for: *+*.*
- Once you have deleted the mixed flexes, you'll need to run the 'Fix Obj Names.exe' file in both folders to correct the name.
- Files are ready to import! Create a layer in 3ds Max called 'morphs_LOW' and use the batchloader_19 importer script to import them.
- Hide all the other layers in Max and select everything in the morphs layer except for the head. Delete.
- From the layers palette, select head_zero and move it to the mesh_CLASSNAME layer.
- Add a SKIN_WRAP modifier to head_zero, using the base character mesh to copy the bone weights. Convert to skin, make sure the head moves correctly, then delete the skin_wrap modifier.
- Add a MORPHER modifier to head_zero, use 'Load Multiple Targets...' and then select your morphs_LOW objects.
- Test a morph to make sure head_zero behaves as expected. Move the MORPHER layer below the SKIN layer.
- Run the TF2 Morph Creator script utility. Under 'Morph Base,' choose head_zero and then click .
- Scrub the animation to make sure the morphs work.
- Rejoice, because you are done!
Extra: Creating Items with Flexes
- The script requires a specific arrangement of modifiers. For the head_zero, it expects from bottom to top - Editable Mesh, Morpher, Skin.
- For the object that NEEDS flexes/morphs, it expects from bottom to top - Editable Mesh, Skin Wrap (Vertex, target being head_zero), Skin.
- First, set up the morph frames. Do this by selecting 'Morph Base' (head_zero) and hitting .
- Second, make sure the object that needs flexes has Skin Wrap targeting the head_zero using vertex (not faces). Scrub the animation and adjust the Skin Wrap parameters until the object deforms as acceptably as it can.
- Create a new layer in Max for the morph targets of your object. Name it appropriately. For example, 'beard_MORPHS' or 'facemask_MORPHS.'
- Select the object needing morphs with the TF2 Morph Utility as 'Base Mesh.' Select head_zero as 'Morph Base.' Click .
- You should have a series of new objects created in the morphs layer, named the same as the morphs on the character.
- Add a Morpher layer to your object and select your newly created morphs as the targets. You can then delete the Skin Wrap modifier.
- Using the TF2 Morph Utility again, select only your newly flexed object as the 'Morph Base,' and click .
- Go through the animation step-by-step and adjust or fix any problems with the morph targets, then reload them. This can be tedious and take awhile, or be very fast and easy, depending on how well the Skin Wrap/script handled the morph creation. Remember that you'll need to make any adjustments to this BY VERTEX - simply moving the prop around will not work.
- Export in FBX format. You do not need to create flexes for LODs other than the highest level.
Source: Video Tutorial by Anatoly Volnov, repeated here so I don't have to watch the video every time I forget I need to make the vs.lua blank.