u/Downtown_Surprise876

▲ 390 r/Maya

I made a Rubik's Cube rig so you don't have to

A few weeks ago someone posted asking for help animating a Rubik's Cube. One of the replies said it would be a good opportunity to learn rigging.

What a horrible thing to say to a person.

A Rubik's Cube seems like it should be straightforward. It's just a bunch of cubes that rotate... until you actually sit down and try to rig one.

The first problem is that a Rubik's Cube isn't really a hierarchy. Maya rigs are built around the idea that the current values on the controls determine the output. A Rubik's Cube doesn't work that way. It has memory. The current state depends on every move that came before it. It's a state machine pretending to be a transform hierarchy, and Maya rigs really wants nothing to do with that.

Then you think, "I'll just move the pivot and rotate the cubelets."

With a bunch of 90 degree turns, Euler interpolation happily invents rotations that no physical Rubik's Cube has ever performed. Ninety degrees somehow stops being ninety degrees because Maya decides the scenic route is more interesting. So you try quaternion slerp interpolation instead, only to discover that while it solves one problem, you also lose the built in ease in and ease out of Euler curves that makes the animation visually appealing.

Somewhere along the way you stop asking, "How do I rig a Rubik's Cube?" and start asking, "Should a Rubik's Cube even be a rig?"

For some reason I decided the answer was "yes" so I wrote a custom dependency node that treats the cube as a state machine.

Features:

  • Supports cubes of any size
  • Layer-based row, column, and slice controls
  • Enforces legal Rubik's Cube moves by allowing only one control family to be active at a time
  • Save/Load tool for storing and restoring cube permutations

The Save/Load tool is a necessary part of the rig. While the control keyframes save the animation, the save/load tool lets you save the state of the cube.

Here is the github repository where you can download the plugin. You'll want the file titled "download this one". Installation is very easy, just drag and drop the install.py file into the maya viewport. This will install and load the plugin, create a shelf and button for the Save/Load tool, and add a pre built 3x3x3 Rubik's Cube to your maya projects folder.

The "read me.txt" file has instructions for animating and how to use the save / load tool. It also has rigging instructions if you want to do something stupid like trying to build and animate 10x10x10 cube.

u/Downtown_Surprise876 — 3 days ago