Vmd2XMLは、3D動画制作ツール、MikuMikuDance(MMD)で用いられるモーションデータファイル(*.vmd)の内容を、XML形式のデータファイルと交換するためのアプリケーションです。
Revision | 89e86bcb809f86c2a89c1e76d9901fa885f4ea55 (tree) |
---|---|
Zeit | 2013-06-08 13:30:39 |
Autor | <olyutorskii@user...> |
MMD Ver7.40 対応 新スキーマ開発開始
@@ -10,6 +10,7 @@ | ||
10 | 10 | ・ベジェ補間パラメータ冗長部がMMDの版により異なるため、検査をやめた。 |
11 | 11 | ・プロセス終了コードの変更。 |
12 | 12 | ・DOMからSAXへの移行。 |
13 | + ・MikuMikuDance Ver7.40以降の新VMDファイルフォーマットに対応 | |
13 | 14 | |
14 | 15 | |
15 | 16 | 1.101.2 (2011-08-25) |
@@ -112,7 +112,7 @@ | ||
112 | 112 | <dependency> |
113 | 113 | <groupId>jp.sourceforge.mikutoga</groupId> |
114 | 114 | <artifactId>togagem</artifactId> |
115 | - <version>2.102.5-SNAPSHOT</version> | |
115 | + <version>2.102.7-SNAPSHOT</version> | |
116 | 116 | <scope>compile</scope> |
117 | 117 | </dependency> |
118 | 118 |
@@ -0,0 +1,81 @@ | ||
1 | +/* | |
2 | + * IK ON/OFF switch | |
3 | + * | |
4 | + * License : The MIT License | |
5 | + * Copyright(c) 2013 MikuToga Partners | |
6 | + */ | |
7 | + | |
8 | +package jp.sfjp.mikutoga.vmd.model; | |
9 | + | |
10 | +import java.text.MessageFormat; | |
11 | + | |
12 | +/** | |
13 | + * IK ON/OFF の管理を行う。 | |
14 | + */ | |
15 | +public class IkSwitch { | |
16 | + | |
17 | + private static final String MSG_TXT = | |
18 | + "IKbone {0} : {1}"; | |
19 | + | |
20 | + | |
21 | + private String boneName = ""; | |
22 | + private boolean valid = true; | |
23 | + | |
24 | + | |
25 | + /** | |
26 | + * コンストラクタ。 | |
27 | + */ | |
28 | + public IkSwitch(){ | |
29 | + super(); | |
30 | + return; | |
31 | + } | |
32 | + | |
33 | + | |
34 | + /** | |
35 | + * ボーン名を返す。 | |
36 | + * @return ボーン名 | |
37 | + */ | |
38 | + public String getBoneName(){ | |
39 | + return this.boneName; | |
40 | + } | |
41 | + | |
42 | + /** | |
43 | + * ボーン名を設定する。 | |
44 | + * @param boneNameArg ボーン名 | |
45 | + * @throws NullPointerException 引数がnull | |
46 | + */ | |
47 | + public void setBoneName(String boneNameArg) throws NullPointerException{ | |
48 | + if(boneNameArg == null) throw new NullPointerException(); | |
49 | + this.boneName = boneNameArg; | |
50 | + return; | |
51 | + } | |
52 | + | |
53 | + /** | |
54 | + * IK処理が有効か否か返す。 | |
55 | + * @return 有効ならtrue | |
56 | + */ | |
57 | + public boolean isValid(){ | |
58 | + return this.valid; | |
59 | + } | |
60 | + | |
61 | + /** | |
62 | + * IK処理が有効か否か設定する。 | |
63 | + * @param validArg 有効ならtrue | |
64 | + */ | |
65 | + public void setValid(boolean validArg){ | |
66 | + this.valid = validArg; | |
67 | + return; | |
68 | + } | |
69 | + | |
70 | + /** | |
71 | + * {@inheritDoc} | |
72 | + * @return {@inheritDoc} | |
73 | + */ | |
74 | + @Override | |
75 | + public String toString(){ | |
76 | + String msg; | |
77 | + msg = MessageFormat.format(MSG_TXT, this.boneName, this.valid); | |
78 | + return msg; | |
79 | + } | |
80 | + | |
81 | +} |
@@ -0,0 +1,92 @@ | ||
1 | +/* | |
2 | + * model presence switch | |
3 | + * | |
4 | + * License : The MIT License | |
5 | + * Copyright(c) 2013 MikuToga Partners | |
6 | + */ | |
7 | + | |
8 | +package jp.sfjp.mikutoga.vmd.model; | |
9 | + | |
10 | +import java.text.MessageFormat; | |
11 | +import java.util.Iterator; | |
12 | +import java.util.LinkedList; | |
13 | +import java.util.List; | |
14 | +import jp.sfjp.mikutoga.vmd.AbstractNumbered; | |
15 | + | |
16 | +/** | |
17 | + * フレーム番号が付けられた各種モーションフラグの管理を行う。 | |
18 | + */ | |
19 | +public class NumberedVmdFlag | |
20 | + extends AbstractNumbered | |
21 | + implements Iterable<IkSwitch> { | |
22 | + | |
23 | + private static final String MSG_TXT = | |
24 | + "#{0} model precense : {1}"; | |
25 | + | |
26 | + | |
27 | + private boolean shown = true; | |
28 | + private List<IkSwitch> ikSwList = new LinkedList<IkSwitch>(); | |
29 | + | |
30 | + | |
31 | + /** | |
32 | + * コンストラクタ。 | |
33 | + * <p>モデル表示ありの状態で初期化される。 | |
34 | + */ | |
35 | + public NumberedVmdFlag(){ | |
36 | + super(); | |
37 | + return; | |
38 | + } | |
39 | + | |
40 | + | |
41 | + /** | |
42 | + * モデルを表示するか否か返す。 | |
43 | + * @return 表示するならtrue | |
44 | + */ | |
45 | + public boolean isModelShown(){ | |
46 | + return this.shown; | |
47 | + } | |
48 | + | |
49 | + /** | |
50 | + * モデルを表示するか否か設定する。 | |
51 | + * @param shownArg 表示するならtrue | |
52 | + */ | |
53 | + public void setModelShown(boolean shownArg){ | |
54 | + this.shown = shownArg; | |
55 | + return; | |
56 | + } | |
57 | + | |
58 | + /** | |
59 | + * 個別IKボーンフラグのリストを返す。 | |
60 | + * @return 個別IKボーンフラグのリスト | |
61 | + */ | |
62 | + public List<IkSwitch> getIkSwitchList(){ | |
63 | + return this.ikSwList; | |
64 | + } | |
65 | + | |
66 | + /** | |
67 | + * {@inheritDoc} | |
68 | + * @return {@inheritDoc} | |
69 | + */ | |
70 | + @Override | |
71 | + public Iterator<IkSwitch> iterator(){ | |
72 | + return this.ikSwList.iterator(); | |
73 | + } | |
74 | + | |
75 | + /** | |
76 | + * {@inheritDoc} | |
77 | + * @return {@inheritDoc} | |
78 | + */ | |
79 | + @Override | |
80 | + public String toString(){ | |
81 | + String msg; | |
82 | + msg = MessageFormat.format(MSG_TXT, getFrameNumber(), this.shown); | |
83 | + | |
84 | + StringBuilder submsg = new StringBuilder(msg); | |
85 | + for(IkSwitch sw : this.ikSwList){ | |
86 | + submsg.append('\n').append("\u0020").append(sw.toString()); | |
87 | + } | |
88 | + | |
89 | + return submsg.toString(); | |
90 | + } | |
91 | + | |
92 | +} |
@@ -22,8 +22,8 @@ | ||
22 | 22 | public class VmdMotion { |
23 | 23 | |
24 | 24 | private static final String MSG_TXT = |
25 | - "model name : {0}\n" | |
26 | - + "bone#{1} morph#{2} camera#{3} luminous#{4} shadow#{5}"; | |
25 | + "model name : {0}\n" | |
26 | + + "bone#{1} morph#{2} camera#{3} luminous#{4} shadow#{5} flag#{6}"; | |
27 | 27 | |
28 | 28 | |
29 | 29 | private String modelName = VmdUniq.MODELNAME_STAGEACT; |
@@ -31,9 +31,10 @@ | ||
31 | 31 | private final Map<String, List<BoneMotion>> bonePartMap; |
32 | 32 | private final Map<String, List<MorphMotion>> morphPartMap; |
33 | 33 | |
34 | - private final List<CameraMotion> cameraMotionList; | |
35 | - private final List<LuminousMotion> luminousMotionList; | |
36 | - private final List<ShadowMotion> shadowMotionList; | |
34 | + private final List<CameraMotion> cameraMotionList; | |
35 | + private final List<LuminousMotion> luminousMotionList; | |
36 | + private final List<ShadowMotion> shadowMotionList; | |
37 | + private final List<NumberedVmdFlag> flagList; | |
37 | 38 | |
38 | 39 | |
39 | 40 | /** |
@@ -48,6 +49,7 @@ | ||
48 | 49 | this.cameraMotionList = new LinkedList<CameraMotion>(); |
49 | 50 | this.luminousMotionList = new LinkedList<LuminousMotion>(); |
50 | 51 | this.shadowMotionList = new LinkedList<ShadowMotion>(); |
52 | + this.flagList = new LinkedList<NumberedVmdFlag>(); | |
51 | 53 | |
52 | 54 | return; |
53 | 55 | } |
@@ -132,6 +134,14 @@ | ||
132 | 134 | } |
133 | 135 | |
134 | 136 | /** |
137 | + * 各種フレーム番号付きフラグのリストを返す。 | |
138 | + * @return フレーム番号付きフラグのリスト | |
139 | + */ | |
140 | + public List<NumberedVmdFlag> getNumberedFlagList(){ | |
141 | + return this.flagList; | |
142 | + } | |
143 | + | |
144 | + /** | |
135 | 145 | * ボーンモーションを追加する。 |
136 | 146 | * 追加順は保持される。 |
137 | 147 | * @param motion ボーンモーション |
@@ -186,6 +196,7 @@ | ||
186 | 196 | Collections.sort(this.cameraMotionList, FrameNumbered.COMPARATOR); |
187 | 197 | Collections.sort(this.luminousMotionList, FrameNumbered.COMPARATOR); |
188 | 198 | Collections.sort(this.shadowMotionList, FrameNumbered.COMPARATOR); |
199 | + Collections.sort(this.flagList, FrameNumbered.COMPARATOR); | |
189 | 200 | |
190 | 201 | return; |
191 | 202 | } |
@@ -209,11 +220,12 @@ | ||
209 | 220 | int cameraNo = this.cameraMotionList .size(); |
210 | 221 | int luminousNo = this.luminousMotionList.size(); |
211 | 222 | int shadowNo = this.shadowMotionList .size(); |
223 | + int flagNo = this.flagList .size(); | |
212 | 224 | |
213 | 225 | String msg; |
214 | 226 | msg = MessageFormat.format(MSG_TXT, |
215 | 227 | this.modelName, |
216 | - boneNo, morphNo, cameraNo, luminousNo, shadowNo ); | |
228 | + boneNo, morphNo, cameraNo, luminousNo, shadowNo, flagNo ); | |
217 | 229 | |
218 | 230 | return msg; |
219 | 231 | } |
@@ -0,0 +1,96 @@ | ||
1 | +/* | |
2 | + * boolean information exporter | |
3 | + * | |
4 | + * License : The MIT License | |
5 | + * Copyright(c) 2013 MikuToga Partners | |
6 | + */ | |
7 | + | |
8 | +package jp.sfjp.mikutoga.vmd.model.binio; | |
9 | + | |
10 | +import java.io.IOException; | |
11 | +import java.io.OutputStream; | |
12 | +import java.util.List; | |
13 | +import jp.sfjp.mikutoga.bin.export.BinaryExporter; | |
14 | +import jp.sfjp.mikutoga.bin.export.IllegalTextExportException; | |
15 | +import jp.sfjp.mikutoga.vmd.VmdConst; | |
16 | +import jp.sfjp.mikutoga.vmd.model.IkSwitch; | |
17 | +import jp.sfjp.mikutoga.vmd.model.NumberedVmdFlag; | |
18 | +import jp.sfjp.mikutoga.vmd.model.VmdMotion; | |
19 | + | |
20 | +/** | |
21 | + * フラグ情報のエクスポーター。 | |
22 | + * <p>MikuMikuDance Ver7.40以降でサポート | |
23 | + */ | |
24 | +class BoolExporter extends BinaryExporter{ | |
25 | + | |
26 | + private static final byte[] FDFILLER = | |
27 | + { (byte)0x00, (byte)0xfd }; | |
28 | + | |
29 | + | |
30 | + /** | |
31 | + * コンストラクタ。 | |
32 | + * @param stream 出力ストリーム | |
33 | + */ | |
34 | + BoolExporter(OutputStream stream){ | |
35 | + super(stream); | |
36 | + return; | |
37 | + } | |
38 | + | |
39 | + | |
40 | + /** | |
41 | + * フラグ情報を出力する。 | |
42 | + * @param motion モーションデータ | |
43 | + * @throws IOException 出力エラー | |
44 | + * @throws IllegalTextExportException 不正な文字列が指定された。 | |
45 | + */ | |
46 | + void dumpNumberedFlagMotion(VmdMotion motion) | |
47 | + throws IOException, IllegalTextExportException { | |
48 | + List<NumberedVmdFlag> list = motion.getNumberedFlagList(); | |
49 | + | |
50 | + if(list.isEmpty()) return; | |
51 | + | |
52 | + int count = list.size(); | |
53 | + dumpLeInt(count); | |
54 | + | |
55 | + for(NumberedVmdFlag flag : list){ | |
56 | + int frameNo = flag.getFrameNumber(); | |
57 | + dumpLeInt(frameNo); | |
58 | + | |
59 | + byte showModel; | |
60 | + if(flag.isModelShown()) showModel = 0x01; | |
61 | + else showModel = 0x00; | |
62 | + dumpByte(showModel); | |
63 | + | |
64 | + dumpIkSwitch(flag); | |
65 | + } | |
66 | + | |
67 | + | |
68 | + return; | |
69 | + } | |
70 | + | |
71 | + /** | |
72 | + * IK有効フラグを出力する。 | |
73 | + * @param flag フラグ情報 | |
74 | + * @throws IOException 出力エラー | |
75 | + * @throws IllegalTextExportException 不正な文字列が指定された。 | |
76 | + */ | |
77 | + private void dumpIkSwitch(NumberedVmdFlag flag) | |
78 | + throws IOException, IllegalTextExportException { | |
79 | + List<IkSwitch> swList = flag.getIkSwitchList(); | |
80 | + int swNo = swList.size(); | |
81 | + dumpLeInt(swNo); | |
82 | + | |
83 | + for(IkSwitch ikSwitch : swList){ | |
84 | + String boneName = ikSwitch.getBoneName(); | |
85 | + dumpFixedW31j(boneName, VmdConst.IKSWBONENAME_MAX, FDFILLER); | |
86 | + | |
87 | + byte ikValid; | |
88 | + if(ikSwitch.isValid()) ikValid = 0x01; | |
89 | + else ikValid = 0x00; | |
90 | + dumpByte(ikValid); | |
91 | + } | |
92 | + | |
93 | + return; | |
94 | + } | |
95 | + | |
96 | +} |
@@ -0,0 +1,126 @@ | ||
1 | +/* | |
2 | + * boolean information builder | |
3 | + * | |
4 | + * License : The MIT License | |
5 | + * Copyright(c) 2013 MikuToga Partners | |
6 | + */ | |
7 | + | |
8 | +package jp.sfjp.mikutoga.vmd.model.binio; | |
9 | + | |
10 | +import java.util.List; | |
11 | +import jp.sfjp.mikutoga.bin.parser.MmdFormatException; | |
12 | +import jp.sfjp.mikutoga.bin.parser.ParseStage; | |
13 | +import jp.sfjp.mikutoga.vmd.model.IkSwitch; | |
14 | +import jp.sfjp.mikutoga.vmd.model.NumberedVmdFlag; | |
15 | +import jp.sfjp.mikutoga.vmd.model.VmdMotion; | |
16 | +import jp.sfjp.mikutoga.vmd.parser.VmdBoolHandler; | |
17 | + | |
18 | +/** | |
19 | + * フラグ情報のビルダ。 | |
20 | + * <p>MikuMikuDance Ver7.40以降でサポート | |
21 | + */ | |
22 | +public class BoolLoader implements VmdBoolHandler{ | |
23 | + | |
24 | + private final List<NumberedVmdFlag> flagList; | |
25 | + | |
26 | + private NumberedVmdFlag currentFlag; | |
27 | + private IkSwitch currentSwitch; | |
28 | + | |
29 | + /** | |
30 | + * コンストラクタ。 | |
31 | + * @param vmdMotion モーションデータの格納先。 | |
32 | + */ | |
33 | + BoolLoader(VmdMotion vmdMotion){ | |
34 | + super(); | |
35 | + this.flagList = vmdMotion.getNumberedFlagList(); | |
36 | + return; | |
37 | + } | |
38 | + | |
39 | + | |
40 | + /** | |
41 | + * {@inheritDoc} | |
42 | + * @param stage {@inheritDoc} | |
43 | + * @param loops {@inheritDoc} | |
44 | + * @throws MmdFormatException {@inheritDoc} | |
45 | + */ | |
46 | + @Override | |
47 | + public void loopStart(ParseStage stage, int loops) | |
48 | + throws MmdFormatException{ | |
49 | + if(stage == VmdBoolHandler.MODELSIGHT_LIST){ | |
50 | + this.currentFlag = new NumberedVmdFlag(); | |
51 | + }else if(stage == VmdBoolHandler.IKSW_LIST){ | |
52 | + this.currentSwitch = new IkSwitch(); | |
53 | + } | |
54 | + | |
55 | + return; | |
56 | + } | |
57 | + | |
58 | + /** | |
59 | + * {@inheritDoc} | |
60 | + * @param stage {@inheritDoc} | |
61 | + * @throws MmdFormatException {@inheritDoc} | |
62 | + */ | |
63 | + @Override | |
64 | + public void loopNext(ParseStage stage) | |
65 | + throws MmdFormatException{ | |
66 | + if(stage == VmdBoolHandler.MODELSIGHT_LIST){ | |
67 | + this.flagList.add(this.currentFlag); | |
68 | + this.currentFlag = new NumberedVmdFlag(); | |
69 | + }else if(stage == VmdBoolHandler.IKSW_LIST){ | |
70 | + List<IkSwitch> swList = this.currentFlag.getIkSwitchList(); | |
71 | + swList.add(this.currentSwitch); | |
72 | + this.currentSwitch = new IkSwitch(); | |
73 | + } | |
74 | + | |
75 | + return; | |
76 | + } | |
77 | + | |
78 | + /** | |
79 | + * {@inheritDoc} | |
80 | + * @param stage {@inheritDoc} | |
81 | + * @throws MmdFormatException {@inheritDoc} | |
82 | + */ | |
83 | + @Override | |
84 | + public void loopEnd(ParseStage stage) | |
85 | + throws MmdFormatException{ | |
86 | + if(stage == VmdBoolHandler.MODELSIGHT_LIST){ | |
87 | + this.currentFlag = null; | |
88 | + }else if(stage == VmdBoolHandler.IKSW_LIST){ | |
89 | + this.currentSwitch = null; | |
90 | + } | |
91 | + | |
92 | + return; | |
93 | + } | |
94 | + | |
95 | + /** | |
96 | + * {@inheritDoc} | |
97 | + * @param show {@inheritDoc} | |
98 | + * @param keyFrameNo {@inheritDoc} | |
99 | + * @throws MmdFormatException {@inheritDoc} | |
100 | + */ | |
101 | + @Override | |
102 | + public void vmdModelSight(boolean show, int keyFrameNo) | |
103 | + throws MmdFormatException { | |
104 | + this.currentFlag.setModelShown(show); | |
105 | + this.currentFlag.setFrameNumber(keyFrameNo); | |
106 | + return; | |
107 | + } | |
108 | + | |
109 | + /** | |
110 | + * {@inheritDoc} | |
111 | + * @param boneName {@inheritDoc} | |
112 | + * @param validIk {@inheritDoc} | |
113 | + * @param keyFrameNo {@inheritDoc} | |
114 | + * @throws MmdFormatException {@inheritDoc} | |
115 | + */ | |
116 | + @Override | |
117 | + public void vmdIkSwitch(String boneName, | |
118 | + boolean validIk, | |
119 | + int keyFrameNo ) | |
120 | + throws MmdFormatException { | |
121 | + this.currentSwitch.setBoneName(boneName); | |
122 | + this.currentSwitch.setValid(validIk); | |
123 | + return; | |
124 | + } | |
125 | + | |
126 | +} |
@@ -21,6 +21,7 @@ | ||
21 | 21 | private BasicExporter basicExporter = null; |
22 | 22 | private CameraExporter cameraExporter = null; |
23 | 23 | private LightingExporter lightingExporter = null; |
24 | + private BoolExporter boolExporter = null; | |
24 | 25 | |
25 | 26 | |
26 | 27 | /** |
@@ -44,6 +45,7 @@ | ||
44 | 45 | this.basicExporter = new BasicExporter(ostream); |
45 | 46 | this.cameraExporter = new CameraExporter(ostream); |
46 | 47 | this.lightingExporter = new LightingExporter(ostream); |
48 | + this.boolExporter = new BoolExporter(ostream); | |
47 | 49 | |
48 | 50 | try{ |
49 | 51 | dumpVmdMotionImpl(motion); |
@@ -76,6 +78,13 @@ | ||
76 | 78 | this.lightingExporter.dumpLuminousMotion(motion); |
77 | 79 | this.lightingExporter.dumpShadowMotion(motion); |
78 | 80 | |
81 | + if(motion.getNumberedFlagList().isEmpty()) return; | |
82 | + try{ | |
83 | + this.boolExporter.dumpNumberedFlagMotion(motion); | |
84 | + }catch(IllegalTextExportException e){ | |
85 | + throw new IllegalVmdDataException(e); | |
86 | + } | |
87 | + | |
79 | 88 | return; |
80 | 89 | } |
81 | 90 |
@@ -25,7 +25,6 @@ | ||
25 | 25 | private boolean loaded = false; |
26 | 26 | private boolean hasMoreData = true; |
27 | 27 | |
28 | - private boolean ignoreName = true; | |
29 | 28 | private boolean redundantCheck = false; |
30 | 29 | |
31 | 30 |
@@ -49,23 +48,11 @@ | ||
49 | 48 | } |
50 | 49 | |
51 | 50 | /** |
52 | - * カメラ・ライティングデータのパースを試みるか否かの判断で、 | |
53 | - * 特殊モデル名判定を無視するか否か設定する。 | |
54 | - * デフォルトではモデル名を無視。 | |
55 | - * <p>※MMDVer7.30前後のVMD出力不具合を回避したい場合は、 | |
56 | - * オフにするとパースに成功する場合がある。 | |
57 | - * @param mode モデル名を無視してパースを強行するならtrue | |
58 | - */ | |
59 | - public void setIgnoreName(boolean mode){ | |
60 | - this.ignoreName = mode; | |
61 | - return; | |
62 | - } | |
63 | - | |
64 | - /** | |
65 | 51 | * ボーンモーション補間情報冗長部のチェックを行うか否か設定する。 |
66 | 52 | * デフォルトではチェックを行わない。 |
67 | 53 | * <p>※MMDVer7.30前後のVMD出力不具合を回避したい場合は、 |
68 | 54 | * オフにするとパースに成功する場合がある。 |
55 | + * <p>※MMD Ver7.39x64以降はチェック回避必須。 | |
69 | 56 | * @param mode チェックさせたければtrue |
70 | 57 | */ |
71 | 58 | public void setRedundantCheck(boolean mode){ |
@@ -92,16 +79,17 @@ | ||
92 | 79 | |
93 | 80 | VmdParser parser = new VmdParser(source); |
94 | 81 | |
95 | - parser.setIgnoreName(this.ignoreName); | |
96 | 82 | parser.setRedundantCheck(this.redundantCheck); |
97 | 83 | |
98 | 84 | BasicLoader basicBuilder = new BasicLoader(motion); |
99 | 85 | CameraLoader cameraBuilder = new CameraLoader(motion); |
100 | 86 | LightingLoader lightingBuilder = new LightingLoader(motion); |
87 | + BoolLoader boolBuilder = new BoolLoader(motion); | |
101 | 88 | |
102 | 89 | parser.setBasicHandler(basicBuilder); |
103 | 90 | parser.setCameraHandler(cameraBuilder); |
104 | 91 | parser.setLightingHandler(lightingBuilder); |
92 | + parser.setBoolHandler(boolBuilder); | |
105 | 93 | |
106 | 94 | try{ |
107 | 95 | parser.parseVmd(); |
@@ -0,0 +1,130 @@ | ||
1 | +/* | |
2 | + * Sax 2 Xsd-types converter | |
3 | + * | |
4 | + * License : The MIT License | |
5 | + * Copyright(c) 2013 MikuToga Partners | |
6 | + */ | |
7 | + | |
8 | +package jp.sfjp.mikutoga.vmd.model.xml; | |
9 | + | |
10 | +import javax.xml.bind.DatatypeConverter; | |
11 | +import org.xml.sax.Attributes; | |
12 | + | |
13 | +/** | |
14 | + * XSD各種型のSAX属性値をJavaプリミティブ型へ変換する。 | |
15 | + */ | |
16 | +public final class SaxAttr { | |
17 | + | |
18 | + /** | |
19 | + * 隠しコンストラクタ。 | |
20 | + */ | |
21 | + private SaxAttr(){ | |
22 | + assert false; | |
23 | + throw new AssertionError(); | |
24 | + } | |
25 | + | |
26 | + | |
27 | + /** | |
28 | + * 属性名に対応する属性値があるか否か判定する。 | |
29 | + * @param attr 属性群 | |
30 | + * @param name 属性名 | |
31 | + * @return 属性名に対応する属性値がある場合はtrue | |
32 | + */ | |
33 | + public static boolean hasAttr(Attributes attr, String name){ | |
34 | + if(attr.getValue(name) == null) return false; | |
35 | + return true; | |
36 | + } | |
37 | + | |
38 | + /** | |
39 | + * xsd:string型属性値の読み込み。 | |
40 | + * @param attr 属性群 | |
41 | + * @param name 属性名 | |
42 | + * @return 属性値。該当する属性が無ければnull。 | |
43 | + */ | |
44 | + public static String getStringAttr(Attributes attr, String name){ | |
45 | + String attrVal = attr.getValue(name); | |
46 | + return attrVal; | |
47 | + } | |
48 | + | |
49 | + /** | |
50 | + * xsd:boolean型属性値の読み込み。 | |
51 | + * @param attr 属性群 | |
52 | + * @param name 属性名 | |
53 | + * @return 属性値。 | |
54 | + * @throws IllegalArgumentException boolean型表記ではない | |
55 | + */ | |
56 | + public static boolean getBooleanAttr(Attributes attr, String name) | |
57 | + throws IllegalArgumentException{ | |
58 | + String attrVal = attr.getValue(name); | |
59 | + boolean bVal; | |
60 | + bVal = DatatypeConverter.parseBoolean(attrVal); | |
61 | + return bVal; | |
62 | + } | |
63 | + | |
64 | + /** | |
65 | + * xsd:boolean型属性値の読み込み。 | |
66 | + * @param attr 属性群 | |
67 | + * @param name 属性名 | |
68 | + * @param def 属性が無い場合のデフォルト値 | |
69 | + * @return 属性値。 | |
70 | + * @throws IllegalArgumentException boolean型表記ではない | |
71 | + */ | |
72 | + public static boolean getBooleanAttr(Attributes attr, | |
73 | + String name, | |
74 | + boolean def ) | |
75 | + throws IllegalArgumentException{ | |
76 | + String attrVal = attr.getValue(name); | |
77 | + if(attrVal == null) return def; | |
78 | + | |
79 | + boolean bVal; | |
80 | + bVal = DatatypeConverter.parseBoolean(attrVal); | |
81 | + | |
82 | + return bVal; | |
83 | + } | |
84 | + | |
85 | + /** | |
86 | + * xsd:byte型属性の読み込み。 | |
87 | + * @param attr 属性群 | |
88 | + * @param name 属性名 | |
89 | + * @return 属性値。 | |
90 | + * @throws NumberFormatException byte型表記ではない | |
91 | + */ | |
92 | + public static byte getByteAttr(Attributes attr, String name) | |
93 | + throws NumberFormatException{ | |
94 | + String attrVal = attr.getValue(name); | |
95 | + byte bVal; | |
96 | + bVal = DatatypeConverter.parseByte(attrVal); | |
97 | + return bVal; | |
98 | + } | |
99 | + | |
100 | + /** | |
101 | + * xsd:float型属性値の読み込み。 | |
102 | + * @param attr 属性群 | |
103 | + * @param name 属性名 | |
104 | + * @return 属性値。 | |
105 | + * @throws NumberFormatException float型表記ではない | |
106 | + */ | |
107 | + public static float getFloatAttr(Attributes attr, String name) | |
108 | + throws NumberFormatException { | |
109 | + String attrVal = attr.getValue(name); | |
110 | + float fVal; | |
111 | + fVal = DatatypeConverter.parseFloat(attrVal); | |
112 | + return fVal; | |
113 | + } | |
114 | + | |
115 | + /** | |
116 | + * xsd:int型属性値の読み込み。 | |
117 | + * @param attr 属性群 | |
118 | + * @param name 属性名 | |
119 | + * @return 属性値。 | |
120 | + * @throws NumberFormatException int型表記ではない | |
121 | + */ | |
122 | + public static int getIntAttr(Attributes attr, String name) | |
123 | + throws NumberFormatException { | |
124 | + String attrVal = attr.getValue(name); | |
125 | + int iVal; | |
126 | + iVal = DatatypeConverter.parseInt(attrVal); | |
127 | + return iVal; | |
128 | + } | |
129 | + | |
130 | +} |
@@ -98,13 +98,13 @@ | ||
98 | 98 | private void openCameraMotion(Attributes attr){ |
99 | 99 | this.currentCamera = new CameraMotion(); |
100 | 100 | |
101 | - int frameNo = SaxXsdUtil.getIntAttr(attr, XmlAttr.ATTR_FRAME); | |
101 | + int frameNo = SaxAttr.getIntAttr(attr, XmlAttr.ATTR_FRAME); | |
102 | 102 | this.currentCamera.setFrameNumber(frameNo); |
103 | 103 | |
104 | 104 | boolean hasPerspective = |
105 | - SaxXsdUtil.getBooleanAttr(attr, | |
106 | - XmlAttr.ATTR_HAS_PERSPECTIVE, | |
107 | - true ); | |
105 | + SaxAttr.getBooleanAttr(attr, | |
106 | + XmlAttr.ATTR_HAS_PERSPECTIVE, | |
107 | + true ); | |
108 | 108 | this.currentCamera.setPerspectiveMode(hasPerspective); |
109 | 109 | |
110 | 110 | return; |
@@ -130,9 +130,9 @@ | ||
130 | 130 | private void openCameraTarget(Attributes attr){ |
131 | 131 | MkPos3D targetPos = this.currentCamera.getCameraTarget(); |
132 | 132 | |
133 | - float xPos = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_X_POS); | |
134 | - float yPos = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_Y_POS); | |
135 | - float zPos = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_Z_POS); | |
133 | + float xPos = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_X_POS); | |
134 | + float yPos = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_Y_POS); | |
135 | + float zPos = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_Z_POS); | |
136 | 136 | |
137 | 137 | targetPos.setPosition(xPos, yPos, zPos); |
138 | 138 |
@@ -150,9 +150,9 @@ | ||
150 | 150 | CameraRotation cameraRotation = |
151 | 151 | this.currentCamera.getCameraRotation(); |
152 | 152 | |
153 | - float latitude = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_X_RAD); | |
154 | - float longitude = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_Y_RAD); | |
155 | - float roll = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_Z_RAD); | |
153 | + float latitude = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_X_RAD); | |
154 | + float longitude = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_Y_RAD); | |
155 | + float roll = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_Z_RAD); | |
156 | 156 | |
157 | 157 | cameraRotation.setLatitude(latitude); |
158 | 158 | cameraRotation.setLongitude(longitude); |
@@ -169,7 +169,7 @@ | ||
169 | 169 | * @param attr 属性群 |
170 | 170 | */ |
171 | 171 | private void openCameraRange(Attributes attr){ |
172 | - float range = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_RANGE); | |
172 | + float range = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_RANGE); | |
173 | 173 | this.currentCamera.setRange(range); |
174 | 174 | |
175 | 175 | BezierParam bez = this.currentCamera.getIntpltRange(); |
@@ -183,7 +183,7 @@ | ||
183 | 183 | * @param attr 属性群 |
184 | 184 | */ |
185 | 185 | private void openProjection(Attributes attr){ |
186 | - int vertDeg = SaxXsdUtil.getIntAttr(attr, XmlAttr.ATTR_VERT_DEG); | |
186 | + int vertDeg = SaxAttr.getIntAttr(attr, XmlAttr.ATTR_VERT_DEG); | |
187 | 187 | this.currentCamera.setProjectionAngle(vertDeg); |
188 | 188 | |
189 | 189 | BezierParam bez = this.currentCamera.getIntpltProjection(); |
@@ -79,7 +79,7 @@ | ||
79 | 79 | private void openLumiAct(Attributes attr){ |
80 | 80 | this.currentLuminous = new LuminousMotion(); |
81 | 81 | |
82 | - int frameNo = SaxXsdUtil.getIntAttr(attr, XmlAttr.ATTR_FRAME); | |
82 | + int frameNo = SaxAttr.getIntAttr(attr, XmlAttr.ATTR_FRAME); | |
83 | 83 | this.currentLuminous.setFrameNumber(frameNo); |
84 | 84 | |
85 | 85 | return; |
@@ -105,9 +105,9 @@ | ||
105 | 105 | private void openLumiColor(Attributes attr){ |
106 | 106 | LuminousColor color = this.currentLuminous.getColor(); |
107 | 107 | |
108 | - float rCol = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_R_COL); | |
109 | - float gCol = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_G_COL); | |
110 | - float bCol = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_B_COL); | |
108 | + float rCol = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_R_COL); | |
109 | + float gCol = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_G_COL); | |
110 | + float bCol = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_B_COL); | |
111 | 111 | |
112 | 112 | color.setColR(rCol); |
113 | 113 | color.setColG(gCol); |
@@ -123,9 +123,9 @@ | ||
123 | 123 | private void openLumiDirection(Attributes attr){ |
124 | 124 | MkVec3D vec = this.currentLuminous.getDirection(); |
125 | 125 | |
126 | - float xVec = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_X_VEC); | |
127 | - float yVec = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_Y_VEC); | |
128 | - float zVec = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_Z_VEC); | |
126 | + float xVec = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_X_VEC); | |
127 | + float yVec = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_Y_VEC); | |
128 | + float zVec = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_Z_VEC); | |
129 | 129 | |
130 | 130 | vec.setXVal(xVec); |
131 | 131 | vec.setYVal(yVec); |
@@ -141,15 +141,15 @@ | ||
141 | 141 | private void openShadowAct(Attributes attr){ |
142 | 142 | ShadowMotion shadowMotion = new ShadowMotion(); |
143 | 143 | |
144 | - int frameNo = SaxXsdUtil.getIntAttr(attr, XmlAttr.ATTR_FRAME); | |
144 | + int frameNo = SaxAttr.getIntAttr(attr, XmlAttr.ATTR_FRAME); | |
145 | 145 | shadowMotion.setFrameNumber(frameNo); |
146 | 146 | |
147 | 147 | float rawParam = |
148 | - SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_RAW_PARAM); | |
148 | + SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_RAW_PARAM); | |
149 | 149 | shadowMotion.setRawScopeParam(rawParam); |
150 | 150 | |
151 | 151 | String modeAttr = |
152 | - SaxXsdUtil.getStringAttr(attr, XmlAttr.ATTR_MODE); | |
152 | + SaxAttr.getStringAttr(attr, XmlAttr.ATTR_MODE); | |
153 | 153 | ShadowMode mode = ShadowMode.valueOf(modeAttr); |
154 | 154 | shadowMotion.setShadowMode(mode); |
155 | 155 |
@@ -104,7 +104,7 @@ | ||
104 | 104 | * @param attr 属性群 |
105 | 105 | */ |
106 | 106 | private void openBonePart(Attributes attr){ |
107 | - this.boneName = SaxXsdUtil.getStringAttr(attr, XmlAttr.ATTR_NAME); | |
107 | + this.boneName = SaxAttr.getStringAttr(attr, XmlAttr.ATTR_NAME); | |
108 | 108 | return; |
109 | 109 | } |
110 | 110 |
@@ -116,7 +116,7 @@ | ||
116 | 116 | this.boneMotion = new BoneMotion(); |
117 | 117 | this.boneMotion.setBoneName(this.boneName); |
118 | 118 | |
119 | - int frameNo = SaxXsdUtil.getIntAttr(attr, XmlAttr.ATTR_FRAME); | |
119 | + int frameNo = SaxAttr.getIntAttr(attr, XmlAttr.ATTR_FRAME); | |
120 | 120 | this.boneMotion.setFrameNumber(frameNo); |
121 | 121 | |
122 | 122 | return; |
@@ -138,9 +138,9 @@ | ||
138 | 138 | private void openBonePosition(Attributes attr){ |
139 | 139 | MkPos3D position = this.boneMotion.getPosition(); |
140 | 140 | |
141 | - float xPos = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_X_POS); | |
142 | - float yPos = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_Y_POS); | |
143 | - float zPos = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_Z_POS); | |
141 | + float xPos = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_X_POS); | |
142 | + float yPos = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_Y_POS); | |
143 | + float zPos = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_Z_POS); | |
144 | 144 | |
145 | 145 | position.setXpos(xPos); |
146 | 146 | position.setYpos(yPos); |
@@ -159,10 +159,10 @@ | ||
159 | 159 | private void openBoneRotQuat(Attributes attr){ |
160 | 160 | MkQuat rotation = this.boneMotion.getRotation(); |
161 | 161 | |
162 | - float qx = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_QX); | |
163 | - float qy = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_QY); | |
164 | - float qz = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_QZ); | |
165 | - float qw = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_QW); | |
162 | + float qx = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_QX); | |
163 | + float qy = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_QY); | |
164 | + float qz = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_QZ); | |
165 | + float qw = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_QW); | |
166 | 166 | |
167 | 167 | rotation.setQ1(qx); |
168 | 168 | rotation.setQ2(qy); |
@@ -182,9 +182,9 @@ | ||
182 | 182 | private void openBoneRotEyxz(Attributes attr){ |
183 | 183 | MkQuat rotation = this.boneMotion.getRotation(); |
184 | 184 | |
185 | - float xDeg = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_X_DEG); | |
186 | - float yDeg = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_Y_DEG); | |
187 | - float zDeg = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_Z_DEG); | |
185 | + float xDeg = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_X_DEG); | |
186 | + float yDeg = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_Y_DEG); | |
187 | + float zDeg = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_Z_DEG); | |
188 | 188 | |
189 | 189 | float xRad = (float)StrictMath.toRadians(xDeg); |
190 | 190 | float yRad = (float)StrictMath.toRadians(yDeg); |
@@ -203,7 +203,7 @@ | ||
203 | 203 | * @param attr 属性群 |
204 | 204 | */ |
205 | 205 | private void openMorphPart(Attributes attr){ |
206 | - this.morphName = SaxXsdUtil.getStringAttr(attr, XmlAttr.ATTR_NAME); | |
206 | + this.morphName = SaxAttr.getStringAttr(attr, XmlAttr.ATTR_NAME); | |
207 | 207 | return; |
208 | 208 | } |
209 | 209 |
@@ -214,8 +214,8 @@ | ||
214 | 214 | private void openMorphMotion(Attributes attr){ |
215 | 215 | MorphMotion morphMotion = new MorphMotion(); |
216 | 216 | |
217 | - int frameNo = SaxXsdUtil.getIntAttr(attr, XmlAttr.ATTR_FRAME); | |
218 | - float flex = SaxXsdUtil.getFloatAttr(attr, XmlAttr.ATTR_FLEX); | |
217 | + int frameNo = SaxAttr.getIntAttr(attr, XmlAttr.ATTR_FRAME); | |
218 | + float flex = SaxAttr.getFloatAttr(attr, XmlAttr.ATTR_FLEX); | |
219 | 219 | |
220 | 220 | morphMotion.setMorphName(this.morphName); |
221 | 221 | morphMotion.setFrameNumber(frameNo); |
@@ -175,10 +175,10 @@ | ||
175 | 175 | * @param attr 属性群 |
176 | 176 | */ |
177 | 177 | protected void openBezier(Attributes attr){ |
178 | - byte p1x = SaxXsdUtil.getByteAttr(attr, XmlAttr.ATTR_P1X); | |
179 | - byte p1y = SaxXsdUtil.getByteAttr(attr, XmlAttr.ATTR_P1Y); | |
180 | - byte p2x = SaxXsdUtil.getByteAttr(attr, XmlAttr.ATTR_P2X); | |
181 | - byte p2y = SaxXsdUtil.getByteAttr(attr, XmlAttr.ATTR_P2Y); | |
178 | + byte p1x = SaxAttr.getByteAttr(attr, XmlAttr.ATTR_P1X); | |
179 | + byte p1y = SaxAttr.getByteAttr(attr, XmlAttr.ATTR_P1Y); | |
180 | + byte p2x = SaxAttr.getByteAttr(attr, XmlAttr.ATTR_P2X); | |
181 | + byte p2y = SaxAttr.getByteAttr(attr, XmlAttr.ATTR_P2Y); | |
182 | 182 | |
183 | 183 | putBezier(p1x, p1y, p2x, p2y); |
184 | 184 |
@@ -1,117 +0,0 @@ | ||
1 | -/* | |
2 | - * Sax 2 Xsd-types converter | |
3 | - * | |
4 | - * License : The MIT License | |
5 | - * Copyright(c) 2013 MikuToga Partners | |
6 | - */ | |
7 | - | |
8 | -package jp.sfjp.mikutoga.vmd.model.xml; | |
9 | - | |
10 | -import javax.xml.bind.DatatypeConverter; | |
11 | -import org.xml.sax.Attributes; | |
12 | - | |
13 | -/** | |
14 | - * XSD各種型のSAX属性値をJavaプリミティブ型へ変換する。 | |
15 | - */ | |
16 | -final class SaxXsdUtil { | |
17 | - | |
18 | - /** | |
19 | - * 隠しコンストラクタ。 | |
20 | - */ | |
21 | - private SaxXsdUtil(){ | |
22 | - assert false; | |
23 | - throw new AssertionError(); | |
24 | - } | |
25 | - | |
26 | - | |
27 | - /** | |
28 | - * xsd:string型属性値の読み込み。 | |
29 | - * @param attr 属性群 | |
30 | - * @param name 属性名 | |
31 | - * @return 属性値。該当する属性が無ければnull。 | |
32 | - */ | |
33 | - static String getStringAttr(Attributes attr, String name){ | |
34 | - String attrVal = attr.getValue(name); | |
35 | - return attrVal; | |
36 | - } | |
37 | - | |
38 | - /** | |
39 | - * xsd:boolean型属性値の読み込み。 | |
40 | - * @param attr 属性群 | |
41 | - * @param name 属性名 | |
42 | - * @return 属性値。 | |
43 | - * @throws IllegalArgumentException boolean型表記ではない | |
44 | - */ | |
45 | - static boolean getBooleanAttr(Attributes attr, String name) | |
46 | - throws IllegalArgumentException{ | |
47 | - String attrVal = attr.getValue(name); | |
48 | - boolean bVal; | |
49 | - bVal = DatatypeConverter.parseBoolean(attrVal); | |
50 | - return bVal; | |
51 | - } | |
52 | - | |
53 | - /** | |
54 | - * xsd:boolean型属性値の読み込み。 | |
55 | - * @param attr 属性群 | |
56 | - * @param name 属性名 | |
57 | - * @param def 属性が無い場合のデフォルト値 | |
58 | - * @return 属性値。 | |
59 | - * @throws IllegalArgumentException boolean型表記ではない | |
60 | - */ | |
61 | - static boolean getBooleanAttr(Attributes attr, String name, boolean def) | |
62 | - throws IllegalArgumentException{ | |
63 | - String attrVal = attr.getValue(name); | |
64 | - if(attrVal == null) return def; | |
65 | - | |
66 | - boolean bVal; | |
67 | - bVal = DatatypeConverter.parseBoolean(attrVal); | |
68 | - | |
69 | - return bVal; | |
70 | - } | |
71 | - | |
72 | - /** | |
73 | - * xsd:byte型属性の読み込み。 | |
74 | - * @param attr 属性群 | |
75 | - * @param name 属性名 | |
76 | - * @return 属性値。 | |
77 | - * @throws NumberFormatException byte型表記ではない | |
78 | - */ | |
79 | - static byte getByteAttr(Attributes attr, String name) | |
80 | - throws NumberFormatException{ | |
81 | - String attrVal = attr.getValue(name); | |
82 | - byte bVal; | |
83 | - bVal = DatatypeConverter.parseByte(attrVal); | |
84 | - return bVal; | |
85 | - } | |
86 | - | |
87 | - /** | |
88 | - * xsd:float型属性値の読み込み。 | |
89 | - * @param attr 属性群 | |
90 | - * @param name 属性名 | |
91 | - * @return 属性値。 | |
92 | - * @throws NumberFormatException float型表記ではない | |
93 | - */ | |
94 | - static float getFloatAttr(Attributes attr, String name) | |
95 | - throws NumberFormatException { | |
96 | - String attrVal = attr.getValue(name); | |
97 | - float fVal; | |
98 | - fVal = DatatypeConverter.parseFloat(attrVal); | |
99 | - return fVal; | |
100 | - } | |
101 | - | |
102 | - /** | |
103 | - * xsd:int型属性値の読み込み。 | |
104 | - * @param attr 属性群 | |
105 | - * @param name 属性名 | |
106 | - * @return 属性値。 | |
107 | - * @throws NumberFormatException int型表記ではない | |
108 | - */ | |
109 | - static int getIntAttr(Attributes attr, String name) | |
110 | - throws NumberFormatException { | |
111 | - String attrVal = attr.getValue(name); | |
112 | - int iVal; | |
113 | - iVal = DatatypeConverter.parseInt(attrVal); | |
114 | - return iVal; | |
115 | - } | |
116 | - | |
117 | -} |
@@ -129,7 +129,7 @@ | ||
129 | 129 | |
130 | 130 | if(tag == VmdTag.MODEL_NAME){ |
131 | 131 | String modelName = |
132 | - SaxXsdUtil.getStringAttr(attr, XmlAttr.ATTR_NAME); | |
132 | + SaxAttr.getStringAttr(attr, XmlAttr.ATTR_NAME); | |
133 | 133 | this.vmdMotion.setModelName(modelName); |
134 | 134 | return; |
135 | 135 | } |
@@ -401,7 +401,6 @@ | ||
401 | 401 | throws IOException, MmdFormatException{ |
402 | 402 | VmdLoader loader = new VmdLoader(); |
403 | 403 | |
404 | - loader.setIgnoreName(true); | |
405 | 404 | loader.setRedundantCheck(false); |
406 | 405 | |
407 | 406 | VmdMotion motion = loader.load(is); |
@@ -0,0 +1,944 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
2 | + | |
3 | +<!-- | |
4 | + MikuMikuDance | |
5 | + motion-data(*.vmd) on XML | |
6 | + schema definition | |
7 | + | |
8 | + License : The MIT License | |
9 | + Copyright(c) 2013 MikuToga Partners | |
10 | +--> | |
11 | + | |
12 | + | |
13 | +<!DOCTYPE xsd:schema [ | |
14 | + <!ENTITY schemaVer "130609A" > | |
15 | + <!ENTITY schemaNS "http://mikutoga.sourceforge.jp/xml/ns/vmdxml/130609A" > | |
16 | +]> | |
17 | + | |
18 | + | |
19 | +<xsd:schema | |
20 | + xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |
21 | + | |
22 | + targetNamespace="&schemaNS;" | |
23 | + xmlns:tns ="&schemaNS;" | |
24 | + | |
25 | + elementFormDefault="qualified" | |
26 | + version="&schemaVer;" | |
27 | +> | |
28 | + | |
29 | + <xsd:annotation> | |
30 | + <xsd:documentation> | |
31 | + MikuMikuDance motion-data(*.vmd) on XML. | |
32 | + License : The MIT License | |
33 | + Copyright(c) 2013 MikuToga Partners | |
34 | + </xsd:documentation> | |
35 | + </xsd:annotation> | |
36 | + | |
37 | + | |
38 | + <!-- ROOT element for motion --> | |
39 | + <xsd:element name="vmdMotion" > | |
40 | + <xsd:annotation> | |
41 | + <xsd:documentation> | |
42 | + Root element. | |
43 | + </xsd:documentation> | |
44 | + </xsd:annotation> | |
45 | + | |
46 | + <xsd:complexType> | |
47 | + <xsd:sequence> | |
48 | + <xsd:element | |
49 | + ref="tns:meta" | |
50 | + minOccurs="0" maxOccurs="unbounded" /> | |
51 | + <xsd:choice> | |
52 | + <xsd:sequence> <!-- model motion --> | |
53 | + <xsd:element ref="tns:modelName" /> | |
54 | + <xsd:element ref="tns:boneMotionSequence" /> | |
55 | + <xsd:element ref="tns:morphSequence" /> | |
56 | + <xsd:element ref="tns:flagSequence" /> | |
57 | + </xsd:sequence> | |
58 | + <xsd:sequence> <!-- stage act --> | |
59 | + <xsd:element ref="tns:cameraSequence" /> | |
60 | + <xsd:element ref="tns:luminousSequence" /> | |
61 | + <xsd:element ref="tns:shadowSequence" /> | |
62 | + </xsd:sequence> | |
63 | + </xsd:choice> | |
64 | + </xsd:sequence> | |
65 | + <xsd:attribute | |
66 | + name="version" | |
67 | + type="xsd:token" | |
68 | + use="required" | |
69 | + fixed="&schemaVer;" /> | |
70 | + </xsd:complexType> | |
71 | + | |
72 | + </xsd:element> | |
73 | + | |
74 | + | |
75 | + <xsd:simpleType name="FrameNo" > | |
76 | + <xsd:annotation> | |
77 | + <xsd:documentation> | |
78 | + frame No. | |
79 | + </xsd:documentation> | |
80 | + </xsd:annotation> | |
81 | + | |
82 | + <xsd:restriction base="xsd:int" > | |
83 | +<!-- | |
84 | + <xsd:minInclusive value="0" /> | |
85 | +--> | |
86 | + </xsd:restriction> | |
87 | + | |
88 | + </xsd:simpleType> | |
89 | + | |
90 | + | |
91 | + <xsd:simpleType name="MorphFlex" > | |
92 | + <xsd:annotation> | |
93 | + <xsd:documentation> | |
94 | + morph flexible value. [0.0-1.0] | |
95 | + </xsd:documentation> | |
96 | + </xsd:annotation> | |
97 | + | |
98 | + <xsd:restriction base="xsd:float" > | |
99 | + <xsd:minInclusive value="-0.0" /> | |
100 | +<!-- | |
101 | + <xsd:maxInclusive value="1.0" /> | |
102 | +--> | |
103 | + </xsd:restriction> | |
104 | + | |
105 | + </xsd:simpleType> | |
106 | + | |
107 | + | |
108 | + <xsd:simpleType name="ProjectionAngle" > | |
109 | + <xsd:annotation> | |
110 | + <xsd:documentation> | |
111 | + screen-projection angle(degree). | |
112 | + </xsd:documentation> | |
113 | + </xsd:annotation> | |
114 | + | |
115 | + <xsd:restriction base="xsd:int" > | |
116 | +<!-- | |
117 | + <xsd:minInclusive value="-0" /> | |
118 | + <xsd:maxInclusive value="+180" /> | |
119 | +--> | |
120 | + </xsd:restriction> | |
121 | + | |
122 | + </xsd:simpleType> | |
123 | + | |
124 | + | |
125 | + <xsd:simpleType name="ColorComponent" > | |
126 | + <xsd:annotation> | |
127 | + <xsd:documentation> | |
128 | + color component value. | |
129 | + </xsd:documentation> | |
130 | + </xsd:annotation> | |
131 | + | |
132 | + <xsd:restriction base="xsd:float" > | |
133 | +<!-- | |
134 | + <xsd:minInclusive value="-0.0" /> | |
135 | + <xsd:maxInclusive value="1.0" /> | |
136 | +--> | |
137 | + </xsd:restriction> | |
138 | + | |
139 | + </xsd:simpleType> | |
140 | + | |
141 | + | |
142 | + <xsd:simpleType name="DirVecComponent" > | |
143 | + <xsd:annotation> | |
144 | + <xsd:documentation> | |
145 | + direction vector component value. | |
146 | + </xsd:documentation> | |
147 | + </xsd:annotation> | |
148 | + | |
149 | + <xsd:restriction base="xsd:float" > | |
150 | +<!-- | |
151 | + <xsd:minInclusive value="-1.0" /> | |
152 | + <xsd:maxInclusive value="+1.0" /> | |
153 | +--> | |
154 | + </xsd:restriction> | |
155 | + | |
156 | + </xsd:simpleType> | |
157 | + | |
158 | + | |
159 | + <xsd:simpleType name="ShadowType" > | |
160 | + <xsd:annotation> | |
161 | + <xsd:documentation> | |
162 | + type of shadow | |
163 | + + NONE : no self-shadow | |
164 | + + MODE_1 : reduce shadow-quality suddenly at range | |
165 | + + MODE_2 : reduce shadow-quality gradually with range | |
166 | + </xsd:documentation> | |
167 | + </xsd:annotation> | |
168 | + | |
169 | + <xsd:restriction base="xsd:string" > | |
170 | + <xsd:enumeration value="NONE" /> | |
171 | + <xsd:enumeration value="MODE_1" /> | |
172 | + <xsd:enumeration value="MODE_2" /> | |
173 | + </xsd:restriction> | |
174 | + | |
175 | + </xsd:simpleType> | |
176 | + | |
177 | + | |
178 | + <xsd:simpleType name="ShadowRawParam" > | |
179 | + <xsd:annotation> | |
180 | + <xsd:documentation> | |
181 | + shadow range raw value. | |
182 | + | |
183 | + UI_VALUE = EFFECTIVE_RANGE * 100 ??? | |
184 | + rawParam = 0.1 - (UI_VALUE / 1.0E+5) | |
185 | + | |
186 | + UI_VALUE:0 => rawParam:0.1 | |
187 | + UI_VALUE:8875 => rawParam:0.01125 | |
188 | + UI_VALUE:9999 => rawParam:1.0E-5 | |
189 | + </xsd:documentation> | |
190 | + </xsd:annotation> | |
191 | + | |
192 | + <xsd:restriction base="xsd:float" > | |
193 | +<!-- | |
194 | + <xsd:minInclusive value="-0.0" /> | |
195 | + <xsd:maxInclusive value="0.1" /> | |
196 | +--> | |
197 | + </xsd:restriction> | |
198 | + | |
199 | + </xsd:simpleType> | |
200 | + | |
201 | + | |
202 | + <xsd:simpleType name="BezPt" > | |
203 | + <xsd:annotation> | |
204 | + <xsd:documentation> | |
205 | + Bezier points coordinates value. [XY:0-127] | |
206 | + </xsd:documentation> | |
207 | + </xsd:annotation> | |
208 | + | |
209 | + <xsd:restriction base="xsd:byte" > | |
210 | + <xsd:minInclusive value= "0" /> | |
211 | + <xsd:maxInclusive value="127" /> | |
212 | + </xsd:restriction> | |
213 | + | |
214 | + </xsd:simpleType> | |
215 | + | |
216 | + | |
217 | + <xsd:complexType name="FrameNumbered" > | |
218 | + <xsd:annotation> | |
219 | + <xsd:documentation> | |
220 | + frame numbered type. | |
221 | + </xsd:documentation> | |
222 | + </xsd:annotation> | |
223 | + | |
224 | + <xsd:attribute name="frame" type="tns:FrameNo" use="required" /> | |
225 | + | |
226 | + </xsd:complexType> | |
227 | + | |
228 | + | |
229 | + <xsd:complexType name="BezParam" > | |
230 | + <xsd:annotation> | |
231 | + <xsd:documentation> | |
232 | + bezier cubic curve parameters. | |
233 | + p0=(0, 0) p3=(127, 127) [implicit points] | |
234 | + </xsd:documentation> | |
235 | + </xsd:annotation> | |
236 | + | |
237 | + <xsd:attribute name="p1x" type="tns:BezPt" use="optional" /> | |
238 | + <xsd:attribute name="p1y" type="tns:BezPt" use="optional" /> | |
239 | + <xsd:attribute name="p2x" type="tns:BezPt" use="optional" /> | |
240 | + <xsd:attribute name="p2y" type="tns:BezPt" use="optional" /> | |
241 | + | |
242 | + </xsd:complexType> | |
243 | + | |
244 | + | |
245 | + <xsd:element name="bezier" > | |
246 | + <xsd:annotation> | |
247 | + <xsd:documentation> | |
248 | + bezier cubic curve parameters. | |
249 | + p0=(0, 0) p3=(127, 127) [implicit points] | |
250 | + P1 and P2 points are required. | |
251 | + </xsd:documentation> | |
252 | + </xsd:annotation> | |
253 | + | |
254 | + <xsd:complexType> | |
255 | + <xsd:complexContent> | |
256 | + <xsd:restriction base="tns:BezParam" > | |
257 | + <xsd:attribute name="p1x" type="tns:BezPt" use="required" /> | |
258 | + <xsd:attribute name="p1y" type="tns:BezPt" use="required" /> | |
259 | + <xsd:attribute name="p2x" type="tns:BezPt" use="required" /> | |
260 | + <xsd:attribute name="p2y" type="tns:BezPt" use="required" /> | |
261 | + </xsd:restriction> | |
262 | + </xsd:complexContent> | |
263 | + </xsd:complexType> | |
264 | + | |
265 | + </xsd:element> | |
266 | + | |
267 | + | |
268 | + <xsd:element name="defLinear" > | |
269 | + <xsd:annotation> | |
270 | + <xsd:documentation> | |
271 | + default linear bezier curve. | |
272 | + p0=(0, 0) p1=(20, 20) p2=(107, 107) p3=(127, 127) | |
273 | + </xsd:documentation> | |
274 | + </xsd:annotation> | |
275 | + | |
276 | + <xsd:complexType> | |
277 | + <xsd:complexContent> | |
278 | + <xsd:restriction base="tns:BezParam" > | |
279 | + <xsd:attribute name="p1x" use="prohibited" fixed= "20" /> | |
280 | + <xsd:attribute name="p1y" use="prohibited" fixed= "20" /> | |
281 | + <xsd:attribute name="p2x" use="prohibited" fixed="107" /> | |
282 | + <xsd:attribute name="p2y" use="prohibited" fixed="107" /> | |
283 | + </xsd:restriction> | |
284 | + </xsd:complexContent> | |
285 | + </xsd:complexType> | |
286 | + | |
287 | + </xsd:element> | |
288 | + | |
289 | + | |
290 | + <xsd:element name="defEaseInOut" > | |
291 | + <xsd:annotation> | |
292 | + <xsd:documentation> | |
293 | + default ease-in-out bezier curve. | |
294 | + p0=(0, 0) p1=(64, 0) p2=(64, 127) p3=(127, 127) | |
295 | + </xsd:documentation> | |
296 | + </xsd:annotation> | |
297 | + | |
298 | + <xsd:complexType> | |
299 | + <xsd:complexContent> | |
300 | + <xsd:restriction base="tns:BezParam" > | |
301 | + <xsd:attribute name="p1x" use="prohibited" fixed= "64" /> | |
302 | + <xsd:attribute name="p1y" use="prohibited" fixed= "0" /> | |
303 | + <xsd:attribute name="p2x" use="prohibited" fixed= "64" /> | |
304 | + <xsd:attribute name="p2y" use="prohibited" fixed="127" /> | |
305 | + </xsd:restriction> | |
306 | + </xsd:complexContent> | |
307 | + </xsd:complexType> | |
308 | + | |
309 | + </xsd:element> | |
310 | + | |
311 | + | |
312 | + <xsd:complexType name="InterpolationSingle" > | |
313 | + <xsd:annotation> | |
314 | + <xsd:documentation> | |
315 | + has single interpolation curve. | |
316 | + If omitted, it means default linear curve. | |
317 | + </xsd:documentation> | |
318 | + </xsd:annotation> | |
319 | + | |
320 | + <xsd:choice minOccurs="0" > | |
321 | + <xsd:element ref="tns:bezier" /> | |
322 | + <xsd:element ref="tns:defLinear" /> | |
323 | + <xsd:element ref="tns:defEaseInOut" /> | |
324 | + </xsd:choice> | |
325 | + | |
326 | + </xsd:complexType> | |
327 | + | |
328 | + | |
329 | + <xsd:complexType name="PosWithInterpolation" > | |
330 | + <xsd:annotation> | |
331 | + <xsd:documentation> | |
332 | + 3D-position with XYZ-interpolation curve. | |
333 | + If omitted, it means default linear curve *3 [XYZ]. | |
334 | + </xsd:documentation> | |
335 | + </xsd:annotation> | |
336 | + | |
337 | + <xsd:sequence minOccurs="0" maxOccurs="1" > | |
338 | + <xsd:choice minOccurs="3" maxOccurs="3" > | |
339 | + <xsd:element ref="tns:bezier" /> | |
340 | + <xsd:element ref="tns:defLinear" /> | |
341 | + <xsd:element ref="tns:defEaseInOut" /> | |
342 | + </xsd:choice> | |
343 | + </xsd:sequence> | |
344 | + | |
345 | + <xsd:attribute name="xPos" type="xsd:float" use="required" /> | |
346 | + <xsd:attribute name="yPos" type="xsd:float" use="required" /> | |
347 | + <xsd:attribute name="zPos" type="xsd:float" use="required" /> | |
348 | + | |
349 | + </xsd:complexType> | |
350 | + | |
351 | + | |
352 | + <xsd:element name="meta" > | |
353 | + <xsd:annotation> | |
354 | + <xsd:documentation> | |
355 | + Meta-information of motion. | |
356 | + Use free. | |
357 | + but, some meta-name has recommended usage. | |
358 | + + "generator" (Generator application name) | |
359 | + + "siteURL" (about motion creator) | |
360 | + </xsd:documentation> | |
361 | + </xsd:annotation> | |
362 | + | |
363 | + <xsd:complexType> | |
364 | + <xsd:attribute | |
365 | + name="name" | |
366 | + type="xsd:NCName" | |
367 | + use="required" /> | |
368 | + <xsd:attribute | |
369 | + name="content" | |
370 | + type="xsd:string" | |
371 | + use="required" /> | |
372 | + </xsd:complexType> | |
373 | + | |
374 | + </xsd:element> | |
375 | + | |
376 | + | |
377 | + <xsd:element name="modelName" > | |
378 | + <xsd:annotation> | |
379 | + <xsd:documentation> | |
380 | + name of motion-model. | |
381 | + </xsd:documentation> | |
382 | + </xsd:annotation> | |
383 | + | |
384 | + <xsd:complexType> | |
385 | + <xsd:attribute | |
386 | + name="name" | |
387 | + type="xsd:string" | |
388 | + use="required" /> | |
389 | + </xsd:complexType> | |
390 | + | |
391 | + </xsd:element> | |
392 | + | |
393 | + | |
394 | + <xsd:element name="boneMotionSequence" > | |
395 | + <xsd:annotation> | |
396 | + <xsd:documentation> | |
397 | + bone motion data sequence. | |
398 | + </xsd:documentation> | |
399 | + </xsd:annotation> | |
400 | + | |
401 | + <xsd:complexType> | |
402 | + <xsd:sequence> | |
403 | + <xsd:element | |
404 | + ref="tns:bonePart" | |
405 | + minOccurs="0" maxOccurs="unbounded" /> | |
406 | + </xsd:sequence> | |
407 | + </xsd:complexType> | |
408 | + | |
409 | + <xsd:unique name="BoneName" > | |
410 | + <xsd:selector xpath="./tns:bonePart" /> | |
411 | + <xsd:field xpath="@name" /> | |
412 | + </xsd:unique> | |
413 | + | |
414 | + </xsd:element> | |
415 | + | |
416 | + | |
417 | + <xsd:element name="bonePart" > | |
418 | + <xsd:annotation> | |
419 | + <xsd:documentation> | |
420 | + bone motion data group by bone-name. | |
421 | + </xsd:documentation> | |
422 | + </xsd:annotation> | |
423 | + | |
424 | + <xsd:complexType> | |
425 | + <xsd:sequence> | |
426 | + <xsd:element | |
427 | + ref="tns:boneMotion" | |
428 | + minOccurs="0" maxOccurs="unbounded" /> | |
429 | + </xsd:sequence> | |
430 | + | |
431 | + <xsd:attribute | |
432 | + name="name" | |
433 | + type="xsd:string" | |
434 | + use="required" /> | |
435 | + </xsd:complexType> | |
436 | + | |
437 | + <xsd:unique name="BoneFrameNo" > | |
438 | + <xsd:selector xpath="./tns:boneMotion" /> | |
439 | + <xsd:field xpath="@frame" /> | |
440 | + </xsd:unique> | |
441 | + | |
442 | + </xsd:element> | |
443 | + | |
444 | + | |
445 | + <xsd:element name="boneMotion" > | |
446 | + <xsd:annotation> | |
447 | + <xsd:documentation> | |
448 | + bone motion data. | |
449 | + </xsd:documentation> | |
450 | + </xsd:annotation> | |
451 | + | |
452 | + <xsd:complexType> | |
453 | + <xsd:complexContent> | |
454 | + <xsd:extension base="tns:FrameNumbered" > | |
455 | + <xsd:sequence> | |
456 | + <xsd:element | |
457 | + ref="tns:bonePosition" | |
458 | + minOccurs="0" maxOccurs="1" /> | |
459 | + <xsd:choice> | |
460 | + <xsd:element ref="tns:boneRotQuat" /> | |
461 | + <xsd:element ref="tns:boneRotEyxz" /> | |
462 | + </xsd:choice> | |
463 | + </xsd:sequence> | |
464 | + </xsd:extension> | |
465 | + </xsd:complexContent> | |
466 | + </xsd:complexType> | |
467 | + | |
468 | + </xsd:element> | |
469 | + | |
470 | + | |
471 | + <xsd:element name="bonePosition" type="tns:PosWithInterpolation" > | |
472 | + <xsd:annotation> | |
473 | + <xsd:documentation> | |
474 | + bone position. | |
475 | + </xsd:documentation> | |
476 | + </xsd:annotation> | |
477 | + | |
478 | + </xsd:element> | |
479 | + | |
480 | + | |
481 | + <xsd:element name="boneRotQuat" > | |
482 | + <xsd:annotation> | |
483 | + <xsd:documentation> | |
484 | + bone rotation. (Quaternion parameters) | |
485 | + </xsd:documentation> | |
486 | + </xsd:annotation> | |
487 | + | |
488 | + <xsd:complexType> | |
489 | + <xsd:complexContent> | |
490 | + <xsd:extension base="tns:InterpolationSingle" > | |
491 | + <xsd:attribute name="qx" type="xsd:float" use="required" /> | |
492 | + <xsd:attribute name="qy" type="xsd:float" use="required" /> | |
493 | + <xsd:attribute name="qz" type="xsd:float" use="required" /> | |
494 | + <xsd:attribute name="qw" type="xsd:float" use="required" /> | |
495 | + </xsd:extension> | |
496 | + </xsd:complexContent> | |
497 | + </xsd:complexType> | |
498 | + | |
499 | + </xsd:element> | |
500 | + | |
501 | + | |
502 | + <xsd:element name="boneRotEyxz" > | |
503 | + <xsd:annotation> | |
504 | + <xsd:documentation> | |
505 | + bone rotation. (YXZ-Euler rotation parameters) | |
506 | + </xsd:documentation> | |
507 | + </xsd:annotation> | |
508 | + | |
509 | + <xsd:complexType> | |
510 | + <xsd:complexContent> | |
511 | + <xsd:extension base="tns:InterpolationSingle" > | |
512 | + <xsd:attribute name="xDeg" type="xsd:float" use="required" /> | |
513 | + <xsd:attribute name="yDeg" type="xsd:float" use="required" /> | |
514 | + <xsd:attribute name="zDeg" type="xsd:float" use="required" /> | |
515 | + </xsd:extension> | |
516 | + </xsd:complexContent> | |
517 | + </xsd:complexType> | |
518 | + | |
519 | + </xsd:element> | |
520 | + | |
521 | + | |
522 | + <xsd:element name="morphSequence" > | |
523 | + <xsd:annotation> | |
524 | + <xsd:documentation> | |
525 | + morphing data sequence. | |
526 | + </xsd:documentation> | |
527 | + </xsd:annotation> | |
528 | + | |
529 | + <xsd:complexType> | |
530 | + <xsd:sequence> | |
531 | + <xsd:element | |
532 | + ref="tns:morphPart" | |
533 | + minOccurs="0" maxOccurs="unbounded" /> | |
534 | + </xsd:sequence> | |
535 | + </xsd:complexType> | |
536 | + | |
537 | + <xsd:unique name="MorphName" > | |
538 | + <xsd:selector xpath="./tns:morphPart" /> | |
539 | + <xsd:field xpath="@name" /> | |
540 | + </xsd:unique> | |
541 | + | |
542 | + </xsd:element> | |
543 | + | |
544 | + | |
545 | + <xsd:element name="morphPart" > | |
546 | + <xsd:annotation> | |
547 | + <xsd:documentation> | |
548 | + morphing data group by morph-name. | |
549 | + </xsd:documentation> | |
550 | + </xsd:annotation> | |
551 | + | |
552 | + <xsd:complexType> | |
553 | + <xsd:sequence> | |
554 | + <xsd:element | |
555 | + ref="tns:morphMotion" | |
556 | + minOccurs="0" maxOccurs="unbounded" /> | |
557 | + </xsd:sequence> | |
558 | + | |
559 | + <xsd:attribute | |
560 | + name="name" | |
561 | + type="xsd:string" | |
562 | + use="required" /> | |
563 | + </xsd:complexType> | |
564 | + | |
565 | + <xsd:unique name="MorphFrameNo" > | |
566 | + <xsd:selector xpath="./tns:morphMotion" /> | |
567 | + <xsd:field xpath="@frame" /> | |
568 | + </xsd:unique> | |
569 | + | |
570 | + </xsd:element> | |
571 | + | |
572 | + | |
573 | + <xsd:element name="morphMotion" > | |
574 | + <xsd:annotation> | |
575 | + <xsd:documentation> | |
576 | + morphing data. | |
577 | + </xsd:documentation> | |
578 | + </xsd:annotation> | |
579 | + | |
580 | + <xsd:complexType> | |
581 | + <xsd:complexContent> | |
582 | + <xsd:extension base="tns:FrameNumbered" > | |
583 | + <xsd:attribute | |
584 | + name="flex" | |
585 | + type="tns:MorphFlex" | |
586 | + use="required" /> | |
587 | + </xsd:extension> | |
588 | + </xsd:complexContent> | |
589 | + </xsd:complexType> | |
590 | + | |
591 | + </xsd:element> | |
592 | + | |
593 | + | |
594 | + <xsd:element name="cameraSequence" > | |
595 | + <xsd:annotation> | |
596 | + <xsd:documentation> | |
597 | + camera sequence. | |
598 | + </xsd:documentation> | |
599 | + </xsd:annotation> | |
600 | + | |
601 | + <xsd:complexType> | |
602 | + <xsd:sequence> | |
603 | + <xsd:element | |
604 | + ref="tns:cameraMotion" | |
605 | + minOccurs="0" maxOccurs="unbounded" /> | |
606 | + </xsd:sequence> | |
607 | + </xsd:complexType> | |
608 | + | |
609 | + <xsd:unique name="CameraFrameNo" > | |
610 | + <xsd:selector xpath="./tns:cameraMotion" /> | |
611 | + <xsd:field xpath="@frame" /> | |
612 | + </xsd:unique> | |
613 | + | |
614 | + </xsd:element> | |
615 | + | |
616 | + | |
617 | + <xsd:element name="cameraMotion" > | |
618 | + <xsd:annotation> | |
619 | + <xsd:documentation> | |
620 | + camera data. | |
621 | + </xsd:documentation> | |
622 | + </xsd:annotation> | |
623 | + | |
624 | + <xsd:complexType> | |
625 | + <xsd:complexContent> | |
626 | + <xsd:extension base="tns:FrameNumbered" > | |
627 | + <xsd:sequence> | |
628 | + <xsd:element ref="tns:cameraTarget" /> | |
629 | + <xsd:element ref="tns:cameraRotation" /> | |
630 | + <xsd:element ref="tns:cameraRange" /> | |
631 | + <xsd:element ref="tns:projection" /> | |
632 | + </xsd:sequence> | |
633 | + <xsd:attribute | |
634 | + name="hasPerspective" | |
635 | + type="xsd:boolean" | |
636 | + use="optional" | |
637 | + default="true" /> | |
638 | + </xsd:extension> | |
639 | + </xsd:complexContent> | |
640 | + </xsd:complexType> | |
641 | + | |
642 | + </xsd:element> | |
643 | + | |
644 | + | |
645 | + <xsd:element name="cameraTarget" type="tns:PosWithInterpolation" > | |
646 | + <xsd:annotation> | |
647 | + <xsd:documentation> | |
648 | + camera target. | |
649 | + </xsd:documentation> | |
650 | + </xsd:annotation> | |
651 | + | |
652 | + </xsd:element> | |
653 | + | |
654 | + | |
655 | + <xsd:element name="cameraRotation" > | |
656 | + <xsd:annotation> | |
657 | + <xsd:documentation> | |
658 | + camera-rotation around camera-target | |
659 | + with polar-coordinates parameters. | |
660 | + | |
661 | + xRad = -radian(UI_X) [latitude] | |
662 | + yRad = radian(UI_Y) [longitude] | |
663 | + zRad = radian(UI_Z) [roll] | |
664 | + </xsd:documentation> | |
665 | + </xsd:annotation> | |
666 | + | |
667 | + <xsd:complexType> | |
668 | + <xsd:complexContent> | |
669 | + <xsd:extension base="tns:InterpolationSingle" > | |
670 | + <xsd:attribute name="xRad" type="xsd:float" use="required" /> | |
671 | + <xsd:attribute name="yRad" type="xsd:float" use="required" /> | |
672 | + <xsd:attribute name="zRad" type="xsd:float" use="required" /> | |
673 | + </xsd:extension> | |
674 | + </xsd:complexContent> | |
675 | + </xsd:complexType> | |
676 | + | |
677 | + </xsd:element> | |
678 | + | |
679 | + | |
680 | + <xsd:element name="cameraRange" > | |
681 | + <xsd:annotation> | |
682 | + <xsd:documentation> | |
683 | + camera range. | |
684 | + sign was negated from UI_RANGE. | |
685 | + </xsd:documentation> | |
686 | + </xsd:annotation> | |
687 | + | |
688 | + <xsd:complexType> | |
689 | + <xsd:complexContent> | |
690 | + <xsd:extension base="tns:InterpolationSingle" > | |
691 | + <xsd:attribute | |
692 | + name="range" | |
693 | + type="xsd:float" | |
694 | + use="required" /> | |
695 | + </xsd:extension> | |
696 | + </xsd:complexContent> | |
697 | + </xsd:complexType> | |
698 | + | |
699 | + </xsd:element> | |
700 | + | |
701 | + | |
702 | + <xsd:element name="projection" > | |
703 | + <xsd:annotation> | |
704 | + <xsd:documentation> | |
705 | + projection data. | |
706 | + vertDeg : vertical screen-projection angle by degree. | |
707 | + </xsd:documentation> | |
708 | + </xsd:annotation> | |
709 | + | |
710 | + <xsd:complexType> | |
711 | + <xsd:complexContent> | |
712 | + <xsd:extension base="tns:InterpolationSingle" > | |
713 | + <xsd:attribute | |
714 | + name="vertDeg" | |
715 | + type="tns:ProjectionAngle" | |
716 | + use="required" /> | |
717 | + </xsd:extension> | |
718 | + </xsd:complexContent> | |
719 | + </xsd:complexType> | |
720 | + | |
721 | + </xsd:element> | |
722 | + | |
723 | + | |
724 | + <xsd:element name="luminousSequence" > | |
725 | + <xsd:annotation> | |
726 | + <xsd:documentation> | |
727 | + luminous sequence. | |
728 | + </xsd:documentation> | |
729 | + </xsd:annotation> | |
730 | + | |
731 | + <xsd:complexType> | |
732 | + <xsd:sequence> | |
733 | + <xsd:element | |
734 | + ref="tns:luminousAct" | |
735 | + minOccurs="0" maxOccurs="unbounded" /> | |
736 | + </xsd:sequence> | |
737 | + </xsd:complexType> | |
738 | + | |
739 | + <xsd:unique name="LuminousFrameNo" > | |
740 | + <xsd:selector xpath="./tns:luminousAct" /> | |
741 | + <xsd:field xpath="@frame" /> | |
742 | + </xsd:unique> | |
743 | + | |
744 | + </xsd:element> | |
745 | + | |
746 | + | |
747 | + <xsd:element name="luminousAct" > | |
748 | + <xsd:annotation> | |
749 | + <xsd:documentation> | |
750 | + luminous data. | |
751 | + </xsd:documentation> | |
752 | + </xsd:annotation> | |
753 | + | |
754 | + <xsd:complexType> | |
755 | + <xsd:complexContent> | |
756 | + <xsd:extension base="tns:FrameNumbered" > | |
757 | + <xsd:sequence> | |
758 | + <xsd:element ref="tns:lumiColor" /> | |
759 | + <xsd:element ref="tns:lumiDirection" /> | |
760 | + </xsd:sequence> | |
761 | + </xsd:extension> | |
762 | + </xsd:complexContent> | |
763 | + </xsd:complexType> | |
764 | + | |
765 | + </xsd:element> | |
766 | + | |
767 | + | |
768 | + <xsd:element name="lumiColor" > | |
769 | + <xsd:annotation> | |
770 | + <xsd:documentation> | |
771 | + luminous color by RGB color space. | |
772 | + </xsd:documentation> | |
773 | + </xsd:annotation> | |
774 | + | |
775 | + <xsd:complexType> | |
776 | + <xsd:attribute | |
777 | + name="rCol" | |
778 | + type="tns:ColorComponent" | |
779 | + use="required" /> | |
780 | + <xsd:attribute | |
781 | + name="gCol" | |
782 | + type="tns:ColorComponent" | |
783 | + use="required" /> | |
784 | + <xsd:attribute | |
785 | + name="bCol" | |
786 | + type="tns:ColorComponent" | |
787 | + use="required" /> | |
788 | + </xsd:complexType> | |
789 | + | |
790 | + </xsd:element> | |
791 | + | |
792 | + | |
793 | + <xsd:element name="lumiDirection" > | |
794 | + <xsd:annotation> | |
795 | + <xsd:documentation> | |
796 | + luminous direction by vector. | |
797 | + </xsd:documentation> | |
798 | + </xsd:annotation> | |
799 | + | |
800 | + <xsd:complexType> | |
801 | + <xsd:attribute | |
802 | + name="xVec" | |
803 | + type="tns:DirVecComponent" | |
804 | + use="required" /> | |
805 | + <xsd:attribute | |
806 | + name="yVec" | |
807 | + type="tns:DirVecComponent" | |
808 | + use="required" /> | |
809 | + <xsd:attribute | |
810 | + name="zVec" | |
811 | + type="tns:DirVecComponent" | |
812 | + use="required" /> | |
813 | + </xsd:complexType> | |
814 | + | |
815 | + </xsd:element> | |
816 | + | |
817 | + | |
818 | + <xsd:element name="shadowSequence" > | |
819 | + <xsd:annotation> | |
820 | + <xsd:documentation> | |
821 | + shadow sequence. | |
822 | + </xsd:documentation> | |
823 | + </xsd:annotation> | |
824 | + | |
825 | + <xsd:complexType> | |
826 | + <xsd:sequence> | |
827 | + <xsd:element | |
828 | + ref="tns:shadowAct" | |
829 | + minOccurs="0" maxOccurs="unbounded" /> | |
830 | + </xsd:sequence> | |
831 | + </xsd:complexType> | |
832 | + | |
833 | + <xsd:unique name="ShadowFrameNo" > | |
834 | + <xsd:selector xpath="./tns:shadowAct" /> | |
835 | + <xsd:field xpath="@frame" /> | |
836 | + </xsd:unique> | |
837 | + | |
838 | + </xsd:element> | |
839 | + | |
840 | + | |
841 | + <xsd:element name="shadowAct" > | |
842 | + <xsd:annotation> | |
843 | + <xsd:documentation> | |
844 | + shadow data. | |
845 | + </xsd:documentation> | |
846 | + </xsd:annotation> | |
847 | + | |
848 | + <xsd:complexType> | |
849 | + <xsd:complexContent> | |
850 | + <xsd:extension base="tns:FrameNumbered" > | |
851 | + <xsd:attribute | |
852 | + name="mode" | |
853 | + type="tns:ShadowType" | |
854 | + use="required" /> | |
855 | + <xsd:attribute | |
856 | + name="rawParam" | |
857 | + type="tns:ShadowRawParam" | |
858 | + use="required" /> | |
859 | + </xsd:extension> | |
860 | + </xsd:complexContent> | |
861 | + </xsd:complexType> | |
862 | + | |
863 | + </xsd:element> | |
864 | + | |
865 | + | |
866 | + <xsd:element name="flagSequence" > | |
867 | + <xsd:annotation> | |
868 | + <xsd:documentation> | |
869 | + numbered flag sequence. | |
870 | + </xsd:documentation> | |
871 | + </xsd:annotation> | |
872 | + | |
873 | + <xsd:complexType> | |
874 | + <xsd:sequence> | |
875 | + <xsd:element | |
876 | + ref="tns:flagMotion" | |
877 | + minOccurs="0" maxOccurs="unbounded" /> | |
878 | + </xsd:sequence> | |
879 | + </xsd:complexType> | |
880 | + | |
881 | + <xsd:unique name="FlagFrameNo" > | |
882 | + <xsd:selector xpath="./tns:flagMotion" /> | |
883 | + <xsd:field xpath="@frame" /> | |
884 | + </xsd:unique> | |
885 | + | |
886 | + </xsd:element> | |
887 | + | |
888 | + | |
889 | + <xsd:element name="flagMotion" > | |
890 | + <xsd:annotation> | |
891 | + <xsd:documentation> | |
892 | + numbered motion flags. | |
893 | + </xsd:documentation> | |
894 | + </xsd:annotation> | |
895 | + | |
896 | + <xsd:complexType> | |
897 | + <xsd:complexContent> | |
898 | + <xsd:extension base="tns:FrameNumbered" > | |
899 | + <xsd:sequence> | |
900 | + <xsd:element | |
901 | + ref="tns:ikSwitch" | |
902 | + minOccurs="0" maxOccurs="unbounded" /> | |
903 | + </xsd:sequence> | |
904 | + <xsd:attribute | |
905 | + name="showModel" | |
906 | + type="xsd:boolean" | |
907 | + use="required" /> | |
908 | + </xsd:extension> | |
909 | + </xsd:complexContent> | |
910 | + </xsd:complexType> | |
911 | + | |
912 | + <xsd:unique name="IkBoneName" > | |
913 | + <xsd:selector xpath="./tns:ikSwitch" /> | |
914 | + <xsd:field xpath="@name" /> | |
915 | + </xsd:unique> | |
916 | + | |
917 | + </xsd:element> | |
918 | + | |
919 | + | |
920 | + <xsd:element name="ikSwitch" > | |
921 | + <xsd:annotation> | |
922 | + <xsd:documentation> | |
923 | + IK ON/OFF switch for each IK-Bone. | |
924 | + </xsd:documentation> | |
925 | + </xsd:annotation> | |
926 | + | |
927 | + <xsd:complexType> | |
928 | + <xsd:attribute | |
929 | + name="name" | |
930 | + type="xsd:string" | |
931 | + use="required" /> | |
932 | + <xsd:attribute | |
933 | + name="valid" | |
934 | + type="xsd:boolean" | |
935 | + use="required" /> | |
936 | + </xsd:complexType> | |
937 | + | |
938 | + </xsd:element> | |
939 | + | |
940 | + | |
941 | +</xsd:schema> | |
942 | + | |
943 | + | |
944 | +<!-- EOF --> |
@@ -395,7 +395,7 @@ | ||
395 | 395 | |
396 | 396 | assertEquals( |
397 | 397 | "model name : カメラ・照明\n" |
398 | - +"bone#0 morph#0 camera#0 luminous#0 shadow#0", | |
398 | + +"bone#0 morph#0 camera#0 luminous#0 shadow#0 flag#0", | |
399 | 399 | motion.toString()); |
400 | 400 | |
401 | 401 | motion.setModelName("model"); |
@@ -414,10 +414,15 @@ | ||
414 | 414 | motion.getShadowMotionList().add(new ShadowMotion()); |
415 | 415 | motion.getShadowMotionList().add(new ShadowMotion()); |
416 | 416 | motion.getShadowMotionList().add(new ShadowMotion()); |
417 | + motion.getNumberedFlagList().add(new NumberedVmdFlag()); | |
418 | + motion.getNumberedFlagList().add(new NumberedVmdFlag()); | |
419 | + motion.getNumberedFlagList().add(new NumberedVmdFlag()); | |
420 | + motion.getNumberedFlagList().add(new NumberedVmdFlag()); | |
421 | + motion.getNumberedFlagList().add(new NumberedVmdFlag()); | |
417 | 422 | |
418 | 423 | assertEquals( |
419 | 424 | "model name : model\n" |
420 | - +"bone#1 morph#2 camera#3 luminous#4 shadow#5", | |
425 | + +"bone#1 morph#2 camera#3 luminous#4 shadow#5 flag#5", | |
421 | 426 | motion.toString()); |
422 | 427 | |
423 | 428 | return; |
@@ -0,0 +1,31 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
2 | + | |
3 | +<!-- | |
4 | + MikuMikuDance | |
5 | + motion-data(*.vmd) on XML | |
6 | +--> | |
7 | + | |
8 | + | |
9 | +<vmdMotion | |
10 | + xmlns="http://mikutoga.sourceforge.jp/xml/ns/vmdxml/130609A" | |
11 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
12 | + xsi:schemaLocation="http://mikutoga.sourceforge.jp/xml/ns/vmdxml/130609A | |
13 | + http://mikutoga.sourceforge.jp/xml/xsd/vmdxml-130609A.xsd" | |
14 | + version="130609A" | |
15 | +> | |
16 | + | |
17 | +<!-- [NAMELESS] --> | |
18 | +<modelName name="" /> | |
19 | + | |
20 | +<boneMotionSequence> | |
21 | +</boneMotionSequence> | |
22 | + | |
23 | +<morphSequence> | |
24 | +</morphSequence> | |
25 | + | |
26 | +<flagSequence> | |
27 | +</flagSequence> | |
28 | + | |
29 | +</vmdMotion> | |
30 | + | |
31 | +<!-- EOF --> |
@@ -0,0 +1,36 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
2 | + | |
3 | +<!-- | |
4 | + MikuMikuDance | |
5 | + motion-data(*.vmd) on XML | |
6 | +--> | |
7 | + | |
8 | + | |
9 | +<vmdMotion | |
10 | + xmlns="http://mikutoga.sourceforge.jp/xml/ns/vmdxml/130609A" | |
11 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
12 | + xsi:schemaLocation="http://mikutoga.sourceforge.jp/xml/ns/vmdxml/130609A | |
13 | + http://mikutoga.sourceforge.jp/xml/xsd/vmdxml-130609A.xsd" | |
14 | + version="130609A" | |
15 | +> | |
16 | + | |
17 | +<!-- [NAMELESS] --> | |
18 | +<modelName name="" /> | |
19 | + | |
20 | +<boneMotionSequence> | |
21 | +</boneMotionSequence> | |
22 | + | |
23 | +<morphSequence> | |
24 | +</morphSequence> | |
25 | + | |
26 | +<flagSequence> | |
27 | + <flagMotion frame="9" showModel="true" /> | |
28 | + <flagMotion frame="99" showModel="false"> | |
29 | + <ikSwitch name="IKBONE1" valid="true" /> | |
30 | + <ikSwitch name="IKBONE2" valid="false" /> | |
31 | + </flagMotion> | |
32 | +</flagSequence> | |
33 | + | |
34 | +</vmdMotion> | |
35 | + | |
36 | +<!-- EOF --> |