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.
Calculating overlapping vertices during collision
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
for every verticle.
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)
}
If you don't have anything nice to say, don't say anything at all.
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!
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!
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.
Well, if you really want to do accurate collision detection, then you shouldHelderash 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!
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