Game Engineering – Building Game Engine – Part 7

Importing Meshes from Maya

Maya is one of the most common software used to create 3D models which are to be put in games. Maya also provides documentation to create plugins to extend the capabilities of the software. In this project, we are creating a maya plugin to export the mesh files in the file format that can be read by our game engine as described in the previous blog post here.

After downloading and setting up the Maya SDK, we have to enable the plugin in Maya to be able to export to our format. One we export to our format, we have to make sure that our engine builds the mesh files and then specify that this the particular mesh we have to use. The file to which we are exporting the data only contains the vertex and index information and comments which show which vertex is at what index. Apart from that we are not importing anything from maya since, the file should be human readable and ediatable and if we include parameters such as normals which we are not using in our game, it would create confusion when someone opens the file.

Output:

Importing Color: First we need to change our maya importer to import color to our files. Then we need to change code in lua, so as to import color to our vertex buffers and after importing, we need to tell both OpenGL and Direct3D that we are adding color to our vertices. After this is done, the output should look like the following.

 

Debugging Maya: Maya also provides debugging symbols (.pdbs) along with the SDK. This allows us to debug the Maya importer we built. The way we do it is to run Maya first and in visual studio, attach the process  to debug by going to ‘Debug->Attach To Process’.

The above screenshot shows Visual Studio breakpoint when first loading the plugin we build in Maya.

The maya mesh  importer is a standalone project which does not depend on any other projects. Hence no need to add references to other projects or add the maya mes importer as reference to other projects.

Opening meshes with a greater number of vertices:

Currently we are storing the total number of vertices that can be in our game in a uint16_t which can hold upto a maximum of 65535 vertices. If the count exceeds this, it would overflow. To mitigate this, we are limiting our vertex count to this value and if a mesh exceeds that, we will not render that mesh.

Controls

  1. WASD to move the Donut
  2. IJKL to move the Plane
  3. F3 to swap the Donut to a Chair
  4. Left and Right arrow to move the camera in X axis.
  5. Up and Down arrows to move the camera in Z axis.
  6. Z and X to rotate the camera around itself
  7. Ctrl and Alt to move camera along the Y axis

Thanks to Chris Cheung for providing me with some Maya meshes like the chair that I could then import into my game. You can find more of his word at his artstation.

Downloads:

MyGame_x86_1017 MyGame_x64_1017

 

Leave a Reply

Your email address will not be published. Required fields are marked *