Calculating overlapping vertices during collision

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Helderash
Posts: 49
Joined: Sun Mar 25, 2007 8:41 pm

Calculating overlapping vertices during collision

Post by Helderash »

Hey folks!

I'm currently working on a deformation project for university, and am now at a stage where a cube can be deformed by setting the position and force of an impact through input boxes.

I'm now wanting to extend the testing environment to include a collision between a rigid body (a sphere) and my deformable cube. I've written code to deal with rigid body collisions in the past, and am comfortable calculating when a collision occurs. However, the project will require me to know which vertices of the cube are being overlapped, or under impact by the rigid sphere at each frame (e.g. the library that deals with deformation requires the index value of vertices upon which an external force is being applied, and the magnitude of the force in the x, y and z directions upon these vertices). Would anyone know of a tutorial that discusses such a problem, or a software library that could handle this?

Thankyou for the help, it is very much appreciated!

James.
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

I'm not aware of such a library, but assuming it is a sphere with only 1 radius, should it not just be possible to check if

Code: Select all


f32 DistSQ = Box.Verticles[?].Position.getDistanceToSQ(Sphere.Position);
f32 SphereRadiusSQ = Sphere.Radius*Sphere.Radius;

f32 OverlappAmount = SphereRadiusSQ - DistSQ;

if (OverlappAmount > 0)
{
   //Now they overlapp, and we have a value that can be used to determine how much (OverlappAmount)
}

for every verticle.
If you don't have anything nice to say, don't say anything at all.
Helderash
Posts: 49
Joined: Sun Mar 25, 2007 8:41 pm

Post by Helderash »

Hi Luben,

I have considered that method. The problem is, the higher end deformable meshes I'll be working with will possess around 17,500+ vertices, and I've a feeling that on this scale the method will be too computationally expensive. I'm considering using this method upon a courser mesh however, and mapping the results to the finer mesh beneath - though this will have an impact on the deformation accuracy. I guess I'll try both out, and put the results in my report.

Thanks for the help!
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

I guess you could organize your meshs verticles in volumes, and cull those who are out of reach. Sortof like a dynamic octree or something.
anyway, good luck =)
If you don't have anything nice to say, don't say anything at all.
Robert Y.
Posts: 212
Joined: Sun Jan 28, 2007 11:23 pm

Post by Robert Y. »

You could calculate an intersection of bounding boxes and only check the triangles that have at least one vertex in this intersection, ignoring all other triangles. And 17000 vertices isn't that many. On my 1GHz machine Irrlicht renders 500k vertices at 10 fps; doing some calculations on them should be fine.
Helderash
Posts: 49
Joined: Sun Mar 25, 2007 8:41 pm

Post by Helderash »

Ah fantastic, I guess I shouldn't have too many problems then. Thankyou both for your help!
Jiang
Posts: 77
Joined: Tue Feb 20, 2007 11:03 am

Post by Jiang »

Helderash wrote:Hi Luben,

I have considered that method. The problem is, the higher end deformable meshes I'll be working with will possess around 17,500+ vertices, and I've a feeling that on this scale the method will be too computationally expensive. I'm considering using this method upon a courser mesh however, and mapping the results to the finer mesh beneath - though this will have an impact on the deformation accuracy. I guess I'll try both out, and put the results in my report.

Thanks for the help!
Well, if you really want to do accurate collision detection, then you should
use other CD libraries.

Usually the CD library will do boardphrase, middlephrase and
narrowphrase collision detection for you, depends on what you want to
do exactly. Boardphrase will give you possible collided mesh pairs by
using AABB/OBB trees or something like that. It is quite fast. And the
overlapped triangle pairs can be obtained by middlephrase collision
detection. If you want to get the collision points/normals or regions to
calculate the impulse/force, then the final narrowphrase detection is
necessary(which is sometimes quite difficult).

Please check :

1. Opcode: http://www.codercorner.com/Opcode.htm
2. GIMPACT: http://gimpact.sourceforge.net/

They all support deformable triangle mesh, IIRC.

Also please do check Physics Simulation Forum @
http://www.continuousphysics.com/Bullet ... /index.php

if you really want to build a good physics simulator.

HTH
Post Reply