Menu

Picking/selection with GLScene for Delphi Rio

Help
Jan Dillen
2019-10-31
2019-11-02
  • Jan Dillen

    Jan Dillen - 2019-10-31

    Since I moved to Delphi Rio (10.3.1) and the corresponding GLScene version, I experience severe problems with selecting items in my scene, which I do via TGLSceneBuffer.GetPickedObject. My scene is simple: a molecule represented by spheres for the atoms and cyclinders for the bonds. Selecting a sphere results in erratic picking behaviour. Success seems to depend on the orientation of the sphere. The behaviour is the same if I try to get a list of selected objects. The problem does not seem to be hardware dependent as it shows on both my laptop as desktop, and I did not have this problem with previous versions of GLScene/Delphi on the same hardware.

    Given the simplicity of my scene, using TGLSceneBuffer.ScreenToWorld would be a simple (and probably much faster) alternative, but I see no relationship between my model coordinates and the 'world' coordinates returned by this routine. The modelview matrix is a unity matrix which, given the way I build my model, is what I expected.

    Any suggestions?

     
  • Daniel

    Daniel - 2019-10-31

    Hi Jan!
    This is a wild shot, and it doesn't explain why it worked for you on previous versions of GLScene.
    But I had big problems with GetPickedObject when my camera and object positions where in very high numbers.
    This caused some floating point precision errors which affected the picking.
    The problem was similar, if I rotated my object, then picking would work.

    All the best,
    Daniel

     
  • Jerome.D (BeanzMaster)

    Hi, strange problem. First the selection is doing by the Hardware and via OpenGL (take a look in GLScelection.pas unit). It use the GL_SELECT command and the camera have nothing to see with the current selecting method. So under Delphi the only thing i see it's because GLScene uses the Delphi's OpenGL header. Pavel should confirm that (i don't think this cause problems here).

    The first clue for trying to fix problem is : try to set the Depth Buffer bits precision to it's maximum.

    Have try the GLGizmo or GLGizmoEx component ? it is the same behaviours with those ?

     
  • Jan Dillen

    Jan Dillen - 2019-11-02

    Thanks Daniel and Jerome for your input. I have implemented the ray tracing mechanism from GLGizmoEx, and although this does not explain why I had the problem in the first place, it works perfectly and seems faster than GetPickedObject. @Jerome. Yes, the GLGizmoEx demo also shows erratic picking when using GetPickedObject on a sphere. Maybe the magnetic field of the African continent is to blame.
    Jan

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.