Collision deformer

by Cee42 posted 98 days ago | 4 comments

Does anybody know of any good papers or websites for a real time collision deformer? Thanks.

by vshotarov posted 97 days ago

I was looking into it at one point and these are some of the resources I remember off the top of my head. - You can look at the source code

What it basically boils down to is finding intersections between meshes and then calculating how to respond to those intersections. A good thing is that a lot of game developers have struggled with this problem, so there are a lot of topics on forums around the web.

The way I've done it in the past was, finding intersections by casting a ray from the vertex along it's normal and checking how many intersections with the collider mesh there are. It works only for closed geometries. If there is an odd number of intersections that means that the current vert is inside of the collider geometry.

Then for responding, to it, I used three methods for different cases

  1. casting a ray from the vert in the negative normal direction and finding the first intersection with the collider. That becomes my deformed vert position.
  2. finding the closest point to the vert on the collider mesh.
  3. using the first method I find the intersected face of the collider and then I project the current vert along that face's normal to get an intersection with the collider.

The 3rd method had best results most of the time, but it was computationally more expensive.

Hope that helps!

Oh, and recently a colleague showed me the membrane node in Maya, which acts as a collision deformer, if you want to just have a play with something and maybe compare your results, though, im not sure how much you should trust it to be a good one.

by Cee42 posted 96 days ago

Do you know how to get the bounding box of the input geometry in python Maya api deformer class? Or would I have to get this externally by connecting the deforming mesh's bounding box as an input attribute?

by vshotarov posted 95 days ago

So, there's this Maya docs page about a bounding box deformer that gets it by using the MBoundingBox class and passing all the verts to it. Here it is

The other thing you can try is getting the bounding box directly from the mesh, as MFnMesh inherits from MFnDagNode so you can use the boundingBox function.

To be honest, I would probably do it one of those two ways, but I haven't thought about getting it from the mesh as an input attribute, so it might be worth giving it a go and checking if there is any performance benefit.

by Cee42 posted 96 days ago

Thanks for your help. :)