Exemplo n.º 1
0
        public void AddSlotMaterial(TargetMaterial tm)
        {
            LogUtil.Debug("Add slot material", tm.editname);

            SlotMaterials slotMat;

            if (!slotMaterials.TryGetValue(tm.slotName, out slotMat))
            {
                slotMat = new SlotMaterials();
                slotMaterials[tm.slotName] = slotMat;
            }
            slotMat.SetMaterial(tm);
        }
Exemplo n.º 2
0
        // Token: 0x0600010E RID: 270 RVA: 0x0000B7FC File Offset: 0x000099FC
        public void AddSlotMaterial(TargetMaterial tm)
        {
            LogUtil.Debug(new object[]
            {
                "Add slot material",
                tm.editname
            });
            SlotMaterials slotMaterials;

            if (!this.slotMaterials.TryGetValue(tm.slotName, out slotMaterials))
            {
                slotMaterials = new SlotMaterials();
                this.slotMaterials[tm.slotName] = slotMaterials;
            }
            slotMaterials.SetMaterial(tm);
        }
        public bool TransferModel(BinaryReader reader, string header, BinaryWriter writer,SlotMaterials slotMat) {

            writer.Write(header);
            writer.Write(reader.ReadInt32());  // ver
            writer.Write(reader.ReadString()); // "_SM_" + name
            writer.Write(reader.ReadString()); // base_bone
            int count = reader.ReadInt32();
            writer.Write(count);  // num (bone_count)
            for(int i=0; i< count; i++) {
                writer.Write(reader.ReadString()); // ボーン名
                writer.Write(reader.ReadByte());   // フラグ (_SCL_追加の有無等)
            }

            for(int i=0; i< count; i++) {
                int count2 = reader.ReadInt32();   // parent index
                writer.Write(count2);
            }

            for(int i=0; i< count; i++) {
                // (x, y, z), (x2, y2, z2, w)
                TransferVec(reader, writer, 7);
            }
            int vertexCount = reader.ReadInt32();
            int facesCount = reader.ReadInt32();
            int localBoneCount = reader.ReadInt32();
            writer.Write(vertexCount);
            writer.Write(facesCount);
            writer.Write(localBoneCount);

            for(int i=0; i< localBoneCount; i++) {
                writer.Write(reader.ReadString()); // ローカルボーン名
            }
            for(int i=0; i< localBoneCount; i++) {
                TransferVec(reader, writer, 16); // matrix (floatx4, floatx4)
            }
            for(int i=0; i< vertexCount; i++) {
                TransferVec(reader, writer, 8);
            }
            int vertexCount2 = reader.ReadInt32();
            writer.Write(vertexCount2);
            for(int i=0; i< vertexCount2; i++) {
                TransferVec4(reader, writer);
            }
            for(int i=0; i< vertexCount; i++) {
                for (int j=0; j< 4; j++) {
                    writer.Write(reader.ReadUInt16());
                }
                TransferVec4(reader, writer);
            }
            for(int i=0; i< facesCount; i++) {
                int cnt = reader.ReadInt32();
                writer.Write(cnt);
                for (int j=0; j< cnt; j++) {
                    writer.Write(reader.ReadInt16());
                }
            }
            // material
            int mateCount = reader.ReadInt32();
            writer.Write(mateCount);
            for(int matNo=0; matNo< mateCount; matNo++) {
                var tm = slotMat.Get(matNo);
                TransferMaterial(reader, writer, tm, tm.onlyModel);
            }
            
            // morph
            while (true) {
                string name = reader.ReadString();
                writer.Write(name);
                if (name == "end") break;

                if (name == "morph") {
                    string key = reader.ReadString();
                    writer.Write(key);
                    int num = reader.ReadInt32();
                    writer.Write(num);
                    for (int i=0; i< num; i++) {
                        writer.Write(reader.ReadUInt16());
                        // (x, y, z), (x, y, z)
                        TransferVec(reader, writer, 6);
                    }
                }
            }
            return true;
        }
 private bool WriteModelFile(BinaryReader reader, string header, string outfilepath, SlotMaterials slotMat) {
     using ( var writer = new BinaryWriter(File.OpenWrite(outfilepath)) ) {
         return TransferModel(reader, header, writer, slotMat);
     }
 }
        ///
        ///
        public bool WriteModelFile(string infile, string outfilepath, SlotMaterials slotMat) {
            bool onBuffer;
            using ( var reader = new BinaryReader(GetStream(infile, out onBuffer), Encoding.UTF8) ) {

                // ヘッダ
                string header = reader.ReadString();
                if (onBuffer || reader.BaseStream.Position > 0) {
                    if (header == FileConst.HEAD_MODEL) {
                        return WriteModelFile(reader, header, outfilepath, slotMat);
                    }
                    var msg = LogUtil.Error("正しいモデルファイルではありません。ヘッダが不正です。", header, ", infile=", infile);
                    throw new ACCException(msg.ToString());
                }
            }

            // arc内のファイルがロードできない場合の回避策: Sybaris 0410向け対策. 一括読み込み
            using (var reader = new BinaryReader(new MemoryStream(FileUtilEx.Instance.LoadInternal(infile), false), Encoding.UTF8)) {
                string header = reader.ReadString(); // hader
                if (header == FileConst.HEAD_MODEL) {
                    return WriteModelFile(reader, header, outfilepath, slotMat);

                } else {
                    var msg = LogUtil.Error("正しいモデルファイルではありません。ヘッダが不正です。", header, ", infile=", infile);
                    throw new ACCException(msg.ToString());
                }
            }
        }
        public void AddSlotMaterial(TargetMaterial tm) {
            LogUtil.Debug("Add slot material", tm.editname);

            SlotMaterials slotMat;
            if (!slotMaterials.TryGetValue(tm.slotName, out slotMat)) {
                slotMat = new SlotMaterials();
                slotMaterials[tm.slotName] = slotMat;
            }
            slotMat.SetMaterial(tm);
        }