added the support for arbitrary attributes defined by artists that has a prefix called <tag>; i.e. tagHoliday Christmas2008 is tagged on the group node as <Tag> Holiday {Christmas2008}
This commit is contained in:
parent
29969b0fa5
commit
5148938ae9
|
|
@ -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<string> &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
|
||||
|
|
|
|||
|
|
@ -81,6 +81,9 @@ bool
|
|||
get_mat4d_attribute(MObject &node, const string &attribute_name,
|
||||
LMatrix4d &value);
|
||||
|
||||
void
|
||||
get_tag_attribute_names(MObject &node, pvector<string> &tag_names);
|
||||
|
||||
bool
|
||||
get_enum_attribute(MObject &node, const string &attribute_name,
|
||||
string &value);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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<string> 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue