Exemplo n.º 1
0
        public TerrainLayerBlendMap(Terrain parent, byte layerIdx, HardwarePixelBuffer buf)
        {
            this.mParent   = parent;
            this.mLayerIdx = layerIdx;
            this.mChannel  = (byte)((this.mLayerIdx - 1) % 4);
            this.mDirty    = false;
            this.mBuffer   = buf;
            this.mData     = new float[this.mBuffer.Width * this.mBuffer.Height * sizeof(float)];

            // we know which of RGBA we need to look at, now find it in the format
            // because we can't guarantee what precise format the RS gives us
            PixelFormat fmt       = this.mBuffer.Format;
            var         rgbaShift = PixelUtil.GetBitShifts(fmt);

            this.mChannelOffset = (byte)(rgbaShift[this.mChannel] / 8); // /8 convert to bytes
#if AXIOM_BIG_ENDIAN
            // invert (dealing bytewise)
            mChannelOffset = (byte)(PixelUtil.GetNumElemBytes(fmt) - mChannelOffset - 1);
#endif
            Download();
        }