PDA

View Full Version : From triangle collision to mesh collision :P



{MSX}
02-02-2005, 06:16 PM
Hi :P I think i managed to translate a triangle-triangle collision routine from C to pascal, an experience that strengthened my hate to C and abuse of macros :mrgreen:

Now, given that the procedure works (i havent set up a unit test yet), how do i pass from a tri-tri collision detection to a mesh-mesh collision detection?
I mean, i have two mesh, but they're oriented in different and arbitrary rotation.
Given that i could test each mesh's triangle to each of the other (a nice o(n<sup>2</sup>) algorithm :mrgreen: ), do i have to orient all the triangle before testing or is there a quicker way ?
Any general hint ?

Thanks

JSoftware
02-02-2005, 06:48 PM
i think of now that i have to start the unpleasant work of defining my collision algos i will use the trick to break up my geometry in chunks which have a bounding box:


for i := 0 to high(chunks) do
begin
for i2 := 0 to high(chunks2) do
begin
if testbb(chunks[i].bb, chunks2[i2].bb) then
begin
//make two for loops here testing each tri.. break at the first intersected tris
end;
end;
end;

{MSX}
02-02-2005, 07:27 PM
i think of now that i have to start the unpleasant work of defining my collision algos i will use the trick to break up my geometry in chunks which have a bounding box:


Umm but how you calculate the boxes ? do you define them by hand ?
Also, i have complex object (for example a ring).. do you think bb can work for them too ?


BTW i really feel the need for a "3d theory" forum :P

Clootie
02-02-2005, 07:44 PM
For example with help of these functions: D3DXComputeBoundingSphere, D3DXComputeBoundingBox.

Paulius
02-02-2005, 07:50 PM
I?¢_~d go about it using a basic bounding sphere/box test and then a full tri-tri test on very low poly versions of the meshes. And yes, you have to multiply all vericies with their corresponding matrices.

{MSX}
02-02-2005, 07:51 PM
For example with help of these functions: D3DXComputeBoundingSphere, D3DXComputeBoundingBox.

I don't use DX.
Anyway i think that functions only gives you one sphere or one box, while i think JSoftware uses a hierarchy of boxes which far better :P

A single bounding box or sphere works very bed with a torus :P