When I first started using game engines like Unity, I was amazed that I could drop a model straight out of maya and into the game scene without any problem and in this assignment I get to do the same! Asset importing has been something I have been looking forward to in this class so I was more than thrilled to start work on this.
It all starts with the MayaMeshExporter project that our professor JP has generously provided us. When compiled, this creates an “mll” file that maya can load as a plugin. In order to get the project to compile, I had to set two environment variables: “MAYA_LOCATION” which points to the installation directory of maya and “MAYA_PLUG_IN_PATH” which points to the library files that are used to make plugins and that are therefore required by the project. There were no other dependencies to add because this is a standalone plugin and doesn’t interact with any engine or game code, it only needs access to the maya libraries. The final thing I had to do was to add the code that would write out the vertex and index data in the custom file format that I established in the previous assignment.
Maya provides more than just vertex position and index data, so it was my choice to export what I needed and ignore the rest. I decided to export as much info as made sense to make it future proof, so that I would have the data I need in case I want to add lighting or materials. The final set of data per vertex that I chose to export includes the following:
Once all the code is written, things can go wrong once maya tries to load the plugin or when exporting the mesh. Visual studio provides a way to debug these problems using the editor.
The next step was to make sure that the file that is exported from maya is being loaded correctly by the game code. Since the parser was already written in last assignment, all I had to add was a function that would extract the UV data.
Now that I had the UV data, I could modify my shader code so that it would use it in the same way the sprite shaders did. I was so happy to see the textures show up on the meshes however, they were upside down in my D3D build! I spent a good 15 minutes trying to figure out the best way to flip them but I was finally able to figure out a way to do. It made me happier when I saw a comment in the exporter code that basically confirmed my way of transforming UVs as being correct.
The game right now renders 3 meshes that have been exported from maya, a cube, a plane and a cog.
You can move the cog using the arrow keys and move the camera forward/backwards and sideways using Home,End,Delete and Page Down keys.