ARTISTIC REFERENCE
RENDER
USER INTERFACE
The UI is very simple and minimal and easier for the artist to use. I have used grid layout of 3 columns where artists can input values in the text boxes. There are three buttons the `Generate Bunch` calls the main proc, the `Delete All` delete all the objects in the scene, and `Close` closes the UI button. following is the MEL script for the UI. The text boxes if left blank then run the script can make Maya crash.
THE SCRIPT
The following procedure makes a Polysphere with random rotation and random radius and sets it to smooth preview.  
Here I am using the 'rand' command to set random values to the radius variable .I declared a vector with random x, y, z values ranging from 1-180 and used it to rotate the spheres randomly.
Then I used the displaySmoothness command to smooth the polysphere.
The following procedure makes nurbsCircles ranging from maximum radius to minimum radius along y axis (Credits to: https://sdm.scad.edu/faculty/mkesson/vsfx705/wip/best/winter17/ali_nikkhouy/mel-matrix.html). The inner loop simultaneously calls generateSphere() proc and creates spheres and places along the circle. The loop then stores the spheres in a string array to create a group.
As seen above one stack been created, then the next picture multiple stacks being created. The stacks are a made using nurbsCircle then using position along the curve command ( Thanks to prof. Tina O'Hailey). The nurbsCircles upon which the stack is created have a reducing radius. I've used a string array to store the spheres in so as to group them.
The final proc/main proc lets user input all the parameters and then duplicate the stacks randomly within the bounds provided by user.
This procedure places the stacks randomly within the max x, y co-ordinates and minimum x, y co-ordinates and groups them .  I used the if else statement to have an error check if the user dosen't provide number of objects
CHALLENGES AND BUGS
The most challenging part of this project for me was to get the logic right and getting the string array right to make a group of objects. 
Following are the bugs and to-do's for this script:
1) Fix the positioning of the circles as they do not fill the whole circle in a stack
2) Fix the multiple creation of the circles on a single layer.
3) Replace the 'textField' to 'floatFiled' so as to have a default value in the UI input boxes, to get rid of the infinite loop bug when the text boxes are left blank. 
CONCLUSION
MEL script was a really useful tool to have a procedural workflow in Maya. It stands apart from other languages for how it manages variables, you can use a variable earlier in the code and declare it later and MEL won't complain. But it has some drawbacks too, like the way it manages memory and the limitation of using a same variable name with different variable types. But in the end it is always useful to learn new things, looking forward to more MEL scripting in the future! 

You may also like

Back to Top