Beispiel #1
0
 public void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
 {
     doc.WriteString(bw, this.Name);
     doc.WriteString(bw, this.EnglishName);
     bw.Write(this.IsSpecial);
     bw.Write(this.Items.Count);
     this.Items.ForEach(_ => _.Write(bw, doc, cache));
 }
Beispiel #2
0
 public void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
 {
     cache.Write(this.TargetBone);
     bw.Write(this.LoopCount);
     bw.Write(this.AngleLimitUnit);
     bw.Write(this.BindedBones.Count);
     this.BindedBones.ForEach(_ => _.Write(bw, doc, cache));
 }
Beispiel #3
0
        public void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
        {
            cache.Write(this.Bone);
            bw.Write(this.IsAngleLimitEnabled);

            if (this.IsAngleLimitEnabled)
            {
                this.LowerAngleLimit.ForEach(bw.Write);
                this.HigherAngleLimit.ForEach(bw.Write);
            }
        }
Beispiel #4
0
        public void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
        {
            if (doc.Version < 2.1f)
                if (this.Kind == PmxMorphKind.Flip)
                    this.Kind = PmxMorphKind.Group;
                else if (this.Kind == PmxMorphKind.Impulse)
                    return;

            doc.WriteString(bw, this.Name);
            doc.WriteString(bw, this.EnglishName);
            bw.Write((byte)this.Category);
            bw.Write((byte)this.Kind);
            bw.Write(this.Offsets.Count);
            this.Offsets.ForEach(_ => _.Write(bw, doc, cache));
        }
Beispiel #5
0
 public override void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
 {
     cache.Write(this.Vertex);
     this.Offset.ForEach(bw.Write);
 }
Beispiel #6
0
 public abstract void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache);
Beispiel #7
0
 public override void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
 {
     cache.Write(this.Material);
     bw.Write((byte)this.Kind);
     this.Diffuse.ForEach(bw.Write);
     this.Specular.ForEach(bw.Write);
     bw.Write(this.Power);
     this.Ambient.ForEach(bw.Write);
     this.EdgeColor.ForEach(bw.Write);
     bw.Write(this.EdgeSize);
     this.Texture.ForEach(bw.Write);
     this.SubTexture.ForEach(bw.Write);
     this.ToonTexture.ForEach(bw.Write);
 }
Beispiel #8
0
 public override void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
 {
     cache.Write(this.Rigid);
     bw.Write(this.IsLocal);
     this.CentralImpulse.ForEach(bw.Write);
     this.TorqueImpulse.ForEach(bw.Write);
 }
Beispiel #9
0
 public override void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
 {
     cache.Write(this.Morph);
     bw.Write(this.Weight);
 }
Beispiel #10
0
 public override void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
 {
     this.Bones.ForEach(_ => cache.Write(_));
     bw.Write(this.Weight);
 }
Beispiel #11
0
 public void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
 {
     doc.WriteString(bw, this.Name);
     doc.WriteString(bw, this.EnglishName);
     cache.Write(this.RelatedBone);
     bw.Write(this.Group);
     bw.Write((ushort)this.CollidableGroups);
     bw.Write((byte)this.Shape);
     this.Size.ForEach(bw.Write);
     this.Position.ForEach(bw.Write);
     this.Rotation.ForEach(bw.Write);
     bw.Write(this.Mass);
     bw.Write(this.LinearDamping);
     bw.Write(this.AngularDamping);
     bw.Write(this.Restitution);
     bw.Write(this.Friction);
     bw.Write((byte)this.Kind);
 }
Beispiel #12
0
        public void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
        {
            doc.WriteString(bw, this.Name);
            doc.WriteString(bw, this.EnglishName);
            this.Position.ForEach(bw.Write);
            cache.Write(this.ParentBone);
            bw.Write(this.Priority);
            bw.Write((ushort)this.Capabilities);

            if (this.Capabilities.HasFlag(PmxBoneCapabilities.ConnectToBone))
                cache.Write(this.ConnectToBone);
            else
                this.ConnectToOffset.ForEach(bw.Write);

            if (this.Capabilities.HasFlag(PmxBoneCapabilities.RotationAffected) ||
                this.Capabilities.HasFlag(PmxBoneCapabilities.MovementAffected))
            {
                cache.Write(this.AffectedBone);
                bw.Write(this.AffectionRate);
            }

            if (this.Capabilities.HasFlag(PmxBoneCapabilities.FixedAxis))
                this.FixedAxis.ForEach(bw.Write);

            if (this.Capabilities.HasFlag(PmxBoneCapabilities.LocalAxis))
            {
                this.LocalVectorX.ForEach(bw.Write);
                this.LocalVectorZ.ForEach(bw.Write);
            }

            if (this.Capabilities.HasFlag(PmxBoneCapabilities.TransformByExternalParent))
                bw.Write(this.ExternalParentKey);

            if (this.Capabilities.HasFlag(PmxBoneCapabilities.IK))
                this.IK.Write(bw, doc, cache);
        }
Beispiel #13
0
        public void Write(Stream stream)
        {
            // leave open
            var bw = new BinaryWriter(stream);
            var cache = new PmxIndexCache(this, bw);

            this.Header.VertexIndexSize =
                cache.Vertices.Count <= byte.MaxValue ? PmxVertexIndexSize.UInt8 :
                cache.Vertices.Count <= ushort.MaxValue ? PmxVertexIndexSize.UInt16 : PmxVertexIndexSize.Int32;
            this.Header.MaterialIndexSize =
                cache.Materials.Count <= sbyte.MaxValue ? PmxIndexSize.Int8 :
                cache.Materials.Count <= short.MaxValue ? PmxIndexSize.Int16 : PmxIndexSize.Int32;
            this.Header.TextureIndexSize =
                cache.Textures.Count <= sbyte.MaxValue ? PmxIndexSize.Int8 :
                cache.Textures.Count <= short.MaxValue ? PmxIndexSize.Int16 : PmxIndexSize.Int32;
            this.Header.BoneIndexSize =
                cache.Bones.Count <= sbyte.MaxValue ? PmxIndexSize.Int8 :
                cache.Bones.Count <= short.MaxValue ? PmxIndexSize.Int16 : PmxIndexSize.Int32;
            this.Header.MorphIndexSize =
                cache.Morphs.Count <= sbyte.MaxValue ? PmxIndexSize.Int8 :
                cache.Morphs.Count <= short.MaxValue ? PmxIndexSize.Int16 : PmxIndexSize.Int32;
            this.Header.RigidIndexSize =
                cache.Rigids.Count <= sbyte.MaxValue ? PmxIndexSize.Int8 :
                cache.Rigids.Count <= short.MaxValue ? PmxIndexSize.Int16 : PmxIndexSize.Int32;

            bw.Write(Encoding.ASCII.GetBytes("PMX "));
            bw.Write(this.Version);
            this.Header.Write(bw);
            this.ModelInformation.Write(bw, this);

            bw.Write(this.Vertices.Count);
            this.Vertices.ForEach(_ => _.Write(bw, this, cache));
            bw.Write(this.Indices.Count);
            this.Indices.ForEach(_ => cache.Write(_));
            bw.Write(this.Textures.Count);
            this.Textures.ForEach(_ => _.Write(bw, this));
            bw.Write(this.Materials.Count);
            this.Materials.ForEach(_ => _.Write(bw, this, cache));
            bw.Write(this.Bones.Count);
            this.Bones.ForEach(_ => _.Write(bw, this, cache));
            bw.Write(this.Morphs.Count);
            this.Morphs.ForEach(_ => _.Write(bw, this, cache));
            bw.Write(this.DisplayList.Count);
            this.DisplayList.ForEach(_ => _.Write(bw, this, cache));
            bw.Write(this.Rigids.Count);
            this.Rigids.ForEach(_ => _.Write(bw, this, cache));
            bw.Write(this.Constraints.Count);
            this.Constraints.ForEach(_ => _.Write(bw, this, cache));

            if (this.Version > 2)
            {
                bw.Write(this.SoftBodies.Count);
                this.SoftBodies.ForEach(_ => _.Write(bw, this, cache));
            }
        }
Beispiel #14
0
 public override void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
 {
     base.Write(bw, doc, cache);
     cache.Write(this.Morph);
 }
Beispiel #15
0
 public virtual void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
 {
     bw.Write((byte)this.Kind);
 }
Beispiel #16
0
        public void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
        {
            if (doc.Version < 2.1f &&
                this.SkinningKind == PmxSkinningKind.DualQuaternionDeforming)
                this.SkinningKind = PmxSkinningKind.LinearBlendDeforming4;

            this.Position.ForEach(bw.Write);
            this.Normal.ForEach(bw.Write);
            this.UV.ForEach(bw.Write);
            this.AdditionalUV.ForEach(_ => _.ForEach(bw.Write));
            bw.Write((byte)this.SkinningKind);
            this.SkinningFunction.Write(bw, doc, cache);
            bw.Write(this.EdgeSize);
        }
Beispiel #17
0
 public override void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
 {
     cache.Write(this.Bone);
     this.MovementOffset.ForEach(bw.Write);
     this.RotationOffset.ForEach(bw.Write);
 }
Beispiel #18
0
 public override void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
 {
     cache.Write(this.Bone);
 }
Beispiel #19
0
 public override void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
 {
     this.Bones.ForEach(_ => cache.Write(_));
     bw.Write(this.Weight);
     this.Center.ForEach(bw.Write);
     this.RangeZero.ForEach(bw.Write);
     this.RangeOne.ForEach(bw.Write);
 }
Beispiel #20
0
        public void Write(BinaryWriter bw, PmxDocument doc, PmxIndexCache cache)
        {
            bw.WriteSizedBuffer(doc.Header.Encoding.GetBytes(this.Name));
            bw.WriteSizedBuffer(doc.Header.Encoding.GetBytes(this.EnglishName));
            this.Diffuse.ForEach(bw.Write);
            this.Specular.ForEach(bw.Write);
            bw.Write(this.Power);
            this.Ambient.ForEach(bw.Write);
            bw.Write((byte)this.Options);
            this.EdgeColor.ForEach(bw.Write);
            bw.Write(this.EdgeSize);
            cache.Write(this.MainTexture);
            cache.Write(this.SubTexture);
            bw.Write((byte)this.SubTextureMode);
            bw.Write(this.UseSharedToonTexture);

            if (this.UseSharedToonTexture)
                bw.Write((byte)this.SharedToonTexture);
            else
                cache.Write(this.CustomToonTexture);

            bw.WriteSizedBuffer(doc.Header.Encoding.GetBytes(this.Comment));
            bw.Write(this.IndexCount);
        }