示例#1
0
        private bool DrawLayer(AppearanceManager.TextureIndex textureIndex)
        {
            int i = 0;

            AssetTexture texture = new AssetTexture();

            if ( ! Textures.TryGetValue(textureIndex, out texture))
                return false;

            Client.DebugLog("DrawLayer(): baking layer " + textureIndex.ToString());

            Image source = texture.Image;

            source.ResizeNearestNeighbor(BakeWidth, BakeHeight);

            if (textureIndex == AppearanceManager.TextureIndex.HeadBodypaint
                || textureIndex == AppearanceManager.TextureIndex.UpperBodypaint
                || textureIndex == AppearanceManager.TextureIndex.LowerBodypaint
                || textureIndex == AppearanceManager.TextureIndex.Skirt
                || textureIndex == AppearanceManager.TextureIndex.EyesIris)
            { // initial layer, just copy onto baked layer

                for (int y = 0; y < BakeHeight; y++)
                {
                    for (int x = 0; x < BakeWidth; x++)
                    {
                        if ((source.Channels & ImageChannels.Alpha) != 0)
                        {
                            if (source.Alpha[i] != 0)
                            {
                                BakedTexture.Image.Red[i] = source.Red[i];
                                BakedTexture.Image.Green[i] = source.Green[i];
                                BakedTexture.Image.Blue[i] = source.Blue[i];

                                BakedTexture.Image.Alpha[i] = source.Alpha[i];
                                BakedTexture.Image.Bump[i] = 0;
                            }
                        }
                        else
                        {
                            BakedTexture.Image.Red[i] = source.Red[i];
                            BakedTexture.Image.Green[i] = source.Green[i];
                            BakedTexture.Image.Blue[i] = source.Blue[i];
                            BakedTexture.Image.Alpha[i] = 255;

                            BakedTexture.Image.Bump[i] = 0;
                        }

                        ++i;
                    }
                }
            }
            else // not skin layer, so composite with alpha blending
            {

                for (int y = 0; y < BakeHeight; y++)
                {
                    for (int x = 0; x < BakeWidth; x++)
                    {

                        float alpha = (float)source.Alpha[i];
                        alpha /= 255.0f;
                        float red = (float)source.Red[i];
                        float green = (float)source.Green[i];
                        float blue = (float)source.Blue[i];
                        red /= 255.0f;
                        green /= 255.0f;
                        blue /= 255.0f;

                        float currRed = (float)BakedTexture.Image.Red[i];
                        float currGreen = (float)BakedTexture.Image.Green[i];
                        float currBlue = (float)BakedTexture.Image.Blue[i];

                        currRed /= 255.0F;
                        currGreen /= 255.0F;
                        currBlue /= 255.0F;

                        BakedTexture.Image.Red[i] = (byte)(255.0f * ((currRed * (1.0 - alpha)) + (red * alpha)));

                        BakedTexture.Image.Green[i] = (byte)(255.0f * ((currGreen * (1.0 - alpha)) + (green * alpha)));
                        BakedTexture.Image.Blue[i] = (byte)(255.0f * ((currBlue * (1.0 - alpha)) + (blue * alpha)));

                        i++;
                    }
                }
            }
            return true;
        }
示例#2
0
        public bool MissingTexture(AppearanceManager.TextureIndex index)
        {
            Client.DebugLog("Missing texture " + index.ToString() + " in bake " + BakeType.ToString());
            TextureCount--;

            if (Textures.Count == TextureCount)
            {
                Bake();
                return true;
            }
            else
                return false;
        }
示例#3
0
        /// <summary>
        /// Adds an image to this baking texture and potentially processes it, or
        /// stores it for processing later
        /// </summary>
        /// <param name="index">The baking texture index of the image to be added</param>
        /// <param name="jp2data">JPEG2000 compressed image to be added to the 
        /// baking texture</param>
        /// <returns>True if this texture is completely baked and JPEG2000 data 
        /// is available, otherwise false</returns>
        public bool AddTexture(AppearanceManager.TextureIndex index, byte[] jp2data)
        {
            lock (EncodedTextures)
            {
                EncodedTextures.Add(index, jp2data);
                Client.DebugLog("Adding texture " + index.ToString() + " to bake " + BakeType.ToString());
            }

            if (EncodedTextures.Count == TextureCount)
            {
                Bake();
                return true;
            }
            else
                return false;
        }
示例#4
0
        /// <summary>
        /// Adds an image to this baking texture and potentially processes it, or
        /// stores it for processing later
        /// </summary>
        /// <param name="index">The baking texture index of the image to be added</param>
        /// <param name="texture">JPEG2000 compressed image to be added to the 
        /// baking texture</param>
        /// <returns>True if this texture is completely baked and JPEG2000 data 
        /// is available, otherwise false</returns>
        public bool AddTexture(AppearanceManager.TextureIndex index, AssetTexture texture)
        {
            lock (Textures)
            {
                try 
                {

                    texture.Decode();
                    Textures.Add(index, texture);
                    Client.DebugLog("Adding texture " + index.ToString() + " ID: " + texture.AssetID.ToString() + " to bake " + BakeType.ToString());
                }
                catch ( Exception e )
                {
                    Client.DebugLog( "caught exception while trying add texture: " + e.Message.ToString());
                }

            }

            if (Textures.Count == TextureCount)
            {
                Bake();
                
                return true;
            }
            else
                return false;
        }
示例#5
0
        /// <summary>
        /// Adds an image to this baking texture and potentially processes it, or
        /// stores it for processing later
        /// </summary>
        /// <param name="index">The baking texture index of the image to be added</param>
        /// <param name="jp2data">JPEG2000 compressed image to be added to the 
        /// baking texture</param>
        /// <returns>True if this texture is completely baked and JPEG2000 data 
        /// is available, otherwise false</returns>
        public bool AddTexture(AppearanceManager.TextureIndex index, AssetTexture texture)
        {
            lock (Textures)
            {
                texture.Decode();
                Textures.Add(index, texture);
                Client.DebugLog("Adding texture " + index.ToString() + " to bake " + BakeType.ToString());
            }

            if (Textures.Count == TextureCount)
            {
                Bake();
                return true;
            }
            else
                return false;
        }