Esempio n. 1
0
        private void readBoneContainer(BinaryReader br)
        {
            uint num = (uint)br.ReadUInt16();

            this.Bones.Clear();
            this.RootBones.Clear();
            for (uint num2 = 0u; num2 < num; num2 += 1u)
            {
                MMDBone mMDBone = new MMDBone();
                mMDBone.BoneIndex     = (int)num2;
                mMDBone.Name          = this.readString(br, 20);
                mMDBone.ParentIndex   = (int)br.ReadInt16();
                mMDBone.TailBoneIndex = (int)br.ReadInt16();
                mMDBone.Type          = (MMDBoneType)br.ReadByte();
                mMDBone.IkParentBone  = (int)br.ReadInt16();
                mMDBone.Position[0]   = br.ReadSingle();
                mMDBone.Position[1]   = br.ReadSingle();
                mMDBone.Position[2]   = br.ReadSingle();
                this.Bones.Add(mMDBone);
                if (mMDBone.ParentIndex < 0)
                {
                    this.RootBones.Add(mMDBone);
                }
            }
            for (int i = 0; i < this.Bones.Count; i++)
            {
                if (this.Bones[i].ParentIndex >= 0)
                {
                    this.Bones[i].Parent = this.Bones[this.Bones[i].ParentIndex];
                }
            }
        }
Esempio n. 2
0
        private void readRigidBodyContainer(BinaryReader br)
        {
            uint num = br.ReadUInt32();

            this.RigidBodys.Clear();
            int num2 = 0;

            while ((long)num2 < (long)((ulong)num))
            {
                ChRigidBody chRigidBody = new ChRigidBody();
                chRigidBody.Name = this.readString(br).Trim().Replace("\r", "").Replace("\n", "").Replace("\t", "");
                this.readString(br).Trim().Replace("\r", "").Replace("\n", "").Replace("\t", "");
                chRigidBody.relBoneIndex = this.readBoneIndex(br);
                byte b = br.ReadByte();
                chRigidBody.Filter        = 1u << (int)b;
                chRigidBody.Mask          = (uint)br.ReadUInt16();
                chRigidBody.ShapeType     = (ChRigidBodyShapeType)br.ReadByte();
                chRigidBody.ShapeParam[0] = br.ReadSingle();
                chRigidBody.ShapeParam[1] = br.ReadSingle();
                chRigidBody.ShapeParam[2] = br.ReadSingle();
                chRigidBody.Position[0]   = br.ReadSingle();
                chRigidBody.Position[1]   = br.ReadSingle();
                chRigidBody.Position[2]   = br.ReadSingle();
                chRigidBody.Rotate[0]     = br.ReadSingle();
                chRigidBody.Rotate[1]     = br.ReadSingle();
                chRigidBody.Rotate[2]     = br.ReadSingle();
                for (int i = 0; i < 3; i++)
                {
                    if (float.IsNaN(chRigidBody.Position[i]) || float.IsInfinity(chRigidBody.Position[i]))
                    {
                        chRigidBody.Position[i] = 0f;
                    }
                    if (float.IsNaN(chRigidBody.Rotate[i]) || float.IsInfinity(chRigidBody.Rotate[i]))
                    {
                        chRigidBody.Rotate[i] = 0f;
                    }
                }
                chRigidBody.Weight      = br.ReadSingle();
                chRigidBody.PositionDim = br.ReadSingle();
                chRigidBody.RotateDim   = br.ReadSingle();
                chRigidBody.Recoil      = br.ReadSingle();
                chRigidBody.Friction    = br.ReadSingle();
                chRigidBody.Type        = br.ReadByte();
                this.RigidBodys.Add(chRigidBody);
                num2++;
            }
            foreach (ChRigidBody current in this.RigidBodys)
            {
                if (current.relBoneIndex >= 0)
                {
                    MMDBone mMDBone = this.Bones[current.relBoneIndex];
                    current.Position[0] -= mMDBone.Position[0];
                    current.Position[1] -= mMDBone.Position[1];
                    current.Position[2] -= mMDBone.Position[2];
                }
            }
        }
Esempio n. 3
0
        private void readBoneContainer(BinaryReader br)
        {
            uint num = br.ReadUInt32();

            this.Bones.Clear();
            this.RootBones.Clear();
            for (uint num2 = 0u; num2 < num; num2 += 1u)
            {
                MMDBone mMDBone = new MMDBone();
                mMDBone.Name = this.readString(br);
                this.readString(br);
                mMDBone.Position    = this.readVector3(br);
                mMDBone.ParentIndex = this.readBoneIndex(br);
                if (mMDBone.ParentIndex < 0)
                {
                    this.RootBones.Add(mMDBone);
                }
                mMDBone.deformRank = br.ReadInt32();
                uint num3  = (uint)br.ReadUInt16();
                bool flag  = (num3 & 1u) == 1u;
                bool flag2 = (num3 & 32u) == 32u;
                bool flag3 = (num3 & 256u) == 256u;
                bool flag4 = (num3 & 512u) == 512u;
                bool flag5 = (num3 & 1024u) == 1024u;
                bool flag6 = (num3 & 2048u) == 2048u;
                bool flag7 = (num3 & 8192u) == 8192u;
                if (flag)
                {
                    this.readBoneIndex(br);
                }
                else
                {
                    this.readFloat(br, 3);
                }
                if (flag3 || flag4)
                {
                    mMDBone.GrantParentIndex = this.readBoneIndex(br);
                    mMDBone.GrantRate        = br.ReadSingle();
                }
                if (flag5)
                {
                    this.readFloat(br, 3);
                }
                if (flag6)
                {
                    this.readFloat(br, 3);
                    this.readFloat(br, 3);
                }
                if (flag7)
                {
                    br.ReadInt32();
                }
                if (flag2)
                {
                    this.readBoneIndex(br);
                    br.ReadInt32();
                    br.ReadSingle();
                    int num4 = br.ReadInt32();
                    for (int i = 0; i < num4; i++)
                    {
                        this.readBoneIndex(br);
                        byte b = br.ReadByte();
                        if (b == 1)
                        {
                            this.readFloat(br, 3);
                            this.readFloat(br, 3);
                        }
                    }
                }
                mMDBone.BoneIndex = (int)num2;
                this.Bones.Add(mMDBone);
            }
            for (int j = 0; j < this.Bones.Count; j++)
            {
                if (this.Bones[j].ParentIndex >= 0)
                {
                    this.Bones[j].Parent = this.Bones[this.Bones[j].ParentIndex];
                }
            }
        }