See Crowd Agents for more information.
Methods ¶
__init__(filename, keep_external_ref = True)
Creates a new agent rig by loading it from the specified JSON file.
Raises hou.OperationFailed if the file does not exist or otherwise cannot be loaded.
filename
A path to a JSON file.
keep_external_ref
A bool
indicating whether the external reference should be maintained when the agent is saved to a geometry file.
If the reference is maintained, then the rig file needs to be available when the saved geometry is used (only the path to the rig file is saved in the geometry file).
Otherwise, a copy of the rig will be inlined when saving out the geometry so that the original rig file is no longer needed.
__init__(name, transform_names, hierarchy)
Creates a new agent rig from the given transform hierarchy.
name
The name of the new rig.
transform_names
A sequence of transform names.
hierarchy
A sequence of int
sequences that specifies, for each transform in transform_names
, the indices of its children in transform_names
.
See hou.AgentRig.transformHierarchy.
The following example shows how to create a simple rig where transforms “b” and “c” are children of transform “a”.
transforms = ["a", "b", "c"] hierarchy = [ [1, 2], [], [] ] rig = hou.AgentRig("my_rig", transforms, hierarchy)
addChannel(name, default_value=0.0, transform=-1)
Adds a new channel to the rig. If a channel already exists with the same name, properties such as the default value will be overwritten.
Raises hou.GeometryPermissionError if the rig is not modifiable.
name
The name of the channel.
`default_value
A float
containing the channel’s default value.
`transform
Optional index of a transform that the channel is associated with.
asJSON()
→ str
Returns a string containing the JSON that represents the rig.
channelCount()
→ int
Returns the number of channels in the rig.
channelDefaultValue(channel_index)
→ float
Returns the default value of the specified channel.
channel_index
Index of a channel in the rig.
channelTransform(channel_index)
→ int
Returns the transform index that the specified channel is associated with, or -1.
channel_index
Index of a channel in the rig.
channelName(channel_index)
→ str
Returns the name of the specified channel.
channel_index
Index of a channel in the rig.
childIndices(transform)
→ tuple
of int
Returns the children of the specified transform.
transform
Index of a transform in the rig.
fileName(expanded = False)
→ str
If the rig is an external reference, returns the path to the file on disk.
expanded
Specifies whether to expand any variables in the path, such as $HIP
.
findChannel(channel_name)
→ int
Returns the index of the channel with the given name, or -1 if the channel name is invalid.
channel_name
Name of a channel in the rig.
findTransform(transform_name)
→ int
Returns the index of the transform with the given name, or -1 if the transform name is invalid.
transform_name
Name of a transform in the rig.
freeze()
→ hou.AgentRig
Creates a modifiable copy of the rig. The copy will not be marked as an external reference.
isExternalReference()
→ bool
Returns a bool
indicating whether the rig references a file on disk.
name()
→ str
Returns the name or filename of the rig.
parentIndex(transform)
→ int
Returns the parent of the specified transform, or -1 if the transform is a root of the transform hierarchy.
transform
Index of a transform in the rig.
restLocalTransform(transform)
→ hou.Matrix4
Returns the local space rest transform for the specified index in the hierarchy.
transform
Index of a transform in the rig.
restWorldTransform(transform)
→ hou.Matrix4
Returns the world space rest transform for the specified index in the hierarchy.
transform
Index of a transform in the rig.
setRestLocalTransforms(xforms)
Sets the local space rest transforms for the rig.
Raises hou.GeometryPermissionError if the rig is not modifiable.
xforms
A sequence of hou.Matrix4, with a local space transform for each joint in the rig. Raises hou.InvalidSize if the length does not match hou.AgentRig.transformCount.
transformCount()
→ int
Returns the number of transforms in the rig.
transformName(transform)
→ str
Returns the name of the specified transform.
transform
Index of a transform in the rig.
transformNames()
→ tuple
of str
Returns a list of the transform names in the rig.
transformHierarchy()
→ tuple
of tuple
of int
Returns a list of the child indices for each transform in the rig.