Feedback

What's your question?

By: [ Admin ] Asked from India

Whats the best way to get the bounding box of a mesh with the Maya API?

I'm writing a Maya plug-in node that has a mesh input and I need to get its bounding box. MFnMesh has a boundingBox() method inherited from MFnDagNode, but it fails. I'm pretty sure the mesh function set is valid and attached to a mesh object.

Any ideas?

Add comment viewed 1,047 times Latest activity 11 months ago

or Cancel

1 answer

  • 1

mr grumpy [ Editor ]

I think boundingBox will only work if the MFnMesh is attached to a dagNode, rather than mesh data coming through the DG; you have to have used the MFnMesh(const MDagPath &) constructor. I would've said use MFnMesh::getPoints and manually compute it. It must be a recent addition, but I just noticed there's also MFnMesh::getRawPoints which provides access to the internal vertex array to avoid the copy. That only supplies floats, so hopefully they mean a rendering representation and they're not converting all doubles down to floats in MFnMesh::setPoints.

NN comments
julian
-

Thanks. You are right it seems. I tried everything I could to get the dag node from the meshData with the exception of tracing back through the connection. In the end I did as you suggested and made the BB from the points. (MBoundingBox::expand() in a loop). The time to build it is not critical because compared to all the intersection tests I’m also doing its plenty fast enough.

Its interesting what you about setPoints(). I’m guessing they are converted to floats in setPoints() – otherwise there would be a: const double * getRawPoints() no?

or Cancel