Wednesday 29 January 2014

Hey good lookings, what's cookings?


Meshes. Meshes are cooking. Through the power of my new meshcooker app. The meshcooker implements my Application Interface and is instantiated instead of the game by command line switches to cook assets into a preferable format.

Here is the backstory: All of the new mesh import work (for certain values of "new") operates through a set of iterators that go over each vertex and triangle to smooth and flip normals to make the mesh look as good as possible. There are some meshes it can't process as it operates on shared vertices and shared edges, but for most convex hulls it works just fine. And thankfully most injection moulded plastic forms a convex hull...

The upside is that most LDR mesh files are loadable, which increases the available brickset from the basic bricks, plates and roof bricks I have to a wide array of brick elements. The unfortunate consequence is each mesh is post processed every time its loads, which leads to ~very looooong~ startup times.

So I've taken the process offline and written a mesh cooker that opens LDR and OBJ mesh files, builds a triangle set and post-processes for smoothing. Finally it converts them to a renderable vertex buffer format and serialises to disk as a bytestream.
The mesh resource bytestream can be loaded directly into a vertex buffer and startup times are now faster than ever!

The mesh resource bytestream also includes data sections for resource ID and version numbering so the mesh cooker can be automated to refresh when new or updated content is added.

I don't have much code to show-and-tell, nor any new screenies, at least not yet, but its only a few steps away from importing a whole bunch-a-bricks from online LDR resources. The code makes heavy use of the existing Mesh Import pipeline, and just derives a new Import and Export pair from the current MeshImport and MeshExport interfaces.

Tests are thin on the ground, but I'll add a few to ensure that the Import/Export implementations are symmetrical and go from there.

More news as it breaks. Recreational Programming is a lot of fun, if you have any questions or comments about game development or the Pioneer project let me know!

No comments:

Post a Comment