4 * License : The MIT License
5 * Copyright(c) 2011 MikuToga Partners
8 package jp.sfjp.mikutoga.vmd.model.binio;
10 import java.io.IOException;
11 import java.io.OutputStream;
12 import jp.sfjp.mikutoga.bin.export.IllegalTextExportException;
13 import jp.sfjp.mikutoga.vmd.IllegalVmdDataException;
14 import jp.sfjp.mikutoga.vmd.model.VmdMotion;
19 public class VmdExporter {
21 private BasicExporter basicExporter = null;
22 private CameraExporter cameraExporter = null;
23 private LightingExporter lightingExporter = null;
24 private BoolExporter boolExporter = null;
36 * モーションデータをVMDファイル形式で出力する。
37 * <p>異常時には出力データのフラッシュが試みられる。
38 * @param motion モーションデータ
39 * @param ostream 出力先ストリーム
40 * @throws IOException 出力エラー
41 * @throws IllegalVmdDataException モーションデータに不備が発見された
43 public void dumpVmdMotion(VmdMotion motion, OutputStream ostream)
44 throws IOException, IllegalVmdDataException{
45 this.basicExporter = new BasicExporter(ostream);
46 this.cameraExporter = new CameraExporter(ostream);
47 this.lightingExporter = new LightingExporter(ostream);
48 this.boolExporter = new BoolExporter(ostream);
51 dumpVmdMotionImpl(motion);
60 * モーションデータをVMDファイル形式で出力する。
61 * @param motion モーションデータ
62 * @throws IOException 出力エラー
63 * @throws IllegalVmdDataException モーションデータに不備が発見された
65 private void dumpVmdMotionImpl(VmdMotion motion)
66 throws IOException, IllegalVmdDataException{
67 this.basicExporter.dumpHeader();
70 this.basicExporter.dumpModelName(motion);
71 this.basicExporter.dumpBoneMotion(motion);
72 this.basicExporter.dumpMorphMotion(motion);
73 }catch(IllegalTextExportException e){
74 throw new IllegalVmdDataException(e);
77 this.cameraExporter.dumpCameraMotion(motion);
78 this.lightingExporter.dumpLuminousMotion(motion);
79 this.lightingExporter.dumpShadowMotion(motion);
81 if(motion.getNumberedFlagList().isEmpty()) return;
83 this.boolExporter.dumpNumberedFlagMotion(motion);
84 }catch(IllegalTextExportException e){
85 throw new IllegalVmdDataException(e);