EAE6320 – Assignment 5 – Extending the Asset Build System

This week’s assignment had us extend our asset build system to make it easy to add and remove different types of assets. The first task was to build assets from a list in a file instead of specifying them in the custom build step. This means we have to make an AssetsToBuild.lua file and come up with a format for the list. My file looks like this:

    mesh = 
        builder = "MeshBuilder.exe",
        sourceExtension = ".lua",
        targetExtension = ".lua",
        assets =
            { src = "Mesh_ColorfulSquare" },
	    { src = "Mesh_Triangle" }
    vertex_shader = 
        builder = "GenericBuilder.exe",
        sourceExtension = ".vert",
        targetExtension = ".vert",
        assets = 
            {src = "square"}

The top level is a dictionary of tables, each table corresponding to a type of an asset. Within these tables, I have information on how to build that type of asset and a list of assets to build. The src is the relative path of that asset from $(AuthoredAssetDir). The sourceExtension is appended to src to get the path to the file. But..this is kind of weird.

Ideally I would have something like:

 { src = "Mesh_Triangle.lua" }

After the asset is built, it would be placed in  $(BuiltAssetDir) with the appropriate change in extension. Its important to have a different extension because it tells us what kind of data is in the file. The problem with this approach was that the builder will have to extract the source extension from src and replace it with the target extension. This can get tricky if wehave file names like File.A.lua.

Therefore I decided to store the sourceExtension and targetExtension separately in the table and then src consists of the relative path minus the extension. I’m not totally comfortable with this approach and would prefer to have the extension in the src path because it makes more sense. But it would mean additional complexity and I’m not sure if the trade-off is worth it at this point.

I placed AssetsToBuild.lua in $(ScriptDir) and subsequently under the “Scripts” filter in my Visual Studio solution.

JP also gave us some new code for the AssetBuilder and a base class which we can use to make more builders.builderhelper_visualstudio

The BuilderHelper is a base C++ class which is to be used by all our builder tools. We can inherit from this class and implement our custom build process.

eae6320::Build<eae6320::MeshBuilder>( i_arguments, i_argumentCount );

There are no changes to the AssetBuilder’s dependencies. It depends on the Lua project like before. BuildAssets now depends on AssetBuilder, GenericBuilder and MeshBuilder. This is because we may need all these builders to build different types of assets when BuildAssets is built. The custom build step for BuildAssets is “$(BinDir)AssetBuilder.exe” . This is because AssetBuilder automatically looks for AssetsToBuild.lua so we don’t have to specify it as a command line argument. In future we may want to provide the lua file through the custom build step.

The last step of the assignment was to add another mesh, build it and draw it. The mesh file was created manually. To build it, we add it to AssetsToBuild.lua. In the above snippet:

src = "Mesh_Triangle"

Once this was done, we have to load and draw this mesh alongside our square. For me it was as simple as adding two lines to add another mesh to the scene and everything just worked:

                Mesh* m;
                if (LoadLuaMesh("data/Mesh_ColorfulSquare.lua", &m))

                if (LoadLuaMesh("data/Mesh_Triangle.lua", &m))

We should also be able to debug our asset builders. To do this I changed my startup project to MeshBuilder and supplied the paths to the asset I wanted to build as command line arguments.



Overall I didn’t face any issues in this assignment. Most of my time was spent editing lua code which is forgiving and mostly easy to fix.

Here is the new triangle along with the square:


Controls: Press Esc to quit.