Re: [Maya2osg-users] Discussion of next changes
Status: Alpha
Brought to you by:
jtaibo
From: Javier T. <jav...@gm...> - 2011-05-29 08:26:54
|
Hi J-S On Sun, May 29, 2011 at 5:15 AM, Jean-Sébastien Guay <jea...@cm...> wrote: > > OK, I'll do it the hard way, it doesn't matter that much because it's > not performance-critical code but I would have throught there was a > way... It feels like I'm doing a series of dynamic_casts to find out the > true concrete type of an object... It *should* be a way. Maybe it is. But I don't know it. >> However, I don't think that exporting all extra attributes is a good >> idea. There are utilities that generate lots of attributes. I would >> focus on the attributes defined by the exporter, maybe naming them >> with a prefix to identify them (tough we can remove the prefix when >> creating the OSG descriptions). > > A prefix is a good idea. I just don't want to have to hard-code > attribute names in the plugin. But if I export any attribute that starts > with say "maya2osg_" that would be ok, is that ok for you? Perfect! >> I don't know if I am understanding you correctly. Is exporting all >> "Extra attributes" what you are proposing? How do you identify what >> attributes are "extra attributes", btw? > > From an MFnDependencyNode, I can do: > > unsigned int count = dnodefn.attributeCount(); > for (unsigned int i = 0; i < count; ++i) > { > MObject attr = dnodefn.attribute(i); > MAttrClass attrClass = dnodefn.attributeClass(attr); > if (attrClass == MFnDependencyNode::kLocalDynamicAttr) > { > // This is a custom attribute (i.e. not part of the normal list > // of attributes for this type of node). > // Also the notes attribute is one of these. > } > } > > So the MFnDependencyNode::MAttrClass enum gives the type of an attribute > when iterating through all attributes of a node. kLocalDynamicAttr is > documented as "Dynamically added, applies to this specific node." and I > verified that when iterating through attributes of a node in a maya > scene being exported, this was the class returned for custom attributes > (added by addAttr or the Attributes menu) as well as the notes. Other > attributes (there were almost 200 on the node I checked) did not have > this class. Interesting. I didn't know that. Quite useful. Regards, -- Javier Taibo |