Harvard graduate student in Software Engineering
The objective of this pairwise project was to create a plugin script for Maya 2015 which could import a two dimensional map image and create a three dimensional environment from it (map to mesh generation). Users can either specify between two different map to mesh generation algorithms. Lightness-based generation allows users to select black & white images, versus user defined max and min hue-based generation.
In addition to the required script component, I was tasked to develop a monthly prototype build showcasing the development milestones. Finally a design document was implemented to encourage a “Design-First” methodology, in order to provide a comparison between the prototype revisions and the final product.
Prototype development began by creating a method for users to import an image into Maya. The original intention was to create an image plane and overlay a 3d polygon mesh over top. Instead, opted to utilize the Python image library (Python Imaging Library PIL, 2009) to analyze the RGB value of each pixel.
This was done to reduce overly complex code, as well as optimize the mesh generation algorithm (although obtaining the image pixel values will likely need further optimization). Once the RGB values of each pixel were stored, they needed to be converted to HSV to obtain the hue range.
Leveraging a method taught in an previous university mathematics course, I applied a conversion algorithm to pass each pixel’s RGB value and obtain the corresponding HSV. After obtaining the HSV for all pixels found in the imported image, I created a primitive polyCube to manipulate the terrain into.
The elevation value in this prototype is fixed to a pre-defined scale value. This fixed elevation value is then scaled by the hue range found in the RGB to HSV conversion. This process is then repeated for each pixel found in the image, with a corresponding primitive polyCube created and translated to the pixel location, resulting in a final model seen in the figure to the left.
Prototype Source Code
Development of the final product began by updating the method for users to import an image into Maya. Originally the script would automatically open a file explorer, this was changed with the implementation of a GUI. Now users can change various map generation settings before processing an imported image.
Python image library (Python Imaging Library PIL, 2009) is still being utilized to obtain each RGB pixel value of an imported image. As previously mentioned, this was done to reduce code complexity, as well as optimize the mesh generation algorithm.
Once the RGB values of each pixel were stored, they are either then converted to HSV to obtain the hue range or passed to a lightness function which will average the maximum and minimum RGB values.
After obtaining the HSV value for all pixels found in the imported image, a base polymesh is then created, and each vertex is translated vertically based on one of two different generation algorithms. The map is produced by either the brightness or hue of the pixel. This is chosen by user selection before map generation begins.
Once all vertices found in the mesh have been cycled through, the final generated map is produced (as seen on the left).