Source 2 Animation System VScript API/CModelVScriptCompile.CreateIKChain: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page with "== Function Description == ''' int CModelVScriptCompile::CreateSequence(string ''chainName'', string ''end_bone'', table ''parameters'') ''' Creates an Inverse Kinematics c...")
 
(Added parameters from the updated version)
 
Line 4: Line 4:
''' int CModelVScriptCompile::CreateSequence(string ''chainName'', string ''end_bone'', table ''parameters'') '''
''' int CModelVScriptCompile::CreateSequence(string ''chainName'', string ''end_bone'', table ''parameters'') '''


Creates an Inverse Kinematics chain, similar to the [[$ikchain]] QC command. The function only seems be available in run-time animation vscripts.
Creates an Inverse Kinematics chain, similar to the [[$ikchain]] QC command. The function only seems be available in run-time animation VScripts. Several IK solvers seem to be available, including [http://mrl.nyu.edu/~perlin/gdc/ik/ Ken Perlin's two bone solver] and the [http://www.andreasaristidou.com/FABRIK.html FABRIK solver].


{{todo|Unknown how much of this works.}}
{{todo|Unknown how much of this works.}}
Line 17: Line 17:
| chainName
| chainName
| Name to refer to the chain by.
| Name to refer to the chain by.
|-
| string
| end_bone
| The ''foot'' in the chain. Needs to have at least two bones higher in the hierarchy.
|-
|-
| table
| table
Line 40: Line 36:
! Type
! Type
! Description
! Description
 
|-
| bones_point_along_positive_x
| boolean
| {{todo}}
|-
| constraints
| array
| List of IK constraints. Syntax: { { < type = "$" >, ... }, ... }
|-
| ik_root_bone
| string
| Name of the first bone in the IK chain. Required.
|-
| ik_end_effector_bone
| string
| The end bone in the IK chain. Required.
|-
| ik_end_effector_target_bone
| string
| {{todo|Maybe something related to procedural targets.}}
|-
|-
| rules
| rules
Line 48: Line 63:
| solverInfo
| solverInfo
| array
| array
| {{todo}} Possible syntax: { < type = ["perlin"|"maya_two_bone"] >, ... }
| Solver configuration. Possible syntax: { < type = [ "perlin" / "fabrik" / "maya_two_bone" ] > }
|-
|-
| lockInfo
| lockInfo
| array
| array
| {{todo}} Possible Syntax: { boneInfluenceDriver = "$", reverseFootLockBone = "$"}
| {{todo}} Possible Syntax: { boneInfluenceDriver = "$", reverseFootLockBone = "$", lockBoneInfluenceDriver = "$", maxLockDistanceToTarget = #, hyperExtensionReleaseThreshold = #}
|-
 
| bones_point_along_positive_x
| unknown
| {{todo}}
|}
|}


Line 70: Line 82:
|-
|-
| ground
| ground
| { rule = "ground", name = "$", trace_diameter = #, height = # }
| { rule = "ground", trace_diameter = #, height = # }
|  
| Attempts to place the end bone on the ground.
|-
|-
| touch
| touch
| { rule = "touch", name = "$"}
| { rule = "touch"}
|  
| {{todo|Possibly unsupported currently}}
|-
|-
| procedural_target
| procedural_target
| { rule = "procedural_target", name = "$", bone= "$"}
| { rule = "procedural_target", name = "$", bone= "$" }
|  
| Attempts to set the end bones position and orientation to values supplied by code. A VScript method for the CBaseAnimating class exists to control this.
|}
 
=== IK Constraints ===
IK constraints in the ''constraints'' array.
 
{{todo|This list is likely incomplete.}}
 
{| class="standard-table" style="width: 100%;"
! Name
! Syntax
! Description
|-
| hinge
| { type = "hinge", joint="$", min_angle = #, max_angle = # }
| {{todo|Adds a hinge of some kind with angle limits to the specified bone}}
|}
|}
[[Category:Scripting]]
[[Category:Scripting]]

Latest revision as of 06:07, 2 October 2017

Function Description

int CModelVScriptCompile::CreateSequence(string chainName, string end_bone, table parameters)

Creates an Inverse Kinematics chain, similar to the $ikchain QC command. The function only seems be available in run-time animation VScripts. Several IK solvers seem to be available, including Ken Perlin's two bone solver and the FABRIK solver.

Todo: Unknown how much of this works.

Parameters

Type Name Description
string chainName Name to refer to the chain by.
table parameters IK chain parameters (see below).

Returns

int - Index of the IK chain.

Sequence Parameters

The parameters are added as keys in the parameters table.

Todo: This list is likely wrong and incomplete.
Name Type Description
bones_point_along_positive_x boolean [Todo]
constraints array List of IK constraints. Syntax: { { < type = "$" >, ... }, ... }
ik_root_bone string Name of the first bone in the IK chain. Required.
ik_end_effector_bone string The end bone in the IK chain. Required.
ik_end_effector_target_bone string
Todo: Maybe something related to procedural targets.
rules array List of IK rules. Syntax: { { < type = "$" >, ... }, ... }
solverInfo array Solver configuration. Possible syntax: { < type = [ "perlin" / "fabrik" / "maya_two_bone" ] > }
lockInfo array [Todo] Possible Syntax: { boneInfluenceDriver = "$", reverseFootLockBone = "$", lockBoneInfluenceDriver = "$", maxLockDistanceToTarget = #, hyperExtensionReleaseThreshold = #}

IK Rules

IK rules in the rules array.

Todo: This list is likely incomplete.
Name Syntax Description
ground { rule = "ground", trace_diameter = #, height = # } Attempts to place the end bone on the ground.
touch { rule = "touch"}
Todo: Possibly unsupported currently
procedural_target { rule = "procedural_target", name = "$", bone= "$" } Attempts to set the end bones position and orientation to values supplied by code. A VScript method for the CBaseAnimating class exists to control this.

IK Constraints

IK constraints in the constraints array.

Todo: This list is likely incomplete.
Name Syntax Description
hinge { type = "hinge", joint="$", min_angle = #, max_angle = # }
Todo: Adds a hinge of some kind with angle limits to the specified bone