Thought it'd be cool to discuss how you might make a vehicle destructible in Dark Dynamix. I can't really play around with actual code and experiment because I need to save all my coding energy for Carnage, but discussing the theories and concepts would be cool.
What I'd like to do is make a PhysX vehicle that is destructible in the following ways:
- Exterior panels (doors, bonnet, wheel arches, roof) can be deformed and removed from the vehicle after collision.
- The core frame/chassis of the vehicle can be deformed and crushed.
My thoughts on how you would do this go something like this ...
- Make a subframe model for the chassis of the car. This is pretty much a simple flat box with the wheels attached around it, like this image.
- This is setup as a convex mesh in Dark Dynamix.
- When a collision occurs, you get the point of impact and the direction of force (calculated from velocity of the car, the object that it hit, and the directions).
- Select all vertices (red blobs on the diagram) that fall within a certain range of the point of impact and move them in the direction of the force by an amount proportional to the magnitude of the force.
- Recreate the convex mesh physX object for the newly deformed chassis
- Reposition the wheels/suspension connection if the area they are connect to have been moved
The only issue I can see with this is, if the side of the car is crushed inwards (say you slide sideway into a lampost) then the new shape wouldn't be convex, so the physX mesh made wouldn't take into account this new dent. Also, what is the performance overhead for recreating the mesh?
An additional mesh for the cabin could behave in the same way and be attached to the chassis mesh either using a static joint or as a composite object (I think that's possible with convex meshes).
The same goes for the exterior panels. The bonnet, wheel arches, bumpers etc. would all be convex meshes and the vertices used to make them would loosely tie in with the arrangement for the chassis. The means when there's an impact on a front corner, the chassis, bumper and wheel arch would all have verts in similar places, and could all be crushed inways, deforming the car in such a way that the various parts are unlikely to push through each other. When the force is enough, the exterior panel could be detached.
The main things I'm unsure about are:
- What would be the best method for setting the various parts up for collision? Convex mesh seems the only real way.
- Will the convex mesh creation be fast enough to remodel it when the car is deformed?
- When the parts are dented, they'll no longer be convex. I wonder if this would be an issue or if there's a way to deal with it.
- What would be the best way to connect the meshes together?
Any thoughts and ideas from people interested in this idea would be cool.