34 AnimBundleMaker(
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);
94 void AnimBundleMaker::
95 inspect_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) {
170 void 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);
217 create_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);
241 create_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 "
265 create_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);