Example #1
0
        private void UpdateFaces(Byte flags)
        {
            Byte topDirection   = Utils.CalcTopDirection(flags);
            Byte leftDirection  = Utils.CalcLeftDirection(flags);
            Byte frontDirection = Utils.CalcFrontDirection(flags);

            _direction = Utils.CalcOppositeDirection(frontDirection); // The back direction

            Vector3 topVector = CubeHelper.GetDirectionVector(topDirection);

            _targetDirections[0] = Utils.CalcOppositeDirection(topDirection);
            _targetDirections[1] = topDirection;
            _xOffsets[0]         = (SByte)topVector.x;
            _yOffsets[0]         = (SByte)(-topVector.y); // Get direction vector returns incorrectly negative y and z values
            _zOffsets[0]         = (SByte)(-topVector.z);

            Vector3 leftVector = CubeHelper.GetDirectionVector(leftDirection);

            _targetDirections[2] = Utils.CalcOppositeDirection(leftDirection);
            _targetDirections[3] = leftDirection;
            _xOffsets[1]         = (SByte)leftVector.x;
            _yOffsets[1]         = (SByte)(-leftVector.y);
            _zOffsets[1]         = (SByte)(-leftVector.z);

            Vector3 frontVector = CubeHelper.GetDirectionVector(frontDirection);

            _targetDirections[4] = Utils.CalcOppositeDirection(frontDirection);
            _targetDirections[5] = frontDirection;
            _xOffsets[2]         = (SByte)frontVector.x;
            _yOffsets[2]         = (SByte)(-frontVector.y);
            _zOffsets[2]         = (SByte)(-frontVector.z);
        }