旋转面Rubik's Cube C# [英] Rotating faces Rubik's Cube C#

查看:99
本文介绍了旋转面Rubik's Cube C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在互联网上浏览了几天,但我找不到真正能充分理解以旋转我的魔方的答案.

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.

我已经使用Rubik's Cube的Blender制作了自己的3D模型,并将其导入到Unity中,这就是我要用来旋转面的内容.

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.

非常感谢!

推荐答案

我的想法:将26个块中的每个块保留为单独的GameObject对象(8个角,12个边,6个中心),每个块的原点位于中心的多维数据集.另外,您可以跟踪当前哪个块在多维数据集上的位置,例如在3D数组中.

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.

然后当需要转脸时:

  • 找出哪些块属于人脸.
  • 使用Unity的常规旋转功能,围绕旋转轴(通过多维数据集的中间)旋转每个块.
  • 更新有关哪些块位于何处的信息.

这篇关于旋转面Rubik's Cube C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆