Open main menu

CDOT Wiki β

GAM531/Brazuca

Brazuca

Repository

Team Repository

Team Members

Progress

Lab Implementation Progress

Lab Direct X Open GL
Lab 01 Karina ------
Lab 02 Karina ------
Lab 03 Karina ------
Lab 04 Karina ------
Lab 05 Karina ------
Lab 06 Bruno ------
Lab 07 Bruno Bruno
Lab 08 Bruno Bruno
Lab 09 Bruno Karina
Lab 10 Bruno Karina

Enhancement

The enhancement that we selected is "Sphere Collision".

For the Sphere Collision enhancement, we created a Sphere Manager, which constantly, in between renders, checks if any sphere collided with any other.

From then, we created a Sphere object which contains all of the sphere's necessary information, such as radius, ID, callback function to execute on a collision and any other object it may need to have access to (void* data).

The Collision check is quite simple, you just need to check if any 2 given spheres' radii sum is equal to or bigger than the distance between them.

For that, our Sphere Object inherits from Scene Object, so all sphere can not only be attached to a node in the game world, but also contain position information for the collision check.

From then on, all you have to do is create the spheres in your scene, attach them to existing nodes, and activate them, as you would do with any other Scene Object(actors, cameras, lights, etc). To activate a Sphere, you have to set its radius and callback functions and, of course be attached to a node.

Upon collision, the Sphere Manager will call the Sphere's operator(), which is going to receive the collided sphere's pointer and then call the callback function defined in the scene by the game programmer.

Lastly, we had to change the iSceneController to create a Sphere object on the scene, calling the manager's CreateObject function.

In our test Scene, we have 2 objects moving towards each other. Once they collide, they go away from each other and, when they reach a given distance, they start to move back against each other again. You can simply check how the collision is the one doing the work by changing what it does on the callback function defined in core.cpp (void cb()).

The solution has 2 core.cpp scenes: One for the graphics test and one for the collision system check. Both are on the same directory, but only one is in the solution.

Bruno was in charge of the test scene, callback system, and Sphere's implementation. Karina was in charge of creating Sphere Manager and iSphere structure.