Skip to content
TiberiumFusion edited this page Jan 3, 2021 · 22 revisions

Basics

Converting SMD files

Find an SMD file, feed it to Smd2Pac. You can simply drop and drop it onto the Smd2Pac executable. From the command line, it can be either the very first or very last parameter. Or, you can use the --smd argument to put it anywhere in your argument list. Get used to using the command line, though, because you'll need it for...

Animation subtraction

Virtually every animation you convert will need to be subtracted!

SMD animations are a kind of "baked" animation. They include a composition of the model's bind pose + the distinct animation itself. This is normally fine, since the Source engine transforms all bones relative to 0,0,0. In PAC3, however, all animations are relative to the current, realtime pose of your model. If you load up an SMD animation into pac without first subtracting it, your model is going to distort horribly, since the resulting animation has effectively been doubled.

The solution is to "subtract" the model's bind pose from your SMD animation, thus turning it into an "additive" animation that PAC3 will combine with the innate engine pose to produce the full pose. Smd2Pac will do the subtraction and all of the complex math for you with via a single argument. You could use studiomdl and Crowbar instead, but Smd2Pac usually does a better job of avoiding singularities and precision loss that would otherwise require you to manually create some fixup rotations.

Animation subtraction requires two SMD files. The destination SMD contains the animation you want to see with pac in gmod. The source SMD contains the base pose for your model (ideally, the bind pose that was used in the destination SMD). If your model doesn't have an SMD animation that contains its bind pose, you should pick an SMD that contains the most neutral pose available, such as the idle standing animation.

Only one frame from the source SMD will be used for subtraction on all frames of your destination SMD, so choose wisely. The very first frame (time 0) will suffice for most situations.

When you have chosen the best source SMD and frame to subtract from your destination SMD, use the arguments --make-additive-from and --additive-base-frame to feed them to Smd2Pac. See the arguments table and examples section for more info.

You can also use Smd2Pac strictly as an animation subtractor. Add the argument --dump-additive-smd and Smd2Pac will write the subtracted (and thus now additive) destination SMD to a file, which you can then import into 3D software, compile into an MDL with studiomdl, etc.

How to get the output animation data into your PAC3 outfit

The custom animation part in PAC3 creates and accepts animation data in a json format. Smd2Pac outputs an escaped json string that contains your animation. In the PAC3 editor, you can copy and paste it directly into the data property of the custom animation part, but pac may choke on it and throw it out for no good reason. To work around this, open up your pac outfit's file (in garrysmod/data/pac3), look for the custom animation element, and paste the json animation data into its data property.

Where to paste img

Save the outfit file, then re-load your pac from that file. If pac still ignores it, you probably didn't paste it into the file correctly.

Alternatively, you can upload your animation data to a direct web link, like a pastebin paste, and set the url property to the URL of the paste.

Once you have the animation data loaded up in pac, the last thing you need to do is set the custom animation part's rate property to the framerate of your SMD animation. For example, if you set rate to 30, your animation will play back at 30 frames per second. If you got your SMD file from an MDL, then the frame rate will be specified by the fps param somewhere in the SMD's $sequence block in the QC file.


Arguments

The only required argument is the path to your SMD file.

All named arguments are optional, unless --ignore-bones is present, in which case --smd must be used.

Argument Description Example
‑‑smd Path to the SMD file you want to convert. Can also be a folder for batch conversions. If the first or last argument is your SMD file, you don't have to use ‑‑smd. ‑‑smd "path\to\my cool anim.smd"
‑‑deep If ‑‑smd is a folder, ‑‑deep will also search subfolders for SMD files to convert. --deep
‑‑output Output filename for the PAC3 animation data. ‑‑output "path\to\my pac3 anim data.txt"
‑‑make‑additive‑from Path to an SMD file to use as the source SMD for animation subtraction. Enables animation subtraction. ‑‑make‑additive‑from "path\to\bind pose.smd"
‑‑additive‑base‑frame Frame from the source SMD to use for animation subtraction. Must correspond to a valid time block in the SMD. Default is 0. ‑‑additive‑base‑frame 0
‑‑dump‑additive‑smd Writes the subtracted destination SMD to a new SMD file in a subfolder. ‑‑dump‑additive‑smd
‑‑optimize Specify an optimization level. The default is 1. ‑‑optimize 0
‑‑ignore‑bones A list of bones to ignore, separated by spaces. These bones won't be included in the output PAC3 animation data. If you use ‑‑ignore‑bones, you must also use ‑‑smd. ‑‑ignore‑bones ValveBiped.Bip01_L_Thigh ValveBiped.Bip01_L_Calf
‑‑bone‑fixup Can be used multiple times. Specifies a fixup translation + rotation for a specific bone. Syntax: bone name TX TY TZ RX RY RZ ‑‑bone‑fixup ValveBiped.Bip01_Pelvis 0 0 0 0 0 90
‑‑dont‑escape‑output By default, Smd2Pac escapes the output json text, which is necessary for importing into PAC3. This argument disables that. ‑‑dont‑escape‑output

Advanced options

Bone fixups

You can specify a constant translation + rotation that will be applied to a chosen bone for the entire animation. This is useful for undoing errors in additive SMD files that were subtracted by studiomdl and decompiled with Crowbar. For example, if your subtracted SMD animation has an erroneous -90 Z rotation on the root bone, you can tell Smd2Pac to apply a +90 Z rotation fixup to cancel out the error. If your model is a valve biped, that might look like this: --bone-fixup ValveBiped.Bip01_Pelvis 0 0 0 0 0 90. The --bone-fixup argument can be used multiple times.

Optimization

Smd2Pac can optimize the output PAC3 animation data to some extent. Use the --optimize argument to set the optimization level.

  • --optimize 0 No optimization.
  • --optimize 1 Bones that don't move for the entire animation are skipped for frames after the initial frame. (Default)

Dumping subtracted SMDs

With the --dump-additive-smd argument, Smd2Pac will write the subtracted SMD animations it calculated to a subfolder. You can import these SMDs into other software, compile them into MDLs, compare them with studiomdl/Crowbar's calculations, etc.


Examples

Smd2Pac.exe taunt_muscle.smd
Converts taunt_muscle.smd into PAC3 animation data and writes it to output\taunt_muscle_pac3animdata.txt. In this case, taunt_muscle.smd is already an additive animation and does not need to be subtracted.
Smd2Pac.exe taunt_muscle_base.smd --make-additive-from idle_all_01.smd
Converts taunt_muscle_base.smd into PAC3 animation data and writes it to output\taunt_muscle_base_pac3animdata.txt. Before the conversion, taunt_muscle_base.smd is subtracted from frame 0 of idle_all_01.smd in order to turn it into an additive animation.
Smd2Pac.exe taunt_muscle_base.smd --make-additive-from idle_all_01.smd --output "pac3 data.txt"
Converts taunt_muscle_base.smd into PAC3 animation data and writes it to pac3 data.txt. Before the conversion, taunt_muscle_base.smd is subtracted from frame 0 of idle_all_01.smd in order to turn it into an additive animation.
Smd2Pac.exe --smd taunt_muscle_base.smd --make-additive-from idle_all_01.smd --ignore-bones ValveBiped.Bip01_L_Hand ValveBiped.Bip01_T_Hand
Converts taunt_muscle_base.smd into PAC3 animation data and writes it to output\taunt_muscle_base_pac3animdata.txt. Before the conversion, taunt_muscle_base.smd is subtracted from frame 0 of idle_all_01.smd in order to turn it into an additive animation. Additionally, the left and right hand bones are omitted from the output animation.
Smd2Pac.exe "bad animation.smd" --make-additive-from "bad bind pose.smd" --additive-base-frame 3 --bone-fixup BadRig_Pelvis 0 0 0 90 0 0
Converts bad animation.smd into PAC3 animation data and writes it to output\bad animation_pac3animdata.txt. Before the conversion, bad animation.smd is subtracted from frame 3 of bad bind pose.smd in order to turn it into an additive animation. Additionally, a 90,0,0 fixup rotation is applied to the BadRig_Pelvis bone.
Smd2Pac.exe "path\to\some smds" --make-additive-from idle_all_01.smd
Converts all *.smd files in the folder path\to\some smds into PAC3 animation data and writes them to path\to\some smds\output\*_pac3animdata.txt. Before the conversion, each SMD is subtracted from frame 0 of idle_all_01.smd in order to turn them into additive animations.
Smd2Pac.exe . --deep --make-additive-from idle_all_01.smd --dump-additive-smd
Converts all *.smd files in the working directory and all subfolders into PAC3 animation data and writes them to *\*\...\*_pac3animdata.txt. Before the conversion, each SMD is subtracted from frame 0 of idle_all_01.smd in order to turn them into additive animations. Additionally, the subtracted SMD animations will be written to *\*\...\*_subtracted.smd.
Clone this wiki locally