Oscar Johnson

Logo

Graduate Game developer

I am a young and aspiring graduate (First class, BSc) with a passion for video games! Feel free to browse my projects or get in touch via the links below. Here's a copy of my CV

View My LinkedIn Profile

View My GitHub Profile

15 April 2018

Destruction physics in unity

by Oscar Johnson


About

Another project in unity 3D! This time to create a system that allowed for the destruction of convex meshes in a realistic fashion.

This project started out by looking at Voronoi diagrams and the implementation of an algorithm that would generate these patterns and then slice up meshes into sections based on randomly generated nodes. This way the system would be able to create realistic looking destruction of props in a scene.

After a quick 2D version of the Voronoi function was implemented, that placed randomly generated nodes across a 2D plane and calculated the boundaries between them, a mesh slicing function was build to cut across these boundaries to break the object down into primitives. This function worked by taking a plane, looking for intersections in existing triangles in the polygon and deleting them. Any triangles not intersected were sorted out into sides (Left or right of the plane) and triangles intersecting the plane would have vertices added across the cutting line that would be used to rebuild the intersected triangles and also to rebuild the face on both sides of the cut. This would result in one object being split into two.

More research was required however as upon implementing the Voronoi algorithm in 2D, the tax on the system of then slicing mesh down into primitives was too high and there was a series of erroneous behavior (Probably to do with the high system cost) that made the project too complex for the 3 week deadline I had. Therefore a more simple approach was required.

Sticking with the same mesh slicing function, a simple function was created to randomly generate a point inside the 3D mesh and then place a series of slices pivoting around that point. This resulted in quite an interesting shattering effect that can be seen in the video above.

This project was coded in c# for unity and can be viewed in the github repository here.