创建指向MFnMesh的指针

时间:2016-06-06 09:19:56

标签: c++ pointers maya maya-api

我正在尝试创建接收MFnMesh指针并在其上执行操作的功能。

问题在于我无法将我的MFnMesh转换为指针,我认为问题不仅存在于此类上,而且存在于MFnBaseClass上,因为我收到此错误。

/usr/autodesk/maya2015-x64/include/maya/MFnBase.h:168:14: error: ‘MFnMesh* MFnMesh::operator&() const’ is private
   MFnClass * operator& () const
              ^
/usr/autodesk/maya2015-x64/include/maya/MFnDagNode.h:237:2: note: in expansion of macro ‘declareMinimalMFn’
  declareMinimalMFn( MFnClass );          \
  ^
/usr/autodesk/maya2015-x64/include/maya/MFnMesh.h:243:2: note: in expansion of macro ‘declareDagMFn’
  declareDagMFn(MFnMesh, MFnDagNode);
  ^
/home/k.masson/Documents/maya/km_extendedColorSet/src/km_particlesToColorSet.cpp:159:9: error: within this context
   test(&meshFn);
         ^

这是函数测试,它位于somefile.h中并包含在调用该函数的文件中。

void test(MFnMesh * meshFn){
  MStatus status = MS::kSuccess;
  MString csName("YOLOSWAQDAZD");
  status = meshFn->createColorSetDataMesh(csName);
  MCheckStatus(status,"Error creating new color set");
}

以下是我在调用test函数之前所做的事情。

// Get the out mesh data
        MDataHandle outMeshHandle = data.outputValue(aOutGeometry, &status);
        MCheckStatus(status,"ERROR getting aOutGeometry");

        // Copy the in mesh to the output
        outMeshHandle.copy(inMeshData);

        // Create a function set for the out mesh
        MFnMesh meshFn(outMeshHandle.asMesh());
        test(&meshFn);

我没有找到任何方法将MFnMesh转换为指针,所以我试图将其直接称为对象,而不是像这样的指针。

test(meshFn);

void test(MFnMesh meshFn){
  MStatus status = MS::kSuccess;
  MString csName("YOLOSWAQDAZD");
  status = meshFn.createColorSetDataMesh(csName);
  MCheckStatus(status,"Error creating new color set");
}

我明白了:

/usr/autodesk/maya2015-x64/include/maya/MFnMesh.h:243:16: error: ‘MFnMesh::MFnMesh(const MFnMesh&)’ is private
  declareDagMFn(MFnMesh, MFnDagNode);
                ^
/usr/autodesk/maya2015-x64/include/maya/MFnBase.h:166:9: note: in definition of macro ‘declareMinimalMFn’
         MFnClass( const MFnClass &rhs );                            \
         ^
/usr/autodesk/maya2015-x64/include/maya/MFnMesh.h:243:2: note: in expansion of macro ‘declareDagMFn’
  declareDagMFn(MFnMesh, MFnDagNode);
  ^
/home/k.masson/Documents/maya/km_extendedColorSet/src/km_particlesToColorSet.cpp:159:14: error: within this context
   test(meshFn);
              ^
In file included from /home/k.masson/Documents/maya/km_extendedColorSet/src/km_particlesToColorSet.cpp:29:0:
/home/k.masson/Documents/maya/km_extendedColorSet/src/kmColorSetTool.h:29:6: error:   initializing argument 1 of ‘void test(MFnMesh)’
 void test(MFnMesh meshFn){

那么你知道吗是否有创建一个以时尚方式作用于MFnBase的函数,或者甚至是具有MFnBase属性的类?我不知道我们不能做这种真正当前的过程。

我是c ++的新手,所以我可能会犯一个愚蠢的错误。

1 个答案:

答案 0 :(得分:0)

MFnBaseClass不允许将转换用于指针,而使用引用,其工作方式几乎相同。有关详细信息,请参阅References vs. Pointers

我的功能的正确签名

void test(MFnMesh& meshFn)

使用它的方法是

test(meshFn);

要在函数中使用引用,只需将其用作常规对象

void test(MFnMesh& meshFn){
  MStatus status = MS::kSuccess;
  MString csName("YOLOSWAQDAZD");
  status = meshFn.createColorSetDataMesh(csName);
  MCheckStatus(status,"Error creating new color set");
}