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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
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
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 ?
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