Esempio n. 1
0
        public override Stream UnParse()
        {
            MemoryStream ms = new MemoryStream();
            BinaryWriter w  = new BinaryWriter(ms);

            w.Write(tag);
            w.Write(version);
            w.Write(materialNameHash);
            w.Write((uint)shader);
            long lenPos = ms.Position;

            w.Write((uint)0);//length
            long pos;

            if (version < 0x00000103)
            {
                pos = ms.Position;
                if (mtrl == null)
                {
                    mtrl = new MTRL(requestedApiVersion, OnRCOLChanged);
                }
                mtrl.UnParse(ms);
            }
            else
            {
                w.Write(isVideoSurface ? 1 : 0);
                w.Write(isPaintingSurface ? 1 : 0);
                pos = ms.Position;
                if (mtnf == null)
                {
                    mtnf = new MTNF(requestedApiVersion, OnRCOLChanged);
                }
                mtnf.UnParse(ms);
            }

            long endPos = ms.Position;

            ms.Position = lenPos;
            w.Write((uint)(endPos - pos));
            ms.Position = endPos;

            return(ms);
        }