【问题标题】:Pass custom data to attributes of MPxLocator (Maya API)将自定义数据传递给 MPxLocator (Maya API) 的属性
【发布时间】:2015-07-08 11:12:25
【问题描述】:

在使用 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 ?
        ...   

    }

我想将指向自定义类的指针传递给属性/插入。定位器类中的哪个属性类型可以帮助我做到这一点? 谢谢

【问题讨论】:

    标签: c++ attributes maya-api


    【解决方案1】:

    MFn???属性 customAttr;

    嗯,类指针是指内存地址吗?在 x64 位机器上,指针是 int64,因此您需要存储一个 int64 整数。您可以使用 MFnNumericAttribute::createAddress() 方式或存储您自己的 int64,如下所述:http://around-the-corner.typepad.com/adn/2012/11/no-64bit-integer-attribute-in-maya-no-way.html

    【讨论】:

      猜你喜欢
      • 2021-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-14
      • 1970-01-01
      • 1970-01-01
      • 2019-12-17
      相关资源
      最近更新 更多