Пример #1
0
        private void LoadLayerRle(Mcly layerInfo, int layer)
        {
            var counterOut = 0;
            var startPos   = layerInfo.OfsMcal;

            while (counterOut < 4096)
            {
                var indicator = mAlphaCompressed[startPos++];
                if ((indicator & 0x80) != 0)
                {
                    var value  = mAlphaCompressed[startPos++];
                    var repeat = indicator & 0x7F;
                    for (var k = 0; k < repeat && counterOut < 4096; ++k)
                    {
                        AlphaValues[counterOut++] |= (uint)value << (layer * 8);
                    }
                }
                else
                {
                    for (var k = 0; k < (indicator & 0x7F) && counterOut < 4096; ++k)
                    {
                        AlphaValues[counterOut++] |= (uint)mAlphaCompressed[startPos++] << (8 * layer);
                    }
                }
            }
        }
Пример #2
0
        private void LoadLayerCompressed(Mcly layerInfo, int layer)
        {
            var startPos = layerInfo.OfsMcal;
            var counter  = 0;

            for (var k = 0; k < 63; ++k)
            {
                for (var j = 0; j < 32; ++j)
                {
                    var alpha = mAlphaCompressed[startPos++];
                    var val1  = alpha & 0xF;
                    var val2  = alpha >> 4;
                    val2 = j == 31 ? val1 : val2;
                    val1 = (byte)((val1 / 15.0f) * 255.0f);
                    val2 = (byte)((val2 / 15.0f) * 255.0f);
                    AlphaValues[counter++] |= (uint)val1 << (8 * layer);
                    AlphaValues[counter++] |= (uint)val2 << (8 * layer);
                }
            }

            for (uint j = 0; j < 64; ++j)
            {
                AlphaValues[63 * 64 + j] |= (uint)(AlphaValues[(62 * 64) + j] & (0xFF << (layer * 8)));
            }
        }
Пример #3
0
        private void LoadUncompressed(Mcly layerInfo, int layer)
        {
            var startPos = layerInfo.OfsMcal;

            for (var i = 0; i < 4096; ++i)
            {
                AlphaValues[i] |= (uint)mAlphaCompressed[startPos++] << (8 * layer);
            }
        }
Пример #4
0
        protected override int AddTextureLayer(string textureName)
        {
            var old = TextureNames;

            TextureNames = new string[old.Count + 1];
            for (var i = 0; i < old.Count; ++i)
            {
                TextureNames[i] = old[i];
            }

            TextureNames[TextureNames.Count - 1] = textureName;

            MapArea parent;

            if (mParent.TryGetTarget(out parent) == false)
            {
                throw new InvalidOperationException("Couldnt get parent of map chunk");
            }

            var texId = parent.GetOrAddTexture(textureName);
            var layer = new Mcly
            {
                Flags     = 0,
                TextureId = texId,
                EffectId  = -1,
                OfsMcal   = 0,
                Padding   = 0
            };

            var layers = mLayers;

            mLayers = new Mcly[layers.Length + 1];
            for (var i = 0; i < layers.Length; ++i)
            {
                mLayers[i] = layers[i];
            }

            mLayers[layers.Length] = layer;

            Textures.Add(parent.GetTexture(texId));
            SpecularTextures.Add(parent.GetSpecularTexture(texId));
            SpecularFactors[SpecularTextures.Count - 1] = parent.IsSpecularTextureLoaded(texId) ? 1 : 0;
            TexturesChanged = true;
            return(mLayers.Length - 1);
        }
Пример #5
0
 private void LoadLayerRle(Mcly layerInfo, int layer)
 {
     var counterOut = 0;
     var startPos = layerInfo.OfsMcal;
     while (counterOut < 4096)
     {
         var indicator = mAlphaCompressed[startPos++];
         if ((indicator & 0x80) != 0)
         {
             var value = mAlphaCompressed[startPos++];
             var repeat = indicator & 0x7F;
             for (var k = 0; k < repeat && counterOut < 4096; ++k)
                 AlphaValues[counterOut++] |= (uint)value << (layer * 8);
         }
         else
         {
             for (var k = 0; k < (indicator & 0x7F) && counterOut < 4096; ++k)
                 AlphaValues[counterOut++] |= (uint)mAlphaCompressed[startPos++] << (8 * layer);
         }
     }
 }
Пример #6
0
        private void LoadLayerCompressed(Mcly layerInfo, int layer)
        {
            var startPos = layerInfo.OfsMcal;
            var counter = 0;
            for (var k = 0; k < 63; ++k)
            {
                for (var j = 0; j < 32; ++j)
                {
                    var alpha = mAlphaCompressed[startPos++];
                    var val1 = alpha & 0xF;
                    var val2 = alpha >> 4;
                    val2 = j == 31 ? val1 : val2;
                    val1 = (byte)((val1 / 15.0f) * 255.0f);
                    val2 = (byte)((val2 / 15.0f) * 255.0f);
                    AlphaValues[counter++] |= (uint)val1 << (8 * layer);
                    AlphaValues[counter++] |= (uint)val2 << (8 * layer);
                }
            }

            for (uint j = 0; j < 64; ++j)
            {
                AlphaValues[63 * 64 + j] |= (uint)(AlphaValues[(62 * 64) + j] & (0xFF << (layer * 8)));
            }
        }
Пример #7
0
 private void LoadUncompressed(Mcly layerInfo, int layer)
 {
     var startPos = layerInfo.OfsMcal;
     for (var i = 0; i < 4096; ++i)
         AlphaValues[i] |= (uint)mAlphaCompressed[startPos++] << (8 * layer);
 }