Esempio n. 1
0
        private int processTexture(Texture2D texture)
        {
            for (int i = 0; i < textureList.Count; i++)
            {
                if (textureList[i].texture == texture)
                {
                    return(i);
                }
            }

            TexturePackage texPack = new TexturePackage();

            texPack.width  = texture.width;
            texPack.height = texture.height;
            texPack.format = texture.format;

            texPack.colorMapData     = texture.GetRawTextureData();
            texPack.colorMapDataSize = texPack.colorMapData.Length;

            texPack.texture = texture;

            textureList.Add(texPack);

            return(textureList.Count - 1);
        }
Esempio n. 2
0
        private void convertTexturesByteStream()
        {
            m_textureList = new List <TexturePackage>();

            int dataIdx = 0;

            m_textureBinaryType = BitConverter.ToInt32(m_texturesByteData, dataIdx);
            dataIdx            += sizeof(int);

            while (dataIdx < m_texturesByteData.Length - 1)
            {
                TexturePackage texPack = new TexturePackage();

                if (m_textureBinaryType == 1)
                {
                    int intValue = BitConverter.ToInt32(m_texturesByteData, dataIdx);
                    dataIdx       += size_int;
                    texPack.width  = intValue;
                    intValue       = BitConverter.ToInt32(m_texturesByteData, dataIdx);
                    dataIdx       += size_int;
                    texPack.height = intValue;
                    intValue       = BitConverter.ToInt32(m_texturesByteData, dataIdx);
                    dataIdx       += size_int;
                    texPack.format = (TextureFormat)intValue;
                }

                // pixel data
                int numValues = BitConverter.ToInt32(m_texturesByteData, dataIdx);
                dataIdx += size_int;
                texPack.colorMapDataSize = numValues;
                texPack.colorMapData     = new byte[numValues];
                Buffer.BlockCopy(m_texturesByteData, dataIdx, texPack.colorMapData, 0, numValues);
                dataIdx += numValues;

                m_textureList.Add(texPack);
            }

            Array.Clear(m_texturesByteData, 0, m_texturesByteData.Length);
            m_texturesByteData = null;
            GC.Collect();
        }