Rotating faces Rubik's Cube C#

こ雲淡風輕ζ 提交于 2019-12-06 06:49:55

问题


I've been looking around the internet for a few days now, and I can't really find an answer that i can understand well enough to rotate my Rubik's Cube.

I have made my own 3D Model using Blender of a Rubik's Cube and imported it in to Unity which is what I'm going to use to rotate the faces.

But I just don't seem to understand the mathematics involved in rotating a Rubik's Cube, should i use Matrices? If so how do i couple it all together for it to work?

I can rotate a single side around by grouping the bricks together by faces, but the moment you turn the next face it would completely disrupt the other one.

Thanks a lot!


回答1:


My idea: Keep each of the 26 blocks as separate GameObject objects (8 corners, 12 edges, 6 centers), with each block's origin in the center of the cube. Separately you keep track of which block is currently where on the cube, for example in a 3D array.

Then when a face needs to be turned:

  • Find out which blocks belong to the face.
  • Rotate each of those blocks around the axis of rotation (through the middle of the cube) using Unity's normal rotation functionality.
  • Update the information on which blocks are where.


来源:https://stackoverflow.com/questions/15572326/rotating-faces-rubiks-cube-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!