Maya Exporter; PIX instrumentation; User Settings .ini
- itzvnodm
- Nov 18, 2014
- 3 min read
Purpose:
The assignment was to
Create a Plug-in for Autodesk Maya to easily export mesh in Lua format (Most convenient thing by the way).
Add User Settings, a .ini file, to load game settings from.
PIX Instrumentation: Organize the PIX output into collapsible rows.
Final Output: There are 4 materials in the scene and 5 meshes. Mapping is as below,
AMD material is applied to CUBE mesh.
Nvidia material is applied to CUBE mesh.
Strip material is applied to Torus and Helix mesh.
Microsoft material is applied to the Plane mesh.

Create a Plug-in for Autodesk Maya: [overwrite cube.mesh.lua in the Assets folder. Game should work with replacing any mesh file though]
Why do we need this?
Pretty much until this point, the only way to create a new shape / mesh in the game was to write a .mesh.lua file by hand. The format is as shown below (also explained in previous posts),

There are two problems with doing this for every single new shape we need,
For a complex mesh, the vertex and index count can get really huge, forex: for a Torus mesh that I created in Maya has 1600 Vertices and 2400 Indices.
If you want to map UVs to such huge number of vertices, it is as good as impossible.
Solution:
Creating a Maya Exporter plug-in automates the above process by exporting any mesh created in Maya editor to .mesh.lua file format that we can use in our game directly. Concept behind this is really simple and this tool will get really powerful and indispensable as and when the mesh requirement in the game get complex. You can see in the torus.mesh.lua file how complex a Torus shape mesh is and that it is impossible to create something by hand with UVs mapped.

All you have to do after exporting a mesh from Maya is, put it in Assets folder, add it in AssetsToBuild and use it in the game.
Problems faced:
I was getting a weirdly mapped Torus in-game. Which I later found out by PIX debugging that there was a bug in mesh builder parsing on UVs to the binary file. I was using unsigned int to read float values and it truncated the values to be either ones or zeros.

User Settings:
Below is the UserSettings.ini that can be modified to see the relevant output changes on loading the game.

All the values in the .ini file are validated and on failing that default values are being used. Any invalid values will output a notification message box during load time and will continue to load the game with corresponding default values. Especially, the values for width and heights are being validated in two ways,
Width or Height can’t be a float number.
Width or Height can take values that are supported by the system running the game.exe. This is done by below code snippet,

PIX Instrumentation:
Having an organized debugging environment always makes much different where a developer can get to what he wants pretty quickly. This is what PIX instrumentation does. We can send custom begin and end events that encapsulate the actual events and create a collapsible row in PIX output. This is especially important when there are many objects in the scene and you want to check on a specific object. The image below shows PIX output for 5 objects in the scene.

Without Pix Instrumentation: Finding details of one specific object in the above pool of events is hard.
The below image show the PIX output with custom events each having their corresponding material and mesh names,

Extra:
Created a default missing texture: If material file does not specify a texture, any object that is using this material will have a “Missing Texture” texture on it by default.
Added antialiasing support in UserSettings.ini


Time Spent:
Creating and Testing Maya Exporter plug-in: 4hrs
Parsing and modifying code to use UserSettings.ini: 3hrs
PIX Instrumentation: 1.5hr
Extra: 1.5hr
Write-up: 2hrs
Total: 12hrs
Comments