I’m using the commands EnableGetGripPointXform(bool bEnable) and GetGripPointXform(ON_Xform& xform) to record the transformation applied by Translate, Rotate and Scale.
I need this transformation to be applied to an ON_3dPointArray points, member of my CRhinoObjectGrips class, to draw a mesh in CRhinoObjectGrips::Draw() and return it in CRhinoObjectGrips::NewObject().
The problem is that it seems that the transformations are being subsequently accumulated, thus the mesh blows away after some translation/rotation.
Ideally, the transform xform should forget about past transforms and just become the new one applied between last time the mesh was drawn and the most recent one (i.e. between subsequent calls of Draw()).
In my code so far, only when I create the grips m_grips[i] I call m_grips[i].EnableGetGripPointXform(true). Then, in Draw() and NewObject() (or inside my UpdateMesh() method) I write
m_grips[i].GetGripPointXform(xform);
and, for an index k depending on i, I update my mesh points
In this plugin I create a horizontal line in x-y with 4 grips. When the grips are modified, the red line is drawn, and a green line shifted by one unit in y direction is drawn. I want the green line to keep a distance of 1 from the red one when all grips are moved at once. At a first time I just updated the green line by adding (0,1,0) to the grips. This works well for translations as you see:
However, when I rotate the grips it doesn’t behave as I’d like. You see in the below screenshot that every point in the green line keeps a distance of 1 in y direction, but I’d actually want it to rotate like the red one, with the same center and angle of rotation, so that the black segments joining the lines are orthogonal to both of them.
Yeah, I see… Though, this is only an example, no real need to keep a line parallel to the other.
The actual question is: if I transform a grip at a time, how to get that transform and apply it to another point at the same time? I followed your advice of keeping a read-only copy of the point in the attached sample, but doesn’t work.
I’m not sure what’s really happening, when using Transform(xform) on a 3d point, xform coming from the grip. What is actually this xform?