Panda3D
|
This is one node of a hierarchy of EggJointData nodes, each of which represents a single joint of the character hierarchy across all loaded files: the various models, the LOD's of each model, and the various animation channel files. More...
#include "eggJointData.h"
Public Member Functions | |
EggJointData (EggCharacterCollection *collection, EggCharacterData *char_data) | |
virtual void | add_back_pointer (int model_index, EggObject *egg_object) |
Adds the indicated model joint or anim table to the data. | |
void | apply_default_pose (int source_model, int frame) |
Applies the pose from the indicated frame of the indicated source model_index as the initial pose for this joint, and does this recursively on all joints below. | |
bool | do_rebuild_all (EggCharacterDb &db) |
Calls do_rebuild() on all models, and recursively on all joints at this node and below. | |
void | expose (EggGroup::DCSType dcs_type=EggGroup::DC_default) |
Calls expose() on all models for this joint, but does not recurse downwards. | |
EggJointData * | find_joint (const string &name) |
Returns the first descendent joint found with the indicated name, or NULL if no joint has that name. | |
virtual TypeHandle | force_init_type () |
void | force_initial_rest_frame () |
Forces all of the joints to have the same rest frame value as the first joint read in. | |
EggJointData * | get_child (int n) const |
LMatrix4d | get_frame (int model_index, int n) const |
Returns the local transform matrix corresponding to this joint position in the nth frame in the indicated model. | |
LMatrix4d | get_net_frame (int model_index, int n, EggCharacterDb &db) const |
Returns the complete transform from the root corresponding to this joint position in the nth frame in the indicated model. | |
LMatrix4d | get_net_frame_inv (int model_index, int n, EggCharacterDb &db) const |
Returns the inverse of get_net_frame(). | |
int | get_num_children () const |
EggJointData * | get_parent () const |
const LMatrix4d & | get_rest_frame () const |
Returns the rest frame of the joint. | |
virtual TypeHandle | get_type () const |
bool | has_rest_frame () const |
Returns true if the joint knows its rest frame, false otherwise. | |
void | move_vertices_to (EggJointData *new_owner) |
Moves the vertices assigned to this joint into the indicated joint, without changing their weight assignments. | |
void | optimize () |
Calls optimize() on all models, and recursively on all joints at this node and below. | |
void | quantize_channels (const string &components, double quantum) |
Calls quantize_channels() on all models for this joint, and then recurses downwards to all joints below. | |
void | reparent_to (EggJointData *new_parent) |
Indicates an intention to change the parent of this joint to the indicated joint, or NULL to remove it from the hierarchy. | |
bool | rest_frames_differ () const |
Returns true if the rest frames for different models differ in their initial value. | |
int | score_reparent_to (EggJointData *new_parent, EggCharacterDb &db) |
Computes a score >= 0 reflecting the similarity of the current joint's animation (in world space) to that of the indicated potential parent joint (in world space). | |
virtual void | write (ostream &out, int indent_level=0) const |
void | zero_channels (const string &components) |
Calls zero_channels() on all models for this joint, but does not recurse downwards. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. | |
Protected Types | |
typedef pvector< EggJointData * > | Children |
Protected Member Functions | |
bool | calc_new_parent_depth (pset< EggJointData * > &chain) |
Calculates the number of joints above this joint in its intended position, as specified by a recent call to reparent_to(), and also checks for a cycle in the new parent chain. | |
void | do_begin_compute_reparent () |
Eliminates any cached values before beginning a walk through all the joints for do_compute_reparent(), for a given model/frame. | |
void | do_begin_reparent () |
Clears out the _children vector in preparation for refilling it from the _new_parent information. | |
bool | do_compute_reparent (int model_index, int n, EggCharacterDb &db) |
Prepares the reparent operation by computing a new transform for each frame of each model, designed to keep the net transform the same when the joint is moved to its new parent. | |
void | do_finish_reparent () |
Performs the actual reparenting operation by removing all of the old children and replacing them with the set of new children. | |
bool | do_joint_rebuild (int model_index, EggCharacterDb &db) |
Calls do_rebuild() on the joint for the indicated model index. | |
Protected Attributes | |
Children | _children |
bool | _got_new_parent_depth |
EggJointData * | _new_parent |
int | _new_parent_depth |
EggJointData * | _parent |
Friends | |
class | EggCharacterCollection |
class | EggCharacterData |
class | OrderJointsByNewDepth |
This is one node of a hierarchy of EggJointData nodes, each of which represents a single joint of the character hierarchy across all loaded files: the various models, the LOD's of each model, and the various animation channel files.
Definition at line 34 of file eggJointData.h.
void EggJointData::add_back_pointer | ( | int | model_index, |
EggObject * | egg_object | ||
) | [virtual] |
Adds the indicated model joint or anim table to the data.
Implements EggComponentData.
Definition at line 452 of file eggJointData.cxx.
References LMatrix4d::almost_equal(), EggJointNodePointer::get_frame(), TypedObject::is_of_type(), and EggComponentData::set_model().
Referenced by EggCharacterCollection::add_egg().
void EggJointData::apply_default_pose | ( | int | source_model, |
int | frame | ||
) |
Applies the pose from the indicated frame of the indicated source model_index as the initial pose for this joint, and does this recursively on all joints below.
Definition at line 423 of file eggJointData.cxx.
References EggJointPointer::apply_default_pose(), apply_default_pose(), and EggComponentData::has_model().
Referenced by apply_default_pose().
bool EggJointData::calc_new_parent_depth | ( | pset< EggJointData * > & | chain | ) | [protected] |
Calculates the number of joints above this joint in its intended position, as specified by a recent call to reparent_to(), and also checks for a cycle in the new parent chain.
Returns true if a cycle is detected, and false otherwise. If a cycle is not detected, _new_parent_depth can be consulted for the depth in the new hierarchy.
This is used by EggCharacterData::do_reparent() to determine the order in which to apply the reparent operations. It should be called after do_begin_reparent().
Definition at line 536 of file eggJointData.cxx.
References calc_new_parent_depth().
Referenced by calc_new_parent_depth(), and EggCharacterData::do_reparent().
void EggJointData::do_begin_compute_reparent | ( | ) | [protected] |
Eliminates any cached values before beginning a walk through all the joints for do_compute_reparent(), for a given model/frame.
Definition at line 563 of file eggJointData.cxx.
Referenced by EggCharacterData::do_reparent().
void EggJointData::do_begin_reparent | ( | ) | [protected] |
Clears out the _children vector in preparation for refilling it from the _new_parent information.
Definition at line 514 of file eggJointData.cxx.
Referenced by EggCharacterData::do_reparent().
bool EggJointData::do_compute_reparent | ( | int | model_index, |
int | n, | ||
EggCharacterDb & | db | ||
) | [protected] |
Prepares the reparent operation by computing a new transform for each frame of each model, designed to keep the net transform the same when the joint is moved to its new parent.
Returns true on success, false on failure.
Definition at line 579 of file eggJointData.cxx.
References EggComponentData::get_model(), get_net_frame(), and EggCharacterDb::set_matrix().
Referenced by EggCharacterData::do_reparent().
void EggJointData::do_finish_reparent | ( | ) | [protected] |
Performs the actual reparenting operation by removing all of the old children and replacing them with the set of new children.
Definition at line 663 of file eggJointData.cxx.
References EggComponentData::get_model(), EggComponentData::get_num_models(), and EggComponentData::has_model().
Referenced by EggCharacterData::do_reparent().
bool EggJointData::do_joint_rebuild | ( | int | model_index, |
EggCharacterDb & | db | ||
) | [protected] |
Calls do_rebuild() on the joint for the indicated model index.
Returns true on success, false on failure (false shouldn't be possible).
Definition at line 636 of file eggJointData.cxx.
References EggJointPointer::do_rebuild(), EggComponentData::get_model(), and EggComponentData::has_model().
Referenced by EggCharacterData::do_reparent().
bool EggJointData::do_rebuild_all | ( | EggCharacterDb & | db | ) |
Calls do_rebuild() on all models, and recursively on all joints at this node and below.
Returns true if all models returned true, false otherwise.
Definition at line 300 of file eggJointData.cxx.
References EggJointPointer::do_rebuild(), and do_rebuild_all().
Referenced by do_rebuild_all().
void EggJointData::expose | ( | EggGroup::DCSType | dcs_type = EggGroup::DC_default | ) |
Calls expose() on all models for this joint, but does not recurse downwards.
Definition at line 358 of file eggJointData.cxx.
References EggJointPointer::expose().
EggJointData * EggJointData::find_joint | ( | const string & | name | ) | [inline] |
Returns the first descendent joint found with the indicated name, or NULL if no joint has that name.
Definition at line 54 of file eggJointData.I.
Referenced by EggCharacterData::find_joint().
Forces all of the joints to have the same rest frame value as the first joint read in.
This is a drastic way to repair models whose rest frame values are completely bogus, but should not be performed on models that are otherwise correct.
Definition at line 131 of file eggJointData.cxx.
References EggComponentData::get_model(), EggComponentData::get_num_models(), get_rest_frame(), EggComponentData::has_model(), has_rest_frame(), and TypedObject::is_of_type().
Referenced by EggCharacterCollection::check_errors().
LMatrix4d EggJointData::get_frame | ( | int | model_index, |
int | n | ||
) | const |
Returns the local transform matrix corresponding to this joint position in the nth frame in the indicated model.
Definition at line 53 of file eggJointData.cxx.
References EggComponentData::get_model(), and LMatrix4d::ident_mat().
Referenced by get_net_frame(), EggRetargetAnim::retarget_anim(), and EggTopstrip::strip_anim().
LMatrix4d EggJointData::get_net_frame | ( | int | model_index, |
int | n, | ||
EggCharacterDb & | db | ||
) | const |
Returns the complete transform from the root corresponding to this joint position in the nth frame in the indicated model.
Definition at line 73 of file eggJointData.cxx.
References get_frame(), EggCharacterDb::get_matrix(), EggComponentData::get_model(), get_net_frame(), LMatrix4d::ident_mat(), and EggCharacterDb::set_matrix().
Referenced by do_compute_reparent(), get_net_frame(), get_net_frame_inv(), score_reparent_to(), EggTopstrip::strip_anim(), and EggTopstrip::strip_anim_vertices().
LMatrix4d EggJointData::get_net_frame_inv | ( | int | model_index, |
int | n, | ||
EggCharacterDb & | db | ||
) | const |
Returns the inverse of get_net_frame().
Definition at line 101 of file eggJointData.cxx.
References EggCharacterDb::get_matrix(), EggComponentData::get_model(), get_net_frame(), LMatrix4d::ident_mat(), LMatrix4d::invert_in_place(), and EggCharacterDb::set_matrix().
Referenced by score_reparent_to().
const LMatrix4d & EggJointData::get_rest_frame | ( | ) | const [inline] |
Returns the rest frame of the joint.
This is the matrix value that appears for the joint in each model file; it should be the same transform in each model.
Definition at line 97 of file eggJointData.I.
References has_rest_frame(), and LMatrix4d::ident_mat().
Referenced by force_initial_rest_frame().
bool EggJointData::has_rest_frame | ( | ) | const [inline] |
Returns true if the joint knows its rest frame, false otherwise.
In general, this will be true as long as the joint is included in at least one model file, or false if it appears only in animation files.
Definition at line 72 of file eggJointData.I.
Referenced by force_initial_rest_frame(), and get_rest_frame().
static void EggJointData::init_type | ( | ) | [inline, static] |
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Making it inline seems to cause problems in the optimizer.
Reimplemented from EggComponentData.
Definition at line 109 of file eggJointData.h.
void EggJointData::move_vertices_to | ( | EggJointData * | new_owner | ) |
Moves the vertices assigned to this joint into the indicated joint, without changing their weight assignments.
Definition at line 156 of file eggJointData.cxx.
References EggComponentData::get_model(), EggComponentData::get_num_models(), EggComponentData::has_model(), and EggJointPointer::move_vertices_to().
void EggJointData::optimize | ( | ) |
Calls optimize() on all models, and recursively on all joints at this node and below.
Definition at line 333 of file eggJointData.cxx.
References EggJointPointer::optimize(), and optimize().
Referenced by optimize(), and EggCharacterFilter::write_eggs().
void EggJointData::quantize_channels | ( | const string & | components, |
double | quantum | ||
) |
Calls quantize_channels() on all models for this joint, and then recurses downwards to all joints below.
Definition at line 396 of file eggJointData.cxx.
References EggJointPointer::quantize_channels(), and quantize_channels().
Referenced by quantize_channels().
void EggJointData::reparent_to | ( | EggJointData * | new_parent | ) | [inline] |
Indicates an intention to change the parent of this joint to the indicated joint, or NULL to remove it from the hierarchy.
The joint is not reparented immediately, but rather all of the joints are reparented at once when do_reparent() is called.
Definition at line 112 of file eggJointData.I.
Referenced by EggCharacterData::choose_optimal_hierarchy().
bool EggJointData::rest_frames_differ | ( | ) | const [inline] |
Returns true if the rest frames for different models differ in their initial value.
This is not technically an error, but it is unusual enough to be suspicious.
Definition at line 85 of file eggJointData.I.
Referenced by EggCharacterCollection::check_errors().
int EggJointData::score_reparent_to | ( | EggJointData * | new_parent, |
EggCharacterDb & | db | ||
) |
Computes a score >= 0 reflecting the similarity of the current joint's animation (in world space) to that of the indicated potential parent joint (in world space).
The lower the number, the more similar the motion, and the more suitable is the proposed parent-child relationship. Returns -1 if there is an error.
Definition at line 191 of file eggJointData.cxx.
References Datagram::get_data(), Datagram::get_length(), EggComponentData::get_model(), get_net_frame(), get_net_frame_inv(), EggComponentData::get_num_frames(), EggComponentData::get_num_models(), LMatrix4d::ident_mat(), FFTCompressor::is_compression_available(), FFTCompressor::write_hprs(), and FFTCompressor::write_reals().
Referenced by EggCharacterData::choose_optimal_hierarchy().
void EggJointData::zero_channels | ( | const string & | components | ) |
Calls zero_channels() on all models for this joint, but does not recurse downwards.
Definition at line 377 of file eggJointData.cxx.
References EggJointPointer::zero_channels().