views:

106

answers:

3

Possible Duplicate:
Collision detection between two general hexahedrons

Right now I do collision detection by finding the min and max and doing bounding box check. Unfortunately, my player cube rotates with the camera and this makes for some annoying results when the player is at a 45 degree angle. The constraints are that each cube is axis alligned and has 8 verticies, but the player one might be rotated (basically I do sin, cos, to each vertex and rotate about the cube's center. Given this, how can I do accurate collision detection since my player is rotated?

Thanks

+1  A: 

Find the intersection line of each pair of planes, and then determine if that intersection line is at least partly within both of the polygons.

Or, for a simpler solution, pretend that the player is a sphere.

erikkallen
Okay how can I do sphere-AABB cube collision detection?
Milo
Sometimes cylinder might be better than sphere. This is how collision detection was done in Quake I for example.
doc
Which ever one is simplest to implement
Milo
Cynlinder collisions should be pretty darned easy. You basically take the distance between the centers and check that it is larger than the sum of the radiuses.
Gian
doesnt that mean the cube is treated like a cylinder too? I want cylinder->cube
Milo
For collision detection or intersection detection between a rotated box and a sphere or a cylinder, you can transform both objects so that the box is a unit AABB (or just any AABB). That should make it easier.
fingerprint211b
A: 

Perhaps the Separating axis theorem is applicable in 3-dimension for your problem.

Gian
A: 

If one of the cubes is not rotated then its easy to check if a single point is within the cube (with bounds checks). So take each of the 8-nodes of the rotated cube and check to see if it falls within the unrotated cube.

jalexiou
Is it possible that two cubes could intersect each other but not have any vertices interior to the other?
andand
We've been over this algorithm in each of the two previous incarnations of this question. It does not work.
dmckee
I agree on this limitation. hmmm...
jalexiou