S&box Wiki

Importing Morphs and Shape Key Animations

Importing Morphs and Shape Key Animations

This page will guide a beginner through the least possible amount of steps required to import new morphs and shape key animations into S&box, as well as have them work and useable in the Animgraph or Face Poser, it assumes you already know how to create shape keys and navigate Blender, it will not show how to create them as that is related to neither ModelDoc nor S&box, and guides for it already exist online.

Exporting the mesh with Shape Keys

We will be using "Blender" as it is the most widely used free modelling program, and the plug-in "Source Export Tools".

  1. Create the shape keys
1.jpg
Avoid using underscores _ in Shape key names, as they're used for Corrective Shape Keys.
  1. Go to "Scene Properties" and then "Source Engine Export", change "Export Format" to "DMX"
  2. Use the latest DMX version, as of writing this it's "Binary 9" and "Model 22"
  3. Select the checked "MeshName.dmx" under "Source Engine Exportables" (in my case "citizen.dmx", check if unchecked)
  4. Go to "Flex Properties" and press Generate Controllers
  5. Press Export to export the model.
2.jpg
The model will need at least one bone, even if it's a static prop, this is because Morphs are animation driven and Animations need bones.
Make sure to reset all Shape Keys to 0 before export, as they will be applied, and change the default mesh if you do, this, however, can be used if you only need the mesh with a certain Shape Key configuration, as you can then reimport the mesh in Blender and delete all shape keys.
If you're using Corrective Shape Keys (Shape Keys with underscores _ in their names) you'll also need to Generate Corrective Shape Key Drivers before export; If they're separate in left and right then you'll need to set the "Stereo Flex Balance" to "Y", as X is the forward axis in Source 2, this will generate a vertex group to differentiate left morphs to right morphs along the Y-axis.

Adding the morphs in ModelDoc

As mentioned before, morphs are animation-driven, this means that even if morphs will appear when importing the model, you won't be able to use them until there's at least 1 animation. If you planned for this model to be static and/or have no animations, you can simply reuse the model itself as a "Simple Animation".

  1. Import the Mesh in ModelDoc
  2. Add any animation, use the model itself if you don't plan on having animations.
  3. Add a material that supports morphs (in "Material Editor" check the Morph Supported box under "Animation").

If you go to "Morph Explorer" and press Enable Manual Slider Control you will be able to manually drive the sliders, this is only a debugging tool, if you want to then see the animations drive the sliders, press Allow animation to drive sliders.

3.jpg

Exporting Shape Key Animations in Blender

Please, if someone knows a way to export shape key animations in the DMX format, feel free to edit this part or tell me on Discord so I can try it out and change the guide, Grodbert#3873.

  1. Create your shape key animation

There needs to be at least one animation as the target for the export, this can be either an Armature or Mesh animation, in this case, we'll do a simple Armature animation that does nothing.

  1. Create an animation that lasts the same as your Shape Key Animation, even if it's just keyframing the location of a random bone in the first and last frame.
5.jpg

The image above shows 2 animations in the NonLinear Animation Editor, you don't actually have to push down any animation, it is just to show that there is an animation for Armature, one for Shape Keys, and that they last the same.

  1. Export in FBX format, the object types will only need to be "Armature" and "Mesh", "Apply Scalings" set to FBX All
image.png
The rotation of the animation may be different in ModelDoc, as FBX exports using Blender's forward axis, which is "Y+", you'll have to rotate the model/armature and "Apply Rotation" as so it faces the Y+ axis.
  1. Import the animation in Modeldoc as a "Simple Animation".

This will be the final result:

Note the morph sliders moving because of the animation, they are not limited by 0 and 1.

Special Pages


Wikis

?

Render Time: 36ms

DB GetPage 28
Generate Html 0
SaveChanges (1) 5
Render Body 0
Render Sidebar 0