1
$\begingroup$

I am trying to make 3D drawing software. I wanted to have the drag feature so I am using object picking using the OBB algorithm. I am facing problems in understanding the algorithm, and my implementation thus is having bugs.

How do I implement object picking, using OBB in OpenGL? As I am new to OpenGL (free-glut library), a step by step explanation would be helpful.

I am not able to understand what t1 and t2 mean and how the algorithm is working. If you explain the algorithm that would be enough.

$\endgroup$
4
  • 1
    $\begingroup$ Could you elaborate on the problems? Also just to be sure, this doesn't have anything directly to do with OpenGL right? $\endgroup$
    – vallentin
    Commented Mar 25, 2017 at 16:13
  • $\begingroup$ I am facing problem in implementing object picking using obb algorithm.I am not able to understand what does t1 and t2 means and how the algorithm is working. And for opengl i am using glut library if you explain the algorithm that would be enough. $\endgroup$
    – dkoder
    Commented Mar 25, 2017 at 16:32
  • $\begingroup$ First of go with GLFW library rather than going with freeglut And check out this tutorial... antongerdelan.net/opengl/raycasting.html $\endgroup$ Commented Mar 27, 2017 at 5:17
  • 1
    $\begingroup$ @dkoder Can you edit the question to summarize what you understand already and where specifically you're having trouble? Currently your question is too unclear to really answer. :( $\endgroup$ Commented Mar 27, 2017 at 17:02

1 Answer 1

3
$\begingroup$

Ray vs OBB intersection works by shooting a ray towards the OBB's planes. This results in 2 intersections referred to as t1 and t2 (per axis), also referred to as tNear and tFar or tMin and tMax.

Checking whether the ray intersects with the box, can then be done by comparing the largest tNear against the smallest tFar. If the largest tNear is less than the smallest tFar then there is a intersection.

$\endgroup$
3
  • $\begingroup$ thanks for this i just have couple of questions....first what are the equations of this plane and for 3d i should have a pair of z planes right? $\endgroup$
    – dkoder
    Commented Mar 26, 2017 at 13:48
  • $\begingroup$ Yes for 3D you'd just have to add z as well, the concept stays the same. I can write you a short snippet of the algorithm. Do you have a preferred language? C, Python or? $\endgroup$
    – vallentin
    Commented Mar 28, 2017 at 0:33
  • $\begingroup$ Sorry for the late reply...python code would be nice $\endgroup$
    – dkoder
    Commented Mar 30, 2017 at 16:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.