Could it be a problem that you are getting the kObject position as the default return value, from the iterator, and using it in a kWorld operation in the closestPoint() call?
MPoint position ( MSpace::Space space = MSpace::kObject, MStatus * ReturnStatus = NULL ) <http://docs.autodesk.com/MAYAUL/2014/ENU/Maya-API-Documentation/index.html?url=cpp_ref/class_m_it_curve_c_v.html,topicNumber=cpp_ref_class_m_it_curve_c_v_htmlb36d28dd-7649-427c-ace4-cbdea26b3be3,hash=a5880c110ed81dd4da0289ccdca5c1592> Does it help if you call it like: iter.position(MSpace::kWorld) That is just a guess, as it is the only thing standing out to me. Maybe someone who does more plugin dev will spot something more specific. Justin On Mon, Apr 20, 2015 at 8:33 PM Emre Tekinalp <[email protected]> wrote: > Hello everybody, > > I know this is mostly a Python forum, but I'm currently writing in C++ a > deformer, > dealing with curves yaay, hopefully it is ok nonetheless, otherwise I come > up with a python api example... > I have also looked through the forum and could find just a > MFnMesh.closestPoint issue, which does not really help me unfortunately. > > My maya setup is as follows: > - I have an ep curve degree=3 > - I want to affect a polyCylinder with the curve, like the wireTool > - As a current idea, one of the steps to achieve that is to get the > closestPoint and param on the curve for each Vertex on my polyCylinder. > - For that I use MFnNurbsCurve closestPoint, but when I'm cout position > and param values, > they are mostly zeroed out and when I'm in component mode selecting the > vertices of the mesh and move them down in ty > I get a bunch of value changes, but only when I'm less then 0, > everything above stays 0 (position and param values) > - Here is the code: > > > // Inside the deform method > > //Get the closestPoint and param on the curve from each vertex > 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(), 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, ¶m, 0.0, MSpace:: > kWorld); > } > > > > > This is basically a part from the closestPoint/TangentAndDistance.cpp > source file. > But for any kind of reason, I don't get proper values... am I missing > something? > > Thanks in advance! > 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/ca5a52a6-b4a0-47d0-ae65-675112ece94a%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/ca5a52a6-b4a0-47d0-ae65-675112ece94a%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAPGFgA1m%3DoPj9rtzGMrX2kOFrC_dZBc9wW7royxS%3DY2Tcb8%2Bsg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
