34AnimBundleMaker(
EggTable *root) : _root(root) {
39 _ok_num_frames =
true;
45 <<
"AnimBundle " << _root->get_name()
46 <<
" specifies contradictory frame rates.\n";
47 }
else if (_fps == 0.0f) {
49 <<
"AnimBundle " << _root->get_name()
50 <<
" does not specify a frame rate.\n";
54 if (!_ok_num_frames) {
56 <<
"AnimBundle " << _root->get_name()
57 <<
" specifies contradictory number of frames.\n";
77 EggTable::const_iterator ci;
78 for (ci = _root->begin(); ci != _root->end(); ++ci) {
79 if ((*ci)->is_of_type(EggTable::get_class_type())) {
81 build_hierarchy(child, bundle);
95inspect_tree(
EggNode *egg_node) {
96 if (egg_node->
is_of_type(EggAnimData::get_class_type())) {
99 if (egg_anim->has_fps()) {
102 }
else if (_fps != egg_anim->
get_fps()) {
104 _fps = min(_fps, (PN_stdfloat)egg_anim->
get_fps());
110 if (egg_node->
is_of_type(EggXfmSAnim::get_class_type())) {
113 if (egg_anim->has_fps()) {
116 }
else if (_fps != egg_anim->
get_fps()) {
118 _fps = min(_fps, (PN_stdfloat)egg_anim->
get_fps());
124 if (egg_node->
is_of_type(EggSAnimData::get_class_type())) {
129 if (num_frames > 1) {
130 if (_num_frames == 1) {
131 _num_frames = num_frames;
132 }
else if (_num_frames != num_frames) {
134 _num_frames = min(_num_frames, num_frames);
135 _ok_num_frames =
false;
140 if (egg_node->
is_of_type(EggXfmAnimData::get_class_type())) {
145 if (num_frames > 1) {
146 if (_num_frames == 1) {
147 _num_frames = num_frames;
148 }
else if (_num_frames != num_frames) {
150 _num_frames = min(_num_frames, num_frames);
151 _ok_num_frames =
false;
156 if (egg_node->
is_of_type(EggGroupNode::get_class_type())) {
159 EggGroupNode::const_iterator ci;
160 for (ci = group->begin(); ci != group->end(); ++ci) {
170void AnimBundleMaker::
178 EggTable::const_iterator ci;
179 for (ci = egg_table->begin(); ci != egg_table->end(); ++ci) {
180 if ((*ci)->get_name() ==
"xform") {
181 if (this_node ==
nullptr) {
182 this_node = create_xfm_channel((*ci), egg_table->get_name(), parent);
185 <<
"Duplicate xform table under node "
186 << egg_table->get_name() <<
"\n";
192 if (this_node ==
nullptr) {
193 this_node =
new AnimGroup(parent, egg_table->get_name());
197 for (ci = egg_table->begin(); ci != egg_table->end(); ++ci) {
198 if ((*ci)->get_name() ==
"xform") {
200 }
else if ((*ci)->is_of_type(EggSAnimData::get_class_type())) {
202 create_s_channel(egg_anim, egg_anim->get_name(), this_node);
204 }
else if ((*ci)->is_of_type(EggTable::get_class_type())) {
206 build_hierarchy(child, this_node);
217create_s_channel(
EggSAnimData *egg_anim,
const std::string &name,
223 PTA_stdfloat new_data = PTA_stdfloat::empty_array(egg_anim->
get_num_rows(),
224 table->get_class_type());
226 new_data[i] = (PN_stdfloat)egg_anim->
get_value(i);
241create_xfm_channel(
EggNode *egg_node,
const std::string &name,
243 if (egg_node->
is_of_type(EggXfmAnimData::get_class_type())) {
246 return create_xfm_channel(&new_anim, name, parent);
248 }
else if (egg_node->
is_of_type(EggXfmSAnim::get_class_type())) {
250 return create_xfm_channel(egg_anim, name, parent);
254 <<
"Inappropriate node named xform under node "
265create_xfm_channel(
EggXfmSAnim *egg_anim,
const std::string &name,
277 EggXfmSAnim::const_iterator ci;
278 for (ci = egg_anim->begin(); ci != egg_anim->end(); ++ci) {
279 if ((*ci)->is_of_type(EggSAnimData::get_class_type())) {
282 if (child->get_name().empty()) {
284 <<
"Unnamed subtable of <Xfm$Anim_S$> " << name
287 char table_id = child->get_name()[0];
289 if (child->get_name().length() > 1 ||
292 <<
"Unexpected table name " << child->get_name()
293 <<
", child of " << name <<
"\n";
297 <<
"Duplicate table definition for " << table_id
298 <<
" under " << name <<
"\n";
304 PTA_stdfloat new_data=PTA_stdfloat::empty_array(child->
get_num_rows(),
305 table->get_class_type());
307 new_data[i] = (PN_stdfloat)child->
get_value(i);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a node that contains a pointer to an AnimBundle.
This is the root of an AnimChannel hierarchy.
An animation channel that issues a matrix each frame, read from a table such as might have been read ...
set_table
Assigns the indicated table.
has_table
Returns true if the indicated subtable has been assigned.
static bool is_valid_id(char table_id)
Returns true if the given letter is one of the nine valid table id's.
An animation channel that issues a scalar each frame, read from a table such as might have been read ...
set_table
Assigns the data table.
This is the base class for AnimChannel and AnimBundle.
void sort_descendants()
Sorts the children nodes at each level of the hierarchy into alphabetical order.
A base class for EggSAnimData and EggXfmAnimData, which contain rows and columns of numbers.
double get_fps() const
This is only valid if has_fps() returns true.
A base class for nodes in the hierarchy that are not leaf nodes.
A base class for things that may be directly added into the egg hierarchy.
Corresponding to an entry, this stores a single column of numbers, for instance for a morph target,...
double get_value(int row) const
Returns the value at the indicated row.
int get_num_rows() const
Returns the number of rows in the table.
Corresponding to an <Xfm$Anim> entry, this stores a two-dimensional table with up to nine columns,...
int get_num_rows() const
Returns the number of rows in the table.
This corresponds to an <Xfm$Anim_S$> entry, which is a collection of up to nine entries that specify...
void optimize_to_standard_order()
Optimizes the table by collapsing redundant sub-tables, and simultaneously ensures that the order str...
double get_fps() const
This is only valid if has_fps() returns true.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.