public void FromStreamEx(Stream s, PmxElementFormat f = null)
        {
            Position = V3_BytesConvert.FromStream(s);
            Normal   = V3_BytesConvert.FromStream(s);
            UV       = V2_BytesConvert.FromStream(s);
            for (int i = 0; i < f.UVACount; i++)
            {
                Vector4 vector = V4_BytesConvert.FromStream(s);
                if (0 <= i && i < UVA.Length)
                {
                    UVA[i] = vector;
                }
            }
            Deform = (DeformType)s.ReadByte();
            SDEF   = false;
            switch (Deform)
            {
            case DeformType.BDEF1:
                Weight[0].Bone  = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize);
                Weight[0].Value = 1f;
                break;

            case DeformType.BDEF2:
                Weight[0].Bone  = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize);
                Weight[1].Bone  = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize);
                Weight[0].Value = PmxStreamHelper.ReadElement_Float(s);
                Weight[1].Value = 1f - Weight[0].Value;
                break;

            case DeformType.BDEF4:
            case DeformType.QDEF:
                Weight[0].Bone  = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize);
                Weight[1].Bone  = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize);
                Weight[2].Bone  = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize);
                Weight[3].Bone  = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize);
                Weight[0].Value = PmxStreamHelper.ReadElement_Float(s);
                Weight[1].Value = PmxStreamHelper.ReadElement_Float(s);
                Weight[2].Value = PmxStreamHelper.ReadElement_Float(s);
                Weight[3].Value = PmxStreamHelper.ReadElement_Float(s);
                break;

            case DeformType.SDEF:
                Weight[0].Bone  = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize);
                Weight[1].Bone  = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize);
                Weight[0].Value = PmxStreamHelper.ReadElement_Float(s);
                Weight[1].Value = 1f - Weight[0].Value;
                C0 = V3_BytesConvert.FromStream(s);
                R0 = V3_BytesConvert.FromStream(s);
                R1 = V3_BytesConvert.FromStream(s);
                CalcSDEF_RW();
                SDEF = true;
                break;
            }
            EdgeScale = PmxStreamHelper.ReadElement_Float(s);
            if (f.WithID)
            {
                base.UID = PmxStreamHelper.ReadElement_UInt(s);
                base.CID = PmxStreamHelper.ReadElement_UInt(s);
            }
        }
 public void FromStreamEx_TexTable(Stream s, PmxTextureTable tx, PmxElementFormat f = null)
 {
     Name       = PmxStreamHelper.ReadString(s, f);
     NameE      = PmxStreamHelper.ReadString(s, f);
     Diffuse    = V4_BytesConvert.FromStream(s);
     Specular   = V3_BytesConvert.FromStream(s);
     Power      = PmxStreamHelper.ReadElement_Float(s);
     Ambient    = V3_BytesConvert.FromStream(s);
     Flags      = (MaterialFlags)s.ReadByte();
     EdgeColor  = V4_BytesConvert.FromStream(s);
     EdgeSize   = PmxStreamHelper.ReadElement_Float(s);
     Tex        = tx.GetName(PmxStreamHelper.ReadElement_Int32(s, f.TexSize));
     Sphere     = tx.GetName(PmxStreamHelper.ReadElement_Int32(s, f.TexSize));
     SphereMode = (SphereModeType)s.ReadByte();
     if (s.ReadByte() == 0)
     {
         Toon = tx.GetName(PmxStreamHelper.ReadElement_Int32(s, f.TexSize));
     }
     else
     {
         int n = s.ReadByte();
         Toon = SystemToon.GetToonName(n);
     }
     Memo = PmxStreamHelper.ReadString(s, f);
     UpdateAttributeFromMemo();
     FaceCount = PmxStreamHelper.ReadElement_Int32(s);
     if (f.WithID)
     {
         base.UID = PmxStreamHelper.ReadElement_UInt(s);
         base.CID = PmxStreamHelper.ReadElement_UInt(s);
     }
 }
        public void FromStreamEx(Stream s, PmxElementFormat f = null)
        {
            Name  = PmxStreamHelper.ReadString(s, f);
            NameE = PmxStreamHelper.ReadString(s, f);
            Bone  = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize);
            Group = PmxStreamHelper.ReadElement_Int32(s, 1);
            ushort bits = (ushort)PmxStreamHelper.ReadElement_Int32(s, 2, signed: false);

            PassGroup.FromFlagBits(bits);
            BoxType  = (BoxKind)s.ReadByte();
            BoxSize  = V3_BytesConvert.FromStream(s);
            Position = V3_BytesConvert.FromStream(s);
            Rotation = V3_BytesConvert.FromStream(s);
            Mass     = PmxStreamHelper.ReadElement_Float(s);
            Vector4 vector = V4_BytesConvert.FromStream(s);

            PositionDamping = vector.X;
            RotationDamping = vector.Y;
            Restitution     = vector.Z;
            Friction        = vector.W;
            Mode            = (ModeType)s.ReadByte();
            if (f.WithID)
            {
                base.UID = PmxStreamHelper.ReadElement_UInt(s);
                base.CID = PmxStreamHelper.ReadElement_UInt(s);
            }
        }
 public virtual void FromStreamEx(Stream s, PmxElementFormat f = null)
 {
     if (f.WithID)
     {
         base.UID = PmxStreamHelper.ReadElement_UInt(s);
         base.CID = PmxStreamHelper.ReadElement_UInt(s);
     }
 }
 public void FromStreamEx(Stream s, PmxElementFormat f = null)
 {
     Name     = PmxStreamHelper.ReadString(s, f);
     NameE    = PmxStreamHelper.ReadString(s, f);
     Position = V3_BytesConvert.FromStream(s);
     Parent   = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize);
     Level    = PmxStreamHelper.ReadElement_Int32(s);
     Flags    = (BoneFlags)PmxStreamHelper.ReadElement_Int32(s, 2, signed: false);
     if (GetFlag(BoneFlags.ToBone))
     {
         To_Bone = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize);
     }
     else
     {
         To_Offset = V3_BytesConvert.FromStream(s);
     }
     if (GetFlag(BoneFlags.AddRotation) || GetFlag(BoneFlags.AddTranslation))
     {
         AddParent = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize);
         AddRatio  = PmxStreamHelper.ReadElement_Float(s);
     }
     if (GetFlag(BoneFlags.FixAxis))
     {
         Axis = V3_BytesConvert.FromStream(s);
     }
     if (GetFlag(BoneFlags.LocalFrame))
     {
         LocalX = V3_BytesConvert.FromStream(s);
         LocalZ = V3_BytesConvert.FromStream(s);
         if (!f.WithID)
         {
             NormalizeLocal();
         }
     }
     if (GetFlag(BoneFlags.ExtParent))
     {
         ExtKey = PmxStreamHelper.ReadElement_Int32(s);
     }
     if (GetFlag(BoneFlags.IK))
     {
         IK.FromStreamEx(s, f);
     }
     if (f.WithID)
     {
         base.UID = PmxStreamHelper.ReadElement_UInt(s);
         base.CID = PmxStreamHelper.ReadElement_UInt(s);
     }
 }
            public void FromStreamEx(Stream s, PmxElementFormat f = null)
            {
                ElementType = (ElementType)s.ReadByte();
                switch (ElementType)
                {
                case ElementType.Bone:
                    Index = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize);
                    break;

                case ElementType.Morph:
                    Index = PmxStreamHelper.ReadElement_Int32(s, f.MorphSize);
                    break;
                }
                if (f.WithID)
                {
                    base.UID = PmxStreamHelper.ReadElement_UInt(s);
                    base.CID = PmxStreamHelper.ReadElement_UInt(s);
                }
            }
        public void FromStreamEx(Stream s, PmxElementFormat f = null)
        {
            Name       = PmxStreamHelper.ReadString(s, f);
            NameE      = PmxStreamHelper.ReadString(s, f);
            SystemNode = (s.ReadByte() != 0);
            int num = PmxStreamHelper.ReadElement_Int32(s);

            ElementList.Clear();
            ElementList.Capacity = num;
            for (int i = 0; i < num; i++)
            {
                NodeElement nodeElement = new NodeElement();
                nodeElement.FromStreamEx(s, f);
                ElementList.Add(nodeElement);
            }
            if (f.WithID)
            {
                base.UID = PmxStreamHelper.ReadElement_UInt(s);
                base.CID = PmxStreamHelper.ReadElement_UInt(s);
            }
        }
Esempio n. 8
0
 public void FromStreamEx(Stream s, PmxElementFormat f = null)
 {
     Name            = PmxStreamHelper.ReadString(s, f);
     NameE           = PmxStreamHelper.ReadString(s, f);
     Kind            = (JointKind)s.ReadByte();
     BodyA           = PmxStreamHelper.ReadElement_Int32(s, f.BodySize);
     BodyB           = PmxStreamHelper.ReadElement_Int32(s, f.BodySize);
     Position        = V3_BytesConvert.FromStream(s);
     Rotation        = V3_BytesConvert.FromStream(s);
     Limit_MoveLow   = V3_BytesConvert.FromStream(s);
     Limit_MoveHigh  = V3_BytesConvert.FromStream(s);
     Limit_AngleLow  = V3_BytesConvert.FromStream(s);
     Limit_AngleHigh = V3_BytesConvert.FromStream(s);
     SpConst_Move    = V3_BytesConvert.FromStream(s);
     SpConst_Rotate  = V3_BytesConvert.FromStream(s);
     if (f.WithID)
     {
         base.UID = PmxStreamHelper.ReadElement_UInt(s);
         base.CID = PmxStreamHelper.ReadElement_UInt(s);
     }
 }
        public void FromStreamEx(Stream s, PmxElementFormat f = null)
        {
            Name  = PmxStreamHelper.ReadString(s, f);
            NameE = PmxStreamHelper.ReadString(s, f);
            Panel = PmxStreamHelper.ReadElement_Int32(s, 1);
            Kind  = (OffsetKind)PmxStreamHelper.ReadElement_Int32(s, 1);
            int num = PmxStreamHelper.ReadElement_Int32(s);

            OffsetList.Clear();
            OffsetList.Capacity = num;
            for (int i = 0; i < num; i++)
            {
                switch (Kind)
                {
                case OffsetKind.Group:
                case OffsetKind.Flip:
                {
                    PmxGroupMorph pmxGroupMorph = new PmxGroupMorph();
                    pmxGroupMorph.FromStreamEx(s, f);
                    OffsetList.Add(pmxGroupMorph);
                    break;
                }

                case OffsetKind.Vertex:
                {
                    PmxVertexMorph pmxVertexMorph = new PmxVertexMorph();
                    pmxVertexMorph.FromStreamEx(s, f);
                    OffsetList.Add(pmxVertexMorph);
                    break;
                }

                case OffsetKind.Bone:
                {
                    PmxBoneMorph pmxBoneMorph = new PmxBoneMorph();
                    pmxBoneMorph.FromStreamEx(s, f);
                    OffsetList.Add(pmxBoneMorph);
                    break;
                }

                case OffsetKind.Impulse:
                {
                    PmxImpulseMorph pmxImpulseMorph = new PmxImpulseMorph();
                    pmxImpulseMorph.FromStreamEx(s, f);
                    OffsetList.Add(pmxImpulseMorph);
                    break;
                }

                case OffsetKind.Material:
                {
                    PmxMaterialMorph pmxMaterialMorph = new PmxMaterialMorph();
                    pmxMaterialMorph.FromStreamEx(s, f);
                    OffsetList.Add(pmxMaterialMorph);
                    break;
                }

                case OffsetKind.UV:
                case OffsetKind.UVA1:
                case OffsetKind.UVA2:
                case OffsetKind.UVA3:
                case OffsetKind.UVA4:
                {
                    PmxUVMorph pmxUVMorph = new PmxUVMorph();
                    pmxUVMorph.FromStreamEx(s, f);
                    OffsetList.Add(pmxUVMorph);
                    break;
                }
                }
            }
            if (f.WithID)
            {
                base.UID = PmxStreamHelper.ReadElement_UInt(s);
                base.CID = PmxStreamHelper.ReadElement_UInt(s);
            }
        }
Esempio n. 10
0
        public void FromStreamEx(Stream s, PmxElementFormat f = null)
        {
            Name     = PmxStreamHelper.ReadString(s, f);
            NameE    = PmxStreamHelper.ReadString(s, f);
            Shape    = (ShapeKind)PmxStreamHelper.ReadElement_Int32(s, 1);
            Material = PmxStreamHelper.ReadElement_Int32(s, f.MaterialSize);
            Group    = PmxStreamHelper.ReadElement_Int32(s, 1);
            ushort bits = (ushort)PmxStreamHelper.ReadElement_Int32(s, 2, signed: false);

            PassGroup.FromFlagBits(bits);
            Flags = (SoftBodyFlags)PmxStreamHelper.ReadElement_Int32(s, 1);
            BendingLinkDistance = PmxStreamHelper.ReadElement_Int32(s);
            ClusterCount        = PmxStreamHelper.ReadElement_Int32(s);
            TotalMass           = PmxStreamHelper.ReadElement_Float(s);
            Margin             = PmxStreamHelper.ReadElement_Float(s);
            Config.AeroModel   = PmxStreamHelper.ReadElement_Int32(s);
            Config.VCF         = PmxStreamHelper.ReadElement_Float(s);
            Config.DP          = PmxStreamHelper.ReadElement_Float(s);
            Config.DG          = PmxStreamHelper.ReadElement_Float(s);
            Config.LF          = PmxStreamHelper.ReadElement_Float(s);
            Config.PR          = PmxStreamHelper.ReadElement_Float(s);
            Config.VC          = PmxStreamHelper.ReadElement_Float(s);
            Config.DF          = PmxStreamHelper.ReadElement_Float(s);
            Config.MT          = PmxStreamHelper.ReadElement_Float(s);
            Config.CHR         = PmxStreamHelper.ReadElement_Float(s);
            Config.KHR         = PmxStreamHelper.ReadElement_Float(s);
            Config.SHR         = PmxStreamHelper.ReadElement_Float(s);
            Config.AHR         = PmxStreamHelper.ReadElement_Float(s);
            Config.SRHR_CL     = PmxStreamHelper.ReadElement_Float(s);
            Config.SKHR_CL     = PmxStreamHelper.ReadElement_Float(s);
            Config.SSHR_CL     = PmxStreamHelper.ReadElement_Float(s);
            Config.SR_SPLT_CL  = PmxStreamHelper.ReadElement_Float(s);
            Config.SK_SPLT_CL  = PmxStreamHelper.ReadElement_Float(s);
            Config.SS_SPLT_CL  = PmxStreamHelper.ReadElement_Float(s);
            Config.V_IT        = PmxStreamHelper.ReadElement_Int32(s);
            Config.P_IT        = PmxStreamHelper.ReadElement_Int32(s);
            Config.D_IT        = PmxStreamHelper.ReadElement_Int32(s);
            Config.C_IT        = PmxStreamHelper.ReadElement_Int32(s);
            MaterialConfig.LST = PmxStreamHelper.ReadElement_Float(s);
            MaterialConfig.AST = PmxStreamHelper.ReadElement_Float(s);
            MaterialConfig.VST = PmxStreamHelper.ReadElement_Float(s);
            int num = PmxStreamHelper.ReadElement_Int32(s);

            BodyAnchorList.Clear();
            BodyAnchorList.Capacity = num;
            for (int i = 0; i < num; i++)
            {
                int body   = PmxStreamHelper.ReadElement_Int32(s, f.BodySize);
                int vertex = PmxStreamHelper.ReadElement_Int32(s, f.VertexSize);
                int num2   = PmxStreamHelper.ReadElement_Int32(s, 1);
                BodyAnchorList.Add(new BodyAnchor
                {
                    Body   = body,
                    Vertex = vertex,
                    IsNear = (num2 != 0)
                });
            }
            num = PmxStreamHelper.ReadElement_Int32(s);
            VertexPinList.Clear();
            VertexPinList.Capacity = num;
            for (int j = 0; j < num; j++)
            {
                int vertex2 = PmxStreamHelper.ReadElement_Int32(s, f.VertexSize);
                VertexPinList.Add(new VertexPin
                {
                    Vertex = vertex2
                });
            }
            NormalizeBodyAnchorList();
            NormalizeVertexPinList();
            if (f.WithID)
            {
                base.UID = PmxStreamHelper.ReadElement_UInt(s);
                base.CID = PmxStreamHelper.ReadElement_UInt(s);
            }
        }