Archive for June, 2014

Voxel Game : Collision System

A few more things are hooked up in the UI to allow spawning entities for testing.  The attributes system is now able to handle a variety of values for each Entity including it’s HP, collision damage, if it collides at all, and if it is controllable by the player.  An optional Behavior is now in charge of creating the illusion of gravity, instead of all entities always being evaluated.

voxel_collisionsThe collision system is now implemented and optimized with an Octree, with actual collisions being evaluated using an Axis-Aligned Bounding Box for each Entity.  It’s much more efficient than a n-to-n comparision, but I still feel like it could be faster.  Perhaps collision spheres instead of AABB.

Voxel Game : UI Added

After a lot of fussing with TWL to get a UI working, I decided to create my own.  I hesitated to do this, as a UI system is practically an entire project unto itself. However the complexity of TWL combined with it only drawing in direct mode led me to engineer my own solution.  The custom solution takes advantage of Vertex Arrays and buffers the data rather than directly drawing the quads to the screen every frame.  A simple nesting pattern with individual offsets and event processing has allowed me to create a very basic UI with blocks of color.  Once the design of the game evolves further and the needed functionality is clearer, I plan to texture buttons and menus to make them look more elegant.

voxel_ui1voxel_ui2

Part of implementing the UI was making a bitmap font that was renderable using Vertex Array Objects.  The BMFont format from angelcode.com has a simple and detailed XML output file that pairs with a generated PNG file.  After some experimenting with alpha blending and kerning, it turned out quite nice.  I allowed the code to scale the font to whatever size it needs, but bitmap fonts generally look best when they aren’t stretched or shrunk.  So currently there is some artifacting, which will be eliminated once the UI design evolves a bit further.

I also spent a good amount of time creating an ANT script that will correctly compile and package everything into a JAR along with the needed assets (textures, sounds, shader files).  All the assets are kept in a separate package structure, separated from all the class files, which helps me keep it organized more easily.  It took some trickery with classpaths to get things to run correctly both in Eclipse and in the compiled JAR.  In the end including the root of the project “/” in the classpath in Eclipse fixed most problems.

Other things that where done since the last update :

  • Added an audio system in a separate thread
  • Added OBJ file loading for loading polygon models
  • Increased flexibility of Entity attribute system
  • Added main menu, game creation, and in game UI