0

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

问题是我无法将 my 转换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);

我没有找到将 my 转换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++ 新手,所以我可能犯了一个愚蠢的错误。

4

1 回答 1

0

MFnBaseClass不允许使用转换为指针,而是使用几乎相同的引用。有关更多信息,请参阅引用与指针

我的函数的正确签名

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");
}
于 2016-06-06T11:01:57.340 回答