PDA

View Full Version : Rigging a Rubik's Cube


foane
11-29-2005, 01:12 PM
well, I've tried lots of things out already but none of the rigs seem to be very useful. At first sight this seemed a very easy piece to rig but once I tried to find a solution, I realized that a Rubik's Cube is in fact quite hard to rig properly. The most userfriendly rig atm seems to be just linking all the little independent cubes to a bigger inner cube or sphere (which you don't see, it's just there to fill the gaps between the little cubes so you can't look trough the little holes between the little independent cubes when looked at in profile).
anyway, I then linked the inner cube to a bigger dummy for easy selecting and keying.

So now I've got to manualy select a side (with 9 little cubes), rotate it, deselect and select another side, rotate........ quite a hassle!

I thinks it's a nice challenge for all you riggers, I would appreciate it if somebody could help me on this.

Thanks in advance,

Foane

marktsang
11-29-2005, 02:01 PM
you could try this...
setup a link constraint controller on all the cubes (all separate)
and link them to controller objecst that represent lines (either horizontal or vertical)
and animate them rotating then.. aniamte the link constraint and repeat

mark

foane
11-29-2005, 04:00 PM
I've tried what you said Mark but all these kind of techniques come down on the same problem, individual animating. I mean, after I animated the controllers I also have to animate the weights of EACH little cube....impossible to work with. The best system would be to have some kind of influence box that 'grabs' all the assigned geometry within its boundries. So then I could animate these influence boxes.... does this make any sense?

I don't know if something like that exists in MAX 8 but it would really help me on this.

Thanks anyway Mark...

marktsang
11-29-2005, 04:13 PM
hi are you sure you tried the link constraint and not pos orientation constarints, link constraint is a transform contoller and does not have any weight(s),
i would say this would probably be your best bet

mark

foane
11-29-2005, 08:07 PM
yeah I know, wrong choice of words...sorry about that

Either way, with the link constraints I still have to fix each seperate cube after I animated the cube (with 'fix' I mean giving the small cubes new link targets)

Foane

eek
11-30-2005, 12:08 AM
i wouldnt use link constraint for this, it would become clunky for animation having to readjust all the all the links over time. I do know of a possible way but id have to use my pose tool for it.

So theres three rotations going on , of a possible 27 cubes. You would have to build a dynamic constrainst relationship of a 81 constraints.

For each cube, it has 3 dynamic positions and rotations for each twist axis, so in theory you need a set weight sliders to change what the cubes being driven by. Also a global parent to keep everything local. Umm...

So the number of possible positions is:

http://mathworld.wolfram.com/images/equations/RubiksCube/equation1.gif

You would probably have to deal with localised xform space, on a local root too.

hmm.. interesting challenge.

eek

foane
11-30-2005, 01:26 AM
hey eek,

yeah I know, it's strange how these simple things can get so ugly :)
you pretty much summed up the things I was thinking about...lots of data!

let me know if you found something.
cheers,

Foane

eek
11-30-2005, 01:47 AM
I'll give it a shot this week, if you dont here from me my head will have probably exploded...

eek

foane
11-30-2005, 01:52 AM
ok, thanks Eek

I've tried binding the little cubes to FFD spacewarps but that was just gambling.... it didn't work.

Harvey
12-02-2005, 02:30 AM
Interesting challenge indeed. Not sure what this is for so a complicated solution may be more than is really needed but it certainly does present some curious possibilities.

If I had more time I would play with it myself but with majors deadlines at work and my vehicle rigging series I dont' have time. However for anyone you might want to give it a shot I will at least say the direction I would go with it.

I wouldn't animate the 26 individual boes at all. I would look for a way to animate the 6 different sides only. And then what ever boxes happen to be in the volume of that side at the time of rotation get moved with it. This would almost certainly require some scripting but there are lots of ways to find if things are within a certain volume..like volume select for instance. This method would have to assume that no two sides would ever be moving at the same time...or else things would break. ...damn I wish I had some free time...

eek
12-02-2005, 03:00 AM
dammit Harvey,

My secret is revealed! hehe ala transforms through volume space


eek

foane
12-02-2005, 08:41 AM
yeah Harvey,

exactly the same thing as I was thinking (and Eek :) ). Volume selection could be the key. however, when I use this method on the cube it all works fine untill you rotate a little box that already has been rotated (then the axis are screwed up so the little box turn in a unexpected orientation). It seems that the changing of local space isn't doing any good...

don't know Maxscript (yet), so I have to rely on you guys.

by the way, the cube is for my short (thesis). The short is about two burglars, one of them is a real moron and plays with a rubik's cube all the time...

Thanks,

Foane

Apollux
12-04-2005, 05:21 PM
From the responses I assume you all are using Max, wich I dont use (Im a Blender guy).. so maybe this wont be of any help to you.

Does Max supports solid body dinamics? If it does them worry no more.

Just assign all your colored cubes some sort of attraction constraint.. all linked to a inner sphere or some other filler figure. Im talking like gravitational attraction, axis independent.

Everytime you push a cube, been solid, it will push its neigboors, creating a domino fx that will make the entire row to rotate. It the rows are not well aligned the movement will be obtructed, just like in the real thing.

arctor
12-05-2005, 05:40 AM
oh lord...not this again.....

I suggested this back in the spring over at od[force]...
http://odforce.net/forum/index.php?showtopic=2731

it's actually a really dificult problem...at least as I described it...
most of the solutions that people came up with involved either writing data to disk or dynamics or some such thing...but none of those solutions allow for the cube to be animated in a scene by an animator just like any other type of prop...animate forward, back, scrub in the timeline etc etc...
good luck...have lots of asprin around for when you get a headache :scream:

foane
12-05-2005, 08:11 AM
yes, altough I don't understand most of that Houdini stuff, I do understand it's not easy at all. it's a pitty they didn't found a real solution over there as well. For the moment it looks like my first (stupid) solution was best, just grabbing the cubes of the side you need and rotate them + an easy parented system to have a bit of quick keying control. The thing that Apollux describes is not quite satisfactory because you're working with simulated dynamics and that doesn't allow itself to be animated on the fly. Maybe there's an easy way to fix the problem by just 'faking' what the viewport does (where grabbing a side with cubes and just rotating them, but in our case + some sort of animation control). Maybe there's a way to script the thing, I don't know if this is hard or not but it would work if somebody could make a piece of code that says: if a certain vertical or horizontal animation control rotates (bound to 90 rotations), then these cubes get linked constrained to it.....
but because where dealing with 27 cubes here, each containing 9 potential link targets this could be a bit cluttered doesn't it?

let's keep it going...

Foane

Apollux
12-05-2005, 08:23 AM
yes, altough I don't understand most of that Houdini stuff, I do understand it's not easy at all. it's a pitty they didn't found a real solution over there as well. For the moment it looks like my first (stupid) solution was best, just grabbing the cubes of the side you need and rotate them + an easy parented system to have a bit of quick keying control. The thing that Apollux describes is not quite satisfactory because you're working with simulated dynamics and that doesn't allow itself to be animated on the fly. Maybe there's an easy way to fix the problem by just 'faking' what the viewport does (where grabbing a side with cubes and just rotating them, but in our case + some sort of animation control). Maybe there's a way to script the thing, I don't know if this is hard or not but it would work if somebody could make a piece of code that says: if a certain vertical or horizontal animation control rotates (bound to 90 rotations), then these cubes get linked constrained to it.....
but because where dealing with 27 cubes here, each containing 9 potential link targets this could be a bit cluttered doesn't it?

let's keep it going...

Foane

Now that I remember, most Linux distros come with an OpenGL screensaver that is nothing less than a self-solving Kubric Cube... source code is alwasys included :thumbsup:

dantea
12-05-2005, 07:58 PM
yes, altough I don't understand most of that Houdini stuff, I do understand it's not easy at all. it's a pitty they didn't found a real solution over there as well.


That's not true at all. There were several workable solutions in that thread. Frank Firching's solution even worked to Arctor's unreasonable requirements.

arctor
12-05-2005, 09:03 PM
Franks' was particle based...no scrubing etc...it's not something that a character animator could use as a regular prop - though it is stilll quite smart :)

foane
12-05-2005, 10:27 PM
exactly, there were several nice and smart solutions in there but the main requirement in this thread is that the cube has to be easely animatable....

cheers

dantea
12-06-2005, 05:40 AM
I think we're splitting straws here. In my mind, there was at least one solution that was significantly easier to animate than otherwise if you were told to animate a Rubik's cube.

foane
12-06-2005, 10:24 AM
hmmm, maybe I could look into it more but I don't have Houdini so I can't open the files.... But it would be cool if one of you guys could translate the interesting stuff to Max terms. Anyway, the hunt is still open :)


Foane

Apollux
12-06-2005, 10:52 AM
I believe that the simplest and more animable solution was mentioned long ago.. and it was using no rig at all.

Parent all the cubes to a central object. Need to rotate a row? select the entire row, rotate it and keyframe the movement relative to the central object.

It is symple, it is fast and it is easy to do. So why do you keep complicating yourself?

dantea
12-06-2005, 02:14 PM
hmmm, maybe I could look into it more but I don't have Houdini so I can't open the files....


There's a free non-commercial version that's on www.sidefx.com (http://www.sidefx.com).

arctor
12-06-2005, 09:14 PM
I believe that the simplest and more animable solution was mentioned long ago.. and it was using no rig at all.

Parent all the cubes to a central object. Need to rotate a row? select the entire row, rotate it and keyframe the movement relative to the central object.

It is symple, it is fast and it is easy to do. So why do you keep complicating yourself?
love to see this in action....
the 'row selection' is only one major issue...

gabio
12-07-2005, 03:34 PM
Here is the solution I came with:
http://img522.imageshack.us/img522/3703/rubiksolving4ju.gif (http://imageshack.us)

The idea is to rig each cube with a bone, letting the tip of the bone out for easy selection.
http://img451.imageshack.us/img451/4109/rubikrigshad7kf.th.jpg (http://img451.imageshack.us/my.php?image=rubikrigshad7kf.jpg)
All you need to do is to select the row, rotate on the good axis, take a key each 45 degree, make sure one move don't overlap the next move and that's it. The selection is easy since all bones-tips get aligned in side-front-top view, a box selectiopn give you instant acces to a row.
To get a nice rotation, all the roots of bones are in the center:
http://img487.imageshack.us/img487/6858/rubikrig0sg.th.jpg (http://img487.imageshack.us/my.php?image=rubikrig0sg.jpg)
Blend file (blender 2.40)
(http://web.netrevolution.com/gbeloin/elysiun/blend/rubik_cube.blend)

foane
12-07-2005, 07:43 PM
hey Gabio,

thanks for this nice tip, it got me thinking on another path...
Altough the notion of selecting the cubes like that is interesting, it's still not THE solution I think. Because now you're basically just extending the selection areas....you might as well just select the boxes. With this method it actually gets even harder to select the boxes when they're in the hand of a character. I do have to say that it's a nice way of thinking, 'extending' the selection area is probably a good way to go!
( In fact , I'm thinking more in the GUI area for the moment...)

Thanks again Gabio,

any other toughts?

Foane

kryoboy
12-09-2005, 04:21 AM
might be possible to creat a rig that can rotate 45 degrees for each section that pops back to orginal rig state after each 90 degree rotation.

and use a texture network to handle all the possible postions.

kinda like creating a grid from U and V ramps that are interlaced in U and V direction that pop to new values of U and V postitions based on every 45 degree of the row control.. like a nurbs circle.

the block row will rotate 45 degrees and pop back to 0 degree once its greater than 45.

so essentially if you can rig it to rotate in each directions by 45 degrees from the starting point. the texture can be ajusted to maintain the visual of infinite rotations in all directions.

eek
12-09-2005, 05:07 AM
i got it working possibly for max, seems to work nicely and easy to set up. Ill post some pics soon.


eek

edit: may of been jumping the gun. Getting some probs.

foane
12-09-2005, 11:54 AM
kryoboy, I'm really interested in the things you're saying. I don't really understand any of it but that's why I'm interested :) . Could you explain your theory a bit with an example?

To Eek, :) ....


Thanks

marktsang
12-09-2005, 12:27 PM
i think it would be quite easy to do in maxscript
i might have a go tonight

mark

MikeRhone
12-09-2005, 06:18 PM
You could place the pivot of each cube at world origin, then rotate in GLOBAL mode. That would be sufficient to do an animation. I just tested it now and it works just fine. In this case I would just slap the animator and tell him not to be such a lazy-ass! ;)

However, if it was life and death and yuo needed a RIG solution...

Set an expression that reads the rotation of the middle cube of each face. When that face reaches a new 90 degree rotation, use MEL and reparent all of the cubes in the rubiks accordingly. Yes, this is a senario that involves usnig MEL in an expression.

IE:

if (yellowCentreCube.rotateY%90= 0)
{
//select the cubes surrounding the yellow centre cube, and reparent
}

if (blueCentreCube.rotateY%90= 0)
{
//select the cubes surrounding the blue centre cube, and reparent
}

Eh? Eh? Possible solution?

eek
12-09-2005, 07:03 PM
hey Mike,

Thats pretty much what im planing, i do however get some weird position offset issues, im gunna check. Dynamic parenting, i have qwarms with, this might be a max thing though.

eek

marktsang
12-10-2005, 03:19 AM
tried my hand at this one tonight,
basically i transformed all the pivots to the center and using maxscprit i do a test to see what side the cubes are on - the cubes on the rotating side inherit the correct rotation

see a rubbish screen cap here http://www.sitesled.com/members/marktsang/rubix.swf

problems so far

* gimbal lock and wobbly rotations (i am going to fix this tomorrow)
* need to press a button to have the ctrl objects affect the cubes (will also sort this out tomorrow)
* does not update in realtime when rotating. ... still thinking of ways to get around this, i see many potential ways.

other than that i think it wokrs pretty good :D


mark

marktsang
12-10-2005, 07:44 PM
Mummy said to never do anything by halves so amonst lounging around enjoying my saturday i managed to finish this thing off

http://www.sitesled.com/members/marktsang/portfolio/rigging/movies/rubix.swf

here is a quick animation with it done in a few seconds..:D


divx http://www.sitesled.com/members/marktsang/portfolio/animation/movies/rubix.avi

im looking for work btw :D

mark

foane
12-14-2005, 12:34 AM
sorry for the late reply Mark but I have to say: looking good man!

it would be great if you would post the scripting code here (+ explaining) so we can take a look at your methods...

(you can also send me an e-mail with the file if you want)

the only thing that's missing now is a funky GUI and that'll be it I guess.
oh and by the way, does the cube have any speed issues?

Thanks for all the help guys, I really appreciate it

Foane

BebeteLANUITE
01-10-2006, 07:39 AM
Hello Marktsang.

Could you post you code here. If it's possible.
I try to rig a rubik's cube too.

Thanks a lot. :)

CGTalk Moderation
01-10-2006, 07:39 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.