Introduction
Iron Cube - drive a tank in completely destroyable world! Upgrade your tank, build manually bridges across rivers and obstacles, dig tunnels under
enemy vehicles to blow it!
The game is written in C++ and use in-house game engine Glow3d (http://www.moddb.com/engines/glow
and http://glow3d.com/blog/ ).
Background
My name is Yakov Sumygin and last several year I spend my free time on developing game engine Glow3D. It's written in C+, cross platform and supports both DirectX and
OpenGL (plus OpenGL ES). Also it uses "Bullet" physics, OpenAL for 3D sound and Recast dynamic navigation meshes for AI.
I decided that the best way to develop engine is make interesting game on it. I was amazed by voxel-based games as Minecraft and Infiniminer,
amazed particularly by ability to change a game world completely. So I decided to play with such kind of world generation and with one more
my obsession - tanks!
Key features
The code
Voxel generation
First version of game uses voxel field generation based on Perlin (Simplex) noise. But I decided to switch it to use prebuilt heightmaps to have more control. Voxel field is generated in chunks of voxels with size 32x32x32, polygons are generated only on edges of voxels between land and air. Engine is multicore ready, so many tasks are executed independently and use all available cores. For example voxel field is built on all available processors same time.
Code for generating triangle meshes from voxel field (fastly implemented first thought):
for ( size_t y=1;y<m_height-1;++y )
for ( size_t z=1;z<m_length-1;++z )
for ( size_t x=1;x<m_width-1;++x )
{
voxel_t v = m_buffer[ index(x, y, z) ];
if ( !e.filter[v] )
continue;
voxel_t neighborhoods[6];
get_voxel_neighborhoods( x, y, z, v, neighborhoods);
if ( !e.filter_neighborhood[neighborhoods[SIDE_LEFT]] )
{
AddQuad(e, v, SIDE_LEFT,
int3(x, y, z+1),
int3(x, y+1, z+1),
int3(x, y+1, z),
int3(x, y, z),
ambient, global_ambient
);
}
}
It's simple solution, but there is more powerful algorithms for triangle mesh generation from voxel fields.
Check next link http://glow3d.com/blog/2012/08/20/geometry-optimization/.
Enemies
Enemies are ruled by state machine. I use recast Navigation library and navigation meshes for bot movement.
This is example of AI state for tank movement toward enemy:
struct tank_move_to_enemy_t: public ai_state_base_t<CTank>
{
tank_move_to_enemy_t(const char* name, int weight, CTank* pThis):
ai_state_base_t(name, weight, pThis), m_enemy(0){}
bool run()
{
m_this->move_toward( m_enemy->position() );
return true;
}
int weight()
{
if ( !ai_state_t::weight() )
return 0;
return m_weight;
}
IEntity* m_enemy;
};
Every bot has set of states, every state has weight. During game loop AI simulation, bot calculates current state to execute, for example if bot sees enemy, the
move_to_enemy_t state is executed.
Modification of voxel world
Voxel chunks are organized by octree, so when some action with voxel modification happens it allows quickly find affected chunks and voxels.
size_t CCubeCluster::process_voxels_in_volume( cluster_entity_info_t& e, const IVolume& volume, voxel_t v, glw::u32 update_version)
{
size_t count = 0;
for ( size_t y=0;y<m_height;++y )
for ( size_t z=0;z<m_length;++z )
for ( size_t x=0;x<m_width;++x )
{
voxel_t old_v = m_buffer[ index(x, y, z) ];
if ( old_v == v )
continue;
CBox box;
voxel_box( int3(x, y, z), box );
if ( volume.collide( box ) )
{
on_voxel_changed( e, int3(x,y,z), v, update_version );
count++;
}
}
return count;
}
IVolume - base class for different types of volumes - sphere, box etc.
The team
Iakov Sumygin, Dmitry Shipilov
Screenshots from final version of the game


Video
http://youtu.be/ioBkVfaQF_Q
What was wrong
- Certificates from Comodo - I started issuing process 2 weeks before deadline and spent around 2 weeks on communication by e-mail. Finally switched to Symantec at 20 of November, but it was too late. I submitted game after deadline.
- Wrong prioritization- in so short period of time I should concentrate on simple but interesting gameplay but I wanted to have it all - several modes of game, good and smooth networking (the game is based on my own engine, so I should to write it by my own hands), nice graphics, proper effects, day-night change etc. At last days I just cut all unnecessary things in gameplay and graphics.
- Lack of testing - as I finished game one or two days before deadline, I didn't have time to properly test it.
What was good
- I finally made a game using my engine! Thanks Intel and Code Project!
- I have shinny new ultrabook, which is not on the market yet. It's super powerful and slim and costs me nothing )) ( actually 75 usd for Windows 8 and 100 usd for post but anyway ).
- Development of this game will be continued and I hope it will raise to something big.
- Lessons are learned and I know, how to concentrate on proper things to finish something.
If you are interested in this project please check my
blog
glow3d.com/blog or follow me on
twitter.