15 #include "eggMatrixTablePointer.h" 17 #include "eggSAnimData.h" 18 #include "eggXfmAnimData.h" 19 #include "eggXfmSAnim.h" 21 TypeHandle EggMatrixTablePointer::_type_handle;
28 EggMatrixTablePointer::
29 EggMatrixTablePointer(
EggObject *
object) {
35 EggGroupNode::iterator ci;
37 for (ci = _table->begin(); ci != _table->end() && !found; ++ci) {
39 if (child->get_name() ==
"xform") {
40 if (child->
is_of_type(EggXfmSAnim::get_class_type())) {
45 }
else if (child->
is_of_type(EggXfmAnimData::get_class_type())) {
50 _table->replace(ci, _xform.p());
66 if (_xform == (
EggXfmSAnim *)NULL || !_xform->has_fps()) {
69 return _xform->get_fps();
84 return _xform->get_num_rows();
97 int num_rows = _xform->get_num_rows();
102 _xform->get_value(num_rows - 1, last_mat);
105 while (num_rows < num_frames) {
106 _xform->add_data(last_mat);
131 _xform->get_value(n, mat);
144 _xform->set_value(n, mat);
160 return _xform->add_data(mat);
176 egg_parent->remove_child(_table.p());
183 if (new_node->_table != _table->get_parent()) {
184 new_node->_table->add_child(_table.p());
205 if (!db.
get_matrix(
this, EggCharacterDb::TT_rebuild_frame, 0, mat)) {
216 _xform->clear_data();
217 if (!_xform->add_data(mat)) {
223 while (db.
get_matrix(
this, EggCharacterDb::TT_rebuild_frame, n, mat)) {
224 if (!_xform->add_data(mat)) {
261 string::const_iterator si;
262 for (si = components.begin(); si != components.end(); ++si) {
263 string table_name(1, *si);
264 EggNode *child = _xform->find_child(table_name);
265 if (child != (
EggNode *)NULL) {
266 _xform->remove_child(child);
285 string::const_iterator si;
286 for (si = components.begin(); si != components.end(); ++si) {
287 string table_name(1, *si);
288 EggNode *child = _xform->find_child(table_name);
289 if (child != (
EggNode *)NULL &&
290 child->
is_of_type(EggSAnimData::get_class_type())) {
306 _table->add_child(new_table);
307 CoordinateSystem cs = CS_default;
309 cs = _xform->get_coordinate_system();
325 _table->set_name(name);
virtual LMatrix4d get_frame(int n) const
Returns the transform matrix corresponding to this joint position in the nth frame.
bool add_data(const LMatrix4d &mat)
Adds a new matrix to the table, by adding a new row to each of the subtables.
This is a 4-by-4 transform matrix.
virtual void set_frame(int n, const LMatrix4d &mat)
Sets the transform matrix corresponding to this joint position in the nth frame.
void quantize(double quantum)
Rounds each element of the table to the nearest multiple of quantum.
A base class for nodes in the hierarchy that are not leaf nodes.
virtual void extend_to(int num_frames)
Extends the table to the indicated number of frames.
virtual void set_name(const string &name)
Applies the indicated name change to the egg file.
Corresponding to an <S$Anim> entry, this stores a single column of numbers, for instance for a morph ...
virtual void optimize()
Resets the table before writing to disk so that redundant rows (e.g.
virtual EggJointPointer * make_new_joint(const string &name)
Creates a new child of the current joint in the egg data, and returns a pointer to it...
This class is used during joint optimization or restructuring to store the table of interim joint com...
virtual bool do_rebuild(EggCharacterDb &db)
Rebuilds the entire table all at once, based on the frames added by repeated calls to add_rebuild_fra...
static const LMatrix4d & ident_mat()
Returns an identity matrix.
virtual bool add_frame(const LMatrix4d &mat)
Appends a new frame onto the end of the data, if possible; returns true if not possible, or false otherwise (e.g.
This corresponds to an <Xfm$Anim_S$> entry, which is a collection of up to nine <S$Anim> entries that...
This is a base class for EggJointNodePointer and EggMatrixTablePointer.
Corresponding to an <Xfm$Anim> entry, this stores a two-dimensional table with up to nine columns...
EggNode * add_child(EggNode *node)
Adds the indicated child to the group and returns it.
This stores a pointer back to an EggXfmSAnim table (i.e.
A base class for things that may be directly added into the egg hierarchy.
virtual int get_num_frames() const
Returns the number of frames of animation for this particular joint.
virtual void quantize_channels(const string &components, double quantum)
Rounds the named components of the transform to the nearest multiple of quantum.
virtual void do_finish_reparent(EggJointPointer *new_parent)
Performs the actual reparenting operation by removing the node from its old parent and associating it...
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
virtual double get_frame_rate() const
Returns the stated frame rate of this particular joint, or 0.0 if it doesn't state.
TypeHandle is the identifier used to differentiate C++ class types.
virtual void zero_channels(const string &components)
Zeroes out the named components of the transform in the animation frames.
The highest-level base class in the egg directory.
bool get_matrix(const EggJointPointer *joint, TableType type, int frame, LMatrix4d &mat) const
Looks up the data for the indicated joint, type, and frame, and fills it in result (and returns true)...