mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
fix coordsys problem in animation
This commit is contained in:
parent
1b31d63ef9
commit
630903f539
@ -65,8 +65,7 @@ create_hierarchy(XFileToEggConverter *converter) {
|
|||||||
bundle->add_child(skeleton);
|
bundle->add_child(skeleton);
|
||||||
|
|
||||||
// Fill in the rest of the hierarchy with empty tables.
|
// Fill in the rest of the hierarchy with empty tables.
|
||||||
mirror_table(converter->_frame_rate,
|
mirror_table(converter, converter->get_dart_node(), skeleton);
|
||||||
converter->get_dart_node(), skeleton);
|
|
||||||
|
|
||||||
// Now populate those empty tables with the frame data.
|
// Now populate those empty tables with the frame data.
|
||||||
JointData::const_iterator ji;
|
JointData::const_iterator ji;
|
||||||
@ -140,7 +139,8 @@ create_frame_data(const string &joint_name) {
|
|||||||
// record.
|
// record.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void XFileAnimationSet::
|
void XFileAnimationSet::
|
||||||
mirror_table(double frame_rate, EggGroup *model_node, EggTable *anim_node) {
|
mirror_table(XFileToEggConverter *converter,
|
||||||
|
EggGroup *model_node, EggTable *anim_node) {
|
||||||
EggGroupNode::iterator gi;
|
EggGroupNode::iterator gi;
|
||||||
for (gi = model_node->begin(); gi != model_node->end(); ++gi) {
|
for (gi = model_node->begin(); gi != model_node->end(); ++gi) {
|
||||||
EggNode *child = (*gi);
|
EggNode *child = (*gi);
|
||||||
@ -150,19 +150,21 @@ mirror_table(double frame_rate, EggGroup *model_node, EggTable *anim_node) {
|
|||||||
// When we come to a <Joint>, create a new Table for it.
|
// When we come to a <Joint>, create a new Table for it.
|
||||||
EggTable *new_table = new EggTable(group->get_name());
|
EggTable *new_table = new EggTable(group->get_name());
|
||||||
anim_node->add_child(new_table);
|
anim_node->add_child(new_table);
|
||||||
EggXfmSAnim *xform = new EggXfmSAnim("xform");
|
CoordinateSystem cs =
|
||||||
|
converter->get_egg_data().get_coordinate_system();
|
||||||
|
EggXfmSAnim *xform = new EggXfmSAnim("xform", cs);
|
||||||
new_table->add_child(xform);
|
new_table->add_child(xform);
|
||||||
xform->set_fps(frame_rate);
|
xform->set_fps(converter->_frame_rate);
|
||||||
TablePair &table_pair = _tables[group->get_name()];
|
TablePair &table_pair = _tables[group->get_name()];
|
||||||
table_pair._table = xform;
|
table_pair._table = xform;
|
||||||
table_pair._joint = group;
|
table_pair._joint = group;
|
||||||
|
|
||||||
// Now recurse.
|
// Now recurse.
|
||||||
mirror_table(frame_rate, group, new_table);
|
mirror_table(converter, group, new_table);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// If we come to an ordinary <Group>, skip past it.
|
// If we come to an ordinary <Group>, skip past it.
|
||||||
mirror_table(frame_rate, group, anim_node);
|
mirror_table(converter, group, anim_node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public:
|
|||||||
FrameData &create_frame_data(const string &joint_name);
|
FrameData &create_frame_data(const string &joint_name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void mirror_table(double frame_rate,
|
void mirror_table(XFileToEggConverter *converter,
|
||||||
EggGroup *model_node, EggTable *anim_node);
|
EggGroup *model_node, EggTable *anim_node);
|
||||||
|
|
||||||
typedef pmap<string, FrameData> JointData;
|
typedef pmap<string, FrameData> JointData;
|
||||||
|
@ -957,11 +957,10 @@ set_animation_frame(const string &joint_name,
|
|||||||
<< nvalues << " for rotation data.\n";
|
<< nvalues << " for rotation data.\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
frame_entry._rot.set(values[0], -values[1], values[2], -values[3]);
|
frame_entry._rot.set(-values[0], values[1], values[2], values[3]);
|
||||||
// frame_entry._rot.set_from_matrix(LMatrix3d::rotate_mat(-90, LVecBase3d(1, 0, 0)) * frame_entry._rot * LMatrix3d::rotate_mat(90, LVecBase3d(1, 0, 0)));
|
|
||||||
table._flags |= XFileAnimationSet::FDF_rot;
|
table._flags |= XFileAnimationSet::FDF_rot;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (nvalues != 3) {
|
if (nvalues != 3) {
|
||||||
xfile_cat.error()
|
xfile_cat.error()
|
||||||
|
@ -55,11 +55,31 @@ XFileToEgg() :
|
|||||||
*/
|
*/
|
||||||
&XFileToEgg::dispatch_string, &_make_char, &_char_name);
|
&XFileToEgg::dispatch_string, &_make_char, &_char_name);
|
||||||
|
|
||||||
|
add_option
|
||||||
|
("fr", "fps", 0,
|
||||||
|
"Specify the frame rate of the resulting animation. The animation "
|
||||||
|
"tables should have one entry per frame, rather than one per "
|
||||||
|
"keyframe; the time component of the animation tables is ignored "
|
||||||
|
"and the frames are played sequentially at the specified frame rate.",
|
||||||
|
&XFileToEgg::dispatch_double, NULL, &_frame_rate);
|
||||||
|
|
||||||
|
redescribe_option
|
||||||
|
("ui",
|
||||||
|
"Specify the units of the input " + _format_name + " file.");
|
||||||
|
|
||||||
|
redescribe_option
|
||||||
|
("uo",
|
||||||
|
"Specify the units of the resulting egg file. If both this and -ui are "
|
||||||
|
"specified, the vertices in the egg file will be scaled as "
|
||||||
|
"necessary to make the appropriate units conversion; otherwise, "
|
||||||
|
"the vertices will be left as they are.");
|
||||||
|
|
||||||
redescribe_option
|
redescribe_option
|
||||||
("cs",
|
("cs",
|
||||||
"Specify the coordinate system of the input " + _format_name +
|
"Specify the coordinate system of the input " + _format_name +
|
||||||
" file. Normally, this is y-up-left.");
|
" file. Normally, this is y-up-left.");
|
||||||
|
|
||||||
|
_frame_rate = 30.0;
|
||||||
_coordinate_system = CS_yup_left;
|
_coordinate_system = CS_yup_left;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,6 +95,7 @@ run() {
|
|||||||
XFileToEggConverter converter;
|
XFileToEggConverter converter;
|
||||||
converter.set_egg_data(&_data, false);
|
converter.set_egg_data(&_data, false);
|
||||||
|
|
||||||
|
converter._frame_rate = _frame_rate;
|
||||||
converter._make_char = _make_char;
|
converter._make_char = _make_char;
|
||||||
converter._char_name = _char_name;
|
converter._char_name = _char_name;
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
bool _make_char;
|
bool _make_char;
|
||||||
string _char_name;
|
string _char_name;
|
||||||
|
double _frame_rate;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user