Beispiel #1
0
        private static void SetCubeSide(ref SmallCube cube, CubeSide side, int value)
        {
            if (cube == null)
                cube = new SmallCube();

            cube[side] = value;
        }
        private void PaintCubePart(CubePart part, SmallCube model, Color[] colorMap)
        {
            for (var side = CubeSide.Left; side <= CubeSide.Back; side++)
            {
                Triangle[] sidePolygons = part[side];
                Color      sideColor    = colorMap[model[side]];

                for (int j = 0; j < sidePolygons.Length; j++)
                {
                    sidePolygons[j].Color = sideColor;
                }
            }
        }
Beispiel #3
0
        public static DataCube<SmallCube> GetDefaultCube(int size)
        {
            if (size <= 0)
                throw new ArgumentOutOfRangeException("size", "size must be > 0.");

            var bigCube = new DataCube<SmallCube>(size);
            int maxIndex = bigCube.Size - 1;

            for (int i = 0; i < bigCube.Size; i++)
            {
                for (int j = 0; j < bigCube.Size; j++)
                {
                    for (int k = 0; k < bigCube.Size; k++)
                    {
                        SmallCube cube = null;

                        if (i == 0)
                            SetCubeSide(ref cube, CubeSide.Left, 1);
                        if (i == maxIndex)
                            SetCubeSide(ref cube, CubeSide.Right, 2);

                        if (j == 0)
                            SetCubeSide(ref cube, CubeSide.Up, 3);
                        if (j == maxIndex)
                            SetCubeSide(ref cube, CubeSide.Down, 4);

                        if (k == 0)
                            SetCubeSide(ref cube, CubeSide.Front, 5);
                        if (k == maxIndex)
                            SetCubeSide(ref cube, CubeSide.Back, 6);

                        bigCube[i, j, k] = cube;
                    }
                }
            }

            return bigCube;
        }