Hello everybody,

thanks for your answer Janos that's how I'm calculating as well.
But in this case my issue was a little bit different.

Finally, I found the solution, I want to share with you guys and it is so 
easy (I realize that it has been a long time ago since I was dealing with 
deformers XD).

Due to the fact that iter.position() does not like MSpace::kWorld, we have 
to make sure of course to multiply with the worldMatrix of the deformed 
mesh's transform...
That explains why I got weird values when translating the mesh in ty. The 
iter.position() gave me objectspace related values...

So now everything works as it should. As a recap here is the code from 
above with the proper fix:


// Inside the deform method

    //Get the closestPoint and param on the curve from each vertex
    //Get inMatrix attribute value as matrix
    MMatrix mMatrix = data.inputValue(aInMatrix, &status).asMatrix();
    CHECK_MSTATUS_AND_RETURN_IT(status);

    MFnNurbsCurve fnCurve(oCurve); //Assume we have the MObject of the 
curve already
    double param;
    MPoint position;

    for (;! iter.isDone(); iter.next())
    {
        //Helper method to retrieve/store the position and param value on 
the curve
        getClosestPoint(fnCurve, iter.position() * mMatrix, position, param
);
        cout << "index: " << iter.index() << " point: " << position.x << " " 
<< position.y << " " << position.z << " param: " << param << endl;
    }

void Curve::getClosestPoint(MFnNurbsCurve& fnCurve, MPoint inPosition, 
MPoint& position, double& param)
{
    position = fnCurve.closestPoint(inPosition, &param, 0.0, MSpace::kWorld
);
}



Thanks guys for the thoughts and help, much appreciated!

Cheerio
Emre

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/857273e3-ee4a-44d8-9617-1a0d5d2002f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to