3D Tile Engine (because Blocks are Cool)

Lately, I’ve been working on a 3D tile engine using Panda, and it’s finally gotten to a point that I’m feeling the urge to show off just a little.


There’s also a short YouTube video at: http://youtu.be/p2GT8jfWR-8

Now that the important part’s out of the way… the tile engine is written using Cython, and boy does that make a difference. Precalculating visible block faces literally became twenty times faster. Or more.

The tile engine generates geometry in chunks of 32x32x32 blocks (though the chunk size is controlled by a single definition and easily changed), and it has a few performance tricks. For one, it only creates two vertex buffers/writers/geom/geomnode sets for each chunk. One for blocks that are transparent, and one for those that aren’t.

Then, it combines faces when it can to reduce polygon count by a lot. Adjacent blocks of the same type will, generally, use just two polygons for a face. I’ve got those all in a GeomTristrips, though I haven’t tested to see if it performs better any other way. (I suspect it doesn’t.)

There are a few things left to code at this point, including a way to get it streaming only chunks around a given location, and some editing functions, but performance is looking pretty nice.

I’m planning to use this tile engine in an RPG creation system, similar to the RPG Maker series of applications.

a couple of cube-generating code has been around the forum for a while. but yours is pretty impressive. so. good job, and good luck doing awesome stuff with it :slight_smile:

I love this!

David

Thanks!

Though, now that I’ve posted, I realize that I’ve left off the actual impressive, fast part. Anyone can bake geometry and get decent FPS.

That said, my tile engine is pretty fast. Here’s some numbers (generated on a Core 2 Duo at 3.5GHz).

Amphibia Luxury Building
Size: 122x122x72
Chunks: 48
Visibility Pre-calculation: 1.98662 (0.041s/chunk)
Geometry Build: 3.81599s (0.079s/chunk)

Circus Maximus
Size: 692x283x69
Chunks: 594
Visibility Pre-calculation: 4.86302s (0.008s/chunk)
Geometry Build: 14.44216s (0.024s/chunk)

Destiny
Size: 514x416x82
Chunks: 663
Visibility Pre-calculation: 4.22558s (0.006s/chunk)
Geometry Build: 12.12092s (0.018s/chunk)

Laputa
Size: 152x152x53
Chunks: 50
Visibility Pre-calculation: 0.58473s (0.011s/chunk)
Geometry Build: 4.53675s (0.090s/chunk)

very nice. Are you planning to make a Minecraft style game?

Blocks FTW :smiley:

This game will have one of the most special art style ^^

Can you release the source?
I’m interested in the optimizations you made. :slight_smile: