Before we can start implementing GJK we needed to set up the Unity environment we will be working in.
We added a few cubes to a scene and attached a Polygon script which finds all vertices of the shape. Finding the vertices of a shape turned out to be more difficult than expected. There is a built in method called Mesh.vertices which finds all vertices of the mesh. However, it creates duplicates since each corner lies on several different planes. On our cube, for example, each of the six sides has four vertices. Each corner has three vertices with the same position but different normal vectors. Hence, Mesh.vertices gives us a list of 24 vertices. Since we only care about the position, we wanted to remove duplicates. We also had to transform the vectors from coordinates local to the mesh into world coordinates.
In these images you can see that as we move our square, the coordinates (in the bottom right corner of the image) change as well. Our first implementation of GJK will handle 2D objects, so here we have used squares. However, our Polygon script also works on 3D objects, as can be seen below.
The last thing we did today was to create the shell for our GJK script. For now it only finds all Polygons in the scene and adds them to a list.
Since none of us has much experience working with Unity, this first session was a bit slow and frustrating. Hopefully today's work will enable us to focus on implementing the algorithm.