Collision between a point and a box

Started by
6 comments, last by pyroExtreme 13 years, 4 months ago
I'm currently working on a 3d game and have been looking into and working on the collisions. I have collision of two OBBs working using the separating axis theorem. But I also need to be able to check if a single point lies within a OBB, obviously I could use SAT and give my OBB representing the point a half size of 0 but I was wondering if the is a different more efficient way of doing this calculation?

Any suggestions would be greatly appreciated, even just the names of some methods.

Thanks in advance.
Advertisement
1. Transform the point into the local space of the box.

2. See if the (transformed) point coordinates are in the range [-extent, extent] for each of the cardinal axes.
thanks for the advice, I kinda have it working can rotate my box through the Y (up) axis and the collision detection works and well as when there is no rotation at all, the problem I have is when I rotate X or Z axis. Not sure if I'm doing everything correctly.

1. Transform the point to local space: Am I right in thinking you do this by multiplying the point by the inverse world matrix of the box.

2. check agains the -extended and extended cardinal axes, this is probably where I'm going wrong. Do I need to do something special when the box is rotated???

Thanks again in advance
Quote:Transform the point to local space: Am I right in thinking you do this by multiplying the point by the inverse world matrix of the box.
Yes.
Quote:Do I need to do something special when the box is rotated???
No.

If it's not working as you expect, you might post your code.
Well with a little digging i've worked out what it is :).

The box when getting rotated in world around the X and Z isn't rotated around the boxes center it getting rotated around the bottom of the box, cos the boxes are constructed from data from Max. so I'm guessing instead of checking if it between -extend and extend for X and Z I just need to check if it inbetween 0 and extend *2?

cos this is part of a group project i'm working on so if i go changing the way the boxes read in from max it will break other areas of the game.
sorry I meant check from 0 to extend*2 for Y axis cos obviously the Y values in local space will need to be worked out from the bottom not the center and from -extend to extend for X and Z axes
Correct, if your boxes are not centered at the origin you'll have to adjust your code accordingly.
thanks for all the help its all working brilliantly now :D :D

This topic is closed to new replies.

Advertisement