在使用Maya API的cpp类中,我启动一个名为myLocatorNode的自定义MPxLocator实例,并将其属性传递给一些变量:
MDagModifier dagMod;
MDGModifier mdgMod;
myObj=dagMod.createNode("myLocatorNode", <existing transform MObject>);
dagMod.doIt();
MFnDagNode myDagNode(myObj);
myDagNode.findPlug("attributeOne").setValue(1.5);
myDagNode.findPlug("attributeTwo").setValue(2.0);
myDagNode.findPlug("attributeThree").setValue(3.1);
myDagNode.findPlug("classAttrib").setValue(classPointer); // <- which type should I use ?
自定义定位器类:
MStatus myLocatorNode::initialize()
{
MFnNumericAttribute nAttr;
MFn???Attribute customAttr; <-- What can I use here ?
attr1= nAttr.create( "attributeOne", "ao", MFnNumericData::kFloat,1.0 );
attr2= nAttr.create( "attributeTwo", "ao", MFnNumericData::kFloat,1.0 );
attr3= nAttr.create( "attributeThree", "ao", MFnNumericData::kFloat,1.0 );
attr4= customAttr.create("classAttrib","ca", MyCustomClass *); <-- and here ?
...
}
我想传递属性/插入指向自定义类的指针。 locator类中的哪个属性类型可以帮助我做到这一点? 感谢
答案 0 :(得分:1)
MFn ???属性customAttr; &lt; - 我可以在这里使用什么?
嗯,通过类指针你的意思是一个内存地址?在x64位机器上,指针是一个int64,所以你需要存储一个int64整数。您可以使用MFnNumericAttribute :: createAddress()方式或存储您自己的int64,如下所述:http://around-the-corner.typepad.com/adn/2012/11/no-64bit-integer-attribute-in-maya-no-way.html