Exemplo n.º 1
0
        public void GenerateGeometry(SharpGL.OpenGL gl)
        {
            HighlightCube.GenerateGeometry(gl);

            const float spacing = 1 + CubeSpacing;

            for (int z = 0; z < Size; z++)
            {
                for (int y = 0; y < Size; y++)
                {
                    for (int x = 0; x < Size; x++)
                    {
                        var cube = new Cube(Colors.Black);
                        ColourCubeFromConfiguration(cube, x, y, z);
                        cube.GenerateGeometry(gl);

                        var position = new Vector3(x * spacing, y * spacing, z * spacing);
                        position += m_cubieCentre;  // Centre
                        string id = string.Format("{0},{1},{2}", x - 1, y - 1, z - 1);
                        var cubie = new Cubie(id, cube, position);
                        AddToConfiguration(cubie, x, y, z);
                        m_animators.Add(new CubieAnimator(cubie));
                    }
                }
            }

            CubeConfiguration.CheckValid();
        }
Exemplo n.º 2
0
 public Cubie(string id, Cube cube, Vector3 position)
 {
     Id = id;
     ModelRotation = Quaternion.Identity;
     WorldRotation = Quaternion.Identity;
     Cube = cube;
     Position = position;
 }
Exemplo n.º 3
0
        private void ColourCubeFromConfiguration(Cube cube, int x, int y, int z)
        {
            var config = m_initialConfiguration ?? CubeConfiguration<FaceColour>.CreateStandardCubeConfiguration(Size);

            var lastIndex = Size - 1;

            if (x == 0)
            {
                // TODO: BETTER WAY OF CREATING FACE SO EXTERNAL DOES NOT CARE ABOUT INDEX ORDER
                var colour = config.Faces[FaceType.Left].Items[lastIndex - y, z];
                cube.SetFaceColour(FaceType.Left, m_faceColours[colour]);
            }
            if (x == lastIndex)
            {
                var colour = config.Faces[FaceType.Right].Items[lastIndex - y, lastIndex - z];
                cube.SetFaceColour(FaceType.Right, m_faceColours[colour]);
            }
            if (y == 0)
            {
                var colour = config.Faces[FaceType.Down].Items[lastIndex - z, x];
                cube.SetFaceColour(FaceType.Down, m_faceColours[colour]);
            }
            if (y == lastIndex)
            {
                var colour = config.Faces[FaceType.Upper].Items[z, x];
                cube.SetFaceColour(FaceType.Upper, m_faceColours[colour]);
            }
            if (z == 0)
            {
                var colour = config.Faces[FaceType.Back].Items[lastIndex - y, lastIndex - x];
                cube.SetFaceColour(FaceType.Back, m_faceColours[colour]);
            }
            if (z == lastIndex)
            {
                var colour = config.Faces[FaceType.Front].Items[lastIndex - y, x];
                cube.SetFaceColour(FaceType.Front, m_faceColours[colour]);
            }
        }