2 * model exporter for pmd-file(Ext1)
4 * License : The MIT License
5 * Copyright(c) 2010 MikuToga Partners
8 package jp.sourceforge.mikutoga.pmd.pmdexporter;
10 import java.io.IOException;
11 import java.io.OutputStream;
12 import java.util.List;
14 import jp.sourceforge.mikutoga.pmd.MorphType;
15 import jp.sourceforge.mikutoga.pmd.model.BoneGroup;
16 import jp.sourceforge.mikutoga.pmd.model.BoneInfo;
17 import jp.sourceforge.mikutoga.pmd.model.MorphPart;
18 import jp.sourceforge.mikutoga.pmd.model.PmdModel;
19 import jp.sourceforge.mikutoga.pmd.parser.PmdLimits;
22 * PMDファイルのエクスポーター(拡張1:英名対応)。
24 * 任意のトゥーンファイル名対応以降のPMDファイルフォーマットを
25 * 使いたくない場合はこのエクスポーターを用いて出力せよ。
27 public class PmdExporterExt1 extends PmdExporterBase{
31 * @param stream 出力ストリーム
32 * @throws NullPointerException 引数がnull
34 public PmdExporterExt1(OutputStream stream)
35 throws NullPointerException{
42 * @param model {@inheritDoc}
43 * @throws IOException {@inheritDoc}
44 * @throws IllegalPmdException {@inheritDoc}
47 public void dumpPmdModel(PmdModel model)
48 throws IOException, IllegalPmdException{
49 super.dumpPmdModel(model);
51 dumpGlobalInfo(model);
59 * @throws IOException 出力エラー
60 * @throws IllegalPmdTextException 文字列が長すぎる。
62 private void dumpGlobalInfo(PmdModel model)
63 throws IOException, IllegalPmdTextException{
64 boolean hasGlobal = model.hasGlobalText();
66 if(hasGlobal) globalFlag = 0x01;
67 else globalFlag = 0x00;
71 dumpBasicGlobal(model);
72 dumpBoneGlobal(model);
73 dumpMorphGlobal(model);
74 dumpBoneGroupGlobal(model);
85 * @throws IOException 出力エラー
86 * @throws IllegalPmdTextException 文字列が長すぎる。
88 private void dumpBasicGlobal(PmdModel model)
89 throws IOException, IllegalPmdTextException{
90 String modelName = model.getModelName().getGlobalText();
91 if(modelName == null) modelName = "";
92 dumpText(modelName, PmdLimits.MAXBYTES_MODELNAME);
94 String description = model.getDescription().getGlobalText();
95 if(description == null) description = "";
96 dumpText(description, PmdLimits.MAXBYTES_MODELDESC);
103 * @param model モデルデータ
104 * @throws IOException 出力エラー
105 * @throws IllegalPmdTextException 文字列が長すぎる。
107 private void dumpBoneGlobal(PmdModel model)
108 throws IOException, IllegalPmdTextException{
109 for(BoneInfo bone : model.getBoneList()){
110 String boneName = bone.getBoneName().getGlobalText();
111 if(boneName == null) boneName = "";
112 dumpText(boneName, PmdLimits.MAXBYTES_BONENAME);
120 * @param model モデルデータ
121 * @throws IOException 出力エラー
122 * @throws IllegalPmdTextException 文字列が長すぎる。
124 private void dumpMorphGlobal(PmdModel model)
125 throws IOException, IllegalPmdTextException{
126 Map<MorphType, List<MorphPart>> morphMap = model.getMorphMap();
128 for(MorphType type : MorphType.values()){
129 if(type.isBase()) continue;
130 List<MorphPart> partList = morphMap.get(type);
131 if(partList == null) continue;
132 for(MorphPart part : partList){
133 String morphName = part.getMorphName().getGlobalText();
134 if(morphName == null) morphName = "";
135 dumpText(morphName, PmdLimits.MAXBYTES_MORPHNAME);
144 * @param model モデルデータ
145 * @throws IOException 出力エラー
146 * @throws IllegalPmdTextException 文字列が長すぎる
148 private void dumpBoneGroupGlobal(PmdModel model)
149 throws IOException, IllegalPmdTextException{
150 for(BoneGroup group : model.getBoneGroupList()){
151 if(group.isDefaultBoneGroup()) continue;
152 String groupName = group.getGroupName().getGlobalText();
153 if(groupName == null) groupName = "";
154 dumpText(groupName, PmdLimits.MAXBYTES_BONEGROUPNAME);