Skip to main content
10-Marble
Mar 17, 2023 12:52 AM UTC
Solved

How to calculate the position of the mouse pick on the model .

Hello everyone!

I want to calculate the coordinates of the mouse left click point on the solid model.

So I tried the following, but the calculation is wrong.

 

pfcSession_ptr mysess = pfcGetProESession();
pfcMouseStatus_ptr MouseStatus = mysess->UIGetNextMousePick(pfcMOUSE_BTN_LEFT);
pfcPoint3D_ptr Position = MouseStatus->GetPosition();
pfcView_ptr view = mysess->GetCurrentModel()->GetCurrentView();
pfcTransform3D_ptr Transform3D = view->GetTransform();
Transform3D->Invert();
pfcPoint3D_ptr model_point = Transform3D->TransformPoint(Position);

 

The “model_point” is wrong .

And I can't select points through the function "pfcBaseSession::select()", because there are no points on the surface, I want to calculate the position of the mouse click on the point position on the surface of the solid model.

Can anyone tell me how to do it, or is there any other way,thanka!

 

 

RPN
RPNAnswer
18-Opal
Mar 19, 2023 1:57 PM UTC

I guess you get only the screen coordinates, no z value.

 

in Toolkit I would use this:

extern ProError ProSelectionPoint3dGet( ProSelection selection,
					ProPoint3d point );
/*
 Purpose: Retrieves the coordinates of the selected point in the member 
 coordinate system.

 Input Arguments:
 selection - The selection object

 Output Arguments:
 point - The point coordinates 

 Return Values:
 PRO_TK_NO_ERROR - The function successfully retrieved the information.
 PRO_TK_BAD_INPUTS - The selection or depth is NULL.
 PRO_TK_INVALID_PTR - The selection argument is an invalid pointer.
*/

 My assumption is, this will return a point on the surface, if your type Is “surface”

 

 

3 replies

10-Marble
Mar 17, 2023 8:51 AM UTC

Use this function to get the point position.

NT_10507751_0-1679043099553.png

 

Translate
RPN
RPN18-OpalAnswer
18-Opal
Mar 19, 2023 1:57 PM UTC

I guess you get only the screen coordinates, no z value.

 

in Toolkit I would use this:

extern ProError ProSelectionPoint3dGet( ProSelection selection,
					ProPoint3d point );
/*
 Purpose: Retrieves the coordinates of the selected point in the member 
 coordinate system.

 Input Arguments:
 selection - The selection object

 Output Arguments:
 point - The point coordinates 

 Return Values:
 PRO_TK_NO_ERROR - The function successfully retrieved the information.
 PRO_TK_BAD_INPUTS - The selection or depth is NULL.
 PRO_TK_INVALID_PTR - The selection argument is an invalid pointer.
*/

 My assumption is, this will return a point on the surface, if your type Is “surface”

 

 

Translate
10-Marble
Mar 29, 2023 6:13 AM UTC

yes, thank you!

Translate