Menu

GetPickedObject doesn't get objects

Help
LefjuCabro
2026-06-29
3 days ago
  • LefjuCabro

    LefjuCabro - 2026-06-29

    Hello,

    In a basic glscene scene, I noticed an issue with the GetPickedObject function.
    This function doesn't always return an object, even though visually it's clear that the user has clicked on it.

    My scene contains a camera (CameraStyle=csPerspective), 1 dummyCube, and 2 spheres (Pickable=True).

    In the attached image, the red dots represent the positions of the mouse clicks for which GetPickedObject returns nil.

    Thanks for your advices

     
  • shine world

    shine world - 2026-06-30

    In the past I've used the function and it worked for me to catch a TGLFreeForm:

    procedure TGLSceneFrame.GLSceneViewerMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    var
      PickedObject: TGLBaseSceneObject;
    begin
      // checks if ctrl + shift + left mouse and control key pressed
      if Shift = [ssCtrl, ssShift, ssLeft] then
      begin
        PickedObject := GLSceneViewer.Buffer.GetPickedObject(X, Y);
        if PickedObject is TGLFreeForm then
        begin
          // my code
        end;
      end;
    end;
    
     
  • LefjuCabro

    LefjuCabro - 3 days ago

    Hi ShineWorld,
    Thanks for your answer.
    Unfortunately, that's the same method I was using, and it was causing the problem mentioned above.

     
  • shine world

    shine world - 3 days ago

    I'm using GetPickedObject without issues with:
    v2025.3 (SHA-1 70d1ef46696949214c615048358a3ad4916d3266 of 19 Sep 2025),
    but I use it ONLY with TGLFreeForm objects (actually they are filled with STL files).

    Check the video ( https://youtu.be/ASK4yTvK_hE ) where with CTLR + SHIFT and LEFT mouse button I can select a TGLFreeForm, draw a red container box, and select it in list of geometries (STL files).

     

Log in to post a comment.