public static PmxSoftBody Parse(BinaryReader br, PmxDocument doc) { return(new PmxSoftBody { Name = doc.ReadString(br), EnglishName = doc.ReadString(br), Kind = (PmxSoftBodyKind)br.ReadByte(), RelatedMaterial = doc.ReadIndex(br, PmxIndexKind.Material), Group = br.ReadByte(), CollidableGroups = (PmdRigidGroups)br.ReadUInt16(), Options = (PmxSoftBodyOptions)br.ReadByte(), BendingLinkDistance = br.ReadInt32(), ClusterCount = br.ReadInt32(), TotalMass = br.ReadSingle(), Margin = br.ReadSingle(), AeroModel = (PmxSoftBodyAeroModel)br.ReadInt32(), Configuration = Enum.GetValues(typeof(PmxConfigurationIndex)).Cast <PmxConfigurationIndex>().ToDictionary(_ => _, _ => br.ReadSingle()), VelocitySolverIteration = br.ReadInt32(), PositonSolverIteration = br.ReadInt32(), DriftSolverIteration = br.ReadInt32(), ClusterSolverIteration = br.ReadInt32(), LinearStiffnessCoefficient = br.ReadSingle(), AreaAngularStiffnessCoefficient = br.ReadSingle(), VolumeStiffnessCoefficient = br.ReadSingle(), Anchors = Enumerable.Range(0, br.ReadInt32()).Select(_ => PmxSoftBodyAnchor.Parse(br, doc)).ToList(), PinnedVertices = Enumerable.Range(0, br.ReadInt32()).Select(_ => doc.ReadIndex(br, PmxIndexKind.Vertex)).ToList(), }); }
public void Write(BinaryWriter bw, PmxDocument doc) { doc.WriteString(bw, this.Name); doc.WriteString(bw, this.EnglishName); bw.Write((byte)this.Kind); doc.WriteIndex(bw, PmxIndexKind.Material, this.RelatedMaterial); bw.Write(this.Group); bw.Write((ushort)this.CollidableGroups); bw.Write((byte)this.Options); bw.Write(this.BendingLinkDistance); bw.Write(this.ClusterCount); bw.Write(this.TotalMass); bw.Write(this.Margin); bw.Write((int)this.AeroModel); this.Configuration.OrderBy(_ => _.Key).Select(_ => _.Value).ForEach(bw.Write); bw.Write(this.VelocitySolverIteration); bw.Write(this.PositonSolverIteration); bw.Write(this.DriftSolverIteration); bw.Write(this.ClusterSolverIteration); bw.Write(this.LinearStiffnessCoefficient); bw.Write(this.AreaAngularStiffnessCoefficient); bw.Write(this.VolumeStiffnessCoefficient); bw.Write(this.Anchors.Count); this.Anchors.ForEach(_ => _.Write(bw, doc)); bw.Write(this.PinnedVertices.Count); this.PinnedVertices.ForEach(_ => doc.WriteIndex(bw, PmxIndexKind.Vertex, _)); }
public static PmxSoftBodyAnchor Parse(BinaryReader br, PmxDocument doc) { return(new PmxSoftBodyAnchor { Rigid = doc.ReadIndex(br, PmxIndexKind.Rigid), Vertex = doc.ReadIndex(br, PmxIndexKind.Vertex), IsNearMode = br.ReadBoolean(), }); }
public static PmxSoftBodyAnchor Parse(BinaryReader br, PmxDocument doc) { return new PmxSoftBodyAnchor { Rigid = doc.ReadRigidBody(br), Vertex = doc.ReadVertex(br), IsNearMode = br.ReadBoolean(), }; }
public void Write(BinaryWriter bw, PmxDocument doc) { doc.WriteIndex(bw, PmxIndexKind.Rigid, this.Rigid); doc.WriteIndex(bw, PmxIndexKind.Vertex, this.Vertex); bw.Write(this.IsNearMode); }
public void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache) { cache.Write(this.Rigid); cache.Write(this.Vertex); bw.Write(this.IsNearMode); }
public void Write(BinaryWriter bw, PmxDocument doc) { doc.WriteIndex(bw, PmxIndexKind.Rigid, this.Rigid); doc.WriteIndex(bw, PmxIndexKind.Vertex, this.Vertex); bw.Write(this.IsNearMode); }
public void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache) { doc.WriteString(bw, this.Name); doc.WriteString(bw, this.EnglishName); bw.Write((byte)this.Kind); cache.Write(this.RelatedMaterial); bw.Write(this.Group); bw.Write((ushort)this.CollidableGroups); bw.Write((byte)this.Options); bw.Write(this.BendingLinkDistance); bw.Write(this.ClusterCount); bw.Write(this.TotalMass); bw.Write(this.Margin); bw.Write((int)this.AeroModel); this.Configuration.OrderBy(_ => _.Key).Select(_ => _.Value).ForEach(bw.Write); bw.Write(this.VelocitySolverIteration); bw.Write(this.PositonSolverIteration); bw.Write(this.DriftSolverIteration); bw.Write(this.ClusterSolverIteration); bw.Write(this.LinearStiffnessCoefficient); bw.Write(this.AreaAngularStiffnessCoefficient); bw.Write(this.VolumeStiffnessCoefficient); bw.Write(this.Anchors.Count); this.Anchors.ForEach(_ => _.Write(bw, doc, cache)); bw.Write(this.PinnedVertices.Count); this.PinnedVertices.ForEach(_ => cache.Write(_)); }
public static PmxSoftBody Parse(BinaryReader br, PmxDocument doc) { return new PmxSoftBody { Name = doc.ReadString(br), EnglishName = doc.ReadString(br), Kind = (PmxSoftBodyKind)br.ReadByte(), RelatedMaterial = doc.ReadMaterial(br), Group = br.ReadByte(), CollidableGroups = (PmdRigidGroups)br.ReadUInt16(), Options = (PmxSoftBodyOptions)br.ReadByte(), BendingLinkDistance = br.ReadInt32(), ClusterCount = br.ReadInt32(), TotalMass = br.ReadSingle(), Margin = br.ReadSingle(), AeroModel = (PmxSoftBodyAeroModel)br.ReadInt32(), Configuration = Enum.GetValues(typeof(PmxConfigurationIndex)).Cast<PmxConfigurationIndex>().ToDictionary(_ => _, _ => br.ReadSingle()), VelocitySolverIteration = br.ReadInt32(), PositonSolverIteration = br.ReadInt32(), DriftSolverIteration = br.ReadInt32(), ClusterSolverIteration = br.ReadInt32(), LinearStiffnessCoefficient = br.ReadSingle(), AreaAngularStiffnessCoefficient = br.ReadSingle(), VolumeStiffnessCoefficient = br.ReadSingle(), Anchors = Enumerable.Range(0, br.ReadInt32()).Select(_ => PmxSoftBodyAnchor.Parse(br, doc)).ToList(), PinnedVertices = Enumerable.Range(0, br.ReadInt32()).Select(_ => doc.ReadVertex(br)).ToList(), }; }