예제 #1
0
        public TileConfiguration GetTileConfiguration(AdjBlendTile[] adj_config)
        {
            ushort[]          explicit_rule = ConvertAdjacentToBytes(adj_config);
            TileConfiguration config        = new TileConfiguration();

            int tile_index = ClassifyTileConfiguration(explicit_rule);

            if (tile_index < 0)
            {
                config.tile = _default_tile;
            }
            else
            {
                config.tile = _blend_tiles[tile_index];
            }
            config.shift = 0;

            if (config.tile == _default_tile)
            {
                return(config);
            }

            BlendRuleElement element = _rule_lists[tile_index].GetElement(explicit_rule);

            //calculate shift
            config.shift = BlendRuleElement.RulesMatch(element.rule_options, explicit_rule, config.tile.UpperSides());

            return(config);
        }
예제 #2
0
 public BlendRuleElement(BlendRuleElement other)
 {
     _element_options    = new ushort[6];
     _element_options[0] = other._element_options[0];
     _element_options[1] = other._element_options[1];
     _element_options[2] = other._element_options[2];
     _element_options[3] = other._element_options[3];
     _element_options[4] = other._element_options[4];
     _element_options[5] = other._element_options[5];
 }
 public BlendRuleElement GetElement(ushort[] generic_rule)
 {
     for (int k = 0; k < _rules.Count; k++)
     {
         int shift = BlendRuleElement.RulesMatch(generic_rule, _rules[k].rule_options);
         if (shift >= 0)
         {
             return(_rules[k]);
         }
     }
     return(null);
 }
예제 #4
0
 public int Compare(BlendRuleElement a, BlendRuleElement b)
 {
     for (int d = 0; d < 6; d++)
     {
         if (a._element_options[d] < b._element_options[d])
         {
             return(1);
         }
         else if (a._element_options[d] > b._element_options[d])
         {
             return(-1);
         }
     }
     return(0);
 }