PDA

View Full Version : Overlapping


VVaari
09-07-2009, 09:20 PM
I have fractured hollow object and i need to create simple collision boxes for each fracture piece and those collision boxes can't overlap each other. I created boxes based on each pieces bounding box and then used intersects() to check if collision objects overlap. Then i scaled overlapping boxes while they don't collide anymore. Well scaling obviously doesn't work because it scales both sides of box. So I think i need to move collision box vertices which are overlapping another collision box. But how do i know which vertices are overlapping? Damn building UI's doing simple tasks is somewhat easy, but this is totally new stuff for me and it's giving me a headache.

denisT
09-07-2009, 09:29 PM
I have fractured hollow object and i need to create simple collision boxes for each fracture piece and those collision boxes can't overlap each other. I created boxes based on each pieces bounding box and then used intersects() to check if collision objects overlap. Then i scaled overlapping boxes while they don't collide anymore. Well scaling obviously doesn't work because it scales both sides of box. So I think i need to move collision box vertices which are overlapping another collision box. But how do i know which vertices are overlapping? Damn building UI's doing simple tasks is somewhat easy, but this is totally new stuff for me and it's giving me a headache.

if two bboxs are intersected that means at least one corner of a bbox is inside another bbox...
check all 8 corners of both bboxs to find corners which are inside another bbox:

fn containsPoint bmin bmax p =
(
(p.x >= bmin.x and p.x <= bmax.x) and (p.y >= bmin.y and p.y <= bmax.y) and (p.z >= bmin.z and p.z <= bmax.z)
)

VVaari
09-09-2009, 07:49 PM
http://dante.daug.net/cgtalk/cg_intersect.jpg
If I have situation like in the image above, vertices in the red box are not inside green box but they still intersect.
Basically what I need to get is both top triangles and rightside triangles from the green box and bottom triangles and leftside triangles from the red box. When i get all those triangles, I know what faces I need to move to get objects separate. And I think I can get the direction to move from inverting triangle normals, right?
I just can't figure out how to get those damn triangles, it can't be that hard :) I've tried few different approaches like rays and looping thru all faces and comparing center distances etc but nothing worked. Well of course they might have worked if I would use them in the right way...

denisT
09-09-2009, 07:59 PM
you have to check corner positions for both bboxs

denisT
09-09-2009, 08:03 PM
do you have exactly boxes or any geometry?

VVaari
09-09-2009, 08:06 PM
I create boxes (converted to editable mesh) based on bounding boxes from different kind of objects. But yes they will be shaped liked boxes :)

denisT
09-09-2009, 08:26 PM
I create boxes (converted to editable mesh) based on bounding boxes from different kind of objects. But yes they will be shaped liked boxes :)

do you want to modify only one box (some particular or any) or both boxes?

VVaari
09-09-2009, 08:31 PM
Both boxes. I'm gonna have lots of boxes and I'm gonna loop thru all of them, and if intersection happens between two objects, both need to be resized so they wont intersect anymore. I've done it now using scale, and it's working mostly okay, but it's not good enough. Would be much better if I could figure out where intersection happens so i wouldn't have to scale whole objects but just move those intersecting faces away from each other.

denisT
09-09-2009, 08:36 PM
... i wouldn't have to scale whole objects but just move those intersecting faces away from each other.

if you would move boxes it might cause another intersection with other boxes...

VVaari
09-09-2009, 08:46 PM
I just want to move those faces (top and rightside from green, bottom and leftside from red in the image), thus making both boxes smaller. I dont want to move whole boxes :)

CGTalk Moderation
09-09-2009, 08:46 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.