This is the root of a MovingPart hierarchy. It defines the hierarchy of moving parts that make up an animatable object.
This is the parameter to
set_blend_type()and specifies the kind of blending operation to be performed when multiple controls are in effect simultaneously (see
set_control_effect()) or between sequential frames of the animation.
BT_linear does a componentwise average of all blended matrices, which is a linear blend. The result of this is that if a particular vertex would have been at point P in one animation and point Q in another one, it will end up on the line in between them in the resulting blend animation. However, this tends to stretch and squash limbs in strange and disturbing ways.
BT_normalized_linear is a compromise on BT_linear. The matrix is blended linearly without the scale and shear components, and the blended scale and shear components are applied separately. This keeps all of the character’s body parts in the correct size and shape. However, if the hierarchy is disconnected, body parts can fly off. It’s essential the skeleton hierarchy be completely connected to use this blend mode successully.
BT_componentwise linearly blends all components separately, including H, P, and R, and recomposes the matrix.
BT_componentwise_quat linearly blends all components separately, except for rotation which is blended as a quaternion.
PartBundle(std::string const &name = "")¶
apply_transform(TransformState const *transform)¶
PartBundlethat is a duplicate of this one, but with the indicated transform applied. If this is called multiple times with the same
TransformStatepointer, it returns the same
bind_anim(AnimBundle *anim, int hierarchy_match_flags = 0, PartSubset const &subset = PartSubset())¶
Binds the animation to the bundle, if possible, and returns a new
AnimControlthat can be used to start and stop the animation. If the anim hierarchy does not match the part hierarchy, returns NULL.
If hierarchy_match_flags is 0, only an exact match is accepted; otherwise, it may contain a union of
PartGroup::HierarchyMatchFlagsvalues indicating conditions that will be tolerated (but warnings will still be issued).
If subset is specified, it restricts the binding only to the named subtree of joints.
AnimControlis not stored within the
PartBundle; it is the user’s responsibility to maintain the pointer. The animation will automatically unbind itself when the
AnimControldestructs (i.e. its reference count goes to zero).
Sets the control effect of all
AnimControlsto zero (but does not “stop” the
AnimControls). The character will no longer be affected by any animation, and will return to its default pose (unless restore-initial-pose is false).
AnimControlswhich are no longer associated will not be using any CPU cycles, but they may still be in the “playing” state; if they are later reassociated with the
PartBundlethey will resume at their current frame as if they’d been running all along.
control_joint(std::string const &joint_name, PandaNode *node)¶
Specifies that the joint with the indicated name should be animated with the transform on the indicated node. It will henceforth always follow the node’s transform, regardless of any animations that may subsequently be bound to the joint.
Returns true if the joint is successfully controlled, or false if the named child is not a joint (or slider) or does not exist.
Updates all the parts in the bundle to reflect the data for the current frame, whether we believe it needs it or not.
freeze_joint(std::string const &joint_name, LVecBase3 const &pos, LVecBase3 const &hpr, LVecBase3 const &scale)¶
freeze_joint(std::string const &joint_name, PN_stdfloat value)¶
Specifies that the joint with the indicated name should be frozen with the specified transform. It will henceforth always hold this fixed transform, regardless of any animations that may subsequently be bound to the joint.
Returns true if the joint is successfully frozen, or false if the named child is not a joint (or slider) or does not exist.
Returns whether the character allows multiple different animations to be bound simultaneously. See
Returns the algorithm that is used when blending multiple frames or multiple animations together, when either anim_blend_flag or frame_blend_flag is set to true.
get_control_effect(AnimControl *control) const¶
Returns whether the character interpolates (blends) between two sequential animation frames, or whether it holds the current frame until the next one is ready. See
get_node(int n) const¶
LMatrix4 const &
Returns the transform matrix which is implicitly applied at the root of the animated hierarchy.
load_bind_anim(Loader *loader, Filename const &filename, int hierarchy_match_flags, PartSubset const &subset, bool allow_async)¶
Binds an animation to the bundle. The animation is loaded from the disk via the indicated Loader object. In other respects, this behaves similarly to
bind_anim(), with the addition of asynchronous support.
If allow_aysnc is true, the load will be asynchronous if possible. This requires that the animation basename can be found in the PartBundle’s preload table (see
In an asynchronous load, the animation file will be loaded and bound in a sub-thread. This means that the animation will not necessarily be available at the time this method returns. You may still use the returned
AnimControlimmediately, though, but no visible effect will occur until the animation eventually becomes available.
You can test
AnimControl::is_pending()to see if the animation has been loaded yet, or wait for it to finish with
PartBundle::wait_pending(). You can also set an event to be triggered when the animation finishes loading with
merge_anim_preloads(PartBundle const *other)¶
Copies the contents of the other PartBundle’s preload table into this one.
output(std::ostream &out) const¶
Writes a one-line description of the bundle.
release_joint(std::string const &joint_name)¶
Returns true if the joint is released, or false if the named child was not previously controlled or frozen, or it does not exist.
Defines the way the character responds to multiple calls to
set_control_effect()). By default, this flag is set false, which disallows multiple animations. When this flag is false, it is not necessary to explicitly set the control_effect when starting an animation; starting the animation will implicitly remove the control_effect from the previous animation and set it on the current one.
However, if this flag is set true, the control_effect must be explicitly set via
set_control_effect()whenever an animation is to affect the character.
Defines the algorithm that is used when blending multiple frames or multiple animations together, when either anim_blend_flag or frame_blend_flag is set to true.
See partBundle.h for a description of the meaning of each of the
set_control_effect(AnimControl *control, PN_stdfloat effect)¶
Sets the amount by which the character is affected by the indicated
AnimControl(and its associated animation). Normally, this will only be zero or one. Zero indicates the animation does not affect the character, and one means it does.
If the _anim_blend_flag is not false (see
set_anim_blend_flag()), it is possible to have multiple
AnimControlsin effect simultaneously. In this case, the effect is a weight that indicates the relative importance of each
AnimControlto the final animation.
Specifies whether the character interpolates (blends) between two sequential frames of an active animation, showing a smooth intra-frame motion, or whether it holds each frame until the next frame is ready, showing precisely the specified animation.
When this value is false, the character holds each frame until the next is ready. When this is true, the character will interpolate between two consecutive frames of animation for each frame the animation is onscreen, according to the amount of time elapsed between the frames.
The default value of this flag is determined by the interpolate-frames Config.prc variable.
set_blend_type()to change the algorithm that the character uses to interpolate matrix positions.
set_root_xform(LMatrix4 const &root_xform)¶
Specifies the transform matrix which is implicitly applied at the root of the animated hierarchy.
Updates all the parts in the bundle to reflect the data for the current frame (as set in each of the
Returns true if any part has changed as a result of this, or false otherwise.
Blocks the current thread until all currently-pending
AnimControls, with a nonzero control effect, have been loaded and are properly bound.