예제 #1
0
        void Parse(Stream s)
        {
            var br = new BinaryReader(s);

            this.version        = br.ReadUInt32();
            this.flags          = br.ReadUInt32();
            this.duration       = br.ReadSingle();
            this.initialOffsetQ = new Quaternion(RecommendedApiVersion, OnResourceChanged, s);
            this.initialOffsetT = new Vector3(RecommendedApiVersion, OnResourceChanged, s);
            if (version >= 5)
            {
                this.referenceNamespaceHash = br.ReadUInt32();
            }
            if (version >= 10)
            {
                this.surfaceNamespaceHash = br.ReadUInt32();
                this.surfaceJointNameHash = br.ReadUInt32();
            }

            if (version >= 11)
            {
                this.surfacechildNamespaceHash = br.ReadUInt32();
            }
            if (version >= 7)
            {
                this.clip_name = br.ReadString32();
            }
            this.rigNameSpace = br.ReadString32();
            if (version >= 4)
            {
                explicitNamespaces = new ExplicitNameSpaceList(OnResourceChanged, s);
            }
            this.slot_assignments = new IkConfiguration(OnResourceChanged, s);
            uint clipEventLength = br.ReadUInt32();
            var  events          = new List <ClipEvent>();

            for (int i = 0; i < clipEventLength; i++)
            {
                ClipEventType clipType = (ClipEventType)br.ReadUInt32();
                uint          size     = br.ReadUInt32();
                ClipEvent     evt      = ClipEvent.Create(clipType, this.OnResourceChanged, size);
                evt.Parse(s);
                events.Add(evt);
            }
            this.clip_events = new ClipEventList(this.OnResourceChanged, events);
            uint codecDataLength = br.ReadUInt32();

            if (codecDataLength > 0)
            {
                this.codecData = new S3CLIP(RecommendedApiVersion, OnResourceChanged, s);
            }
        }
예제 #2
0
        protected override Stream UnParse()
        {
            var ms = new MemoryStream();
            var bw = new BinaryWriter(ms);

            if (this.version == 0)
            {
                this.version = 14;
            }
            bw.Write(this.version);
            bw.Write(this.flags);
            bw.Write(this.duration);
            if (this.initialOffsetQ == null)
            {
                this.initialOffsetQ = new Quaternion(RecommendedApiVersion, OnResourceChanged);
            }
            this.initialOffsetQ.UnParse(ms);
            if (this.initialOffsetT == null)
            {
                this.initialOffsetT = new Vector3(RecommendedApiVersion, OnResourceChanged);
            }
            this.initialOffsetT.UnParse(ms);
            if (version >= 5)
            {
                bw.Write(this.referenceNamespaceHash);
            }
            if (version >= 10)
            {
                bw.Write(this.surfaceNamespaceHash);
                bw.Write(this.surfaceJointNameHash);
            }

            if (version >= 11)
            {
                bw.Write(this.surfacechildNamespaceHash);
            }
            if (version >= 7)
            {
                if (this.clip_name == null)
                {
                    this.clip_name = "";
                }
                bw.WriteString32(this.clip_name);
            }
            if (this.rigNameSpace == null)
            {
                this.rigNameSpace = "";
            }
            bw.WriteString32(this.rigNameSpace);
            if (version >= 4)
            {
                if (this.explicitNamespaces == null)
                {
                    this.explicitNamespaces = new ExplicitNameSpaceList(OnResourceChanged);
                }
                this.explicitNamespaces.UnParse(ms);
            }
            if (this.slot_assignments == null)
            {
                this.slot_assignments = new IkConfiguration(OnResourceChanged);
            }
            this.slot_assignments.UnParse(ms);
            if (this.clip_events == null)
            {
                this.clip_events = new ClipEventList(OnResourceChanged);
            }
            bw.Write(this.clip_events.Count);
            foreach (var clip_event in clip_events)
            {
                bw.Write((uint)clip_event.TypeId);
                bw.Write(clip_event.Size);
                clip_event.UnParse(ms);
            }
            long codecStart = ms.Position;

            bw.Write(0);
            if (this.codecData == null)
            {
                this.codecData = new S3CLIP(RecommendedApiVersion, OnResourceChanged);
            }
            this.codecData.UnParse(ms);
            long codecEnd = ms.Position;

            ms.Position = codecStart;
            bw.Write((uint)(codecEnd - codecStart - 4));
            ms.Position = 0L;
            return(ms);
        }