Say I have a rubick's cube. how do i set up my glPush/glPop's to allow me to rotate each row and each column and each face separately? I hope this is enough information
Say I have a rubick's cube. how do i set up my glPush/glPop's to allow me to rotate each row and each column and each face separately? I hope this is enough information
each sub-cube will have its own rotation. glpush the rotation draw the subcube, glpop the rotation. Pretty basic in that sense.
"You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter
you'll want to translate to the centre of the middle cube of the rotating face, this is your pivot point for rotation. Then rotate each cube around this point within the plane formed by the face using the method FYB described.
I think this will have to be more than just push/pop voodoo, since if you rotate, say the left side, you will be rotating different blocks depending on the position of hte top side, which depends on the right side, etc. as both FYB and Perspective were saying.
I would like to know what progress you make on this =)
I was about to answer this as well but then it hit me. There are a lot of rotations there and you cannot just create one set of cubes to rotate. Since all of the cubes can rotate my suggestion would be to make each cube a separate entity. The overall cube shape will only be there simply because that's how you arrange each individual cube in world space. If you approach the cube this way it should work:
1. Arrange all individual cubes around the center of the entire rubix cube using translation
2. Now rotate the cubes - as a group. This will require some code to determine which cubes are a part of the face the player is attempting to rotate.
3. Because you translated first and then rotated, your cubes will now properly rotate around the center x,y,z of the entire cube.
If you don't translate your cubes will rotate around their local center (transformed to world space of course) which is not what you want.