Hello People,
Am back with a new question.
As a part of my previous post, I have been trying to create a custom cluster deformer(the move tool from my previous post is intended to move this cluster across), and have been able to move the mesh points based on the deformerHandle(locator). I can paint the weights and animate the envelope value, it all works. But as far as the behavior is concerned it does not work like the native clusterDeformer. Here is the part of code that makes it work
MStatus magnet::deform(MDataBlock &data,
MItGeometry &iter,
const MMatrix &localToWorld,
unsigned int geomIndex)
{
MStatus status;
float env = data.inputValue(envelope).asFloat();
float w;
MPoint pt;
MMatrix mat = data.inputValue(aInputMatrix).asMatrix();
MMatrix invMat = mat.inverse();
MMatrix worldToLocal = localToWorld.inverse();
MPointArray ptArray;
MVector vec;
iter.allPositions(ptArray);
for(;!iter.isDone();iter.next())
{
w = weightValue(data,geomIndex,iter.index());
pt = iter.position();
pt *= localToWorld;
pt *= mat;
vec = pt - ptArray[iter.index()];
vec *= env * w;
pt += vec;
pt*= invMat;
pt *= worldToLocal;
iter.setPosition(pt);
}
The above code works for translation, but again , the translations go wonky if I move the geometry across(the diff vector being based on it).
So my question is, how should I make it work like a native cluster deformer? . I have seen the native cluster deformer and the shapeNode for the clusterNode has some bundled matrices like clusterXforms(preMatrix,weightedMatrix,postMarrix).What are these matrices?? Disconnecting the worldMatrix output from the clusterHandle seems to have no effect on the functioning of the clusterNode.
I would appreciate if anyone can point me in the right direction.
Again thanks for the help in advance.