void Parse(Stream s) { var br = new BinaryReader(s); this.version = br.ReadUInt32(); this.unknown1 = br.ReadUInt32(); this.duration = br.ReadSingle(); this.unknown_floats = new float[8]; for (int i = 0; i < this.unknown_floats.Length; i++) { this.unknown_floats[i] = br.ReadSingle(); } this.unknown_hashes = new uint[3]; for (int i = 0; i < this.unknown_hashes.Length; i++) { this.unknown_hashes[i] = br.ReadUInt32(); } this.clip_name = br.ReadString32(); this.actor_name = br.ReadString32(); var extra_actor_count = br.ReadInt32(); var extra_actors = new string[extra_actor_count]; for (int i = 0; i < extra_actor_count; i++) { extra_actors[i] = br.ReadString32(); } this.actor_list = string.Join(",", extra_actors); var ik_target_count = br.ReadInt32(); this.IKChainCount = br.ReadInt32(); var ik_targets = new IKTarget[ik_target_count]; for (int i = 0; i < ik_target_count; i++) { ik_targets[i] = new IKTarget(RecommendedApiVersion, this.OnResourceChanged, s); } this.ik_targets = new IKTargetList(this.OnResourceChanged, ik_targets); UInt32 next = br.ReadUInt32(); bool end = false; var events = new List <ClipEvent>(); while (stream.Position + next != stream.Length) { var evt = ClipEvent.Create(next, this.OnResourceChanged, next); var evt_end = br.ReadInt32() + br.BaseStream.Position; evt.Parse(s); events.Add(evt); if (Settings.Settings.Checking && br.BaseStream.Position != evt_end) { throw new InvalidDataException(); } next = br.ReadUInt32(); } this.clip_events = new ClipEventList(this.OnResourceChanged, events); this.s3clip = new byte[next]; s.Read(this.s3clip, 0, this.s3clip.Length); }
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); } }
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); }
public ClipResource(int apiVersion) : base(apiVersion, null) { this.ik_targets = new IKTargetList(this.OnResourceChanged); this.clip_events = new ClipEventList(this.OnResourceChanged); }