How to detect if part or all of object overlaps with another object in Android OpenGL-ES application? -


assume have 3 cubes @ random location/orientation , want detect if of cube overlapping (or colliding) cube. overlap or collision happen cubes location/rotation changed in each frame. please note looking android based , opengl es (1.0 or 1.1) based solution this.

this isn't opengl problem - rendering. don't know of ready-made android libraries 3d collision detection, might have maths yourself. efficient collision detection art of using quick, cheap tests avoid doing more expensive analysis. problem, approach detecting if cube intersects cube b quick rejection test, either

  1. compute bounding spheres , b - if distance between 2 sphere's centers greater sum of radii, , b not intersect
  2. compute axis-aligned bounding boxes , b - if bounds not intersect (very easy test), neither , b

if bounds test indicates possible collision it's time maths. there 2 ways go here: testing vertex inclusion , testing edge/face intersection

vertex inclusion testing vertices of see if lie within b: either rotate vertex b's frame of reference test inclusion, or use planes of b's faces directly in frustum-culling style operation.

edge/face intersection testing each of edges of intersection b's face triangles.

while vertex inclusion test bit cheaper edge/face testing, it's possible cubes intersect without encompassing each other's vertices, negative result not mean no intersection. similarly, it's possible cubes intersect without intersection between edge , face (if 1 lies within other). you'll have little of both tests catch every intersection. can avoided if can make assupmtions how cubes can move frame frame, i.e.: if , b not touching last frame, it's unlikely wholly within b now.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -