Esempio n. 1
0
        protected override void OnVisitNode( Node node, int x, int y )
        {
            if ( node.Level > 2 || node.IsLeaf() ) return;

            // Simple mode for now
            int scolor = 0;
            int sborder = 0;
            ushort[] id = new ushort[Province.MaxValue];
            ushort[] riverid = new ushort[Province.MaxValue];
            int samples = 0;

            SampleNode( node.BottomRightChild, ref scolor, ref sborder, ref id, ref riverid, ref samples );
            SampleNode( node.BottomLeftChild, ref scolor, ref sborder, ref id, ref riverid, ref samples );
            SampleNode( node.TopRightChild, ref scolor, ref sborder, ref id, ref riverid, ref samples );
            SampleNode( node.TopLeftChild, ref scolor, ref sborder, ref id, ref riverid, ref samples );

            ushort ididx = 0;
            ushort riveridx = 0;
            for ( ushort i=1; i<Province.MaxValue; ++i ) {
                if ( id[i] > id[ididx] ) ididx = i;
                if ( riverid[i] > riverid[riveridx] ) riveridx = i;
            }

            Debug.Assert( (byte)((sborder/samples)>>16) >= 0 && (byte)((sborder/samples)>>16) <= 2, "border assert failed" );

            node.BecomeLeaf( new Pixel(
                (byte)((scolor/samples)>>16),
                ididx,
                riveridx,
                (byte)((sborder/samples)>>16) ) );
        }
Esempio n. 2
0
        protected override void OnVisitNode( Node node, int x, int y )
        {
            if ( node.IsLeaf() ) return;
            if ( lowestonly && node.Level > 1 ) return;

            // Check if children are leafs
            if ( !node.BottomRightChild.IsLeaf() || !node.BottomLeftChild.IsLeaf() || !node.TopRightChild.IsLeaf() || !node.TopLeftChild.IsLeaf() ) return;

            // Yes, check for same values
            if (  node.BottomRightChild.Data == node.BottomLeftChild.Data &&
                node.BottomRightChild.Data == node.TopRightChild.Data &&
                node.BottomRightChild.Data == node.TopLeftChild.Data ) {
                // Merge
                node.BecomeLeaf( node.BottomRightChild.Data );
                optimised = true;
            }
        }
Esempio n. 3
0
        protected override void OnVisitNode( Node node, int x, int y )
        {
            if ( node.Level > 1 || node.IsLeaf() ) return;

            // Simple mode for now
            byte color = (byte)(
                ((float)(node.BottomRightChild.Data.Color) * 0.15) +
                ((float)(node.BottomLeftChild.Data.Color) * 0.25) +
                ((float)(node.TopRightChild.Data.Color) * 0.25) +
                ((float)(node.TopLeftChild.Data.Color) * 0.35));
            //byte color = (byte)((((node.BottomRightChild.Data.Color<<16) + (node.BottomLeftChild.Data.Color<<16) +
            //	(node.TopRightChild.Data.Color<<16) + (node.TopLeftChild.Data.Color<<16)) / 4) >> 16);

            byte border = (byte)((((node.BottomRightChild.Data.Border<<16) + (node.BottomLeftChild.Data.Border<<16) +
                (node.TopRightChild.Data.Border<<16) + (node.TopLeftChild.Data.Border<<16)) / 4) >> 16);

            //if ( node.BottomRightChild.Data.Border == 1 || node.BottomLeftChild.Data.Border == 1 || node.TopRightChild.Data.Border == 1 || node.TopLeftChild.Data.Border == 1 ) border = 1;
            //if ( node.BottomRightChild.Data.Border == 2 || node.BottomLeftChild.Data.Border == 2 || node.TopRightChild.Data.Border == 2 || node.TopLeftChild.Data.Border == 2 ) border = 2;

            ushort id = node.TopLeftChild.Data.ID;
            ushort riverid = node.TopLeftChild.Data.RiverID;

            node.BecomeLeaf( new Pixel( color, id, riverid, border ) );
        }