Changes

Jump to: navigation, search

GAM531/Brazuca

539 bytes added, 18:22, 7 December 2014
Enhancement
===Enhancement===
The enhancement that we selected is "Sphere Collision".
Second option in case it's taken is Terrain Generator (2/3)
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 from the 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 towardseach 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()). 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.

Navigation menu