15 #include "mayaNodeTree.h" 16 #include "mayaBlendDesc.h" 17 #include "mayaEggGroupUserData.h" 18 #include "mayaToEggConverter.h" 19 #include "config_mayaegg.h" 20 #include "maya_funcs.h" 23 #include "eggXfmSAnim.h" 24 #include "eggSAnimData.h" 26 #include "eggSwitchCondition.h" 29 #include "pre_maya_include.h" 30 #include <maya/MString.h> 31 #include <maya/MItDag.h> 32 #include <maya/MSelectionList.h> 33 #include <maya/MGlobal.h> 34 #include "post_maya_include.h" 62 MayaNodeDesc *node_desc = r_build_node(dag_path.fullPathName().asChar());
77 MItDag dag_iterator(MItDag::kDepthFirst, MFn::kTransform, &status);
79 status.perror(
"MItDag constructor");
94 while (!dag_iterator.isDone()) {
96 status = dag_iterator.getPath(dag_path);
98 status.perror(
"MItDag::getPath");
107 _root->check_pseudo_joints(
false);
122 _root->tag_joint_recursively();
137 bool found_any =
false;
140 for (ni = _nodes.begin(); ni != _nodes.end(); ++ni) {
142 if (glob.
matches(node->get_name())) {
143 node->tag_joint_recursively();
159 _root->tag_recursively();
174 bool found_any =
false;
177 for (ni = _nodes.begin(); ni != _nodes.end(); ++ni) {
179 if (glob.
matches(node->get_name())) {
180 node->tag_recursively();
200 bool found_any =
false;
203 for (ni = _nodes.begin(); ni != _nodes.end(); ++ni) {
205 if (glob.
matches(node->get_name())) {
206 node->untag_recursively();
225 MItDag dag_iterator(MItDag::kDepthFirst, MFn::kTransform, &status);
227 status.perror(
"MItDag constructor");
231 MSelectionList selection;
232 status = MGlobal::getActiveSelectionList(selection);
234 status.perror(
"MGlobal::getActiveSelectionList");
238 if (selection.isEmpty()) {
240 <<
"Selection list is empty.\n";
246 unsigned int length = selection.length();
247 for (
unsigned int i = 0; i < length; i++) {
249 status = selection.getDagPath(i, root_path);
251 status.perror(
"MSelectionList::getDagPath");
255 dag_iterator.reset(root_path);
256 while (!dag_iterator.isDone()) {
258 status = dag_iterator.getPath(dag_path);
260 status.perror(
"MItDag::getPath");
271 _root->check_pseudo_joints(
false);
285 return _nodes.size();
296 nassertr(n >= 0 && n < (
int)_nodes.size(), NULL);
314 _nodes_by_path.clear();
329 BlendDescs::iterator bi;
330 for (bi = _blend_descs.
begin(); bi != _blend_descs.
end(); ++bi) {
334 _egg_data = egg_data;
335 _egg_root = egg_root;
336 _skeleton_node = skeleton_node;
337 _morph_node = morph_node;
351 if (node_desc->_egg_group == (
EggGroup *)NULL) {
355 nassertr(node_desc->_parent != (
MayaNodeDesc *)NULL, NULL);
356 egg_group =
new EggGroup(node_desc->get_name());
360 egg_group->set_group_type(EggGroup::GT_joint);
366 if (node_desc->_parent == _root) {
376 DCAST_INTO_R(parent_user_data, parent_egg_group->
get_user_data(), NULL);
385 if (get_enum_attribute(dag_object,
"eggObjectTypes1", object_type)) {
386 egg_group->add_object_type(object_type);
388 if (get_enum_attribute(dag_object,
"eggObjectTypes2", object_type)) {
389 egg_group->add_object_type(object_type);
391 if (get_enum_attribute(dag_object,
"eggObjectTypes3", object_type)) {
392 egg_group->add_object_type(object_type);
395 if(has_attribute(dag_object,
"scrollUV")) {
396 if(get_vec3d_attribute(dag_object,
"scrollUV", value)) {
397 egg_group->set_scroll_u(value[0]);
398 egg_group->set_scroll_v(value[1]);
399 egg_group->set_scroll_r(value[2]);
404 get_tag_attribute_names(dag_object, tag_attribute_names);
405 for (uint ti=0; ti < tag_attribute_names.size(); ti++) {
406 if (get_enum_attribute(dag_object, tag_attribute_names[ti], object_type)) {
407 egg_group->
set_tag(tag_attribute_names[ti].substr(3), object_type);
416 get_bool_attribute(dag_object,
"visibility", visible);
417 if (!visible && egg_group->get_num_object_types() == 0) {
426 egg_group->set_group_type(EggGroup::GT_instance);
427 egg_group->set_billboard_type(EggGroup::BT_axis);
431 egg_group->set_group_type(EggGroup::GT_instance);
432 egg_group->set_billboard_type(EggGroup::BT_point_camera_relative);
436 egg_group->set_group_type(EggGroup::GT_instance);
437 egg_group->set_billboard_type(EggGroup::BT_point_camera_relative);
444 egg_group->set_dcs_type(EggGroup::DC_default);
448 egg_group->set_model_flag(
true);
463 user_data->_vertex_color =
true;
467 user_data->_double_sided =
true;
472 if (node_desc->_is_lod) {
475 node_desc->_switch_out,
479 node_desc->_egg_group = egg_group;
482 return node_desc->_egg_group;
495 nassertr(node_desc->
is_joint(), NULL);
497 if (node_desc->_egg_table == (
EggTable *)NULL) {
499 nassertr(node_desc->_parent != (
MayaNodeDesc *)NULL, NULL);
503 node_desc->_anim->set_fps(_fps);
506 if (!node_desc->_parent->
is_joint()) {
516 node_desc->_egg_table = egg_table;
519 return node_desc->_egg_table;
532 return node_desc->_anim;
549 egg_anim->set_fps(_fps);
552 blend_desc->_anim = egg_anim;
555 return blend_desc->_anim;
577 if (_ignored_slider_names.insert(name).second) {
579 <<
"Ignoring slider " << name <<
"\n";
599 BlendDescs::iterator bi = _blend_descs.insert(blend_desc).first;
613 return _blend_descs.
size();
624 nassertr(n >= 0 && n < (
int)_blend_descs.
size(), NULL);
625 return _blend_descs[n];
636 BlendDescs::iterator bi;
637 for (bi = _blend_descs.
begin(); bi != _blend_descs.
end(); ++bi) {
638 (*bi)->set_slider(0.0);
649 r_build_node(
const string &path) {
652 NodesByPath::const_iterator ni = _nodes_by_path.find(path);
653 if (ni != _nodes_by_path.end()) {
671 size_t bar = path.rfind(
"|");
672 string parent_path, local_name;
673 if (bar != string::npos) {
674 parent_path = path.substr(0, bar);
676 local_name = path.substr(bar + 1);
677 if (local_name == _subroot_parent_name) {
685 if (node_desc != _root) {
686 MayaNodeDesc *parent_node_desc = r_build_node(parent_path);
688 mayaegg_cat.info() <<
"empty parent: " << local_name << endl;
689 node_desc =
new MayaNodeDesc(
this, parent_node_desc, local_name);
690 _nodes.push_back(node_desc);
694 _nodes_by_path.insert(NodesByPath::value_type(path, node_desc));
EggXfmSAnim * get_egg_anim(MayaNodeDesc *node_desc)
Returns the anim table corresponding to the joint for the indicated node.
bool matches(const string &candidate) const
Returns true if the candidate string matches the pattern, false otherwise.
A handle to a Maya blend shape description.
void from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter)
Indicates an association between the MayaNodeDesc and some Maya instance.
void tag_all()
Tags the entire hierarchy for conversion.
int get_num_nodes() const
Returns the total number of nodes in the hierarchy, not counting the root node.
bool ignore_slider(const string &name) const
Returns true if the indicated name is on the list of sliders to ignore, false otherwise.
bool ignore_slider(const string &name) const
Returns true if the indicated name is on the list of sliders to ignore, false otherwise.
size_type_0 size() const
Returns the number of elements in the ordered vector.
bool has_object_type(const string &object_type) const
Returns true if the indicated object type has been added to the group, or false otherwise.
A base class for nodes in the hierarchy that are not leaf nodes.
void clear()
Resets the entire tree in preparation for repopulating with a new scene.
iterator_0 begin()
Returns the iterator that marks the first element in the ordered vector.
CoordinateSystem get_coordinate_system() const
Returns the coordinate system in which the egg file is defined.
Corresponding to an <S$Anim> entry, this stores a single column of numbers, for instance for a morph ...
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
EggGroup * get_egg_group(MayaNodeDesc *node_desc)
Returns the EggGroupNode corresponding to the group or joint for the indicated node.
This is the primary interface into all the egg data, and the root of the egg file structure...
bool has_dag_path() const
Returns true if a Maya dag path has been associated with this node, false otherwise.
void clear_egg(EggData *egg_data, EggGroupNode *egg_root, EggGroupNode *skeleton_node, EggGroupNode *morph_node)
Removes all of the references to generated egg structures from the tree, and prepares the tree for ge...
bool tag_named(const GlobPattern &glob)
Tags nodes matching the indicated glob (and all of their children) for conversion.
bool has_user_data() const
Returns true if a generic user data pointer has recently been set and not yet cleared, false otherwise.
MayaNodeDesc * build_node(const MDagPath &dag_path)
Returns a pointer to the node corresponding to the indicated dag_path object, creating it first if ne...
bool remove_object_type(const string &object_type)
Removes the first instance of the indicated object type from the group if it is present.
MayaBlendDesc * get_blend_desc(int n) const
Returns the nth MayaBlendDesc object discovered in the tree.
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
void reset_sliders()
Resets all of the sliders associated with all blend shapes down to 0.
MayaBlendDesc * add_blend_desc(MayaBlendDesc *blend_desc)
Adds the indicated MayaBlendDesc object to the list of blends collected so far.
Describes a single instance of a node in the Maya scene graph, relating it to the corresponding egg s...
bool is_joint() const
Returns true if the node should be treated as a joint by the converter.
int get_num_blend_descs() const
Returns the number of unique MayaBlendDesc objects (and hence the number of morph sliders) discovered...
AnimationConvert get_animation_convert() const
Returns how source animation will be converted into egg structures.
This corresponds to an <Xfm$Anim_S$> entry, which is a collection of up to nine <S$Anim> entries that...
EggUserData * get_user_data() const
Returns the user data pointer most recently stored on this object, or NULL if nothing was previously ...
MayaNodeDesc * get_node(int n) const
Returns the nth node in the hierarchy, in an arbitrary ordering.
static const LPoint3d & zero()
Returns a zero-length point.
bool tag_joint_named(const GlobPattern &glob)
Tags nodes matching the indicated glob (and all of their children) for conversion.
const MDagPath & get_dag_path() const
Returns the dag path associated with this node.
void set_visibility_mode(VisibilityMode mode)
Specifies whether this geometry is to be considered normally visible, or hidden.
bool build_hierarchy()
Walks through the complete Maya hierarchy but does not tag any nodes for conversion.
void set_tag(const string &key, const string &value)
Associates a user-defined value with a user-defined key which is stored on the node.
This class supervises the construction of an EggData structure from a single Maya file...
void set_user_data(EggUserData *user_data)
Sets the user data associated with this object.
bool untag_named(const GlobPattern &glob)
Un-tags nodes matching the indicated glob (and all of their children) for conversion.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
EggNode * add_child(EggNode *node)
Adds the indicated child to the group and returns it.
EggTable * get_egg_table(MayaNodeDesc *node_desc)
Returns the EggTable corresponding to the joint for the indicated node.
EggSAnimData * get_egg_slider(MayaBlendDesc *blend_desc)
Returns the anim table corresponding to the slider for the indicated blend.
void tag_joint_all()
Tags the entire hierarchy for conversion.
void report_ignored_slider(const string &name)
Outputs a message to the user reporting that a slider was ignored.
A SwitchCondition that switches the levels-of-detail based on distance from the camera's eyepoint...
This class contains extra user data which is piggybacked onto EggGroup objects for the purpose of the...
bool tag_selected()
Tags the just the selected hierarchy for conversion, or the entire hierarchy if nothing is selected...
This class can be used to test for string matches against standard Unix-shell filename globbing conve...