PDA

View Full Version : correct syntax for MFnMesh::booleanOp


davegreenwood
08-17-2009, 08:14 PM
Hi All, perhaps a bit of a basic c++ question this but I can't get the proper use of the enumerated type as passed to the booleanOp function. I tried:

MFnMesh meshFS;

//empty meshdata
numFaces=0;
numVertices=0;
points.clear();
faceCounts.clear();
faceConnects.clear();

MObject newMesh = meshFS.create(numVertices, numFaces,
points, faceCounts, faceConnects,
outData, &stat);


MFnMesh::BoolOperation bop = MFnMesh::kIntersection;
meshFS.booleanOp(bop, meshA, meshB );


but that doesn't work. Sorry if it's a basic question but I can't find a single example anywhere...

Thanks for any help
Dave.

cbamber85
08-17-2009, 09:56 PM
Shouldn't it just be:
meshFS.booleanOp(MFnMesh::kIntersection, meshA, meshB);
Can't test it at the mo though. It would have been helpful to have an error output! :)

davegreenwood
08-17-2009, 10:25 PM
Hi thanks for getting back, well I've tried that one also.
meshFS.booleanOp(MFnMesh::kIntersection, meshA, meshB);
It produces this error:
error: no matching function for call to 'MFnMesh::booleanOp(MFnMesh::BoolOperation, MObject&, MObject&)'
note: candidates are: MStatus MFnMesh::booleanOp(MFnMesh::BoolOperation, MFnMesh&, MFnMesh&)


which means the wrong argument is passed.
I must of tried it a hundred ways, but not the right one yet:banghead:
And can I find an example... apparently nobody on the www has posted any little snippet using this method??
I'm also trying to check through the required headers, but I think I have what's needed.
I'm sure it's a simple thing, but so far, it eludes me!


thanks again for responding
Dave.

davegreenwood
08-18-2009, 09:07 AM
the plot thickens...

MObject bool::createBoolMesh(MObject meshA, MObject meshB, MObject& outData, MStatus& stat)
{

int numVertices;
int numFaces;
MFloatPointArray points;
MIntArray faceCounts;
MIntArray faceConnects;

MFnMesh meshFS;

//empty meshdata
numFaces=0;
numVertices=0;
points.clear();
faceCounts.clear();
faceConnects.clear();

MObject newMesh = meshFS.create(numVertices, numFaces,
points, faceCounts, faceConnects,
outData, &stat);

MFnMesh A(meshA);
MFnMesh B(meshB);
stat = meshFS.booleanOp(MFnMesh::kIntersection, A, B );

return newMesh;
}


after looking at the error, I noticed that it was not the boolean argument at fault... I was passing mesh data in as an MObject whereas it should be MFnMesh(I think).

Now, in use, if I connect a cube to A and a sphere to B... I get a beautiful union... not right. I know the result is in my empty mesh because that's what I'm returning from the function. Order shouldn't matter with intersection, as it's the data common to both??

So now I'm past the syntax but I'm into an issue of concept.


All help gratefully received:)
Dave

davegreenwood
08-18-2009, 01:40 PM
hmm, perhaps I'm not getting something here, but when I want a polyshape that has a volume common to the volumes of two others I need to do this:


int numVertices;
int numFaces;
MFloatPointArray points;
MIntArray faceCounts;
MIntArray faceConnects;

MFnMesh A(meshA);
MFnMesh B(meshB);

MFnMesh meshFn;

//empty meshdata
numFaces=0;
numVertices=0;
points.clear();
faceCounts.clear();
faceConnects.clear();

MObject newMesh = meshFn.create(numVertices, numFaces,
points, faceCounts, faceConnects,
outData, &stat);

stat = meshFn.booleanOp(MFnMesh::kUnion, A, B );

return newMesh;


here's what I mean:
http://lh6.ggpht.com/_BvtzOLkIACs/Soqu3rVpCuI/AAAAAAAAARg/mMYgLyWjgsM/s400/intersection.png

the shape on the right being the result... oh well.

Dave.

CGTalk Moderation
08-18-2009, 01:40 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.