Re: [Maya2osg-users] Discussion of next changes
Status: Alpha
Brought to you by:
jtaibo
|
From: Jean-Sébastien G. <jea...@cm...> - 2011-05-29 03:15:31
|
Hi Javier,
> I don't know a way of querying the type of an attribute, sorry.
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...
> 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?
> 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.
> About the "notes" field, yes I would export it like the other custom
> attributes.
Great. Thanks,
J-S
--
______________________________________________________
Jean-Sebastien Guay jea...@cm...
http://www.cm-labs.com/
http://whitestar02.dyndns-web.com/
|