Questions tagged [mouse-picking]

77 questions
1
vote
2 answers

OpenGL ray casting (picking): account for object's transform

For picking objects, I've implemented a ray casting algorithm similar to what's described here. After converting the mouse click to a ray (with origin and direction) the next task is to intersect this ray with all triangles in the scene to determine…
Maghoumi
  • 3,295
  • 3
  • 33
  • 49
1
vote
1 answer

Why Do I Always Zoom in When Picking? (OpenGL)

I have the following code: #define GLUT_DISABLE_ATEXIT_HACK #include #include #include #include GLfloat ctrlptsBezier[4][4][3] = { { {-2.0, -2.0, 1.0}, {-0.5, -2.0, 0.0}, {0.5,…
Rome_Leader
  • 2,518
  • 9
  • 42
  • 73
1
vote
1 answer

Translating mouse coordinates to model coordinates in OpenGL when rotations are involved

In the Qt Forums I found this question and sparkled my curiosity. I found a very simple example in Qt to display a cube and modified the cube logic to create a cube with a side length of 1 unit. Then I tried to click on the model and show the…
Adri C.S.
  • 2,909
  • 5
  • 36
  • 63
1
vote
2 answers

get mouse in world coordinates with 2 gluUnproject calls to create ray

I try to use what many people seem to find a good way, I call gluUnproject 2 times with different z-values and then try to calculate the direction vector for the ray from these 2 vectors. I read this question and tried to use the structure there…
Big_Chair
  • 2,781
  • 3
  • 31
  • 58
1
vote
0 answers

How to convert mouse coordinates into world coordinates

What I want to do Picking an object. Requirements / Conditions My mouse is always in the center of the screen. Pick only the first / nearest object What I want to know How can I convert my mouse coordinates (actually 0,0 since the mouse is…
boop
  • 7,413
  • 13
  • 50
  • 94
1
vote
1 answer

Translating mouse X & Y to 3D model coordinates

I'm building a simple 3D drag and drop interface in processing, and want to detect when the mouse rolls over an object. I would imagine that I need to do some matrix translations to the 3D model coordinates to get them into screen space and so on…
Matti Lyra
  • 12,828
  • 8
  • 49
  • 67
1
vote
1 answer

mouse picking in opengl using `gluUnProject`

I have a scene that I am rendering couple of cubes in it with openGL (program structure is not using GLUT,it is in win32 program structure but I just draw cubes with glutSolidCube) now I want to select these cubes by mouse by picking. this is what I…
user667222
  • 179
  • 3
  • 16
1
vote
1 answer

OpenTK mouse picking

I have developed a small C# sample to pick the point by using OpenTK and winforms There is a method to draw the Squares and there is another method to pick the triangle. Somehow I am not getting any hits. Is there any problem with Readpixel methods?…
RobinAtTech
  • 1,299
  • 3
  • 22
  • 48
0
votes
0 answers

DirectX11-raycast mouse picking has proplem

gif Creating View, Porjection Matrix void CameraSystem::CreateMatrix() { camera->aspect = viewport->Width / viewport->Height; projection_matrix = XMMatrixPerspectiveFovLH(camera->fov, camera->aspect, camera->near_z, camera->far_z); …
0
votes
1 answer

OpenGL: screen-to-world transformation and good use of glm::unProject

I have what I believed to be a basic need: from "2D position of the mouse on the screen", I need to get "the closest 3D point in the 3D world". Looks like ray-tracing common problematic (even if it's not mine). I googled / read a lot: looks like the…
fghoussen
  • 393
  • 3
  • 16
0
votes
2 answers

How to manage text labels in a simple interactive matplotlib plot?

In this code snippet: import matplotlib.pyplot as plt import numpy as np def onclick(event): plt.text(event.xdata, event.ydata, f'x', color='black') plt.show() fig, ax = plt.subplots() fig.canvas.mpl_connect('button_press_event', onclick) data…
Paul Jurczak
  • 7,008
  • 3
  • 47
  • 72
0
votes
1 answer

GPU Picking inconsistent across devices

I’m trying to implement GPU picking with Points using code I modified from the latter half of this article https://threejsfundamentals.org/threejs/lessons/threejs-picking.html It’s been working fine for me on desktop, but I started testing different…
0
votes
0 answers

GPU picking on loaded GLTF objects

i have tried a lot of ways to go around this topic, before asking and now i really have no clue how to accomplish object picking with gpu on a gltf loaded file, so im hoping for any help that i can get :( I've loaded a huge GLTF file, with a lot of…
nosh247
  • 13
  • 5
0
votes
0 answers

How to check whether mouse clicked over a polygon in OpenGL?

I'm trying to make a color picker tool in OpenGL. It works you can use the code below. However there is one glaring issue, if you test the program you will find that if you click the black background, the color selected will become black. So my…
0
votes
0 answers

OpenGL moving vertices with mouse

I am using legacy OpenGL and trying to move vertices around with the mouse. To test whether a vertex is clicked on I loop through all vertices and multiply them by the model and projection matrix before dividing by the w value. This works fine and…