Blogger Templates

Wednesday, November 15, 2017

0

Graphics (11 of ∞) Maya magic for the models. (Plugin and integration)

Posted in ,
EAE 6320-001
write-ups


So far I have a really good system that is capable of rendering a model from lua based mesh file. Its really difficult to handcraft these model data and hence a good idea would be to use a Graphical rich application like Maya which can help us make the models. I can then import the Maya mesh information into my game system and have rendered the same way it was designed. Let’s look at how I arrived there.


Maya Exporter
To allow Maya to support saving meshes in the intended format, I have to create a Maya plugin that can work with Maya seamlessly. So I have to add an independent Maya Exporter project and modify the way it would create the file format for me. (i.e) I need to make sure the plugin gives my existing format which is Dictionary of Array of Dictionary of Dictionaries. This way my existing C++ read operations can work on the mesh files without changing any logic. I also added tab space and new line such that its easy for me to compare the human made file and the Maya made mesh file. The good thing about the plugin development is that I can develop the plugin as a debug file and debug the plugin real time while it is working with the Maya IDE. This is very handful in understanding how my mesh data is being processed and make corresponding changes. Note that this Maya exporter is an independent project that does not depend on any other project modules nor it is used by any project. We can build it separately to get the plugin.





Maya Integration
Once I got all the plugin integrated, all I have to do is design the model in maya. For the start, I recreated the exact same model and plane with similar geometry details and color details. Then I exported that to a mesh format using my plugin and checked the format to be consistent with the one I created. First, I did focus on getting the textures in as I had to make changes for my mesh cpp to support the texture data. So I simply started by getting the basic vertices, indices and color data in. I was able to create the same visual representation that I did in maya into my game.


Texture Integration
Texture integration was fairly straightforward but it took a bit of time as I have to copy a lot of code across the cpp files and the shader files. I followed the same pattern as that of Sprites and tried replicating the same flow. Once I had a system ready for my textures I need the right UV data for my meshes. So While adding support for the UV via the plugin, I also supported other parameters like normals, tangents and bitangents. So now my plugin is capable of giving all the mesh related information. This way I don't have to recreate the plugin time and again if there is an extra future requirement. Based on the need of game, I also have flexibility in just reading and using the data that I am most interested in. Once I have the UV data in the right format, I just built my texture using the texture builder and wired it up with my mesh and I was able to render it on screen.


Fancy Experiments
When the whole system was ready, I was fascinated to make more complex model and import them into engine. I started with a really big Dinosaur model and when I tried importing it, I ran out of my uint16_t size limit and crashed the game. I plan to change those in a future project to support higher vertex count and index count. For the time being, I was able to import a less complex geometry such as a Dog, and Earth and get it rendered on screen with applied texture.







Controls
Right Arrow - Move the 3D game object to the right.
Left Arrow - Move the 3D game object to the left.
Up Arrow - Move the 3D game object upwards.
Down Arrow - Move the 3D game object downwards.


W - Forward Acceleration
S - Backward Acceleration
A - Rotate towards the left side
D - Rotate towards the right side
Q - Rotate Upwards
E - Rotate Downwards



0 comments: