This article's documentation is for anything that uses the Source engine. Click here for more information.

$definebone: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Bone orders)
No edit summary
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Defines a bone outside of any .smd source. This is useful when building animation only mdl's that would otherwise optimize out all the bones since none of them are connected to any geometry or attachment points. You can get [[studiomdl]] to dump this out using the <code>"-definebones"</code> command line option.
{{this is a|QC command|name=$definebone}} It defines a bone outside of any .smd source. This is useful when building animation only mdl's that would otherwise optimize out all the bones since none of them are connected to any geometry or attachment points. You can get [[studiomdl]] to dump this out using the <code>"-definebones"</code> command line option.


The (fixup) fields specify how the IK solver has rotated any of the bones to match the ''single X axis as the long axis'' requirement for all bones in an IK chain.  All the source animations are resolved to match this new orientation.
The (fixup) fields specify how the IK solver has rotated any of the bones to match the ''single X axis as the long axis'' requirement for all bones in an IK chain.  All the source animations are resolved to match this new orientation.
Line 6: Line 6:


This command is run before any [[$hierarchy]] commands.
This command is run before any [[$hierarchy]] commands.
{{note|If the same bone is defined multiple times with this command, only the first definition is used.}}


== Syntax ==
== Syntax ==


  $definebone (name) (parent) (X) (Y) (Z) (xr) (yr) (zr) (fixup XR) (fixup YR) (fixup ZR)
  $definebone (name) (parent) (X) (Y) (Z) (xr) (yr) (zr) (fixup X) (fixup Y) (fixup Z) (fixup X Rotation) (fixup Y Rotation) (fixup Z Rotation)
 
== How To ==
How to generate $definebone data from an existing model:
 
{{note|Before you start, '''do not''' separate out the shared animations. You need to leave them all in the same .QC file before you start since studiomdl will optimize out all the bones that it doesn't think are animating.}}


# Decompile the mdl file containing bone data (not the animation mdl)
== Generating definebone lines using [[Crowbar]]==
# Place the resultant qc file in ''...\USERNAME\sourcesdk\bin\orangebox\bin\''
[[File:Crowbar-Definebones.png|thumb|The $define bone process of crowbar. highlighted are: The definebone checkboxes in blue, The bone collapsing messages in red, and the generated definebone lines in green. (Click to enlarge)]]
# Using which ever method you prefer, run studiomdl with the following parameters ''-definebones mdldecompile.qc > sharedbones.qci''. ''sharedbones.qci'' will be created in the same folder as ''studiomdl''
The [[Crowbar]] Decompiling tool has a user interface for [[studiomdl]], which also contains an automated process for writing $definebone lines.
# Open ''sharedbones.qci'' and remove all lines that do not begin with ''$definebone''


GUIStudioMDL can also be used to generate the $definebone data, but placing the data into the file has to be done manually. To do this simply load the qc file and tick the "Define Bones" check box at the bottom.
#Remove all existing $definebone lines. Alternatively; comment out all definebone lines by adding a /* before the first definebone line and a */ after the last, to comment out multiple lines.
{{warning|Errors can occur in the resulting text, but they are easily noticeable and fixed.}}
#In the "Compile" tab of Crowbar, select the "definebones" checkbox. You can decide to write everything into a qci file by checking the "Create qci file" checkbox underneath
#Click "Compile". This will not compile the model itself, it will only generate definebone lines. If you did not decide to write a qci file, you must copy the lines from crowbars compile-log text box and paste it into your qc file.


[[Category:QC Commands|definebone]]__NOTOC__
{{note|Attempting to generate definebone lines, while already having definebone lines present will cause studiomdl to print the existing definebone lines again and collapse all bones that do not have definebone lines.<br> If you want to add definebone lines to your existing set of definebones you must first comment out all existing definebone lines from your QC file, compile the definebone list with crowbar and then copy just the new definebone lines into your qc file.}}
{{note|If some bones collapse ''even after using the above stated workaround'' add [[$bonemerge]] lines for each collapsed bone to your qc file.}}
__NOTOC__

Latest revision as of 21:32, 16 July 2025

$definebone is a QC command available in all Source Source games. It defines a bone outside of any .smd source. This is useful when building animation only mdl's that would otherwise optimize out all the bones since none of them are connected to any geometry or attachment points. You can get studiomdl to dump this out using the "-definebones" command line option.

The (fixup) fields specify how the IK solver has rotated any of the bones to match the single X axis as the long axis requirement for all bones in an IK chain. All the source animations are resolved to match this new orientation.

$definebone can also be used to change the bone order of a model (for example, bone merging purposes), by specifying it before any model references and changing around the $definebone list order.

This command is run before any $hierarchy commands.

Note.pngNote:If the same bone is defined multiple times with this command, only the first definition is used.

Syntax

$definebone (name) (parent) (X) (Y) (Z) (xr) (yr) (zr) (fixup X) (fixup Y) (fixup Z) (fixup X Rotation) (fixup Y Rotation) (fixup Z Rotation)

Generating definebone lines using Crowbar

The $define bone process of crowbar. highlighted are: The definebone checkboxes in blue, The bone collapsing messages in red, and the generated definebone lines in green. (Click to enlarge)

The Crowbar Decompiling tool has a user interface for studiomdl, which also contains an automated process for writing $definebone lines.

  1. Remove all existing $definebone lines. Alternatively; comment out all definebone lines by adding a /* before the first definebone line and a */ after the last, to comment out multiple lines.
  2. In the "Compile" tab of Crowbar, select the "definebones" checkbox. You can decide to write everything into a qci file by checking the "Create qci file" checkbox underneath
  3. Click "Compile". This will not compile the model itself, it will only generate definebone lines. If you did not decide to write a qci file, you must copy the lines from crowbars compile-log text box and paste it into your qc file.
Note.pngNote:Attempting to generate definebone lines, while already having definebone lines present will cause studiomdl to print the existing definebone lines again and collapse all bones that do not have definebone lines.
If you want to add definebone lines to your existing set of definebones you must first comment out all existing definebone lines from your QC file, compile the definebone list with crowbar and then copy just the new definebone lines into your qc file.
Note.pngNote:If some bones collapse even after using the above stated workaround add $bonemerge lines for each collapsed bone to your qc file.