I want to create GeometryB at the boundingbox center of GeometryA,
I tried using the following code, but it didn’t work since centerPointA return {0.0, 0.0, 0.0}.
Did I use CRhinoMeshObject and CRhinoObjRef incorrectly?
myClass{
...
public:
CRhinoMeshObject* m_rGeoA= nullptr;
CRhinoObjRef m_RefGeoA;
};
void MemberFun1(){
// Imported a ON_Mesh* GeoA and store its reference
...
m_rGeoA= RhinoApp().ActiveDoc()->AddMeshObject(*GeoA );
m_RefGeoA= CRhinoObjRef(m_rGeoA);
}
// Drag and move GeoA in Rhino Window by user
...
void MemberFunc2(){
// Create a ON_Mesh* GeoB with a center point at (0.0, 0.0, 0.0)
...
CRhinoMeshObject* m_rGeoB = RhinoApp().ActiveDoc()->AddMeshObject(*GeoB);
// Transform its position to the imported mesh
ON_3dPoint centerPointA = m_RefGeoA.Object()->BoundingBox().Center();
ON_Xform transform = ON_Xform::TranslationTransformation(centerPointA - ON_3dPoint(0.0, 0.0, 0.0));
RhinoApp().ActiveDoc()->TransformObject(m_rGeoB , transform, true, true, true);
}
Thanks, Dale.
My previous description may not have been very clear. Allow me to provide a detailed description of the actual problem:
I am developing a surface parameterization plugin, which requires selecting a surface first and then generating a planar mesh. Since users may move the surface after selecting it, I would like to set the generation position of the planar mesh at the center point of the surface.
Another question:
I’m a bit confused about the relationship between CRhinoMeshObject, CRhinoObjRef, CRhinoMeshObject.Geometry(), and CRhinoMeshObject.Mesh().
When I want to repositioned a user-selected mesh on the screen, which data structure should I be interacting with?
When I want to store a user-selected object for further use, which element type should I use?