S&box Wiki

Revision Difference

Importing_Morphs_and_Shape_Key_Animations#544222

<cat>Dev.Model</cat> <title>Importing Morphs and Shape Key Animations</title> 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 <upload src="a4aaf/8d93962437800af.jpg" size="41445" name="1.jpg" /> <note>Avoid using underscores <key>_</key> in Shape key names, as they're used for Corrective Shape Keys.</note> 2. Go to **"Scene Properties"** and then *"Source Engine Export"*, change *"Export Format"* to **"DMX"** 3. Use the latest *DMX version*, as of writing this it's *"Binary 9"* and *"Model 22"* 4. Go to *"Flex Properties"* and press `Generate Controllers`⤶ 5. Press `Export` to export the model.⤶ 4. Select the checked *"MeshName.dmx"* under *"Source Engine Exportables"* (in my case "citizen.dmx", check if unchecked)⤶ 5. Go to *"Flex Properties"* and press `Generate Controllers`⤶ 6. Press `Export` to export the model.⤶ <upload src="a4aaf/8d939634d8baf38.jpg" size="119599" name="2.jpg" /> <warning>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.</warning> <warning>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.</warning> <note>If you're using Corrective Shape Keys *(Shape Keys with underscores <key>_</key> 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.</note> # 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. 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`. <upload src="a4aaf/8d93965a322ce25.jpg" size="228630" name="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. 2. 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. <upload src="a4aaf/8d9396b8714f874.jpg" size="48241" name="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.`* 3. Export in FBX format, the object types will only need to be **"Armature"** and **"Mesh"** <upload src="a4aaf/8d9396c17c4fe56.jpg" size="12401" name="8.jpg" /> <warning>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.</warning> 4. Import the animation in Modeldoc as a **"Simple Animation"** This will be the final result: <upload src="a4aaf/8d9396ca05584ce.mp4" size="230449" name="9.mp4" /> *`Note the morph sliders moving because of the animation, they are not limited by 0 and 1.`*