Monday 12 July 2010

Model Editor

Since completing the shadow mapping I've added normal mapping to the shader and started to look at adding more models to the level.

I purchased some spaceship models from 3DRT.com which are in a style that suits the game.

To get them to work in the game I have to add collision bounds to them. In my case all the bounds in the game are based on spheres. I have a function that divides the model up in to larger and then smaller spheres.

That works well but does not care if a sphere overhangs an edge. In the case of square buildings this does not cause any noticable problems. These space ships have overhanging wings.

While testing them I kept getting stuck where I should not have got stuck. I had to write an editor for my bounds creation function so that I can remove bounding spheres that unnecessarily get in the way.



Most of the code I needed to do this was already in the game. I find this a lot now. Most of what I have to change or add is just a variation of something I've already written so the game is moving on more quickly now.

In the above picture you can see the small spheres clusterred round one part of the model. The whole model is coverred with those spheres but to make collision detection quicker those spheres are included in a larger sphere. The small group shown above are the smaller spheres in just one of the larger spheres.

Just in case its not obvious, those spheres are never visible in game. I had to deliberately add the line drawn circles to visualise them while editing. A long time ago I added a shapes class to the game that is only used by the editor to represent frustums, bounding spheres, bullet trajectories and anything else where I needed to visualise the result of some function or other. Over time I have a lot of options that I can overlay on the view.

No comments: