add -force-joint

This commit is contained in:
David Rose 2005-01-24 00:26:49 +00:00
parent f2c3f1a18e
commit de5b77dc2c
7 changed files with 84 additions and 5 deletions

View File

@ -19,6 +19,7 @@
#include "mayaNodeDesc.h"
#include "mayaNodeTree.h"
#include "mayaBlendDesc.h"
#include "mayaToEggConverter.h"
#include "maya_funcs.h"
#include "config_mayaegg.h"
@ -88,14 +89,24 @@ MayaNodeDesc::
// some Maya instance.
////////////////////////////////////////////////////////////////////
void MayaNodeDesc::
from_dag_path(const MDagPath &dag_path) {
from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter) {
MStatus status;
if (_dag_path == (MDagPath *)NULL) {
_dag_path = new MDagPath(dag_path);
if (_dag_path->hasFn(MFn::kJoint)) {
// This node is a joint.
string name;
MFnDagNode dag_node(dag_path, &status);
if (!status) {
status.perror("MFnDagNode constructor");
} else {
name = dag_node.name().asChar();
cerr << "node " << name << "\n";
}
if (_dag_path->hasFn(MFn::kJoint) || converter->force_joint(name)) {
// This node is a joint, or the user specifically asked to treat
// it like a joint.
_joint_type = JT_joint;
if (_parent != (MayaNodeDesc *)NULL) {
_parent->mark_joint_parent();

View File

@ -31,6 +31,7 @@
#include <maya/MFnDagNode.h>
#include "post_maya_include.h"
class MayaToEggConverter;
class MayaNodeTree;
class EggGroup;
class EggTable;
@ -49,7 +50,7 @@ public:
MayaNodeDesc *parent = NULL, const string &name = string());
~MayaNodeDesc();
void from_dag_path(const MDagPath &dag_path);
void from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter);
bool has_dag_path() const;
const MDagPath &get_dag_path() const;

View File

@ -63,7 +63,7 @@ MayaNodeTree(MayaToEggConverter *converter) :
MayaNodeDesc *MayaNodeTree::
build_node(const MDagPath &dag_path) {
MayaNodeDesc *node_desc = r_build_node(dag_path.fullPathName().asChar());
node_desc->from_dag_path(dag_path);
node_desc->from_dag_path(dag_path, _converter);
return node_desc;
}

View File

@ -111,6 +111,7 @@ MayaToEggConverter(const MayaToEggConverter &copy) :
_from_selection(copy._from_selection),
_subsets(copy._subsets),
_ignore_sliders(copy._ignore_sliders),
_force_joints(copy._force_joints),
_tree(this),
_maya(copy._maya),
_polygon_output(copy._polygon_output),
@ -284,6 +285,52 @@ ignore_slider(const string &name) const {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: MayaToEggConverter::clear_force_joints
// Access: Public
// Description: Empties the list of force_joints added via
// add_force_joint(). No joints will be forced.
////////////////////////////////////////////////////////////////////
void MayaToEggConverter::
clear_force_joints() {
_force_joints.clear();
}
////////////////////////////////////////////////////////////////////
// Function: MayaToEggConverter::add_force_joint
// Access: Public
// Description: Adds a name pattern to the list of force_joints.
//
// Any DAG node that matches a name on the list will be
// treated as if it were a joint during the conversion
// process; it will receive animation and position
// information. Normally, a true Maya joint, as well as
// any DAG nodes whose transforms are animated, will
// automatically be flagged as a Panda joint.
////////////////////////////////////////////////////////////////////
void MayaToEggConverter::
add_force_joint(const GlobPattern &glob) {
_force_joints.push_back(glob);
}
////////////////////////////////////////////////////////////////////
// Function: MayaToEggConverter::force_joint
// Access: Public
// Description: Returns true if the indicated name is on the list of
// DAG nodes to treat as a joint, false otherwise.
////////////////////////////////////////////////////////////////////
bool MayaToEggConverter::
force_joint(const string &name) const {
Globs::const_iterator gi;
for (gi = _force_joints.begin(); gi != _force_joints.end(); ++gi) {
if ((*gi).matches(name)) {
return true;
}
}
return false;
}
////////////////////////////////////////////////////////////////////
// Function: MayaToEggConverter::set_from_selection
// Access: Public

View File

@ -84,6 +84,10 @@ public:
void add_ignore_slider(const GlobPattern &glob);
bool ignore_slider(const string &name) const;
void clear_force_joints();
void add_force_joint(const GlobPattern &glob);
bool force_joint(const string &name) const;
void set_from_selection(bool from_selection);
bool convert_maya();
@ -144,6 +148,7 @@ private:
typedef pvector<GlobPattern> Globs;
Globs _subsets;
Globs _ignore_sliders;
Globs _force_joints;
MayaNodeTree _tree;

View File

@ -103,6 +103,13 @@ MayaToEgg() :
"as needed.",
&MayaToEgg::dispatch_vector_string, NULL, &_ignore_sliders);
add_option
("force-joint", "name", 0,
"Specifies the name of a DAG node that maya2egg "
"should treat as a joint, even if it does not appear to be a Maya joint "
"and does not appear to be animated.",
&MayaToEgg::dispatch_vector_string, NULL, &_force_joints);
add_option
("v", "", 0,
"Increase verbosity. More v's means more verbose.",
@ -174,6 +181,13 @@ run() {
}
}
if (!_force_joints.empty()) {
converter.clear_force_joints();
for (si = _force_joints.begin(); si != _force_joints.end(); ++si) {
converter.add_force_joint(GlobPattern(*si));
}
}
// Copy in the path and animation parameters.
apply_parameters(converter);

View File

@ -44,6 +44,7 @@ protected:
MayaToEggConverter::TransformType _transform_type;
vector_string _subsets;
vector_string _ignore_sliders;
vector_string _force_joints;
};
#endif