top of page
Writer's picturewu iris

Import Models From Maya

Updated: Oct 14, 2020

Downloadable

Controls:

Exit: ESC or click X

Pause/Resume: Space (hold)

Hide Mesh: Shift (hold)

Change Effect: Ctrl (hold)

Change Mesh: Enter (hold)

Move Object: Up/Down/Left/Right (hold)

Move Camera: W/A/S/D (hold)

Rotate Camera: Q/E (hold)


Key Points

Export Meshes Using My File Format

Exporting meshes is just like writing to files. Since we have already had the vertex array and the index array as parameters of the WriteMeshToFile() function, the only thing we need to take into consideration is the format we defined in the last assignment. I created a table for each vertex last time, so I only need to add information to each vertex, instead of modifying my format. I also decided to export all data in sVertex_maya because I will have to export my meshes again if they become useful in the future (at least, I knew the color was essential for this assignment). When loading the file, I chose to ignore the data I would not use for now.

The exporter uses Maya libraries, which are external libraries. I don't think the exporter depends on any projects. The cpp file is not using any functions from other projects. And I don't think any projects depend on the exporter either. Neither the engine nor the game is tightly connected with the exporter. Whether the exporter is built before or after them does not make any difference.

Here is a screenshot of debugging the plugin:

After all these tasks are done, theoretically, the MyGame project should work, but our mesh can only have a limited number of vertices. I scanned through the initialization() function and discovered why we could not have too many vertices. The size of each index is 16 bits which means it can only represent 2^16 vertices. When the size exceeds this number, it might not draw the correct shape, so I decided to change it to uint32_t instead.


Add Color To Vertex

Besides modifying Graphics APIs and vertex/fragment shaders, I added one more helper function to load the color table. In this function, alpha is set to 1.0f by default, so it can still work even when we don’t export alpha. I converted [0,1] to [0,255] by first multiplying it by 255 and then use Roundf() to round up/down to get a comparatively precise value.

Here is a screenshot of the game:

Here is a video of gameplay:


22 views0 comments

Recent Posts

See All

Audio Project v1.0

Downloadable See How to use it? for more information. What does the project do? This audio project is based on Windows XAudio2 library....

Comments


bottom of page