public bool NormalizeSDEF_C0(List <PmxBone> boneList)
        {
            if (Deform != DeformType.SDEF)
            {
                return(true);
            }
            int     bone     = Weight[0].Bone;
            int     bone2    = Weight[1].Bone;
            PmxBone pmxBone  = null;
            PmxBone pmxBone2 = null;

            if (CP.InRange(boneList, bone))
            {
                pmxBone = boneList[bone];
                if (CP.InRange(boneList, bone2))
                {
                    pmxBone2 = boneList[bone2];
                    Vector3 position = pmxBone.Position;
                    Vector3 vector   = pmxBone2.Position - position;
                    vector.Normalize();
                    Vector3 position2 = Position;
                    position2 -= position;
                    float scale = Vector3.Dot(vector, position2);
                    C0 = vector * scale + position;
                    return(true);
                }
                return(false);
            }
            return(false);
        }
        // Token: 0x0600027E RID: 638 RVA: 0x00013C64 File Offset: 0x00011E64
        public bool IsSDEF_EnableBone(List <PmxBone> boneList)
        {
            int  bone  = this.Weight[0].Bone;
            int  bone2 = this.Weight[1].Bone;
            bool flag  = !CP.InRange <PmxBone>(boneList, bone);
            bool result;

            if (flag)
            {
                result = false;
            }
            else
            {
                PmxBone pmxBone = boneList[bone];
                bool    flag2   = CP.InRange <PmxBone>(boneList, bone2);
                if (flag2)
                {
                    PmxBone pmxBone2 = boneList[bone2];
                    result = (pmxBone.Parent == bone2 || pmxBone2.Parent == bone);
                }
                else
                {
                    result = false;
                }
            }
            return(result);
        }
Exemple #3
0
        // Token: 0x06000105 RID: 261 RVA: 0x0000E460 File Offset: 0x0000C660
        public void FromPmxBone(PmxBone bone, bool nonStr)
        {
            bool flag = !nonStr;

            if (flag)
            {
                this.Name  = bone.Name;
                this.NameE = bone.NameE;
            }
            this.Flags        = bone.Flags;
            this.Parent       = bone.Parent;
            this.To_Bone      = bone.To_Bone;
            this.To_Offset    = bone.To_Offset;
            this.Position     = bone.Position;
            this.Level        = bone.Level;
            this.AppendParent = bone.AppendParent;
            this.AppendRatio  = bone.AppendRatio;
            this.Axis         = bone.Axis;
            this.LocalX       = bone.LocalX;
            this.LocalY       = bone.LocalY;
            this.LocalZ       = bone.LocalZ;
            this.ExtKey       = bone.ExtKey;
            this.IK           = bone.IK.Clone();
            this.IKKind       = bone.IKKind;
        }
Exemple #4
0
 public static void UpdateBoneIKKind(List <PmxBone> boneList)
 {
     for (int i = 0; i < boneList.Count; i++)
     {
         boneList[i].IKKind = PmxBone.IKKindType.None;
     }
     for (int j = 0; j < boneList.Count; j++)
     {
         PmxBone pmxBone = boneList[j];
         if (!pmxBone.GetFlag(PmxBone.BoneFlags.IK))
         {
             continue;
         }
         pmxBone.IKKind = PmxBone.IKKindType.IK;
         int target = pmxBone.IK.Target;
         if (CP.InRange(boneList, target))
         {
             boneList[target].IKKind = PmxBone.IKKindType.Target;
         }
         for (int k = 0; k < pmxBone.IK.LinkList.Count; k++)
         {
             int bone = pmxBone.IK.LinkList[k].Bone;
             if (CP.InRange(boneList, bone))
             {
                 boneList[bone].IKKind = PmxBone.IKKindType.Link;
             }
         }
     }
 }
Exemple #5
0
 // Token: 0x060000B6 RID: 182 RVA: 0x0000D528 File Offset: 0x0000B728
 public static void UpdateBoneIKKind(List <PmxBone> boneList)
 {
     for (int i = 0; i < boneList.Count; i++)
     {
         PmxBone pmxBone = boneList[i];
         pmxBone.IKKind = PmxBone.IKKindType.None;
     }
     for (int j = 0; j < boneList.Count; j++)
     {
         PmxBone pmxBone2 = boneList[j];
         bool    flag     = pmxBone2.GetFlag(PmxBone.BoneFlags.IK);
         if (flag)
         {
             pmxBone2.IKKind = PmxBone.IKKindType.IK;
             int  target = pmxBone2.IK.Target;
             bool flag2  = CP.InRange <PmxBone>(boneList, target);
             if (flag2)
             {
                 boneList[target].IKKind = PmxBone.IKKindType.Target;
             }
             for (int k = 0; k < pmxBone2.IK.LinkList.Count; k++)
             {
                 int  bone  = pmxBone2.IK.LinkList[k].Bone;
                 bool flag3 = CP.InRange <PmxBone>(boneList, bone);
                 if (flag3)
                 {
                     boneList[bone].IKKind = PmxBone.IKKindType.Link;
                 }
             }
         }
     }
 }
Exemple #6
0
        public void InitializeBone()
        {
            BoneList.Clear();
            PmxBone pmxBone = new PmxBone();

            pmxBone.Name   = "センター";
            pmxBone.NameE  = "center";
            pmxBone.Parent = -1;
            pmxBone.SetFlag(PmxBone.BoneFlags.Translation, val: true);
            BoneList.Add(pmxBone);
        }
        // Token: 0x0600027D RID: 637 RVA: 0x00013B6C File Offset: 0x00011D6C
        public bool NormalizeSDEF_C0(List <PmxBone> boneList)
        {
            bool flag = this.Deform != PmxVertex.DeformType.SDEF;
            bool result;

            if (flag)
            {
                result = true;
            }
            else
            {
                int  bone  = this.Weight[0].Bone;
                int  bone2 = this.Weight[1].Bone;
                bool flag2 = !CP.InRange <PmxBone>(boneList, bone);
                if (flag2)
                {
                    result = false;
                }
                else
                {
                    PmxBone pmxBone = boneList[bone];
                    bool    flag3   = CP.InRange <PmxBone>(boneList, bone2);
                    if (flag3)
                    {
                        PmxBone pmxBone2  = boneList[bone2];
                        Vector3 position  = pmxBone.Position;
                        Vector3 position2 = pmxBone2.Position;
                        Vector3 vector    = position2 - position;
                        Vector3 vector2   = vector;
                        vector2.Normalize();
                        Vector3 vector3 = this.Position;
                        vector3 -= position;
                        float d = Vector3.Dot(vector2, vector3);
                        this.C0 = vector2 * d + position;
                        result  = true;
                    }
                    else
                    {
                        result = false;
                    }
                }
            }
            return(result);
        }
 public void FromPmxBone(PmxBone bone, bool nonStr = false)
 {
     if (!nonStr)
     {
         Name  = bone.Name;
         NameE = bone.NameE;
     }
     Flags     = bone.Flags;
     Parent    = bone.Parent;
     To_Bone   = bone.To_Bone;
     To_Offset = bone.To_Offset;
     Position  = bone.Position;
     Level     = bone.Level;
     AddParent = bone.AddParent;
     AddRatio  = bone.AddRatio;
     Axis      = bone.Axis;
     LocalX    = bone.LocalX;
     LocalY    = bone.LocalY;
     LocalZ    = bone.LocalZ;
     ExtKey    = bone.ExtKey;
     IK        = bone.IK.Clone();
     IKKind    = bone.IKKind;
     FromID(bone);
 }
 public PmxBone(PmxBone bone, bool nonStr = false)
     : this()
 {
     FromPmxBone(bone, nonStr);
 }
Exemple #10
0
 // Token: 0x06000104 RID: 260 RVA: 0x0000E44D File Offset: 0x0000C64D
 public PmxBone(PmxBone bone, bool nonStr)
 {
     this.FromPmxBone(bone, nonStr);
 }
Exemple #11
0
        public virtual void FromStream(Stream s, bool id)
        {
            Action <Action> action = delegate(Action a)
            {
                try
                {
                    a();
                }
                catch (Exception)
                {
                    LoadErrCount++;
                }
            };
            PmxHeader head = new PmxHeader();

            head.FromStreamEx(s);
            Header.FromHeader(head);
            head.ElementFormat.WithID = id;
            action(delegate
            {
                ModelInfo.FromStreamEx(s, head.ElementFormat);
            });
            int count = 0;

            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            VertexList.Clear();
            VertexList.Capacity = count;
            for (int k = 0; k < count; k++)
            {
                PmxVertex v = new PmxVertex();
                action(delegate
                {
                    v.FromStreamEx(s, head.ElementFormat);
                });
                VertexList.Add(v);
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            FaceList.Clear();
            FaceList.Capacity = count;
            for (int l = 0; l < count; l++)
            {
                int ix = 0;
                action(delegate
                {
                    ix = PmxStreamHelper.ReadElement_Int32(s, head.ElementFormat.VertexSize, signed: false);
                });
                FaceList.Add(ix);
            }
            PmxTextureTable tx = new PmxTextureTable();

            action(delegate
            {
                tx.FromStreamEx(s, head.ElementFormat);
            });
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            MaterialList.Clear();
            MaterialList.Capacity = count;
            for (int m = 0; m < count; m++)
            {
                PmxMaterial j = new PmxMaterial();
                action(delegate
                {
                    j.FromStreamEx_TexTable(s, tx, head.ElementFormat);
                });
                MaterialList.Add(j);
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            BoneList.Clear();
            BoneList.Capacity = count;
            for (int n = 0; n < count; n++)
            {
                PmxBone b = new PmxBone();
                action(delegate
                {
                    b.FromStreamEx(s, head.ElementFormat);
                });
                BoneList.Add(b);
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            MorphList.Clear();
            MorphList.Capacity = count;
            for (int num = 0; num < count; num++)
            {
                PmxMorph morph = new PmxMorph();
                action(delegate
                {
                    morph.FromStreamEx(s, head.ElementFormat);
                });
                MorphList.Add(morph);
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            NodeList.Clear();
            NodeList.Capacity = count;
            for (int num2 = 0; num2 < count; num2++)
            {
                PmxNode node = new PmxNode();
                action(delegate
                {
                    node.FromStreamEx(s, head.ElementFormat);
                });
                NodeList.Add(node);
                if (NodeList[num2].SystemNode)
                {
                    if (NodeList[num2].Name == "Root")
                    {
                        RootNode = NodeList[num2];
                    }
                    else if (NodeList[num2].Name == "表情")
                    {
                        ExpNode = NodeList[num2];
                    }
                }
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            BodyList.Clear();
            BodyList.Capacity = count;
            for (int num3 = 0; num3 < count; num3++)
            {
                PmxBody b2 = new PmxBody();
                action(delegate
                {
                    b2.FromStreamEx(s, head.ElementFormat);
                });
                BodyList.Add(b2);
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            JointList.Clear();
            JointList.Capacity = count;
            for (int num4 = 0; num4 < count; num4++)
            {
                PmxJoint i = new PmxJoint();
                action(delegate
                {
                    i.FromStreamEx(s, head.ElementFormat);
                });
                JointList.Add(i);
            }
            if (head.Ver >= 2.1f)
            {
                action(delegate
                {
                    count = PmxStreamHelper.ReadElement_Int32(s);
                });
                SoftBodyList.Clear();
                SoftBodyList.Capacity = count;
                for (int num5 = 0; num5 < count; num5++)
                {
                    PmxSoftBody b3 = new PmxSoftBody();
                    action(delegate
                    {
                        b3.FromStreamEx(s, head.ElementFormat);
                    });
                    SoftBodyList.Add(b3);
                }
            }
            if (id)
            {
                action(delegate
                {
                    FilePath = PmxStreamHelper.ReadString(s, head.ElementFormat);
                });
            }
            head.ElementFormat.WithID = false;
        }
Exemple #12
0
        // Token: 0x060000B2 RID: 178 RVA: 0x0000CC80 File Offset: 0x0000AE80
        public virtual void FromStreamEx(Stream s, PmxElementFormat f)
        {
            PmxHeader pmxHeader = new PmxHeader(2.1f);

            pmxHeader.FromStreamEx(s, null);
            this.Header.FromHeader(pmxHeader);
            this.ModelInfo.FromStreamEx(s, pmxHeader.ElementFormat);
            int num = PmxStreamHelper.ReadElement_Int32(s, 4, true);

            this.VertexList.Clear();
            this.VertexList.Capacity = num;
            for (int i = 0; i < num; i++)
            {
                PmxVertex pmxVertex = new PmxVertex();
                pmxVertex.FromStreamEx(s, pmxHeader.ElementFormat);
                this.VertexList.Add(pmxVertex);
            }
            num = PmxStreamHelper.ReadElement_Int32(s, 4, true);
            this.FaceList.Clear();
            this.FaceList.Capacity = num;
            for (int j = 0; j < num; j++)
            {
                int item = PmxStreamHelper.ReadElement_Int32(s, pmxHeader.ElementFormat.VertexSize, false);
                this.FaceList.Add(item);
            }
            PmxTextureTable pmxTextureTable = new PmxTextureTable();

            pmxTextureTable.FromStreamEx(s, pmxHeader.ElementFormat);
            num = PmxStreamHelper.ReadElement_Int32(s, 4, true);
            this.MaterialList.Clear();
            this.MaterialList.Capacity = num;
            for (int k = 0; k < num; k++)
            {
                PmxMaterial pmxMaterial = new PmxMaterial();
                pmxMaterial.FromStreamEx_TexTable(s, pmxTextureTable, pmxHeader.ElementFormat);
                this.MaterialList.Add(pmxMaterial);
            }
            num = PmxStreamHelper.ReadElement_Int32(s, 4, true);
            this.BoneList.Clear();
            this.BoneList.Capacity = num;
            for (int l = 0; l < num; l++)
            {
                PmxBone pmxBone = new PmxBone();
                pmxBone.FromStreamEx(s, pmxHeader.ElementFormat);
                this.BoneList.Add(pmxBone);
            }
            num = PmxStreamHelper.ReadElement_Int32(s, 4, true);
            this.MorphList.Clear();
            this.MorphList.Capacity = num;
            for (int m = 0; m < num; m++)
            {
                PmxMorph pmxMorph = new PmxMorph();
                pmxMorph.FromStreamEx(s, pmxHeader.ElementFormat);
                this.MorphList.Add(pmxMorph);
            }
            num = PmxStreamHelper.ReadElement_Int32(s, 4, true);
            this.NodeList.Clear();
            this.NodeList.Capacity = num;
            for (int n = 0; n < num; n++)
            {
                PmxNode pmxNode = new PmxNode();
                pmxNode.FromStreamEx(s, pmxHeader.ElementFormat);
                this.NodeList.Add(pmxNode);
                bool systemNode = this.NodeList[n].SystemNode;
                if (systemNode)
                {
                    bool flag = this.NodeList[n].Name == "Root";
                    if (flag)
                    {
                        this.RootNode = this.NodeList[n];
                    }
                    else
                    {
                        bool flag2 = this.NodeList[n].Name == "表情";
                        if (flag2)
                        {
                            this.ExpNode = this.NodeList[n];
                        }
                    }
                }
            }
            num = PmxStreamHelper.ReadElement_Int32(s, 4, true);
            this.BodyList.Clear();
            this.BodyList.Capacity = num;
            for (int num2 = 0; num2 < num; num2++)
            {
                PmxBody pmxBody = new PmxBody();
                pmxBody.FromStreamEx(s, pmxHeader.ElementFormat);
                this.BodyList.Add(pmxBody);
            }
            num = PmxStreamHelper.ReadElement_Int32(s, 4, true);
            this.JointList.Clear();
            this.JointList.Capacity = num;
            for (int num3 = 0; num3 < num; num3++)
            {
                PmxJoint pmxJoint = new PmxJoint();
                pmxJoint.FromStreamEx(s, pmxHeader.ElementFormat);
                this.JointList.Add(pmxJoint);
            }
            bool flag3 = pmxHeader.Ver >= 2.1f;

            if (flag3)
            {
                num = PmxStreamHelper.ReadElement_Int32(s, 4, true);
                this.SoftBodyList.Clear();
                this.SoftBodyList.Capacity = num;
                for (int num4 = 0; num4 < num; num4++)
                {
                    PmxSoftBody pmxSoftBody = new PmxSoftBody();
                    pmxSoftBody.FromStreamEx(s, pmxHeader.ElementFormat);
                    this.SoftBodyList.Add(pmxSoftBody);
                }
            }
        }