Beispiel #1
0
        //methods...
        /// <summary>
        /// Read関数
        /// </summary>
        /// <remarks>この関数はModelManagerから呼び出される。呼び出し時にはマジック文字とバージョン番号が読まれた状態で渡される</remarks>
        /// <param name="reader">マジック文字とバージョン番号読み込み済みのBinaryReader</param>
        /// <param name="coordinate">変換先座標系</param>
        /// <param name="scale">スケーリング値</param>
        public void Read(BinaryReader reader, CoordinateType coordinate, float scale)
        {
            Coordinate = coordinate;//座標系セット
            //通常ヘッダ読み込み(英語ヘッダはBoneIndexの後(ミクなら0x00071167)に書かれている
            Header.Read(reader);
            //頂点リスト読み込み
            DWORD num_vertex = BitConverter.ToUInt32(reader.ReadBytes(4), 0);

            Vertexes = new ModelVertex[num_vertex];
            for (DWORD i = 0; i < num_vertex; i++)
            {
                Vertexes[i] = new ModelVertex();
                Vertexes[i].Read(reader, CoordZ, scale);
            }
            //面リスト読み込み
            DWORD face_vert_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0);

            FaceVertexes = new WORD[face_vert_count];
            for (DWORD i = 0; i < face_vert_count; i++)
            {
                FaceVertexes[i] = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
            }
            //材質リスト読み込み
            DWORD material_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0);

            Materials = new ModelMaterial[material_count];
            for (DWORD i = 0; i < material_count; i++)
            {
                Materials[i] = new ModelMaterial();
                Materials[i].Read(reader);
            }
            //ボーンリスト読み込み
            WORD bone_count = BitConverter.ToUInt16(reader.ReadBytes(2), 0);

            Bones = new ModelBone[bone_count];
            for (WORD i = 0; i < bone_count; i++)
            {
                Bones[i] = new ModelBone();
                Bones[i].Read(reader, CoordZ, scale);
            }
            //IKリスト読み込み
            WORD ik_count = BitConverter.ToUInt16(reader.ReadBytes(2), 0);

            IKs = new ModelIK[ik_count];
            for (WORD i = 0; i < ik_count; i++)
            {
                IKs[i] = new ModelIK();
                IKs[i].Read(reader);
            }
            //表情リスト読み込み
            WORD skin_count = BitConverter.ToUInt16(reader.ReadBytes(2), 0);

            Skins = new ModelSkin[skin_count];
            for (WORD i = 0; i < skin_count; i++)
            {
                Skins[i] = new ModelSkin();
                Skins[i].Read(reader, CoordZ, scale);
            }
            //表情枠用表示リスト
            byte skin_disp_count = reader.ReadByte();

            SkinIndex = new WORD[skin_disp_count];
            for (byte i = 0; i < SkinIndex.Length; i++)
            {
                SkinIndex[i] = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
            }
            //ボーン枠用枠名リスト
            byte bone_disp_name_count = reader.ReadByte();

            BoneDispNames = new ModelBoneDispName[bone_disp_name_count];
            for (byte i = 0; i < BoneDispNames.Length; i++)
            {
                BoneDispNames[i] = new ModelBoneDispName();
                BoneDispNames[i].Read(reader);
            }
            //ボーン枠用表示リスト
            DWORD bone_disp_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0);

            BoneDisps = new ModelBoneDisp[bone_disp_count];
            for (DWORD i = 0; i < BoneDisps.Length; i++)
            {
                BoneDisps[i] = new ModelBoneDisp();
                BoneDisps[i].Read(reader);
            }
            //英語表記フラグ
            Expantion = (reader.ReadByte() != 0);
            if (Expantion)
            {
                //英語ヘッダ
                Header.ReadExpantion(reader);
                //ボーンリスト(英語)
                for (WORD i = 0; i < bone_count; i++)
                {
                    Bones[i].ReadExpantion(reader);
                }
                //スキンリスト(英語)
                for (WORD i = 0; i < skin_count; i++)
                {
                    if (Skins[i].SkinType != 0)//baseのスキンには英名無し
                    {
                        Skins[i].ReadExpantion(reader);
                    }
                }
                //ボーン枠用枠名リスト(英語)
                for (byte i = 0; i < BoneDispNames.Length; i++)
                {
                    BoneDispNames[i].ReadExpantion(reader);
                }
            }
            if (reader.BaseStream.Position >= reader.BaseStream.Length)
            {
                ToonExpantion = false;
            }
            else
            {
                ToonExpantion = true;
                //トゥーンテクスチャリスト
                ToonFileNames = new string[NumToonFileName];//10個固定
                for (int i = 0; i < ToonFileNames.Length; i++)
                {
                    ToonFileNames[i] = GetString(reader.ReadBytes(100));
                }
            }
            if (reader.BaseStream.Position >= reader.BaseStream.Length)
            {
                PhysicsExpantion = false;
            }
            else
            {
                PhysicsExpantion = true;
                //剛体リスト
                DWORD rididbody_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0);
                RigidBodies = new ModelRigidBody[rididbody_count];
                for (DWORD i = 0; i < rididbody_count; i++)
                {
                    RigidBodies[i] = new ModelRigidBody();
                    RigidBodies[i].ReadExpantion(reader, CoordZ, scale);
                }
                //ジョイントリスト
                DWORD joint_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0);
                Joints = new ModelJoint[joint_count];
                for (DWORD i = 0; i < joint_count; i++)
                {
                    Joints[i] = new ModelJoint();
                    Joints[i].ReadExpantion(reader, CoordZ, scale);
                }
            }
        }
Beispiel #2
0
 //methods...
 /// <summary>
 /// Read関数
 /// </summary>
 /// <remarks>この関数はModelManagerから呼び出される。呼び出し時にはマジック文字とバージョン番号が読まれた状態で渡される</remarks>
 /// <param name="reader">マジック文字とバージョン番号読み込み済みのBinaryReader</param>
 /// <param name="coordinate">変換先座標系</param>
 /// <param name="scale">スケーリング値</param>
 public void Read(BinaryReader reader, CoordinateType coordinate, float scale)
 {
     Coordinate = coordinate;//座標系セット
     //通常ヘッダ読み込み(英語ヘッダはBoneIndexの後(ミクなら0x00071167)に書かれている
     Header.Read(reader);
     //頂点リスト読み込み
     DWORD num_vertex = BitConverter.ToUInt32(reader.ReadBytes(4), 0);
     Vertexes = new ModelVertex[num_vertex];
     for (DWORD i = 0; i < num_vertex; i++)
     {
         Vertexes[i] = new ModelVertex();
         Vertexes[i].Read(reader, CoordZ, scale);
     }
     //面リスト読み込み
     DWORD face_vert_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0);
     FaceVertexes = new WORD[face_vert_count];
     for (DWORD i = 0; i < face_vert_count; i++)
     {
         FaceVertexes[i] = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
     }
     //材質リスト読み込み
     DWORD material_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0);
     Materials = new ModelMaterial[material_count];
     for (DWORD i = 0; i < material_count; i++)
     {
         Materials[i] = new ModelMaterial();
         Materials[i].Read(reader);
     }
     //ボーンリスト読み込み
     WORD bone_count = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
     Bones = new ModelBone[bone_count];
     for (WORD i = 0; i < bone_count; i++)
     {
         Bones[i] = new ModelBone();
         Bones[i].Read(reader, CoordZ, scale);
     }
     //IKリスト読み込み
     WORD ik_count = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
     IKs = new ModelIK[ik_count];
     for (WORD i = 0; i < ik_count; i++)
     {
         IKs[i] = new ModelIK();
         IKs[i].Read(reader);
     }
     //表情リスト読み込み
     WORD skin_count = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
     Skins = new ModelSkin[skin_count];
     for (WORD i = 0; i < skin_count; i++)
     {
         Skins[i] = new ModelSkin();
         Skins[i].Read(reader, CoordZ, scale);
     }
     //表情枠用表示リスト
     byte skin_disp_count = reader.ReadByte();
     SkinIndex = new WORD[skin_disp_count];
     for (byte i = 0; i < SkinIndex.Length; i++)
         SkinIndex[i] = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
     //ボーン枠用枠名リスト
     byte bone_disp_name_count = reader.ReadByte();
     BoneDispNames = new ModelBoneDispName[bone_disp_name_count];
     for (byte i = 0; i < BoneDispNames.Length; i++)
     {
         BoneDispNames[i] = new ModelBoneDispName();
         BoneDispNames[i].Read(reader);
     }
     //ボーン枠用表示リスト
     DWORD bone_disp_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0);
     BoneDisps = new ModelBoneDisp[bone_disp_count];
     for (DWORD i = 0; i < BoneDisps.Length; i++)
     {
         BoneDisps[i] = new ModelBoneDisp();
         BoneDisps[i].Read(reader);
     }
     //英語表記フラグ
     Expantion = (reader.ReadByte() != 0);
     if (Expantion)
     {
         //英語ヘッダ
         Header.ReadExpantion(reader);
         //ボーンリスト(英語)
         for (WORD i = 0; i < bone_count; i++)
         {
             Bones[i].ReadExpantion(reader);
         }
         //スキンリスト(英語)
         for (WORD i = 0; i < skin_count; i++)
         {
             if (Skins[i].SkinType != 0)//baseのスキンには英名無し
                 Skins[i].ReadExpantion(reader);
         }
         //ボーン枠用枠名リスト(英語)
         for (byte i = 0; i < BoneDispNames.Length; i++)
         {
             BoneDispNames[i].ReadExpantion(reader);
         }
     }
     if (reader.BaseStream.Position >= reader.BaseStream.Length)
         ToonExpantion = false;
     else
     {
         ToonExpantion = true;
         //トゥーンテクスチャリスト
         ToonFileNames = new string[NumToonFileName];//10個固定
         for (int i = 0; i < ToonFileNames.Length; i++)
         {
             ToonFileNames[i] = GetString(reader.ReadBytes(100));
         }
     }
     if (reader.BaseStream.Position >= reader.BaseStream.Length)
         PhysicsExpantion = false;
     else
     {
         PhysicsExpantion = true;
         //剛体リスト
         DWORD rididbody_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0);
         RigidBodies = new ModelRigidBody[rididbody_count];
         for (DWORD i = 0; i < rididbody_count; i++)
         {
             RigidBodies[i] = new ModelRigidBody();
             RigidBodies[i].ReadExpantion(reader, CoordZ, scale);
         }
         //ジョイントリスト
         DWORD joint_count = BitConverter.ToUInt32(reader.ReadBytes(4), 0);
         Joints = new ModelJoint[joint_count];
         for (DWORD i = 0; i < joint_count; i++)
         {
             Joints[i] = new ModelJoint();
             Joints[i].ReadExpantion(reader, CoordZ, scale);
         }
     }
     
 }