# OBB-Line Intersection

This topic is 3779 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I am trying to implement OBB-Line intersection but unable to implement it correctly Sorry if this has already been answered. I have structured my OBB as follows and assuming I have a variable::
struct OBB
{
D3DXVECTOR3 pos, min, max;
D3DXMATRIX rot;
};

D3DXMATRIX objTransform;


The objTransform will store the final transformation of the OBB. Then this is how I do my collision detection. I use the inverse transformation of OBB to transform the line origin and ray to OBB space. Also I did the same thing for min and max. Finally calling an Ray-AABB intersection function.
D3DXVECTOR3 bMin, bMax, p1, p2;
D3DXMATRIX invFinal;
D3DXMatrixInverse(&invFinal, NULL, &objTransform);

// Transform min and max first
D3DXVec3TransformCoord(&bMin, &oBBox->min, &invFinal);
D3DXVec3TransformCoord(&bMax, &oBBox->max, &invFinal);

// Transform line to OBB space
D3DXVec3TransformCoord(&p1, &(lineOri - oBBox->pos), &invFinal);
D3DXVec3TransformCoord(&p2, &(lineEnd - oBBox->pos), &invFinal);

if( CollisionDetector::RayAABBIntersection(bMin, bMax, p1, p2, time) )
// Do something
else
// Do something


But this doesn't seem to work. What have I done wrong in my algorithm? Hope someone could help me out. If there is any article on this I could read up to understand it will be much better. Thanks.

##### Share on other sites
Alright, I know where I was wrong in the algorithm.
However, I am now looking for a way to actually calculate the collision normal.
Is there a way to determine the collision normal without having to check within the collision code which side is colliding?
Thanks.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 13
• 9
• 12
• 9
• ### Forum Statistics

• Total Topics
631438
• Total Posts
3000073
×