Rubik's Cube
by JensVanhoof
on
Dec 13, 2006 at 4:48:16 pm
Hi,
I'm constructing a Rubrik's cube with video footage in After Effects. I created 54 layers, one for each square. When I'm trying to make the upper row rotate, it works just fine. I select all the components for that layer and I'm rotating them 90
Re: Rubik's Cube by Steve Roberts on Dec 13, 2006 at 5:14:42 pm
The Rubik's cube presents the classic "dynamic parenting" issue. The only way that I've found to solve it is to fake it by creating different animated states of rotation that are not connected, then rendering each animation with a lot of motion blur, then dissolving between the states. If the rotations are fast, you get a zip-zip-zip effect. Oh, and that was in Lightwave. :)
But if they want it to be slow, and they want to see every face, you're in for a hard, if not impossible time.
Re: Rubik's Cube by Tyler Paul on Dec 13, 2006 at 5:37:04 pm
Holy crappers, talk about collective conciousness. Not an hour ago I was sitting in a waiting room thinking "I wonder if I could make a Rubiks Cube". I enter my apartment and BAM there's your post. Good luck on finding a solution I'll be thinking about it as well.
Re: Rubik's Cube by Mylenium on Dec 13, 2006 at 6:27:24 pm
*lol* I'd give up right now if I were you, Tyler. Thing is, you cannot animate more than 2 twists at a time, after that everything goes boom and becomes unmanageable. You really can only combine multiple compositions where one's end state represents the starting point for the next two moves. Think of this: For every move there are either 18 (3 squared cube) or 32 (4 squared cube) possible positions for each face with the next move. So after only 2 moves, you have close to 1000 possibilities, where your face can end up with the following move (4 squared cube). Like Steve said - this represents a major parenting dilemma that cannot be solved regardless of what tools you use.
Re: Rubik's Cube by Mylenium on Dec 13, 2006 at 7:59:43 pm
Yes, the underlying math isn't that complex, but it is still difficult to implement. Thing is you always need to know where each cube is and which faces are currently side by side. Not impossible to do with expressions, but probably extremely slow.
Re: Rubik's Cube by Tyler Paul on Dec 13, 2006 at 7:46:49 pm
I'll just throw my thoughts out here and see if anything sticks but alas your most likely right.
You've got 26 comps for each indivisual cube
You could use the nine expression plugins for layer selection to represent the cubes on a specific side. Which side you would like turn will also be set buy an expression plugin of some kind. Even a numerical value to represent the front back left.... would work
The position of each cube will always land on specific points on a 3X3X3 grid.
By using the current positions, layer selection, and expressions you can asign which 9 comps you'd like to parent together and then spin them.
When the spin is complete all nine cubes will again land on those specific points on the grid and you can reassign spin again.
Anyone think that might work or see where I would hit a snag?
Re: Rubik's Cube by Mylenium on Dec 13, 2006 at 8:04:41 pm
Yes, it might work, though it's still a lot of hand animation and manually setting parameters. I'd probably look for a solution based on mutually exclusive conditions - if cube X is here and Cube Y is there, then cube Z must be in the middle and act as the rotational center. Like I said in the other post, it's not unsolvable, but pretty complex.
Re: Rubik's Cube by Dan Ebberts on Dec 13, 2006 at 9:19:13 pm
Sounds like fun. Here's how I'd approach it. You really only have 22 pieces - 8 corners, 8 sides and 6 centers. The centers are easy because the don't move - they just rotate.
I don't think I'd use any parenting except to keep the three faces of a corner piece or the two faces of a side piece together. You have to keep track of the moves somehow, because the expressions won't be able to figure out their own current value without recreating the whole sequence. So I think I'd use a text layer with "standard" Rubik's cube notation of:
U = upper face
D = down, bottom face
L = left face
R = right face
F = front face
B = back face
Maybe use upper case for a clockwise turn and lower case for ccw. So a sequence of moves might look like: LFlf
For a simple scheme, where moves happen at fixed intervals, the expressions for each piece would use the text layer sequence info and the time to figure out where they should be right now in position and orientation.
Re: Rubik's Cube by Dan Ebberts on Dec 14, 2006 at 12:53:17 am
I think you could save yourself a lot of trouble if you set the cube up centered at [0,0,0] with the faces parallel to the xy,xz, and yz planes (you can position the camera off-axis later). Then you're just dealing with equations for circular motion in two dimensions.So, in the xy plane you'd be dealing with something like:
Re: Rubik's Cube by accpph on Dec 14, 2006 at 2:39:28 am
Well I brute forced it. Although I like the expressions idea. I set up a simple example with each side of nine squares centered at 0,0,0. I also created up, down, front, back, right and left nulls to be have each side parented to. These in turn were ALL parented to one global null so that I could move the whole cube.
As in the posts above I comped all pertinent squares to the side that was to rotate. At the end of each 90 degree rotation, I duplicated the comp and deleted all keys in the new comp. I then re-parented to whichever controllers were about to make the next 90 degree move. And then I made the new 90 degree animation... And repeat.
Re: Rubik's Cube by Joel Hooton on Dec 14, 2006 at 12:17:30 pm
I have already made one of these. I setup precomps for each "box". Then I manually keyframed a rotation. Then, did it again. I have about 5 or 6 rotations done. Each side is its one comp so I can edit or animate each side individually. It was a while ago and I just wanted to see if it could be done. I will upload it after work. I made it in AE 5.5.
I also made a foldable paper airplane that i just have not posted yet. I might do that too.
Re: Rubik's Cube by Tyler Paul on Dec 14, 2006 at 8:08:10 pm
Very nice. I can't wait to see the final.
I had already had my cube set at (0,0,0) so that was nice. I also had the sides spinning but Dan's expression seemed like a better idea so I went with it. The boxes are all set at (0,0,0) and I have used 2 radii values depending on whether they're a Side or Corner piece. I divided the Degrees by 57.295 to get the radians because I couldn't get toRadians() to work so that's my first question.
Now I'm coming up to the part that made making the cube so hard in the first place and that's keeping track of all the cubes. In programming I'm used to being able to add varaibles to a parameter and that amount sticking. (Example: a=a+1 and a will remain at that value until you tell it otherwise) If this were the case I'd be able to figuare out what boxes made up a face twist them around drop them, Choose a new face and again look at box positions to find the correct boxes for a face twist etc. With expressions as soon as I let go of a box (I change which face I'd like to control) the boxes reset to their original values.
My current idea is each box has an angle control for the 6 faces of the cube. Degrees are added to or subtracted from depending on the turns I tell it to make. This would allow me to keep track of every twist and turn a box has gone through. How can I make the angle controls count up 45 degrees and then stay there. I'm pretty sure I'll end up with the same problem as I had just moving the boxes and expecting them to stay.
Re: Rubik's Cube by Joel Hooton on Dec 14, 2006 at 9:55:29 pm
Here is the video
Each corner, side and middle of the cube is its own sub comp. They are parented to a Null and ALL of the are keyframed each roation. Each side has its own precomp so you can vary the picture or video or whatever for each. If you go to each the precomp for each side and look at Solid 1 there are numbers. Turn on these numbers when keyframing the main cube. It helps to identify what you are looking at when keyframing. Here is the AEP fiel
http://jmhooton.iweb.bsu.edu/joel/rubix%20cube%203x3x3.aep
Re: Rubik's Cube by Joel Hooton on Dec 14, 2006 at 9:56:12 pm
Here is the video
Each corner, side and middle of the cube is its own sub comp. They are parented to a Null and ALL of the are keyframed each roation. Each side has its own precomp so you can vary the picture or video or whatever for each. If you go to each the precomp for each side and look at Solid 1 there are numbers. Turn on these numbers when keyframing the main cube. It helps to identify what you are looking at when keyframing. Here is the AEP file
http://jmhooton.iweb.bsu.edu/joel/rubix%20cube%203x3x3.aep