Panda3D
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Friends

PartBundle Class Reference

This is the root of a MovingPart hierarchy. More...

#include "partBundle.h"

Inheritance diagram for PartBundle:
PartGroup TypedWritableReferenceCount Namable TypedWritable ReferenceCount MemoryBase TypedObject MemoryBase MemoryBase CharacterJointBundle

List of all members.

Classes

class  CData

Public Types

enum  BlendType { BT_linear, BT_normalized_linear, BT_componentwise, BT_componentwise_quat }
typedef pmap< AnimControl
*, PN_stdfloat > 
ChannelBlend

Public Member Functions

 PartBundle (const string &name="")
 Normally, a PartBundle constructor should not be called directly--it will get created when a PartBundleNode is created.
void clear_anim_preload ()
 Removes any AnimPreloadTable associated with the PartBundle.
void clear_control_effects ()
 Sets the control effect of all AnimControls to zero (but does not "stop" the AnimControls).
virtual int complete_pointers (TypedWritable **p_list, BamReader *manager)
 Takes in a vector of pointers to TypedWritable objects that correspond to all the requests for pointers that this object made to BamReader.
virtual void control_activated (AnimControl *control)
 Called by the AnimControl whenever it starts an animation.
bool control_joint (const string &joint_name, PandaNode *node)
 Specifies that the joint with the indicated name should be animated with the transform on the indicated node.
 CPT (AnimPreloadTable) get_anim_preload() const
bool do_bind_anim (AnimControl *control, AnimBundle *anim, int hierarchy_match_flags, const PartSubset &subset)
 The internal implementation of bind_anim(), this receives a pointer to an uninitialized AnimControl and fills it in if the bind is successful.
virtual void finalize (BamReader *manager)
 Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed.
virtual TypeHandle force_init_type ()
bool force_update ()
 Updates all the parts in the bundle to reflect the data for the current frame, whether we believe it needs it or not.
bool freeze_joint (const string &joint_name, const TransformState *transform)
 Specifies that the joint with the indicated name should be frozen with the specified transform.
bool freeze_joint (const string &joint_name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale)
 Specifies that the joint with the indicated name should be frozen with the specified transform.
bool freeze_joint (const string &joint_name, PN_stdfloat value)
 Specifies that the joint with the indicated name should be frozen with the specified transform.
bool get_anim_blend_flag () const
 Returns whether the character allows multiple different animations to be bound simultaneously.
BlendType get_blend_type () const
 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.
PN_stdfloat get_control_effect (AnimControl *control) const
 Returns the amount by which the character is affected by the indicated AnimControl and its associated animation.
bool get_frame_blend_flag () 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.
PartBundleNodeget_node (int n) const
 Returns the nth PartBundleNode associated with this PartBundle.
int get_num_nodes () const
 Returns the number of PartBundleNodes that contain a pointer to this PartBundle.
const LMatrix4get_root_xform () const
 Returns the transform matrix which is implicitly applied at the root of the animated hierarchy.
virtual TypeHandle get_type () const
virtual PartGroupmake_copy () const
 Allocates and returns a new copy of the node.
 MAKE_SEQ (get_nodes, get_num_nodes, get_node)
void merge_anim_preloads (const PartBundle *other)
 Copies the contents of the other PartBundle's preload table into this one.
virtual void output (ostream &out) const
 Writes a one-line description of the bundle.
 PT (PartBundle) apply_transform(const TransformState *transform)
 PT (AnimPreloadTable) modify_anim_preload()
 PT (AnimControl) load_bind_anim(Loader *loader
 PT (AnimControl) bind_anim(AnimBundle *anim
bool release_joint (const string &joint_name)
 Releases the named joint from the effects of a previous call to freeze_joint() or control_joint().
void set_anim_blend_flag (bool anim_blend_flag)
 Defines the way the character responds to multiple calls to set_control_effect()).
void set_anim_preload (AnimPreloadTable *table)
 Replaces the AnimPreloadTable associated with the PartBundle.
void set_blend_type (BlendType bt)
 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.
void 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).
void set_frame_blend_flag (bool frame_blend_flag)
 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.
void set_root_xform (const LMatrix4 &root_xform)
 Specifies the transform matrix which is implicitly applied at the root of the animated hierarchy.
void set_update_delay (double delay)
 Specifies the minimum amount of time, in seconds, that should elapse between any two consecutive updates.
bool update ()
 Updates all the parts in the bundle to reflect the data for the current frame (as set in each of the AnimControls).
void wait_pending ()
 Blocks the current thread until all currently-pending AnimControls, with a nonzero control effect, have been loaded and are properly bound.
virtual void write (ostream &out, int indent_level) const
 Writes a brief description of the bundle and all of its descendants.
virtual void write_datagram (BamWriter *manager, Datagram &dg)
 Writes the contents of this object to the datagram for shipping out to a Bam file.
void xform (const LMatrix4 &mat)
 Applies the indicated transform to the root of the animated hierarchy.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()
static void register_with_read_factory ()
 Factory method to generate a PartBundle object.

Public Attributes

const Filename int const
PartSubset bool 
allow_async
const Filenamefilename
const Filename int hierarchy_match_flags
int hierarchy_match_flags = 0
int const PartSubsetsubset = PartSubset())
const Filename int const
PartSubset
subset

Protected Member Functions

 PartBundle (const PartBundle &copy)
 Normally, you'd use make_copy() or copy_subgraph() to make a copy of this.
virtual void add_node (PartBundleNode *node)
 Adds the PartBundleNode pointer to the set of nodes associated with the PartBundle.
void fillin (DatagramIterator &scan, BamReader *manager)
 This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new PartBundle.
virtual void remove_node (PartBundleNode *node)
 Removes the PartBundleNode pointer from the set of nodes associated with the PartBundle.

Static Protected Member Functions

static TypedWritablemake_from_bam (const FactoryParams &params)
 Factory method to generate a PartBundle object.

Friends

class Character
class MovingPartBase
class MovingPartMatrix
class MovingPartScalar
class PartBundleNode

Detailed Description

This is the root of a MovingPart hierarchy.

It defines the hierarchy of moving parts that make up an animatable object.

Definition at line 49 of file partBundle.h.


Constructor & Destructor Documentation

PartBundle::PartBundle ( const PartBundle copy) [protected]

Normally, you'd use make_copy() or copy_subgraph() to make a copy of this.

Definition at line 53 of file partBundle.cxx.

Referenced by make_copy(), and make_from_bam().

PartBundle::PartBundle ( const string &  name = "")

Normally, a PartBundle constructor should not be called directly--it will get created when a PartBundleNode is created.

Definition at line 75 of file partBundle.cxx.


Member Function Documentation

void PartBundle::add_node ( PartBundleNode node) [protected, virtual]

Adds the PartBundleNode pointer to the set of nodes associated with the PartBundle.

Normally called only by the PartBundleNode itself, for instance when the bundle is flattened with another node.

Reimplemented in CharacterJointBundle.

Definition at line 685 of file partBundle.cxx.

Referenced by PartBundleNode::update_bundle().

void PartBundle::clear_anim_preload ( ) [inline]

Removes any AnimPreloadTable associated with the PartBundle.

Definition at line 58 of file partBundle.I.

void PartBundle::clear_control_effects ( )

Sets the control effect of all AnimControls to 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).

The AnimControls which 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 PartBundle they will resume at their current frame as if they'd been running all along.

Definition at line 215 of file partBundle.cxx.

References PartGroup::determine_effective_channels(), and Thread::get_current_pipeline_stage().

int PartBundle::complete_pointers ( TypedWritable **  p_list,
BamReader manager 
) [virtual]

Takes in a vector of pointers to TypedWritable objects that correspond to all the requests for pointers that this object made to BamReader.

Reimplemented from PartGroup.

Definition at line 854 of file partBundle.cxx.

References BamReader::get_file_minor_ver().

void PartBundle::control_activated ( AnimControl control) [virtual]

Called by the AnimControl whenever it starts an animation.

This is just a hook so the bundle can do something, if necessary, before the animation starts.

Definition at line 605 of file partBundle.cxx.

References Thread::get_current_pipeline_stage(), and AnimControl::get_part().

Referenced by AnimControl::animation_activated().

bool PartBundle::control_joint ( const string &  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.

Definition at line 496 of file partBundle.cxx.

References PartGroup::apply_control(), and PartGroup::find_child().

bool PartBundle::do_bind_anim ( AnimControl control,
AnimBundle anim,
int  hierarchy_match_flags,
const PartSubset subset 
)

The internal implementation of bind_anim(), this receives a pointer to an uninitialized AnimControl and fills it in if the bind is successful.

Returns true if successful, false otherwise.

Definition at line 628 of file partBundle.cxx.

References BitArray::all_on(), PartGroup::bind_hierarchy(), PartGroup::check_hierarchy(), PartGroup::determine_effective_channels(), Thread::get_current_pipeline_stage(), PartSubset::is_include_empty(), PartGroup::pick_channel_index(), and AnimControl::setup_anim().

Referenced by BindAnimRequest::do_task().

void PartBundle::fillin ( DatagramIterator scan,
BamReader manager 
) [protected, virtual]

This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new PartBundle.

Reimplemented from PartGroup.

Definition at line 889 of file partBundle.cxx.

References DatagramIterator::get_bool(), BamReader::get_file_minor_ver(), BamReader::read_cdata(), and BamReader::read_pointer().

Referenced by CharacterJointBundle::make_CharacterJointBundle(), and make_from_bam().

void PartBundle::finalize ( BamReader manager) [virtual]

Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed.

Reimplemented from TypedWritable.

Definition at line 827 of file partBundle.cxx.

References PartGroup::do_update(), and Thread::get_current_thread().

bool PartBundle::force_update ( )

Updates all the parts in the bundle to reflect the data for the current frame, whether we believe it needs it or not.

Definition at line 579 of file partBundle.cxx.

References PartGroup::do_update(), Thread::get_current_thread(), and AnimControl::mark_channels().

Referenced by Character::force_update().

bool PartBundle::freeze_joint ( const string &  joint_name,
const TransformState transform 
)

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.

Definition at line 418 of file partBundle.cxx.

References PartGroup::apply_freeze(), and PartGroup::find_child().

bool PartBundle::freeze_joint ( const string &  joint_name,
const LVecBase3 pos,
const LVecBase3 hpr,
const LVecBase3 scale 
)

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.

Definition at line 444 of file partBundle.cxx.

References PartGroup::apply_freeze_matrix(), and PartGroup::find_child().

bool PartBundle::freeze_joint ( const string &  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.

Definition at line 470 of file partBundle.cxx.

References PartGroup::apply_freeze_scalar(), and PartGroup::find_child().

bool PartBundle::get_anim_blend_flag ( ) const [inline]

Returns whether the character allows multiple different animations to be bound simultaneously.

See set_anim_blend_flag().

Definition at line 102 of file partBundle.I.

PartBundle::BlendType PartBundle::get_blend_type ( ) const [inline]

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.

Definition at line 89 of file partBundle.I.

PN_stdfloat PartBundle::get_control_effect ( AnimControl control) const [inline]

Returns the amount by which the character is affected by the indicated AnimControl and its associated animation.

See set_control_effect().

Definition at line 247 of file partBundle.I.

bool PartBundle::get_frame_blend_flag ( ) const [inline]

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 set_frame_blend_flag().

Definition at line 145 of file partBundle.I.

PartBundleNode * PartBundle::get_node ( int  n) const [inline]

Returns the nth PartBundleNode associated with this PartBundle.

Reimplemented in CharacterJointBundle.

Definition at line 209 of file partBundle.I.

Referenced by CharacterJointBundle::get_node().

int PartBundle::get_num_nodes ( ) const [inline]

Returns the number of PartBundleNodes that contain a pointer to this PartBundle.

Definition at line 198 of file partBundle.I.

Referenced by CharacterJointBundle::remove_node(), and PartBundleNode::xform().

const LMatrix4 & PartBundle::get_root_xform ( ) const [inline]

Returns the transform matrix which is implicitly applied at the root of the animated hierarchy.

Definition at line 186 of file partBundle.I.

Referenced by CharacterJoint::update_internals().

PartGroup * PartBundle::make_copy ( ) const [virtual]

Allocates and returns a new copy of the node.

Children are not copied, but see copy_subgraph().

Reimplemented from PartGroup.

Reimplemented in CharacterJointBundle.

Definition at line 88 of file partBundle.cxx.

References PartBundle().

TypedWritable * PartBundle::make_from_bam ( const FactoryParams params) [static, protected]

Factory method to generate a PartBundle object.

Definition at line 870 of file partBundle.cxx.

References fillin(), PartBundle(), and BamReader::register_finalize().

Referenced by register_with_read_factory().

void PartBundle::merge_anim_preloads ( const PartBundle other)

Copies the contents of the other PartBundle's preload table into this one.

Definition at line 99 of file partBundle.cxx.

Referenced by Character::merge_bundles().

void PartBundle::output ( ostream &  out) const [virtual]

Writes a one-line description of the bundle.

Reimplemented from Namable.

Definition at line 234 of file partBundle.cxx.

void PartBundle::register_with_read_factory ( ) [static]

Factory method to generate a PartBundle object.

Reimplemented from PartGroup.

Reimplemented in CharacterJointBundle.

Definition at line 909 of file partBundle.cxx.

References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().

bool PartBundle::release_joint ( const string &  joint_name)

Releases the named joint from the effects of a previous call to freeze_joint() or control_joint().

It will henceforth once again follow whatever transforms are dictated by the animation.

Returns true if the joint is released, or false if the named child was not previously controlled or frozen, or it does not exist.

Definition at line 521 of file partBundle.cxx.

References PartGroup::clear_forced_channel(), and PartGroup::find_child().

void PartBundle::remove_node ( PartBundleNode node) [protected, virtual]

Removes the PartBundleNode pointer from the set of nodes associated with the PartBundle.

Normally called only by the PartBundleNode itself, for instance when the bundle is flattened with another node.

Reimplemented in CharacterJointBundle.

Definition at line 700 of file partBundle.cxx.

Referenced by PartBundleNode::steal_bundles(), and PartBundleNode::update_bundle().

void PartBundle::set_anim_blend_flag ( bool  anim_blend_flag)

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.

Definition at line 134 of file partBundle.cxx.

References Thread::get_current_pipeline_stage().

void PartBundle::set_anim_preload ( AnimPreloadTable table) [inline]

Replaces the AnimPreloadTable associated with the PartBundle.

Definition at line 47 of file partBundle.I.

void PartBundle::set_blend_type ( PartBundle::BlendType  bt) [inline]

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 BlendType values.

Definition at line 74 of file partBundle.I.

References Thread::get_current_pipeline_stage().

void PartBundle::set_control_effect ( AnimControl control,
PN_stdfloat  effect 
) [inline]

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 AnimControls in effect simultaneously. In this case, the effect is a weight that indicates the relative importance of each AnimControl to the final animation.

Definition at line 232 of file partBundle.I.

References Thread::get_current_pipeline_stage().

void PartBundle::set_frame_blend_flag ( bool  frame_blend_flag) [inline]

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.

Use set_blend_type() to change the algorithm that the character uses to interpolate matrix positions.

Definition at line 130 of file partBundle.I.

References Thread::get_current_pipeline_stage().

void PartBundle::set_root_xform ( const LMatrix4 root_xform) [inline]

Specifies the transform matrix which is implicitly applied at the root of the animated hierarchy.

Definition at line 157 of file partBundle.I.

References Thread::get_current_pipeline_stage().

void PartBundle::set_update_delay ( double  delay) [inline]

Specifies the minimum amount of time, in seconds, that should elapse between any two consecutive updates.

This is normally used by Character::set_lod_animation(), and should not be called directly.

Definition at line 262 of file partBundle.I.

bool PartBundle::update ( )

Updates all the parts in the bundle to reflect the data for the current frame (as set in each of the AnimControls).

Returns true if any part has changed as a result of this, or false otherwise.

Definition at line 544 of file partBundle.cxx.

References PartGroup::do_update(), Thread::get_current_thread(), ClockObject::get_frame_time(), ClockObject::get_global_clock(), and AnimControl::mark_channels().

void PartBundle::wait_pending ( )

Blocks the current thread until all currently-pending AnimControls, with a nonzero control effect, have been loaded and are properly bound.

Definition at line 390 of file partBundle.cxx.

References AnimControl::wait_pending().

void PartBundle::write ( ostream &  out,
int  indent_level 
) const [virtual]

Writes a brief description of the bundle and all of its descendants.

Reimplemented from PartGroup.

Definition at line 245 of file partBundle.cxx.

References PartGroup::write_descendants().

Referenced by Character::write_parts().

void PartBundle::write_datagram ( BamWriter manager,
Datagram dg 
) [virtual]

Writes the contents of this object to the datagram for shipping out to a Bam file.

Reimplemented from PartGroup.

Definition at line 840 of file partBundle.cxx.

References BamWriter::write_cdata(), and BamWriter::write_pointer().

void PartBundle::xform ( const LMatrix4 mat) [inline]

Applies the indicated transform to the root of the animated hierarchy.

Definition at line 171 of file partBundle.I.

References PartGroup::do_xform(), and Thread::get_current_pipeline_stage().

Referenced by PartBundleNode::xform().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations