diff --git a/pandatool/src/maya/maya_funcs.cxx b/pandatool/src/maya/maya_funcs.cxx index bb0a095259..7d1afb173f 100644 --- a/pandatool/src/maya/maya_funcs.cxx +++ b/pandatool/src/maya/maya_funcs.cxx @@ -375,6 +375,40 @@ get_mat4d_attribute(MObject &node, const string &attribute_name, return true; } +//////////////////////////////////////////////////////////////////// +// Function: get_tag_attribute_names +// Description: artists should be able to set arbitrary tags. +// Query all the attributes on this object and return +// the lists of attribute names that has "tag" prefix +//////////////////////////////////////////////////////////////////// +void +get_tag_attribute_names(MObject &node, pvector &tag_names) { + MStatus status; + MFnDependencyNode node_fn(node, &status); + if (!status) { + maya_cat.warning() + << "Object is a " << node.apiTypeStr() << ", not a DependencyNode.\n"; + return; + } + + string name = node_fn.name().asChar(); + unsigned i; + + for (i = 0; i < node_fn.attributeCount(); i++) { + MObject attr = node_fn.attribute(i, &status); + if (status) { + MFnAttribute attrib(attr, &status); + if (status) { + string attribute_name = attrib.name().asChar(); + if (attribute_name.find("tag", 0) != string::npos) { + maya_cat.info() << ":" << name << ":" << " is tagged with <" + << attribute_name << ">" << endl; + tag_names.push_back(attribute_name); + } + } + } + } +} //////////////////////////////////////////////////////////////////// // Function: get_enum_attribute // Description: Extracts the enum attribute from the MObject as a diff --git a/pandatool/src/maya/maya_funcs.h b/pandatool/src/maya/maya_funcs.h index 79d924da59..f8f1a01073 100644 --- a/pandatool/src/maya/maya_funcs.h +++ b/pandatool/src/maya/maya_funcs.h @@ -81,6 +81,9 @@ bool get_mat4d_attribute(MObject &node, const string &attribute_name, LMatrix4d &value); +void +get_tag_attribute_names(MObject &node, pvector &tag_names); + bool get_enum_attribute(MObject &node, const string &attribute_name, string &value); diff --git a/pandatool/src/mayaegg/mayaEggLoader.cxx b/pandatool/src/mayaegg/mayaEggLoader.cxx index bd2f3076cc..4d942967b8 100755 --- a/pandatool/src/mayaegg/mayaEggLoader.cxx +++ b/pandatool/src/mayaegg/mayaEggLoader.cxx @@ -1578,7 +1578,7 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a mesh->_transNode = parent; } - // [gjeon] add eggFlag attributes it any exists + // [gjeon] add eggFlag attributes if any exists for (unsigned i = 0; i < mesh->_eggObjectTypes.length(); i++) { MString attrName = "eggObjectTypes"; attrName += (int)(i + 1); @@ -1675,7 +1675,7 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a surface->_transNode = parent; } - // [gjeon] add eggFlag attributes it any exists + // [gjeon] add eggFlag attributes if any exists for (unsigned i = 0; i < surface->_eggObjectTypes.length(); i++) { MString attrName = "eggObjectTypes"; attrName += (int)(i + 1); diff --git a/pandatool/src/mayaegg/mayaNodeTree.cxx b/pandatool/src/mayaegg/mayaNodeTree.cxx index f50cb0f3f2..f3439b6962 100755 --- a/pandatool/src/mayaegg/mayaNodeTree.cxx +++ b/pandatool/src/mayaegg/mayaNodeTree.cxx @@ -390,6 +390,13 @@ get_egg_group(MayaNodeDesc *node_desc) { if (get_enum_attribute(dag_object, "eggObjectTypes3", object_type)) { egg_group->add_object_type(object_type); } + pvector tag_attribute_names; + get_tag_attribute_names(dag_object, tag_attribute_names); + for (uint ti=0; ti < tag_attribute_names.size(); ti++) { + if (get_enum_attribute(dag_object, tag_attribute_names[ti], object_type)) { + egg_group->set_tag(tag_attribute_names[ti].substr(3), object_type); + } + } // Is the node flagged to be invisible? If it is, it is tagged // with the "hidden" visibility flag, so it won't get converted