示例#1
0
        protected override Stream UnParse()
        {
            Stream s  = new MemoryStream();
            var    bw = new BinaryWriter(s);

            bw.Write(mVersion);
            var  keys     = new ResourceKeyTable();
            long startPos = keys.BeginWrite(s);

            if (mShaderKeyList == null)
            {
                mShaderKeyList = new ShaderKeyList(OnResourceChanged);
            }
            mShaderKeyList.UnParse(s);
            if (mSkinSubSRampKey == null)
            {
                mSkinSubSRampKey = new TGIBlock(0, OnResourceChanged);
            }
            if (mToneRampKey == null)
            {
                mToneRampKey = new TGIBlock(0, OnResourceChanged);
            }
            bw.Write(keys.Add(mSkinSubSRampKey));
            bw.Write(keys.Add(mToneRampKey));
            if (mTextureKeyList == null)
            {
                mTextureKeyList = new TextureKeyList(OnResourceChanged, this);
            }
            mTextureKeyList.UnParse(s, keys);
            bw.Write(mIsDominant ? (byte)1 : (byte)0);
            keys.EndWrite(s, startPos);
            return(s);
        }
示例#2
0
        private void Parse(Stream s)
        {
            var br = new BinaryReader(s);

            mVersion = br.ReadUInt32();
            var keys = new ResourceKeyTable();

            ResourceKeyTable.TablePtr ptr = keys.BeginRead(s);
            mShaderKeyList   = new ShaderKeyList(OnResourceChanged, s);
            mSkinSubSRampKey = new TGIBlock(0, OnResourceChanged, keys[br.ReadInt32()]);
            mToneRampKey     = new TGIBlock(0, OnResourceChanged, keys[br.ReadInt32()]);
            mTextureKeyList  = new TextureKeyList(OnResourceChanged, s, this, keys);
            mIsDominant      = br.ReadByte() == 1;
            keys.EndRead(s, ptr);
        }