Week 7
In this lesson we have to define a function that creates a pyramid shape using polyCubes.
Func 1:
My first try at a pyramid function. This creates a basic pyramid with 4 cube objects, moving each one individually. This implementation, while functional, could use a lot of improvement. First, it is very hard to change values and extend the pyramid. Second, It uses a lot of repetive elements. And third, it could be made much more consise for readability and editability.
Func 2:
Here is my much improved pyramid function. This uses a for loop to automatically create a pyramid specified by arguments supplied by the user.
Func 3:
This script includes the previous functionality and uses a a window to provide a GUI for the user for easy access and choice. This script also contains a new function 'custom_pyramid'. This function utilises intField to allow user input of integers from the GUI.
Window image:
Test 1: 7 steps
Test 2: 25 steps
Functionality: Delete all
After testing the code I found it necessary to delete all the shapes. This is a repetitive task and can be automated with another button in the window. Using the semicolon allows 2 Maya commands to be executed using only 1 line of code.
Delete test:
When the button is pressed all the selectable objects are deleted as expected.
Week 7 Activities:
1. Maya Cubes
a) create a 20 units height rectangular box with 15 subdivisions along X, 10 along Y and 15 along Z
b) move this cube to position [1, 1.70, 4]
2. Adding Functionalities
- rotating the cube from the previous activity by 40 degrees around the X axis, 60 degrees around the Y axis and 20 degrees around the Z axis, then
- freezing the translation and rotation, then
- modifying its name to become “myCube999” and finally,
- selecting the Cube and deleting it from the Maya scene.
3. Modularising Scripts
- a function called my_create, to create a rectangular box of a user specified height, and subdivisions along X, Y and Z;
- a function called my_move, to move a cube to a user specified position XYZ;
- a function called my_rotate, to rotate a cube around X, Y and Z axes by a user specified amount of RX, RY and RZ degrees,;
- a function called my_freeze, to freeze the translation and rotation;
- a function called my_modify, to modify the name of the asset to be a user specified name and finally
- a function called my_select, to select the cube and delete it.
4 User Interfaces (UIs) and Windows
In this task I combine the previous functionality with a new GUI that takes user input to specify the function parameters.
Here are my modified functions. The maya queries are used to get the values from the window.
And here is the window. All the buttons have been tested and are working. The layout could use some modification to make it more visually uniform.
Programming for Animation Blog
Status | In development |
Category | Other |
Author | up2115462 |
Leave a comment
Log in with itch.io to leave a comment.