public static MvdSection Parse(MvdDocument document, BinaryReader br) { var tag = (MvdTag)br.ReadByte(); MvdSection rt = null; switch (tag) { case MvdTag.NameList: rt = new MvdNameList(); break; case MvdTag.Bone: rt = new MvdBoneData(); break; case MvdTag.Morph: rt = new MvdMorphData(); break; case MvdTag.ModelProperty: rt = new MvdModelPropertyData(); break; case MvdTag.AccessoryProperty: rt = new MvdAccessoryPropertyData(); break; case MvdTag.EffectProperty: rt = new MvdEffectPropertyData(); break; case MvdTag.Camera: rt = new MvdCameraData(); break; case MvdTag.Light: rt = new MvdLightData(); break; case MvdTag.Project: rt = new MvdProjectData(); break; case MvdTag.Eof: return null; } rt.MinorType = br.ReadByte(); rt.RawKey = br.ReadInt32(); rt.RawItemSize = br.ReadInt32(); rt.RawCount = br.ReadInt32(); using (var exr = br.CreateSizedBufferReader()) rt.ReadExtensionRegion(document, exr); rt.Read(document, br); return rt; }
public static MvdSection Parse(MvdDocument document, BinaryReader br) { var tag = (MvdTag)br.ReadByte(); MvdSection rt = null; switch (tag) { case MvdTag.NameList: rt = new MvdNameList(); break; case MvdTag.Bone: rt = new MvdBoneData(); break; case MvdTag.Morph: rt = new MvdMorphData(); break; case MvdTag.ModelProperty: rt = new MvdModelPropertyData(); break; case MvdTag.AccessoryProperty: rt = new MvdAccessoryPropertyData(); break; case MvdTag.EffectProperty: rt = new MvdEffectPropertyData(); break; case MvdTag.Camera: rt = new MvdCameraData(); break; case MvdTag.Light: rt = new MvdLightData(); break; case MvdTag.Project: rt = new MvdProjectData(); break; case MvdTag.Eof: return(null); } rt.MinorType = br.ReadByte(); rt.RawKey = br.ReadInt32(); rt.RawItemSize = br.ReadInt32(); rt.RawCount = br.ReadInt32(); using (var exr = br.CreateSizedBufferReader()) rt.ReadExtensionRegion(document, exr); rt.Read(document, br); return(rt); }
public void Write(MvdCameraData cd, BinaryWriter bw) { if (cd.MinorType != 3) throw new NotImplementedException("MinorType != 3 not implemented"); bw.Write(this.StageId); bw.Write(this.FrameTime); bw.Write(this.Radius); this.Position.ForEach(bw.Write); this.Angle.ForEach(bw.Write); bw.Write(this.Fov); bw.Write(this.Spline); bw.Write(new byte[] { 0, 0, 0 }); this.PositionInterpolation.ForEach(_ => _.Write(bw)); this.AngleInterpolation.ForEach(_ => _.Write(bw)); this.RadiusInterpolation.ForEach(_ => _.Write(bw)); this.FovInterpolation.ForEach(_ => _.Write(bw)); }
public static MvdCameraFrame Parse(MvdCameraData cd, BinaryReader br, out MvdCameraPropertyFrame propertyFrame) { var rt = new MvdCameraFrame { StageId = br.ReadInt32(), FrameTime = br.ReadInt64(), Radius = br.ReadSingle(), Position = new[] { br.ReadSingle(), br.ReadSingle(), br.ReadSingle() }, Angle = new[] { br.ReadSingle(), br.ReadSingle(), br.ReadSingle() }, Fov = br.ReadSingle(), }; propertyFrame = null; switch (cd.MinorType) { case 0: propertyFrame = new MvdCameraPropertyFrame { FrameTime = rt.FrameTime, Perspective = br.ReadBoolean(), }; break; case 1: propertyFrame = new MvdCameraPropertyFrame { FrameTime = rt.FrameTime, Enabled = br.ReadBoolean(), Perspective = br.ReadBoolean(), Alpha = br.ReadSingle(), EffectEnabled = br.ReadBoolean(), }; break; case 3: rt.Spline = br.ReadBoolean(); br.ReadBytes(3); break; } rt.PositionInterpolation = new[] { MvdInterpolationPoint.Parse(br), MvdInterpolationPoint.Parse(br) }; rt.AngleInterpolation = new[] { MvdInterpolationPoint.Parse(br), MvdInterpolationPoint.Parse(br) }; rt.RadiusInterpolation = new[] { MvdInterpolationPoint.Parse(br), MvdInterpolationPoint.Parse(br) }; rt.FovInterpolation = new[] { MvdInterpolationPoint.Parse(br), MvdInterpolationPoint.Parse(br) }; return rt; }
public string GetName(MvdNameList names, MvdCameraData cameraData) { if (this.StageId == 0) return names.Names[cameraData.Key]; else { var key = cameraData.Key * -1000 - this.StageId; return names.Names.ContainsKey(key) ? names.Names[key] : this.StageId.ToString("000"); } }