mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 17:35:34 -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);
|
||||
|
||||
// Fill in the rest of the hierarchy with empty tables.
|
||||
mirror_table(converter->_frame_rate,
|
||||
converter->get_dart_node(), skeleton);
|
||||
mirror_table(converter, converter->get_dart_node(), skeleton);
|
||||
|
||||
// Now populate those empty tables with the frame data.
|
||||
JointData::const_iterator ji;
|
||||
@ -140,7 +139,8 @@ create_frame_data(const string &joint_name) {
|
||||
// record.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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;
|
||||
for (gi = model_node->begin(); gi != model_node->end(); ++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.
|
||||
EggTable *new_table = new EggTable(group->get_name());
|
||||
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);
|
||||
xform->set_fps(frame_rate);
|
||||
xform->set_fps(converter->_frame_rate);
|
||||
TablePair &table_pair = _tables[group->get_name()];
|
||||
table_pair._table = xform;
|
||||
table_pair._joint = group;
|
||||
|
||||
// Now recurse.
|
||||
mirror_table(frame_rate, group, new_table);
|
||||
mirror_table(converter, group, new_table);
|
||||
|
||||
} else {
|
||||
// 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);
|
||||
|
||||
private:
|
||||
void mirror_table(double frame_rate,
|
||||
void mirror_table(XFileToEggConverter *converter,
|
||||
EggGroup *model_node, EggTable *anim_node);
|
||||
|
||||
typedef pmap<string, FrameData> JointData;
|
||||
|
@ -957,11 +957,10 @@ set_animation_frame(const string &joint_name,
|
||||
<< nvalues << " for rotation data.\n";
|
||||
return false;
|
||||
}
|
||||
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)));
|
||||
frame_entry._rot.set(-values[0], values[1], values[2], values[3]);
|
||||
table._flags |= XFileAnimationSet::FDF_rot;
|
||||
break;
|
||||
|
||||
|
||||
case 1:
|
||||
if (nvalues != 3) {
|
||||
xfile_cat.error()
|
||||
|
@ -55,11 +55,31 @@ XFileToEgg() :
|
||||
*/
|
||||
&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
|
||||
("cs",
|
||||
"Specify the coordinate system of the input " + _format_name +
|
||||
" file. Normally, this is y-up-left.");
|
||||
|
||||
_frame_rate = 30.0;
|
||||
_coordinate_system = CS_yup_left;
|
||||
}
|
||||
|
||||
@ -75,6 +95,7 @@ run() {
|
||||
XFileToEggConverter converter;
|
||||
converter.set_egg_data(&_data, false);
|
||||
|
||||
converter._frame_rate = _frame_rate;
|
||||
converter._make_char = _make_char;
|
||||
converter._char_name = _char_name;
|
||||
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
public:
|
||||
bool _make_char;
|
||||
string _char_name;
|
||||
double _frame_rate;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user