mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 08:44:19 -04:00
more on animated models
This commit is contained in:
parent
623c59ee8f
commit
b4203252e2
@ -89,6 +89,30 @@ get_animation_convert() const {
|
||||
return _animation_convert;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SomethingToEggConverter::set_character_name
|
||||
// Access: Public
|
||||
// Description: Specifies the name of the character generated. This
|
||||
// name should match between all the model and channel
|
||||
// egg files for a particular character and its
|
||||
// associated animations.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void SomethingToEggConverter::
|
||||
set_character_name(const string &character_name) {
|
||||
_character_name = character_name;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SomethingToEggConverter::get_character_name
|
||||
// Access: Public
|
||||
// Description: Returns the name of the character generated. See
|
||||
// set_character_name().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const string &SomethingToEggConverter::
|
||||
get_character_name() const {
|
||||
return _character_name;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SomethingToEggConverter::set_start_frame
|
||||
// Access: Public
|
||||
|
@ -62,6 +62,9 @@ public:
|
||||
INLINE void set_animation_convert(AnimationConvert animation_convert);
|
||||
INLINE AnimationConvert get_animation_convert() const;
|
||||
|
||||
INLINE void set_character_name(const string &character_name);
|
||||
INLINE const string &get_character_name() const;
|
||||
|
||||
INLINE void set_start_frame(double start_frame);
|
||||
INLINE bool has_start_frame() const;
|
||||
INLINE double get_start_frame() const;
|
||||
@ -132,6 +135,7 @@ protected:
|
||||
Filename _mpc_directory;
|
||||
|
||||
AnimationConvert _animation_convert;
|
||||
string _character_name;
|
||||
double _start_frame;
|
||||
double _end_frame;
|
||||
double _frame_inc;
|
||||
|
@ -110,6 +110,13 @@ add_animation_options() {
|
||||
"are supported: none, pose, or flip.",
|
||||
&SomethingToEgg::dispatch_animation_convert, NULL, &_animation_convert);
|
||||
|
||||
add_option
|
||||
("cn", "name", 40,
|
||||
"Specifies the name of the animation character. This should match "
|
||||
"between all of the model files and all of the channel files for a "
|
||||
"particular model and its associated channels.",
|
||||
&SomethingToEgg::dispatch_string, NULL, &_character_name);
|
||||
|
||||
add_option
|
||||
("sf", "start-frame", 40,
|
||||
"Specifies the starting frame of animation to extract. If omitted, "
|
||||
|
@ -69,6 +69,7 @@ protected:
|
||||
DistanceUnit _output_units;
|
||||
|
||||
AnimationConvert _animation_convert;
|
||||
string _character_name;
|
||||
double _start_frame;
|
||||
double _end_frame;
|
||||
double _frame_inc;
|
||||
|
@ -160,6 +160,11 @@ convert_file(const Filename &filename) {
|
||||
<< "Unable to read " << filename << "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_character_name.empty()) {
|
||||
_character_name = filename.get_basename_wo_extension();
|
||||
}
|
||||
|
||||
return convert_maya();
|
||||
}
|
||||
|
||||
@ -229,12 +234,13 @@ convert_maya() {
|
||||
|
||||
case AC_none:
|
||||
// none: just get out a static model, no animation.
|
||||
// fall through
|
||||
all_ok = convert_hierarchy(&get_egg_data());
|
||||
break;
|
||||
|
||||
case AC_model:
|
||||
// model: get out an animatable model with joints and vertex
|
||||
// membership.
|
||||
all_ok = convert_hierarchy(&get_egg_data());
|
||||
all_ok = convert_char_model();
|
||||
break;
|
||||
|
||||
case AC_flip:
|
||||
@ -285,6 +291,21 @@ close_api() {
|
||||
_maya.clear();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MayaToEggConverter::convert_char_model
|
||||
// Access: Private
|
||||
// Description: Converts the animation as an animatable character
|
||||
// model, with joints and vertex membership.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool MayaToEggConverter::
|
||||
convert_char_model() {
|
||||
EggGroup *char_node = new EggGroup(_character_name);
|
||||
get_egg_data().add_child(char_node);
|
||||
char_node->set_dart_type(EggGroup::DT_default);
|
||||
|
||||
return convert_hierarchy(char_node);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MayaToEggConverter::convert_flip
|
||||
// Access: Private
|
||||
@ -301,7 +322,7 @@ convert_flip(double start_frame, double end_frame, double frame_inc,
|
||||
double output_frame_rate) {
|
||||
bool all_ok = true;
|
||||
|
||||
EggGroup *sequence_node = new EggGroup("model");
|
||||
EggGroup *sequence_node = new EggGroup(_character_name);
|
||||
get_egg_data().add_child(sequence_node);
|
||||
sequence_node->set_switch_flag(true);
|
||||
sequence_node->set_switch_fps(output_frame_rate / frame_inc);
|
||||
@ -443,24 +464,29 @@ process_node(const MDagPath &dag_path, EggGroupNode *egg_root) {
|
||||
}
|
||||
|
||||
} else if (dag_path.hasFn(MFn::kNurbsCurve)) {
|
||||
EggGroup *egg_group = get_egg_group(dag_path, egg_root);
|
||||
|
||||
if (egg_group == (EggGroup *)NULL) {
|
||||
nout << "Cannot determine group node.\n";
|
||||
|
||||
} else {
|
||||
get_transform(dag_path, egg_group);
|
||||
|
||||
MFnNurbsCurve curve(dag_path, &status);
|
||||
if (!status) {
|
||||
mayaegg_cat.info()
|
||||
<< "Error in node " << dag_path.fullPathName() << ":\n"
|
||||
<< " it appears to have a NURBS curve, but does not.\n";
|
||||
// Only convert NurbsCurves if we aren't making an animated model.
|
||||
// Animated models, as a general rule, don't want these sorts of
|
||||
// things in them.
|
||||
if (_animation_convert != AC_model) {
|
||||
EggGroup *egg_group = get_egg_group(dag_path, egg_root);
|
||||
|
||||
if (egg_group == (EggGroup *)NULL) {
|
||||
nout << "Cannot determine group node.\n";
|
||||
|
||||
} else {
|
||||
make_nurbs_curve(dag_path, curve, egg_group, egg_root);
|
||||
get_transform(dag_path, egg_group);
|
||||
|
||||
MFnNurbsCurve curve(dag_path, &status);
|
||||
if (!status) {
|
||||
mayaegg_cat.info()
|
||||
<< "Error in node " << dag_path.fullPathName() << ":\n"
|
||||
<< " it appears to have a NURBS curve, but does not.\n";
|
||||
} else {
|
||||
make_nurbs_curve(dag_path, curve, egg_group, egg_root);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else if (dag_path.hasFn(MFn::kMesh)) {
|
||||
EggGroup *egg_group = get_egg_group(dag_path, egg_root);
|
||||
|
||||
|
@ -69,6 +69,7 @@ public:
|
||||
void close_api();
|
||||
|
||||
private:
|
||||
bool convert_char_model();
|
||||
bool convert_flip(double start_frame, double end_frame, double frame_inc,
|
||||
double output_frame_rate);
|
||||
bool convert_hierarchy(EggGroupNode *egg_root);
|
||||
|
@ -100,6 +100,7 @@ run() {
|
||||
|
||||
// Copy in the animation parameters.
|
||||
converter.set_animation_convert(_animation_convert);
|
||||
converter.set_character_name(_character_name);
|
||||
if (_got_start_frame) {
|
||||
converter.set_start_frame(_start_frame);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user