I'm implementing successfully the picking ray sphere strategy, in order to get the clicked object. In figure, I selected the green cube, and the vertex bottom left is highlighted with a small red cube.
But I'm not able to move the cube on the plane z. In particular, my mouse position doesn't match the vertex position that I found moving the cursor. It works only with a Top view (XY plane).
I'm becoming crazy to understand where I'm wrong but I cannot understand.
I'm sure I didn't understand something, but what?
At a beginning, I store the mouse x,y coordinate (_init_drag_pos), then I make the difference between the previous coordinates and the new ones
dx = (mouse.X - _init_drag_pos.X); //pixel
dy = -1* (pmouse.Y - _init_drag_pos.Y); //pixel
//world position
vec3 res = glm.unProject(new vec3(mouse.Y, mouse.Y, 0), ModelViewMtx, ProjectionMtx, ViewPortVec);
I tried different approaches, this is the one that works best. Read many articles!
I want to see the cube small red cube that has the same position of the cursor!
Any suggestion?