・Maven3対応。
・オイラー角出力時の精度を向上させた。
・ベジェ補間パラメータ冗長部がMMDの版により異なるため、検査をやめた。
+ ・プロセス終了コードの変更。
1.101.2 (2011-08-25)
・初回リリース。
<groupId>jp.sourceforge.mikutoga</groupId>
<artifactId>vmd2xml</artifactId>
- <version>1.101.3-SNAPSHOT</version>
+ <version>1.101.5-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Vmd2XML</name>
<dependency>
<groupId>jp.sourceforge.mikutoga</groupId>
<artifactId>togagem</artifactId>
- <version>2.102.3-SNAPSHOT</version>
+ <version>2.102.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
/*
- * 3D bezier intaerpolation curve params
+ * 3D bezier interpolation curve params
*
* License : The MIT License
* Copyright(c) 2011 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd.model;
+package jp.sfjp.mikutoga.vmd.model;
+
+import java.text.MessageFormat;
/**
* 三次ベジェ曲線による補間カーブを記述する。
public static final byte EIO_P2Y = 127;
/**
- * 制御点空間最小値。
+ * 制御点空間各軸最小値。
*/
public static final byte MIN_VAL = 0;
/**
- * 制御点空間最大値。
+ * 制御点空間各軸最大値。
*/
public static final byte MAX_VAL = 127;
+ private static final String MSG_TXT = "P1=({0}, {1}) P2=({2}, {3})";
+
private byte p1x = DEF_P1X;
private byte p1y = DEF_P1Y;
if(this.p2x != DEF_P2X) return false;
if(this.p2y != DEF_P2Y) return false;
- assert isLinear();
-
return true;
}
*/
@Override
public String toString(){
- StringBuilder result = new StringBuilder();
-
- String delim = ", ";
- result.append("P1=(")
- .append(this.p1x).append(delim).append(this.p1y).append(") ");
- result.append("P2=(")
- .append(this.p2x).append(delim).append(this.p2y).append(")");
-
- return result.toString();
+ String msg = MessageFormat.format(MSG_TXT,
+ this.p1x, this.p1y,
+ this.p2x, this.p2y );
+ return msg;
}
}
* Copyright(c) 2011 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd.model;
+package jp.sfjp.mikutoga.vmd.model;
+import java.text.MessageFormat;
import jp.sfjp.mikutoga.math.MkPos3D;
import jp.sfjp.mikutoga.math.MkQuat;
-import jp.sourceforge.mikutoga.vmd.AbstractNumbered;
+import jp.sfjp.mikutoga.vmd.AbstractNumbered;
/**
* ボーンのモーション情報。
*/
public class BoneMotion extends AbstractNumbered {
+ private static final String MSG_TXT =
+ "bone name : [{0}] #{1}\n"
+ + "rotation {2} R-Bezier {3}\n"
+ + "position {4}\n"
+ + "{5}";
+
+
private String boneName;
private final MkQuat rotation = new MkQuat();
*/
@Override
public String toString(){
- StringBuilder result = new StringBuilder();
-
- result.append("bone name : [").append(this.boneName);
- result.append("] #").append(getFrameNumber()).append('\n');
-
- result.append("rotation ").append(this.rotation);
- result.append(" R-Bezier ").append(this.intpltRotation).append('\n');
-
- result.append("position ").append(this.position).append('\n');
- result.append(this.posCurve);
-
- return result.toString();
+ String msg;
+ msg = MessageFormat.format(MSG_TXT,
+ this.boneName,
+ getFrameNumber(),
+ this.rotation, this.intpltRotation,
+ this.position, this.posCurve );
+ return msg;
}
}
* Copyright(c) 2011 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd.model;
+package jp.sfjp.mikutoga.vmd.model;
+import java.text.MessageFormat;
import jp.sfjp.mikutoga.math.MkPos3D;
-import jp.sourceforge.mikutoga.vmd.AbstractNumbered;
+import jp.sfjp.mikutoga.vmd.AbstractNumbered;
/**
* カメラモーション情報。
*/
public class CameraMotion extends AbstractNumbered {
+ private static final String MSG_TXT =
+ "#{0} {1} Rot-Bezier {2}\n"
+ + "range : {3} Range-Bezier {4}\n"
+ + "target-pos : {5}\n"
+ + "{6}\n"
+ + "perspective : {7}\n"
+ + "projection angle : {8}deg Bezier {9}";
+
+
private final MkPos3D cameraTarget = new MkPos3D();
private final PosCurve posCurve = new PosCurve();
private final CameraRotation cameraRotation = new CameraRotation();
private final BezierParam intpltRotation = new BezierParam();
- private float range;
+ private double range;
private final BezierParam intpltRange = new BezierParam();
private boolean hasPerspective;
* カメラ-ターゲット間の距離を返す。
* @return カメラ-ターゲット間の距離
*/
- public float getRange(){
+ public double getRange(){
return this.range;
}
* カメラ-ターゲット間の距離を設定する。
* @param range カメラ-ターゲット間の距離
*/
- public void setRange(float range){
+ public void setRange(double range){
this.range = range;
return;
}
*/
@Override
public String toString(){
- StringBuilder result = new StringBuilder();
-
- result.append("#").append(getFrameNumber()).append(' ');
- result.append(this.cameraRotation);
- result.append(" Rot-Bezier ")
- .append(this.intpltRotation).append('\n');
-
- result.append("range : ").append(this.range);
- result.append(" Range-Bezier ").append(this.intpltRange).append('\n');
-
- result.append("target-pos : ").append(this.cameraTarget).append('\n');
- result.append(this.posCurve).append('\n');
-
- result.append("perspective : ");
- if(this.hasPerspective) result.append("ON");
- else result.append("OFF");
- result.append('\n');
-
- result.append("projection angle : ").append(this.projectionAngle);
- result.append("deg Bezier ").append(this.intpltProjection);
-
- return result.toString();
+ String msg;
+ msg = MessageFormat.format(MSG_TXT,
+ getFrameNumber(),
+ this.cameraRotation, this.intpltRotation,
+ this.range, this.intpltRange,
+ this.cameraTarget, this.posCurve,
+ this.hasPerspective,
+ this.projectionAngle, this.intpltProjection );
+ return msg;
}
}
/*
- * VMD camerawork handler
+ * camera rotation
*
* License : The MIT License
* Copyright(c) 2011 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd.model;
+package jp.sfjp.mikutoga.vmd.model;
+
+import java.text.MessageFormat;
/**
- * カメラの回転情報。
+ * 左手系空間でターゲットの周りを回るカメラの回転情報。
+ * いずれもカメラ姿勢ではなくカメラ運動量を示すため、
+ * 回転量0と2Πの区別には意味がある。
* <p>latitudeはターゲットから見たカメラの仰俯角(≒緯度)。
* 単位はラジアン。
* Y軸回転量が0の時のZ正軸がY正軸へ倒れる方向が正回転。
* (MMDのUIとは符号が逆になるので注意)
* 仰俯角が0の場合、
* カメラはターゲットに対しXZ平面(水平)と平行な箇所に位置する。
- * <p>longitudeはY軸周りの回転量(≒経度)。単位はラジアン。
+ * <p>longitudeはY軸周りの回転量(≒経度)。
+ * 単位はラジアン。
* X正軸がZ正軸へ倒れる方向が正回転。(ボーン回転と逆)
* 仰俯角およびY軸回転量が0の場合、
* カメラレンズはZ軸-∞方向からZ軸+∞方向を向く。
* <p>rollはレンズをターゲットを向けたカメラのロール回転量。
+ * 単位はラジアン。
* 仰俯角とY軸回転量が0の時にY正軸がX正軸に倒れる方向が正回転。
* 仰俯角およびロール回転量が0の場合、カメラ上部はY軸+∞の方を向く。
*/
public class CameraRotation {
- private float latitude;
- private float longitude;
- private float roll;
+ private static final String MSG_TXT =
+ "latitude={0} longitude={1} roll={2}";
+
+
+ private double latitude;
+ private double longitude;
+ private double roll;
/**
* ターゲットから見たカメラの仰俯角(≒緯度)を返す。
* @return ターゲットから見たカメラの仰俯角(≒緯度)
*/
- public float getLatitude(){
+ public double getLatitude(){
return this.latitude;
}
* ターゲットから見たカメラの仰俯角(≒緯度)を設定する。
* @param latitude ターゲットから見たカメラの仰俯角(≒緯度)
*/
- public void setLatitude(float latitude){
+ public void setLatitude(double latitude){
this.latitude = latitude;
return;
}
* Y軸周りの回転量(≒経度)を返す。
* @return Y軸周りの回転量(≒経度)
*/
- public float getLongitude(){
+ public double getLongitude(){
return this.longitude;
}
* Y軸周りの回転量(≒経度)を設定する。
* @param longitude Y軸周りの回転量(≒経度)
*/
- public void setLongitude(float longitude){
+ public void setLongitude(double longitude){
this.longitude = longitude;
return;
}
* レンズをターゲットを向けたカメラのロール回転量を返す。
* @return レンズをターゲットを向けたカメラのロール回転量
*/
- public float getRoll(){
+ public double getRoll(){
return this.roll;
}
* レンズをターゲットを向けたカメラのロール回転量を設定する。
* @param roll レンズをターゲットを向けたカメラのロール回転量
*/
- public void setRoll(float roll){
+ public void setRoll(double roll){
this.roll = roll;
return;
}
*/
@Override
public String toString(){
- StringBuilder result = new StringBuilder();
-
- result.append("latitude=").append(this.latitude);
- result.append(" longitude=").append(this.longitude);
- result.append(" roll=").append(this.roll);
-
- return result.toString();
+ String msg;
+ msg = MessageFormat.format(MSG_TXT,
+ this.latitude, this.longitude, this.roll );
+ return msg;
}
}
* Copyright(c) 2011 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd.model;
+package jp.sfjp.mikutoga.vmd.model;
+
+import java.text.MessageFormat;
/**
* 光源の色設定。
/** デフォルトの成分値。 */
public static final float DEF_BRIGHT = 0.602f; // ≒ (154.0 / 256.0)
+ private static final String MSG_TXT = "r={0} g={1} b={2}";
+
+ static{
+ assert 0.602f != 0.602;
+ }
+
private float colR = DEF_BRIGHT;
private float colG = DEF_BRIGHT;
*/
@Override
public String toString(){
- StringBuilder result = new StringBuilder();
-
- result.append("r=").append(this.colR);
- result.append(" g=").append(this.colG);
- result.append(" b=").append(this.colB);
-
- return result.toString();
+ String msg;
+ msg = MessageFormat.format(MSG_TXT,
+ this.colR, this.colG, this.colB );
+ return msg;
}
}
--- /dev/null
+/*
+ * luminous motion
+ *
+ * License : The MIT License
+ * Copyright(c) 2011 MikuToga Partners
+ */
+
+package jp.sfjp.mikutoga.vmd.model;
+
+import java.text.MessageFormat;
+import jp.sfjp.mikutoga.math.MkVec3D;
+import jp.sfjp.mikutoga.vmd.AbstractNumbered;
+
+/**
+ * 光源演出情報。
+ * <p>照明方向は、
+ * ワールド座標原点から伸びる方向ベクトルとして記述される。
+ * この方向ベクトルに向けて、無限遠の光源から照明が当たる。
+ * <p>MMDのスライダUI上では
+ * 方向ベクトル各軸成分の定義域は-1.0以上+1.0以下だが、
+ * さらに絶対値の大きな値を指定することも可能。
+ * <p>方向ベクトルの長さは演出上の意味を持たないが、
+ * キーフレーム間の照明方向の補間に影響を及ぼすかもしれない。
+ * <p>方向ベクトルが零ベクトル(0,0,0)の場合、MMDでは全ポリゴンに影が落ちる。
+ */
+public class LuminousMotion extends AbstractNumbered {
+
+ /** デフォルトのX成分。 */
+ public static final double DEF_VECX = -0.5;
+ /** デフォルトのY成分。 */
+ public static final double DEF_VECY = -1.0;
+ /** デフォルトのZ成分。 */
+ public static final double DEF_VECZ = +0.5;
+
+ private static final String MSG_TXT =
+ "#{0} luminous color : {1} direction : {2}";
+
+
+ private final LuminousColor color = new LuminousColor();
+ private final MkVec3D direction = new MkVec3D();
+
+
+ /**
+ * コンストラクタ。
+ */
+ public LuminousMotion(){
+ super();
+ this.direction.setVector(DEF_VECX, DEF_VECY, DEF_VECZ);
+ return;
+ }
+
+
+ /**
+ * 光源の色情報を返す。
+ * @return 光源の色情報
+ */
+ public LuminousColor getColor(){
+ return this.color;
+ }
+
+ /**
+ * 光源からの照射方向情報を返す。
+ * @return 光源からの照射方向情報
+ */
+ public MkVec3D getDirection(){
+ return this.direction;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @return {@inheritDoc}
+ */
+ @Override
+ public String toString(){
+ String msg;
+ msg = MessageFormat.format(MSG_TXT,
+ getFrameNumber(), this.color, this.direction );
+ return msg;
+ }
+
+}
* Copyright(c) 2011 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd.model;
+package jp.sfjp.mikutoga.vmd.model;
-import jp.sourceforge.mikutoga.vmd.AbstractNumbered;
+import java.text.MessageFormat;
+import jp.sfjp.mikutoga.vmd.AbstractNumbered;
/**
* モーフ情報。
*/
public class MorphMotion extends AbstractNumbered {
+ private static final String MSG_TXT =
+ "morph name : [{0}] #{1} flex = {2}";
+
+
private String morphName = "";
private float flex = 0.0f;
*/
@Override
public String toString(){
- StringBuilder result = new StringBuilder();
-
- result.append("morph name : [").append(this.morphName);
- result.append("] #").append(getFrameNumber());
- result.append(" flex = ").append(this.flex);
-
- return result.toString();
+ String msg;
+ msg = MessageFormat.format(MSG_TXT,
+ this.morphName, getFrameNumber(), this.flex );
+ return msg;
}
}
/*
- * position curve
+ * position interpolation curve
*
* License : The MIT License
* Copyright(c) 2011 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd.model;
+package jp.sfjp.mikutoga.vmd.model;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
/**
- * 3次元位置移動の補間情報。
+ * 3次元位置移動のモーション補間曲線情報。
* <p>XYZ3軸それぞれに対応するベジェ曲線を3本持つ。
*/
-public class PosCurve {
+public class PosCurve implements Iterable<BezierParam> {
+
+ private static final int IT_SZ = 3;
+ private static final String MSG_TXT =
+ "X-Bezier {0}\n" + "Y-Bezier {1}\n" + "Z-Bezier {2}";
+
private final BezierParam intpltXpos = new BezierParam();
private final BezierParam intpltYpos = new BezierParam();
/**
+ * {@inheritDoc}
+ * X軸、Y軸、Z軸の順で補間曲線情報を列挙する。
+ * @return {@inheritDoc} 3要素を返す列挙子
+ */
+ @Override
+ public Iterator<BezierParam> iterator(){
+ List<BezierParam> list;
+ list = new ArrayList<BezierParam>(IT_SZ);
+ list.add(this.intpltXpos);
+ list.add(this.intpltYpos);
+ list.add(this.intpltZpos);
+ return list.iterator();
+ }
+
+ /**
* ボーンX軸移動の補間曲線情報を返す。
* @return ボーンX軸移動の補間曲線情報
*/
}
/**
- * インデックス指定された各軸の補間曲線情報を返す。
- * <p>インデックス値0がX軸、1がY軸、2がZ軸に対応する。
- * @param no インデックス値[0-2]
- * @return 各軸の補間曲線情報
- * @throws IllegalArgumentException インデックス値が範囲外
- */
- public BezierParam item(int no) throws IllegalArgumentException {
- BezierParam result;
- switch(no){
- case 0: result = this.intpltXpos; break;
- case 1: result = this.intpltYpos; break;
- case 2: result = this.intpltZpos; break;
- default:
- throw new IllegalArgumentException();
- }
- return result;
- }
-
- /**
* 3軸ともMMDデフォルトの直線補間か判定する。
* @return 3軸ともMMDデフォルトの直線補間ならtrue
*/
*/
@Override
public String toString(){
- StringBuilder result = new StringBuilder();
-
- result.append("X-Bezier ").append(this.intpltXpos).append('\n');
- result.append("Y-Bezier ").append(this.intpltYpos).append('\n');
- result.append("Z-Bezier ").append(this.intpltZpos);
+ String msg;
+ msg = MessageFormat.format(MSG_TXT,
+ this.intpltXpos, this.intpltYpos, this.intpltZpos );
- return result.toString();
+ return msg;
}
}
* Copyright(c) 2011 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd.model;
+package jp.sfjp.mikutoga.vmd.model;
/**
* セルフシャドウ描画モード。
* Copyright(c) 2011 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd.model;
+package jp.sfjp.mikutoga.vmd.model;
-import jp.sourceforge.mikutoga.vmd.AbstractNumbered;
+import java.text.MessageFormat;
+import jp.sfjp.mikutoga.vmd.AbstractNumbered;
/**
* 影(セルフシャドウ)演出情報。
* 「 0.1 - (S / 1.0E+5) 」
* となる。
*/
-public class ShadowMotion extends AbstractNumbered {
+public strictfp class ShadowMotion extends AbstractNumbered {
/**
* デフォルトの影描画モード。
* デフォルトの範囲指定生パラメータ。
* <p>MMDのスライダUI値「8875」にほぼ相当。
*/
- public static final float DEF_SCOPE = 0.01125f;
+ public static final double DEF_SCOPE = 0.01125;
+ private static final int DEF_UIVAL = 8875;
private static final double OFFSET = 0.1;
private static final double SCALE = 1.0E+5;
+ private static final String MSG_TXT =
+ "#{0} shadow mode : {1} rawparam={2}";
+
+ static{
+ assert (float)(OFFSET - (DEF_UIVAL / SCALE)) == (float)DEF_SCOPE;
+ }
+
private ShadowMode shadowMode = DEF_MODE;
- private float rawScopeParam = DEF_SCOPE;
+ private double rawScopeParam = DEF_SCOPE;
/**
* @param param 生パラメータ
* @return MMDのスライダUI上の距離情報
*/
- public static double rawParamToScope(float param){
+ public static double rawParamToScope(double param){
double result;
result = OFFSET - param;
result *= SCALE;
* @param scope MMDのスライダUI上の距離情報
* @return 生パラメータ
*/
- public static float scopeToRawParam(double scope){
+ public static double scopeToRawParam(double scope){
double result;
result = scope / SCALE;
result = OFFSET - result;
- return (float) result;
+ return result;
}
* 影演出の範囲指定の生パラメータを設定する。
* @param rawScopeParam 生パラメータ
*/
- public void setRawScopeParam(float rawScopeParam) {
+ public void setRawScopeParam(double rawScopeParam) {
this.rawScopeParam = rawScopeParam;
return;
}
* 影演出の範囲指定の生パラメータを返す。
* @return 生パラメータ
*/
- public float getRawScopeParam() {
+ public double getRawScopeParam() {
return this.rawScopeParam;
}
* @param scope スライダUI値
*/
public void setScope(double scope){
- float rawVal = scopeToRawParam(scope);
+ float rawVal = (float) scopeToRawParam(scope);
setRawScopeParam(rawVal);
return;
}
* @return スライダUI値
*/
public double getScope(){
- float rawVal = getRawScopeParam();
+ double rawVal = getRawScopeParam();
double scope = rawParamToScope(rawVal);
return scope;
}
*/
@Override
public String toString(){
- StringBuilder result = new StringBuilder();
-
- result.append("#").append(getFrameNumber());
- result.append(" shadow mode : ").append(this.shadowMode);
- result.append(" rawparam=").append(this.rawScopeParam);
-
- return result.toString();
+ String msg;
+ msg = MessageFormat.format(MSG_TXT,
+ getFrameNumber(),
+ this.shadowMode,
+ Double.toString(this.rawScopeParam) );
+ return msg;
}
}
* Copyright(c) 2011 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd.model;
+package jp.sfjp.mikutoga.vmd.model;
+import java.text.MessageFormat;
import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
-import jp.sourceforge.mikutoga.vmd.FrameNumbered;
-import jp.sourceforge.mikutoga.vmd.VmdConst;
+import java.util.Map;
+import jp.sfjp.mikutoga.vmd.FrameNumbered;
+import jp.sfjp.mikutoga.vmd.VmdUniq;
/**
* モーション及び演出情報。
*/
public class VmdMotion {
- private String modelName = VmdConst.MODELNAME_STAGEACT;
+ private static final String MSG_TXT =
+ "model name : {0}\n"
+ + "bone#{1} morph#{2} camera#{3} luminous#{4} shadow#{5}";
- private final NamedListMap<BoneMotion> bonePartMap;
- private final NamedListMap<MorphMotion> morphPartMap;
+
+ private String modelName = VmdUniq.MODELNAME_STAGEACT;
+
+ private final Map<String, List<BoneMotion>> bonePartMap;
+ private final Map<String, List<MorphMotion>> morphPartMap;
private final List<CameraMotion> cameraMotionList;
private final List<LuminousMotion> luminousMotionList;
public VmdMotion(){
super();
- this.bonePartMap = new NamedListMap<BoneMotion>();
- this.morphPartMap = new NamedListMap<MorphMotion>();
+ this.bonePartMap = new LinkedHashMap<String, List<BoneMotion>>();
+ this.morphPartMap = new LinkedHashMap<String, List<MorphMotion>>();
this.cameraMotionList = new LinkedList<CameraMotion>();
this.luminousMotionList = new LinkedList<LuminousMotion>();
* このモデル名で判別される。
* @param modelName モデル名
* @throws NullPointerException 引数がnull
+ * @see jp.sfjp.mikutoga.vmd.VmdUniq#MODELNAME_STAGEACT
*/
public void setModelName(String modelName) throws NullPointerException{
if(modelName == null) throw new NullPointerException();
* モデルモーションか否か判別する。
* <p>判別は特殊なモデル名を持つか否かで決定される。
* @return モデルモーションならtrue
+ * @see jp.sfjp.mikutoga.vmd.VmdUniq#MODELNAME_STAGEACT
*/
public boolean isModelMotion(){
- if(VmdConst.isStageActName(this.modelName)){
+ if(VmdUniq.isStageActName(this.modelName)){
return false;
}
}
/**
- * 名前付きボーンモーションマップを返す。
- * @return 名前付きボーンモーションマップ
+ * 順序保証されたボーンモーションマップを返す。
+ * @return ボーンモーションマップ
+ * @see java.util.LinkedHashMap
*/
- public NamedListMap<BoneMotion> getBonePartMap(){
+ public Map<String, List<BoneMotion>> getBonePartMap(){
return this.bonePartMap;
}
/**
- * 名前付きモーフモーションマップを返す。
- * @return 名前付きモーフモーションマップ
+ * 順序保証されたモーフモーションマップを返す。
+ * @return モーフモーションマップ
+ * @see java.util.LinkedHashMap
*/
- public NamedListMap<MorphMotion> getMorphPartMap(){
+ public Map<String, List<MorphMotion>> getMorphPartMap(){
return this.morphPartMap;
}
/**
* ボーンモーションを追加する。
+ * 追加順は保持される。
* @param motion ボーンモーション
+ * @see java.util.LinkedHashMap
*/
public void addBoneMotion(BoneMotion motion){
String name = motion.getBoneName();
- this.bonePartMap.addNamedElement(name, motion);
+
+ List<BoneMotion> list = this.bonePartMap.get(name);
+ if(list == null){
+ list = new LinkedList<BoneMotion>();
+ this.bonePartMap.put(name, list);
+ }
+
+ list.add(motion);
+
return;
}
/**
* モーフモーションを追加する。
+ * 追加順は保持される。
* @param motion モーフモーション
+ * @see java.util.LinkedHashMap
*/
public void addMorphMotion(MorphMotion motion){
String name = motion.getMorphName();
- this.morphPartMap.addNamedElement(name, motion);
+
+ List<MorphMotion> list = this.morphPartMap.get(name);
+ if(list == null){
+ list = new LinkedList<MorphMotion>();
+ this.morphPartMap.put(name, list);
+ }
+
+ list.add(motion);
+
return;
}
* 各データをフレーム番号順に昇順ソートする。
*/
public void frameSort(){
- for(String name : this.bonePartMap.getNames()){
- List<BoneMotion> motionList =
- this.bonePartMap.getNamedList(name);
- Collections.sort(motionList, FrameNumbered.COMPARATOR);
+ for(List<BoneMotion> list : this.bonePartMap.values()){
+ Collections.sort(list, FrameNumbered.COMPARATOR);
}
- for(String name : this.morphPartMap.getNames()){
- List<MorphMotion> motionList =
- this.morphPartMap.getNamedList(name);
- Collections.sort(motionList, FrameNumbered.COMPARATOR);
+ for(List<MorphMotion> list : this.morphPartMap.values()){
+ Collections.sort(list, FrameNumbered.COMPARATOR);
}
Collections.sort(this.cameraMotionList, FrameNumbered.COMPARATOR);
*/
@Override
public String toString(){
- String dash = "---";
-
- StringBuilder result = new StringBuilder();
-
- result.append("model name : ").append(this.modelName).append('\n');
-
- for(String boneName : this.bonePartMap.getNames()){
- List<BoneMotion> motionList =
- this.bonePartMap.getNamedList(boneName);
- for(BoneMotion motion : motionList){
- result.append(dash).append('\n');
- result.append(motion.toString()).append('\n');
- }
+ int boneNo = 0;
+ for(List<BoneMotion> motionList : this.bonePartMap.values()){
+ boneNo += motionList.size();
}
- for(String morphName : this.morphPartMap.getNames()){
- if(VmdConst.isBaseMorphName(morphName)) continue;
- List<MorphMotion> motionList =
- this.morphPartMap.getNamedList(morphName);
- for(MorphMotion morph : motionList){
- result.append(morph.toString()).append('\n');
- }
+ int morphNo = 0;
+ for(List<MorphMotion> motionList : this.morphPartMap.values()){
+ morphNo += motionList.size();
}
- for(CameraMotion camera : this.cameraMotionList){
- result.append(dash).append('\n');
- result.append(camera.toString()).append('\n');
- }
-
- for(LuminousMotion luminous : this.luminousMotionList){
- result.append(luminous.toString()).append('\n');
- }
+ int cameraNo = this.cameraMotionList .size();
+ int luminousNo = this.luminousMotionList.size();
+ int shadowNo = this.shadowMotionList .size();
- for(ShadowMotion shadow : this.shadowMotionList){
- result.append(shadow.toString()).append('\n');
- }
+ String msg;
+ msg = MessageFormat.format(MSG_TXT,
+ this.modelName,
+ boneNo, morphNo, cameraNo, luminousNo, shadowNo );
- return result.toString();
+ return msg;
}
}
* Copyright(c) 2011 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd.model.binio;
+package jp.sfjp.mikutoga.vmd.model.binio;
import java.io.IOException;
import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import jp.sfjp.mikutoga.bin.export.BinaryExporter;
import jp.sfjp.mikutoga.bin.export.IllegalTextExportException;
import jp.sfjp.mikutoga.math.MkPos3D;
import jp.sfjp.mikutoga.math.MkQuat;
-import jp.sourceforge.mikutoga.vmd.VmdConst;
-import jp.sourceforge.mikutoga.vmd.model.BezierParam;
-import jp.sourceforge.mikutoga.vmd.model.BoneMotion;
-import jp.sourceforge.mikutoga.vmd.model.MorphMotion;
-import jp.sourceforge.mikutoga.vmd.model.NamedListMap;
-import jp.sourceforge.mikutoga.vmd.model.PosCurve;
-import jp.sourceforge.mikutoga.vmd.model.VmdMotion;
+import jp.sfjp.mikutoga.vmd.VmdConst;
+import jp.sfjp.mikutoga.vmd.VmdUniq;
+import jp.sfjp.mikutoga.vmd.model.BezierParam;
+import jp.sfjp.mikutoga.vmd.model.BoneMotion;
+import jp.sfjp.mikutoga.vmd.model.MorphMotion;
+import jp.sfjp.mikutoga.vmd.model.PosCurve;
+import jp.sfjp.mikutoga.vmd.model.VmdMotion;
/**
* ボーンモーション及びモーフ情報のエクスポーター。
private static final int BZ_REDUNDANT = 4; // redundant spare
private static final int BZTOTAL_SIZE = BZXYZR_SIZE * BZ_REDUNDANT;
+ private static final Charset CS_ASCII = Charset.forName("US-ASCII");
+ private static final String HEADFILLER = "\u0000" + "JKLM";
private static final byte[] FDFILLER =
{ (byte)0x00, (byte)0xfd };
+ private static final byte[] INTPLT_FILLER = {
+ (byte) 0x01, // 0x00の版もあり。
+ (byte) 0x00,
+ (byte) 0x00,
+ };
private final byte[] motionIntplt = new byte[BZTOTAL_SIZE];
+ private final ByteBuffer intpltBuf;
+ private final ByteBuffer rdBuf;
/**
*/
BasicExporter(OutputStream stream){
super(stream);
+
+ this.intpltBuf = ByteBuffer.wrap(this.motionIntplt);
+ ByteBuffer buf = ByteBuffer.wrap(this.motionIntplt, 0, BZXYZR_SIZE);
+ this.rdBuf = buf.asReadOnlyBuffer();
+
+ return;
+ }
+
+
+ /**
+ * ヘッダ情報を出力する。
+ * @throws IOException 出力エラー
+ */
+ void dumpHeader() throws IOException{
+ byte[] header = (VmdConst.MAGIC_TXT + HEADFILLER).getBytes(CS_ASCII);
+ assert header.length == VmdConst.HEADER_LENGTH;
+
+ dumpByteArray(header);
+
return;
}
+ /**
+ * モデル名を出力する。
+ * <p>演出データのモデル名には
+ * 便宜的に
+ * {@link jp.sfjp.mikutoga.vmd.VmdUniq#MODELNAME_STAGEACT}
+ * が使われる。
+ * @param motion モーションデータ
+ * @throws IOException 出力エラー
+ * @throws IllegalTextExportException 不正なモデル名の出現
+ */
+ void dumpModelName(VmdMotion motion)
+ throws IOException, IllegalTextExportException{
+ String modelName = motion.getModelName();
+ if(modelName == null) modelName = VmdUniq.MODELNAME_STAGEACT;
+
+ dumpFixedW31j(modelName, VmdConst.MODELNAME_MAX, FDFILLER);
+
+ return;
+ }
/**
* ボーンモーション情報を出力する。
*/
void dumpBoneMotion(VmdMotion motion)
throws IOException, IllegalTextExportException{
- NamedListMap<BoneMotion> map = motion.getBonePartMap();
- List<String> nameList = map.getNames();
+ Map<String, List<BoneMotion>> map = motion.getBonePartMap();
List<BoneMotion> bmotionList = new LinkedList<BoneMotion>();
-
- int count = 0;
- for(String name : nameList){
- List<BoneMotion> namedList = map.getNamedList(name);
- for(BoneMotion boneMotion : namedList){
- bmotionList.add(boneMotion);
- count++;
- }
+ for(List<BoneMotion> eachList : map.values()){
+ bmotionList.addAll(eachList);
}
- dumpLeInt(count);
+ dumpLeInt(bmotionList.size());
for(BoneMotion boneMotion : bmotionList){
String boneName = boneMotion.getBoneName();
BezierParam zCurve = posCurve.getIntpltZpos();
BezierParam rCurve = boneMotion.getIntpltRotation();
- int idx = 0;
+ this.intpltBuf.clear();
- this.motionIntplt[idx++] = xCurve.getP1x();
- this.motionIntplt[idx++] = yCurve.getP1x();
- this.motionIntplt[idx++] = zCurve.getP1x();
- this.motionIntplt[idx++] = rCurve.getP1x();
+ this.intpltBuf.put(xCurve.getP1x());
+ this.intpltBuf.put(yCurve.getP1x());
+ this.intpltBuf.put(zCurve.getP1x());
+ this.intpltBuf.put(rCurve.getP1x());
- this.motionIntplt[idx++] = xCurve.getP1y();
- this.motionIntplt[idx++] = yCurve.getP1y();
- this.motionIntplt[idx++] = zCurve.getP1y();
- this.motionIntplt[idx++] = rCurve.getP1y();
+ this.intpltBuf.put(xCurve.getP1y());
+ this.intpltBuf.put(yCurve.getP1y());
+ this.intpltBuf.put(zCurve.getP1y());
+ this.intpltBuf.put(rCurve.getP1y());
- this.motionIntplt[idx++] = xCurve.getP2x();
- this.motionIntplt[idx++] = yCurve.getP2x();
- this.motionIntplt[idx++] = zCurve.getP2x();
- this.motionIntplt[idx++] = rCurve.getP2x();
+ this.intpltBuf.put(xCurve.getP2x());
+ this.intpltBuf.put(yCurve.getP2x());
+ this.intpltBuf.put(zCurve.getP2x());
+ this.intpltBuf.put(rCurve.getP2x());
- this.motionIntplt[idx++] = xCurve.getP2y();
- this.motionIntplt[idx++] = yCurve.getP2y();
- this.motionIntplt[idx++] = zCurve.getP2y();
- this.motionIntplt[idx++] = rCurve.getP2y();
+ this.intpltBuf.put(xCurve.getP2y());
+ this.intpltBuf.put(yCurve.getP2y());
+ this.intpltBuf.put(zCurve.getP2y());
+ this.intpltBuf.put(rCurve.getP2y());
- assert idx == BZXYZR_SIZE;
+ assert this.intpltBuf.position() == BZXYZR_SIZE;
redundantCopy();
/**
* 補間情報冗長部の組み立て。
+ * <p>※ MMDの版によって若干出力内容が異なる。
*/
private void redundantCopy(){
- int lack = 1;
- for(int ct = 1; ct < BZ_REDUNDANT; ct++){
- int sourceIdx = 0 + lack;
- int targetIdx = BZXYZR_SIZE * ct;
- int span = BZXYZR_SIZE - lack;
-
- System.arraycopy(this.motionIntplt, sourceIdx,
- this.motionIntplt, targetIdx,
- span );
-
- int onePos = targetIdx + span;
- this.motionIntplt[onePos] = (byte) 0x01;
-
- int zeroPosStart = onePos + 1;
- int zeroPosEnd = targetIdx + BZXYZR_SIZE;
- for(int idx = zeroPosStart; idx < zeroPosEnd; idx++){
- this.motionIntplt[idx] = (byte) 0x00;
- }
-
- lack++;
+ this.intpltBuf.position(BZXYZR_SIZE);
+
+ for(int lack = 1; lack < BZ_REDUNDANT; lack++){
+ this.rdBuf.position(lack);
+ this.intpltBuf.put(this.rdBuf);
+ this.intpltBuf.put(INTPLT_FILLER, 0, lack);
}
+ assert this.intpltBuf.position() == BZTOTAL_SIZE;
+
return;
}
*/
void dumpMorphMotion(VmdMotion motion)
throws IOException, IllegalTextExportException{
- NamedListMap<MorphMotion> map = motion.getMorphPartMap();
- List<String> nameList = map.getNames();
+ Map<String, List<MorphMotion>> map = motion.getMorphPartMap();
List<MorphMotion> morphList = new LinkedList<MorphMotion>();
-
- int count = 0;
- for(String name : nameList){
- List<MorphMotion> namedList = map.getNamedList(name);
- for(MorphMotion morphMotion : namedList){
- morphList.add(morphMotion);
- count++;
- }
+ for(List<MorphMotion> eachList : map.values()){
+ morphList.addAll(eachList);
}
- dumpLeInt(count);
+ dumpLeInt(morphList.size());
for(MorphMotion morphMotion : morphList){
String morphName = morphMotion.getMorphName();
* Copyright(c) 2011 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd.model.binio;
+package jp.sfjp.mikutoga.vmd.model.binio;
import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
import jp.sfjp.mikutoga.bin.parser.ParseStage;
import jp.sfjp.mikutoga.math.MkPos3D;
import jp.sfjp.mikutoga.math.MkQuat;
-import jp.sourceforge.mikutoga.vmd.model.BezierParam;
-import jp.sourceforge.mikutoga.vmd.model.BoneMotion;
-import jp.sourceforge.mikutoga.vmd.model.MorphMotion;
-import jp.sourceforge.mikutoga.vmd.model.PosCurve;
-import jp.sourceforge.mikutoga.vmd.model.VmdMotion;
-import jp.sourceforge.mikutoga.vmd.parser.VmdBasicHandler;
+import jp.sfjp.mikutoga.vmd.model.BezierParam;
+import jp.sfjp.mikutoga.vmd.model.BoneMotion;
+import jp.sfjp.mikutoga.vmd.model.MorphMotion;
+import jp.sfjp.mikutoga.vmd.model.PosCurve;
+import jp.sfjp.mikutoga.vmd.model.VmdMotion;
+import jp.sfjp.mikutoga.vmd.parser.VmdBasicHandler;
/**
* ボーンモーション、モーフ情報のビルダ。
/**
* コンストラクタ。
- * @param vmdMotion モーション情報
+ * @param vmdMotion モーションデータの格納先
*/
BasicLoader(VmdMotion vmdMotion){
super();
*/
@Override
public void vmdParseStart() throws MmdFormatException{
- // NOTHING
+ assert this.currentBoneMotion == null;
+ assert this.currentMorphMotion == null;
+
return;
}
public void vmdParseEnd(boolean hasMoreDataArg)
throws MmdFormatException{
this.hasMoreData = hasMoreDataArg;
+
+ assert this.currentBoneMotion == null;
+ assert this.currentMorphMotion == null;
+
return;
}
*/
@Override
public void vmdHeaderInfo(byte[] header) throws MmdFormatException{
- // NOTHING
+ assert header != null;
return;
}
* Copyright(c) 2011 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd.model.binio;
+package jp.sfjp.mikutoga.vmd.model.binio;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import jp.sfjp.mikutoga.bin.export.BinaryExporter;
import jp.sfjp.mikutoga.math.MkPos3D;
-import jp.sourceforge.mikutoga.vmd.model.BezierParam;
-import jp.sourceforge.mikutoga.vmd.model.CameraMotion;
-import jp.sourceforge.mikutoga.vmd.model.CameraRotation;
-import jp.sourceforge.mikutoga.vmd.model.PosCurve;
-import jp.sourceforge.mikutoga.vmd.model.VmdMotion;
+import jp.sfjp.mikutoga.vmd.model.BezierParam;
+import jp.sfjp.mikutoga.vmd.model.CameraMotion;
+import jp.sfjp.mikutoga.vmd.model.CameraRotation;
+import jp.sfjp.mikutoga.vmd.model.PosCurve;
+import jp.sfjp.mikutoga.vmd.model.VmdMotion;
/**
* カメラ情報のエクスポーター。
int frame = cameraMotion.getFrameNumber();
dumpLeInt(frame);
- float range = cameraMotion.getRange();
+ float range = (float) cameraMotion.getRange();
dumpLeFloat(range);
MkPos3D targetPos = cameraMotion.getCameraTarget();
dumpLeFloat((float) targetPos.getZpos());
CameraRotation rotation = cameraMotion.getCameraRotation();
- dumpLeFloat(rotation.getLatitude());
- dumpLeFloat(rotation.getLongitude());
- dumpLeFloat(rotation.getRoll());
+ dumpLeFloat((float) rotation.getLatitude());
+ dumpLeFloat((float) rotation.getLongitude());
+ dumpLeFloat((float) rotation.getRoll());
dumpCameraCurve(cameraMotion);
* Copyright(c) 2011 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd.model.binio;
+package jp.sfjp.mikutoga.vmd.model.binio;
import java.util.List;
import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
import jp.sfjp.mikutoga.bin.parser.ParseStage;
-import jp.sourceforge.mikutoga.vmd.model.BezierParam;
-import jp.sourceforge.mikutoga.vmd.model.CameraMotion;
-import jp.sourceforge.mikutoga.vmd.model.CameraRotation;
-import jp.sourceforge.mikutoga.vmd.model.PosCurve;
-import jp.sourceforge.mikutoga.vmd.model.VmdMotion;
-import jp.sourceforge.mikutoga.vmd.parser.VmdCameraHandler;
+import jp.sfjp.mikutoga.math.MkPos3D;
+import jp.sfjp.mikutoga.vmd.model.BezierParam;
+import jp.sfjp.mikutoga.vmd.model.CameraMotion;
+import jp.sfjp.mikutoga.vmd.model.CameraRotation;
+import jp.sfjp.mikutoga.vmd.model.PosCurve;
+import jp.sfjp.mikutoga.vmd.model.VmdMotion;
+import jp.sfjp.mikutoga.vmd.parser.VmdCameraHandler;
/**
* カメラ情報のビルダ。
/**
* コンストラクタ。
- * @param vmdMotion モーションデータ。
+ * @param vmdMotion ã\83¢ã\83¼ã\82·ã\83§ã\83³ã\83\87ã\83¼ã\82¿ã\81®æ ¼ç´\8då\85\88ã\80\82
*/
CameraLoader(VmdMotion vmdMotion){
super();
@Override
public void vmdCameraPosition(float xPos, float yPos, float zPos)
throws MmdFormatException{
- this.currentCameraMotion.getCameraTarget()
- .setPosition(xPos, yPos, zPos);
+ MkPos3D cameraPos = this.currentCameraMotion.getCameraTarget();
+ cameraPos.setPosition(xPos, yPos, zPos);
return;
}
* Copyright(c) 2011 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd.model.binio;
+package jp.sfjp.mikutoga.vmd.model.binio;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import jp.sfjp.mikutoga.bin.export.BinaryExporter;
-import jp.sourceforge.mikutoga.vmd.model.LuminousColor;
-import jp.sourceforge.mikutoga.vmd.model.LuminousMotion;
-import jp.sourceforge.mikutoga.vmd.model.LuminousVector;
-import jp.sourceforge.mikutoga.vmd.model.ShadowMode;
-import jp.sourceforge.mikutoga.vmd.model.ShadowMotion;
-import jp.sourceforge.mikutoga.vmd.model.VmdMotion;
+import jp.sfjp.mikutoga.math.MkVec3D;
+import jp.sfjp.mikutoga.vmd.model.LuminousColor;
+import jp.sfjp.mikutoga.vmd.model.LuminousMotion;
+import jp.sfjp.mikutoga.vmd.model.ShadowMode;
+import jp.sfjp.mikutoga.vmd.model.ShadowMotion;
+import jp.sfjp.mikutoga.vmd.model.VmdMotion;
/**
* ライティング情報のエクスポーター。
dumpLeFloat(color.getColG());
dumpLeFloat(color.getColB());
- LuminousVector vector = luminousMotion.getDirection();
- dumpLeFloat(vector.getVecX());
- dumpLeFloat(vector.getVecY());
- dumpLeFloat(vector.getVecZ());
+ MkVec3D vector = luminousMotion.getDirection();
+ dumpLeFloat((float) vector.getXVal());
+ dumpLeFloat((float) vector.getYVal());
+ dumpLeFloat((float) vector.getZVal());
}
return;
byte shadowType = mode.getEncodedByte();
dumpByte(shadowType);
- float rawParam = shadowMotion.getRawScopeParam();
+ float rawParam = (float) shadowMotion.getRawScopeParam();
dumpLeFloat(rawParam);
}
* Copyright(c) 2011 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd.model.binio;
+package jp.sfjp.mikutoga.vmd.model.binio;
import java.util.List;
import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
import jp.sfjp.mikutoga.bin.parser.ParseStage;
-import jp.sourceforge.mikutoga.vmd.model.LuminousColor;
-import jp.sourceforge.mikutoga.vmd.model.LuminousMotion;
-import jp.sourceforge.mikutoga.vmd.model.LuminousVector;
-import jp.sourceforge.mikutoga.vmd.model.ShadowMode;
-import jp.sourceforge.mikutoga.vmd.model.ShadowMotion;
-import jp.sourceforge.mikutoga.vmd.model.VmdMotion;
-import jp.sourceforge.mikutoga.vmd.parser.VmdLightingHandler;
+import jp.sfjp.mikutoga.math.MkVec3D;
+import jp.sfjp.mikutoga.vmd.model.LuminousColor;
+import jp.sfjp.mikutoga.vmd.model.LuminousMotion;
+import jp.sfjp.mikutoga.vmd.model.ShadowMode;
+import jp.sfjp.mikutoga.vmd.model.ShadowMotion;
+import jp.sfjp.mikutoga.vmd.model.VmdMotion;
+import jp.sfjp.mikutoga.vmd.parser.VmdLightingHandler;
/**
* ライティング情報のビルダ。
/**
* コンストラクタ。
- * @param vmdMotion モーションデータ。
+ * @param vmdMotion ã\83¢ã\83¼ã\82·ã\83§ã\83³ã\83\87ã\83¼ã\82¿ã\81®æ ¼ç´\8då\85\88ã\80\82
*/
LightingLoader(VmdMotion vmdMotion){
super();
@Override
public void vmdLuminousDirection(float xVec, float yVec, float zVec)
throws MmdFormatException{
- LuminousVector direction = this.currentLuminousMotion.getDirection();
- direction.setVecX(xVec);
- direction.setVecY(yVec);
- direction.setVecZ(zVec);
+ MkVec3D direction = this.currentLuminousMotion.getDirection();
+ direction.setXVal(xVec);
+ direction.setYVal(yVec);
+ direction.setZVal(zVec);
return;
}
--- /dev/null
+/*
+ * vmd exporter
+ *
+ * License : The MIT License
+ * Copyright(c) 2011 MikuToga Partners
+ */
+
+package jp.sfjp.mikutoga.vmd.model.binio;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import jp.sfjp.mikutoga.bin.export.IllegalTextExportException;
+import jp.sfjp.mikutoga.vmd.IllegalVmdDataException;
+import jp.sfjp.mikutoga.vmd.model.VmdMotion;
+
+/**
+ * VMDファイルのエクスポーター。
+ */
+public class VmdExporter {
+
+ private BasicExporter basicExporter;
+ private CameraExporter cameraExporter;
+ private LightingExporter lightingExporter;
+
+
+ /**
+ * コンストラクタ。
+ */
+ public VmdExporter(){
+ super();
+ return;
+ }
+
+ /**
+ * モーションデータをVMDファイル形式で出力する。
+ * <p>異常時には出力データのフラッシュが試みられる。
+ * @param motion モーションデータ
+ * @param ostream 出力先ストリーム
+ * @throws IOException 出力エラー
+ * @throws IllegalVmdDataException モーションデータに不備が発見された
+ */
+ public void dumpVmdMotion(VmdMotion motion, OutputStream ostream)
+ throws IOException, IllegalVmdDataException{
+ this.basicExporter = new BasicExporter(ostream);
+ this.cameraExporter = new CameraExporter(ostream);
+ this.lightingExporter = new LightingExporter(ostream);
+
+ try{
+ dumpVmdMotionImpl(motion);
+ }finally{
+ ostream.flush();
+ }
+
+ return;
+ }
+
+ /**
+ * モーションデータをVMDファイル形式で出力する。
+ * @param motion モーションデータ
+ * @throws IOException 出力エラー
+ * @throws IllegalVmdDataException モーションデータに不備が発見された
+ */
+ private void dumpVmdMotionImpl(VmdMotion motion)
+ throws IOException, IllegalVmdDataException{
+ this.basicExporter.dumpHeader();
+
+ try{
+ this.basicExporter.dumpModelName(motion);
+ this.basicExporter.dumpBoneMotion(motion);
+ this.basicExporter.dumpMorphMotion(motion);
+ }catch(IllegalTextExportException e){
+ throw new IllegalVmdDataException(e);
+ }
+
+ this.cameraExporter.dumpCameraMotion(motion);
+ this.lightingExporter.dumpLuminousMotion(motion);
+ this.lightingExporter.dumpShadowMotion(motion);
+
+ return;
+ }
+
+}
--- /dev/null
+/*
+ * VMD file loader
+ *
+ * License : The MIT License
+ * Copyright(c) 2011 MikuToga Partners
+ */
+
+package jp.sfjp.mikutoga.vmd.model.binio;
+
+import java.io.IOException;
+import java.io.InputStream;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.vmd.model.VmdMotion;
+import jp.sfjp.mikutoga.vmd.parser.VmdParser;
+
+/**
+ * VMDモーションファイルを読み込むためのバイナリローダ。
+ */
+public class VmdLoader {
+
+ private static final String ERR_TRYLOAD = "try loading first.";
+ private static final String ERR_LOADED = "has been loaded.";
+
+
+ private boolean loaded = false;
+ private boolean hasMoreData = true;
+
+ private boolean ignoreName = true;
+ private boolean redundantCheck = false;
+
+
+ /**
+ * コンストラクタ。
+ */
+ public VmdLoader(){
+ super();
+ return;
+ }
+
+
+ /**
+ * 正常パース時に読み残したデータがあったか判定する。
+ * @return 読み残したデータがあればtrue
+ * @throws IllegalStateException まだパースを試みていない。
+ */
+ public boolean hasMoreData() throws IllegalStateException{
+ if( ! this.loaded ) throw new IllegalStateException(ERR_TRYLOAD);
+ return this.hasMoreData;
+ }
+
+ /**
+ * カメラ・ライティングデータのパースを試みるか否かの判断で、
+ * 特殊モデル名判定を無視するか否か設定する。
+ * デフォルトではモデル名を無視。
+ * <p>※MMDVer7.30前後のVMD出力不具合を回避したい場合は、
+ * オフにするとパースに成功する場合がある。
+ * @param mode モデル名を無視してパースを強行するならtrue
+ */
+ public void setIgnoreName(boolean mode){
+ this.ignoreName = mode;
+ return;
+ }
+
+ /**
+ * ボーンモーション補間情報冗長部のチェックを行うか否か設定する。
+ * デフォルトではチェックを行わない。
+ * <p>※MMDVer7.30前後のVMD出力不具合を回避したい場合は、
+ * オフにするとパースに成功する場合がある。
+ * @param mode チェックさせたければtrue
+ */
+ public void setRedundantCheck(boolean mode){
+ this.redundantCheck = mode;
+ return;
+ }
+
+ /**
+ * VMDファイルの読み込みを行いモーション情報を返す。
+ * 1インスタンスにつき一度しかロードできない。
+ * @param source VMDファイル入力ソース
+ * @return モーション情報
+ * @throws IOException 入力エラー
+ * @throws MmdFormatException VMDファイルフォーマットの異常を検出
+ * @throws IllegalStateException このインスタンスで再度のロードを試みた。
+ */
+ public VmdMotion load(InputStream source)
+ throws IOException,
+ MmdFormatException,
+ IllegalStateException {
+ if(this.loaded) throw new IllegalStateException(ERR_LOADED);
+
+ VmdMotion motion = new VmdMotion();
+
+ VmdParser parser = new VmdParser(source);
+
+ parser.setIgnoreName(this.ignoreName);
+ parser.setRedundantCheck(this.redundantCheck);
+
+ BasicLoader basicBuilder = new BasicLoader(motion);
+ CameraLoader cameraBuilder = new CameraLoader(motion);
+ LightingLoader lightingBuilder = new LightingLoader(motion);
+
+ parser.setBasicHandler(basicBuilder);
+ parser.setCameraHandler(cameraBuilder);
+ parser.setLightingHandler(lightingBuilder);
+
+ try{
+ parser.parseVmd();
+ this.hasMoreData = basicBuilder.hasMoreData();
+ }finally{
+ this.loaded = true;
+ }
+
+ return motion;
+ }
+
+}
* 独自データモデル向けVMDモーションファイル(*.vmd)用入出力ライブラリ。
*/
-package jp.sourceforge.mikutoga.vmd.model.binio;
+package jp.sfjp.mikutoga.vmd.model.binio;
/* EOF */
/**
* VMDモーションファイル内の各要素に相当するオブジェクト各種。
- * <p>VMDを正確に記述するのが主目的。使い勝手は二の次。
*/
-package jp.sourceforge.mikutoga.vmd.model;
+package jp.sfjp.mikutoga.vmd.model;
/* EOF */
--- /dev/null
+/*
+ * command line parser
+ *
+ * License : The MIT License
+ * Copyright(c) 2013 MikuToga Partners
+ */
+
+package jp.sfjp.mikutoga.vmd2xml;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * コマンドラインの1オプションとその引数群に相当。
+ */
+final class CmdLine {
+
+ private OptSwitch opt;
+ private List<String> optArgs;
+
+
+ /**
+ * コンストラクタ。
+ */
+ private CmdLine() {
+ super();
+ return;
+ }
+
+
+ /**
+ * コマンドライン解析を行う。
+ * @param args コマンドライン
+ * @return 解析されたコマンドライン並び
+ */
+ static List<CmdLine> parse(String... args){
+ List<String> list = Arrays.asList(args);
+ return parse(list);
+ }
+
+ /**
+ * コマンドライン解析を行う。
+ * @param argList コマンドライン
+ * @return 解析されたコマンドライン並び
+ */
+ static List<CmdLine> parse(List<String> argList){
+ List<CmdLine> result = new LinkedList<CmdLine>();
+
+ Iterator<String> it = argList.iterator();
+ while (it.hasNext()) {
+ String arg = it.next();
+
+ CmdLine info = new CmdLine();
+ result.add(info);
+
+ info.opt = OptSwitch.parse(arg);
+
+ int exArgNum = 0;
+ if (info.opt != null) {
+ exArgNum = info.opt.getExArgNum();
+ }
+ info.optArgs = new ArrayList<String>(exArgNum + 1);
+
+ info.optArgs.add(arg);
+
+ for (int argCt = 0; argCt < exArgNum; argCt++) {
+ if ( ! it.hasNext()) {
+ break;
+ }
+ String exarg = it.next();
+ info.optArgs.add(exarg);
+ }
+ }
+
+ return result;
+ }
+
+
+ /**
+ * オプション識別子を返す。
+ * @return オプション識別子。
+ * オプションを伴わない単純なコマンドライン引数の場合はnullを返す。
+ */
+ OptSwitch getOptSwitch() {
+ return this.opt;
+ }
+
+ /**
+ * オプションに付随する引数群を返す。
+ * @return オプションに付随する引数群。
+ * 先頭要素はオプション識別子。
+ * 単純なコマンドライン引数の場合は自身が1要素のみを占める。
+ */
+ List<String> getOptArgs() {
+ return this.optArgs;
+ }
+
+}
--- /dev/null
+/*
+ * command line exception
+ *
+ * License : The MIT License
+ * Copyright(c) 2013 MikuToga Partners
+ */
+
+package jp.sfjp.mikutoga.vmd2xml;
+
+/**
+ * コマンドライン引数の不備による異常系。
+ */
+@SuppressWarnings("serial")
+class CmdLineException extends Exception{
+
+ /**
+ * コンストラクタ。
+ * @param message {@inheritDoc}
+ */
+ public CmdLineException(String message) {
+ super(message);
+ return;
+ }
+
+}
* Copyright(c) 2013 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd2xml;
+package jp.sfjp.mikutoga.vmd2xml;
/**
* モーションファイル種別。
--- /dev/null
+/*
+ * command line argument info
+ *
+ * License : The MIT License
+ * Copyright(c) 2013 MikuToga Partners
+ */
+
+package jp.sfjp.mikutoga.vmd2xml;
+
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * コマンドラインオプション情報。
+ */
+final class OptInfo {
+
+ private static final String EOL_LF = "\n";
+ private static final String EOL_CRLF = "\r\n";
+ private static final String EOL_DEFAULT = EOL_LF;
+
+ private static final String FORMAT_VMD = "vmd";
+ private static final String FORMAT_XML = "xml";
+ private static final String FORMAT_XML110820 = "xml110820";
+
+ private static final String SFX_VMD = ".vmd";
+ private static final String SFX_XML = ".xml";
+
+ private static final String NL_LF = "lf";
+ private static final String NL_CRLF = "crlf";
+
+ private static final String GENERATOR =
+ Vmd2Xml.APPNAME + ' ' + Vmd2Xml.APPVER;
+
+ private static final String ERRMSG_UNKNOWN =
+ "Unknown option : {0}";
+ private static final String ERRMSG_MOREARG =
+ "You need option arg with : {0}";
+ private static final String ERRMSG_INTYPE =
+ "You must specify input format with -iform.";
+ private static final String ERRMSG_OUTTYPE =
+ "You must specify output format with -oform.";
+ private static final String ERRMSG_NOINFILE =
+ "You must specify input file with -i.";
+ private static final String ERRMSG_NOOUTFILE =
+ "You must specify output file with -o.";
+ private static final String ERRMSG_INVFORM =
+ "Unknown format : \"{0}\" must be \"vmd\" or \"xml\" "
+ + "or \"xml110820\"";
+ private static final String ERRMSG_INVNL =
+ "Unknown newline : \"{0}\" must be \"lf\" or \"crlf\"";
+ private static final String ERRMSG_INVBOOL =
+ "Unknown switch : \"{0}\" must be \"on\" or \"off\"";
+
+
+ private boolean needHelp = false;
+ private MotionFileType inTypes = MotionFileType.NONE;
+ private MotionFileType outTypes = MotionFileType.NONE;
+ private String inFilename = null;
+ private String outFilename = null;
+ private boolean overwrite = false;
+ private String newline = EOL_DEFAULT;
+ private String generator = GENERATOR;
+ private boolean isQuaternionMode = true;
+
+
+ /**
+ * コンストラクタ。
+ */
+ private OptInfo(){
+ super();
+ return;
+ }
+
+
+ /**
+ * フォーマット種別指定子をデコードする。
+ * @param arg 文字列
+ * @return デコード結果。
+ * @throws CmdLineException 不正なフォーマット種別
+ */
+ private static MotionFileType decodeFormatType(String arg)
+ throws CmdLineException{
+ MotionFileType result;
+
+ if (FORMAT_VMD.equals(arg)){
+ result = MotionFileType.VMD;
+ }else if(FORMAT_XML.equals(arg)){
+ result = MotionFileType.XML_110820;
+ }else if(FORMAT_XML110820.equals(arg)){
+ result = MotionFileType.XML_110820;
+ }else{
+ String errMsg = MessageFormat.format(ERRMSG_INVFORM, arg);
+ throw new CmdLineException(errMsg);
+ }
+
+ return result;
+ }
+
+ /**
+ * 改行文字指定子をデコードする。
+ * @param arg 文字列
+ * @return デコード結果。
+ * @throws CmdLineException 不正なフォーマット種別
+ */
+ private static String decodeNewline(String arg)
+ throws CmdLineException{
+ String result;
+
+ if (NL_LF.equals(arg)){
+ result = EOL_LF;
+ }else if(NL_CRLF.equals(arg)){
+ result = EOL_CRLF;
+ }else{
+ String errMsg = MessageFormat.format(ERRMSG_INVNL, arg);
+ throw new CmdLineException(errMsg);
+ }
+
+ return result;
+ }
+
+ /**
+ * ブール指定子をデコードする。
+ * @param arg 文字列
+ * @return デコード結果。
+ * @throws CmdLineException 不正なフォーマット種別
+ */
+ private static boolean decodeBoolean(String arg)
+ throws CmdLineException{
+ boolean result;
+
+ if( "on" .equals(arg)
+ || "true".equals(arg)
+ || "yes" .equals(arg) ){
+ result = true;
+ }else if( "off" .equals(arg)
+ || "false".equals(arg)
+ || "no" .equals(arg) ){
+ result = false;
+ }else{
+ String errMsg = MessageFormat.format(ERRMSG_INVBOOL, arg);
+ throw new CmdLineException(errMsg);
+ }
+
+ return result;
+ }
+
+ /**
+ * ファイル名からファイル種別を類推する。
+ * <p>拡張子が「.vmd」ならVMDファイル、「.xml」ならXMLファイル。
+ * @param fileName ファイル名
+ * @return ファイル種別。識別不可ならNONE。
+ */
+ private static MotionFileType getFileType(String fileName){
+ MotionFileType result = MotionFileType.NONE;
+ if(fileName == null) return result;
+
+ String lower = fileName.toLowerCase(Locale.ROOT);
+ if (lower.endsWith(SFX_VMD)) result = MotionFileType.VMD;
+ else if(lower.endsWith(SFX_XML)) result = MotionFileType.XML_110820;
+
+ return result;
+ }
+
+ /**
+ * コマンドラインを解析する。
+ * @param args コマンドライン
+ * @return オプション情報
+ * @throws CmdLineException 不正なコマンドライン
+ */
+ static OptInfo parseOption(String... args) throws CmdLineException{
+ OptInfo result = new OptInfo();
+
+ List<CmdLine> cmdLines = CmdLine.parse(args);
+ for(CmdLine cmd : cmdLines){
+ OptSwitch opt = cmd.getOptSwitch();
+ if(opt == OptSwitch.OPT_HELP){
+ result.needHelp = true;
+ return result;
+ }
+ }
+
+ checkCmdLineList(cmdLines);
+
+ for(CmdLine cmd : cmdLines){
+ List<String> optArgs = cmd.getOptArgs();
+ String exArg1 = null;
+ if(optArgs.size() >= 2){
+ exArg1 = optArgs.get(1);
+ }
+
+ OptSwitch opt = cmd.getOptSwitch();
+ switch(opt){
+ case OPT_HELP:
+ break;
+ case OPT_FORCE:
+ result.overwrite = true;
+ break;
+ case OPT_INFILE:
+ result.inFilename = exArg1;
+ break;
+ case OPT_OUTFILE:
+ result.outFilename = exArg1;
+ break;
+ case OPT_NEWLINE:
+ result.newline = decodeNewline(exArg1);
+ break;
+ case OPT_GENOUT:
+ boolean genout = decodeBoolean(exArg1);
+ if(genout) result.generator = GENERATOR;
+ else result.generator = null;
+ break;
+ case OPT_QUAT:
+ result.isQuaternionMode = true;
+ break;
+ case OPT_EYXZ:
+ result.isQuaternionMode = false;
+ break;
+ case OPT_IFORM:
+ MotionFileType itype = decodeFormatType(exArg1);
+ result.inTypes = itype;
+ break;
+ case OPT_OFORM:
+ MotionFileType otype = decodeFormatType(exArg1);
+ result.outTypes = otype;
+ break;
+ default:
+ assert false;
+ throw new AssertionError();
+ }
+ }
+
+ fixFormat(result);
+
+ checkResult(result);
+
+ return result;
+ }
+
+ /**
+ * 単純なコマンドラインエラーを検出する。
+ * <p>検出項目は未知のオプションおよび不正な引数の個数
+ * @param cmdLines コマンドライン
+ * @throws CmdLineException 異常系
+ */
+ private static void checkCmdLineList(List<CmdLine> cmdLines)
+ throws CmdLineException{
+ for(CmdLine cmd : cmdLines){
+ List<String> optArgs = cmd.getOptArgs();
+ assert ! optArgs.isEmpty();
+
+ String optTxt = optArgs.get(0);
+ assert optTxt != null;
+
+ OptSwitch opt = cmd.getOptSwitch();
+ if(opt == null){
+ String errMsg =
+ MessageFormat.format(ERRMSG_UNKNOWN, optTxt);
+ throw new CmdLineException(errMsg);
+ }
+
+ int exArgNum = opt.getExArgNum();
+ if(optArgs.size() != 1 + exArgNum){
+ String errMsg =
+ MessageFormat.format(ERRMSG_MOREARG, optTxt);
+ throw new CmdLineException(errMsg);
+ }
+ }
+
+ return;
+ }
+
+ /**
+ * ファイルフォーマット情報の推測を行う。
+ * @param result オプション情報
+ */
+ private static void fixFormat(OptInfo result){
+ if(result.inTypes == MotionFileType.NONE){
+ result.inTypes = getFileType(result.inFilename);
+ }
+
+ if(result.outTypes == MotionFileType.NONE){
+ result.outTypes = getFileType(result.outFilename);
+ }
+
+ return;
+ }
+
+ /**
+ * オプション整合性の事後検査。
+ * @param result オプション情報
+ * @throws CmdLineException 不正なオプション設定
+ */
+ private static void checkResult(OptInfo result)
+ throws CmdLineException{
+ if(result.getInFilename() == null){
+ throw new CmdLineException(ERRMSG_NOINFILE);
+ }
+
+ if(result.getOutFilename() == null){
+ throw new CmdLineException(ERRMSG_NOOUTFILE);
+ }
+
+ if(result.getInFileType() == MotionFileType.NONE){
+ throw new CmdLineException(ERRMSG_INTYPE);
+ }
+
+ if(result.getOutFileType() == MotionFileType.NONE){
+ throw new CmdLineException(ERRMSG_OUTTYPE);
+ }
+
+ return;
+ }
+
+
+ /**
+ * ヘルプ表示が必要か否か判定する。
+ * @return 必要ならtrue
+ */
+ boolean needHelp(){
+ return this.needHelp;
+ }
+
+ /**
+ * 入力ファイル種別を返す。
+ * @return 入力ファイル種別
+ */
+ MotionFileType getInFileType(){
+ return this.inTypes;
+ }
+
+ /**
+ * 出力ファイル種別を返す。
+ * @return 出力ファイル種別
+ */
+ MotionFileType getOutFileType(){
+ return this.outTypes;
+ }
+
+ /**
+ * 入力ファイル名を返す。
+ * @return 入力ファイル名
+ */
+ String getInFilename(){
+ return this.inFilename;
+ }
+
+ /**
+ * 出力ファイル名を返す。
+ * @return 出力ファイル名
+ */
+ String getOutFilename(){
+ return this.outFilename;
+ }
+
+ /**
+ * 上書きモードか否か返す。
+ * @return 上書きモードならtrue
+ */
+ boolean overwriteMode(){
+ return this.overwrite;
+ }
+
+ /**
+ * XML改行文字を返す。
+ * @return 改行文字
+ */
+ String getNewline(){
+ return this.newline;
+ }
+
+ /**
+ * ジェネレータ名を返す。
+ * @return ジェネレータ名。表示したくない時はnull
+ */
+ String getGenerator(){
+ return this.generator;
+ }
+
+ /**
+ * 回転情報のXML出力形式を得る。
+ * @return クォータニオン形式ならtrue、YXZオイラー角形式ならfalse。
+ */
+ boolean isQuaterniomMode(){
+ return this.isQuaternionMode;
+ }
+
+}
--- /dev/null
+/*
+ * command line option definition
+ *
+ * License : The MIT License
+ * Copyright(c) 2013 MikuToga Partners
+ */
+
+package jp.sfjp.mikutoga.vmd2xml;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * オプションスイッチ群定義。
+ */
+enum OptSwitch {
+
+ OPT_HELP (0, "-h", "-help", "-?"),
+ OPT_INFILE (1, "-i"),
+ OPT_OUTFILE (1, "-o"),
+ OPT_FORCE (0, "-f"),
+ OPT_NEWLINE (1, "-nl"),
+ OPT_GENOUT (1, "-genout"),
+ OPT_IFORM (1, "-iform"),
+ OPT_OFORM (1, "-oform"),
+ OPT_QUAT (0, "-quat"),
+ OPT_EYXZ (0, "-eyxz"),
+ ;
+
+ private static final String HELP_CONSOLE =
+ "-h : put help message\n\n"
+ + "-i <file> : specify input file\n"
+ + "-o <file> : specify output file\n"
+ + "-f : force overwriting\n\n"
+ + "-nl <newline> : specify XML-newline character"
+ + " (default:lf)\n"
+ + "-genout <bool> : mark generator-name to XML"
+ + " (default:on)\n\n"
+ + "-quat : Quaternion form rotation (default)\n"
+ + "-eyxz : Euler-YXZ form rotation\n\n"
+ + "-iform <format> : specify input format explicitly\n"
+ + "-oform <format> : specify output format explicitly\n\n"
+ + " bool : \"on\" or \"off\""
+ + " or \"true\" or \"false\""
+ + " or \"yes\" or \"no\"\n"
+ + " format : \"vmd\" or \"xml\" or"
+ + " \"xml110820\"\n"
+ + " newline : \"lf\" or \"crlf\"\n"
+ ;
+
+ private static final Map<String, OptSwitch> MAP_OPT;
+
+ static{
+ Map<String, OptSwitch> map = new HashMap<String, OptSwitch>();
+
+ for(OptSwitch opt : values()){
+ for(String cmdarg : opt.cmdopts){
+ map.put(cmdarg, opt);
+ }
+ }
+
+ map = Collections.unmodifiableMap(map);
+ MAP_OPT = map;
+ }
+
+
+ private final int exArgNum;
+ private final List<String> cmdopts;
+
+
+ /**
+ * コンストラクタ。
+ * @param argnum 必要な引数の数
+ * @param cmdopts オプションスイッチパターン群
+ */
+ private OptSwitch(int argnum, String... cmdopts) {
+ this.exArgNum = argnum;
+
+ List<String> optlist;
+ optlist = Arrays.asList(cmdopts);
+ optlist = Collections.unmodifiableList(optlist);
+ this.cmdopts = optlist;
+
+ return;
+ }
+
+
+ /**
+ * コンソール提示用ヘルプ出力文字列を返す。
+ * @return オプションヘルプ文字列
+ */
+ static String getConsoleHelp(){
+ return HELP_CONSOLE;
+ }
+
+ /**
+ * 文字列に合致するオプションを返す。
+ * <p>一つのオプションが複数の表記に合致する場合がある。
+ * @param cmd 文字列
+ * @return オプション種別。合致する物が見つからなければnull
+ */
+ static OptSwitch parse(String cmd){
+ OptSwitch result = MAP_OPT.get(cmd);
+ return result;
+ }
+
+
+ /**
+ * 各オプションに後続する引数の数を返す。
+ * <p>引数をとらないオプションは0を返す。
+ * @return 引数の数
+ */
+ int getExArgNum(){
+ return this.exArgNum;
+ }
+
+}
--- /dev/null
+/*
+ * vmd to xml converter main entry
+ *
+ * License : The MIT License
+ * Copyright(c) 2011 MikuToga Partners
+ */
+
+package jp.sfjp.mikutoga.vmd2xml;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.nio.channels.FileChannel;
+import java.text.MessageFormat;
+import java.util.Properties;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.vmd.IllegalVmdDataException;
+import jp.sourceforge.mikutoga.xml.TogaXmlException;
+import org.xml.sax.SAXException;
+
+
+/**
+ * VMDモーションファイルとXMLとの間で変換を行うアプリケーション。
+ */
+public final class Vmd2Xml {
+
+ /** 正常系。 */
+ public static final int EXIT_OK = 0;
+ /** 内部エラー。 */
+ public static final int EXIT_INTERR = 1;
+ /** 実行環境に起因するエラー。 */
+ public static final int EXIT_ENVERR = 2;
+ /** オプション指定に起因するエラー。 */
+ public static final int EXIT_OPTERR = 3;
+ /** ファイル入出力に起因するエラー。 */
+ public static final int EXIT_IOERR = 4;
+ /** XMLフォーマットに起因するエラー。 */
+ public static final int EXIT_XMLERR = 5;
+ /** VMDフォーマットに起因するエラー。 */
+ public static final int EXIT_VMDERR = 7;
+
+ /** アプリ名。 */
+ public static final String APPNAME;
+ /** バージョン識別子。 */
+ public static final String APPVER;
+ /** ライセンス種別。 */
+ public static final String APPLICENSE;
+ /** 開発元URL。 */
+ public static final String APPURL;
+
+ private static final Class<?> THISCLASS;
+ private static final String RES_VER = "resources/version.properties";
+
+ private static final PrintStream ERROUT = System.err;
+ private static final String MSG_ERR = "ERROR:\n{0}\n(-h for help)";
+ private static final String MSG_HELP =
+ "{0} {1}\n"
+ + "\u0020\u0020License\u0020:\u0020{2}\n"
+ + "\u0020\u0020{3}\n";
+ private static final String MSG_NOINFILE = "Can't find input file:{0}";
+ private static final String MSG_ABNFILE = "{0} is not file.";
+ private static final String MSG_OWOUTFILE =
+ "{0} already exists.\n"
+ + "If you want to overwrite, use -f.";
+
+ private static final String MSG_OLDJRE = "You need JRE {0} or later.";
+ private static final String REQUIRED_JRE = "1.6";
+
+ static{
+ THISCLASS = Vmd2Xml.class;
+ InputStream ver = THISCLASS.getResourceAsStream(RES_VER);
+ Properties verProps = new Properties();
+ try{
+ try{
+ verProps.load(ver);
+ }finally{
+ ver.close();
+ }
+ }catch(IOException e){
+ throw new ExceptionInInitializerError(e);
+ }
+
+ APPNAME = verProps.getProperty("app.name");
+ APPVER = verProps.getProperty("app.version");
+ APPLICENSE = verProps.getProperty("app.license");
+ APPURL = verProps.getProperty("app.url");
+
+ new Vmd2Xml().hashCode();
+ }
+
+
+ /**
+ * ダミーコンストラクタ。
+ */
+ private Vmd2Xml(){
+ super();
+ assert this.getClass().equals(THISCLASS);
+ return;
+ }
+
+
+ /**
+ * VMを終了させる。
+ * @param code 終了コード
+ * @see java.lang.System#exit(int)
+ */
+ private static void exit(int code){
+ System.exit(code);
+ assert false;
+ throw new AssertionError();
+ }
+
+ /**
+ * 共通エラーメッセージを出力する。
+ * @param text 個別メッセージ
+ */
+ private static void errMsg(String text){
+ String msg = MessageFormat.format(MSG_ERR, text);
+ ERROUT.println(msg);
+ return;
+ }
+
+ /**
+ * 標準エラー出力へ例外情報出力。
+ * @param ex 例外
+ * @param dumpStack スタックトレースを出力するならtrue
+ */
+ private static void thPrintln(Throwable ex, boolean dumpStack){
+ if(dumpStack){
+ ex.printStackTrace(ERROUT);
+ }else{
+ String text = ex.toString();
+ ERROUT.println(text);
+ }
+
+ return;
+ }
+
+ /**
+ * 標準エラー出力へ例外情報出力。
+ * @param ex 例外
+ */
+ private static void thPrintln(Throwable ex){
+ thPrintln(ex, false);
+ return;
+ }
+
+ /**
+ * 入出力エラー処理。
+ * 例外を出力してVM終了する。
+ * @param ex 例外
+ */
+ private static void ioError(IOException ex){
+ thPrintln(ex);
+ exit(EXIT_IOERR);
+ }
+
+ /**
+ * XML構文エラー処理。
+ * 例外を出力してVM終了する。
+ * @param ex 例外
+ */
+ private static void xmlError(Throwable ex){
+ thPrintln(ex);
+ exit(EXIT_XMLERR);
+ }
+
+ /**
+ * VMDファイルフォーマットエラー処理。
+ * 例外を出力してVM終了する。
+ * @param ex 例外
+ */
+ private static void vmdError(MmdFormatException ex){
+ thPrintln(ex, true);
+ exit(EXIT_VMDERR);
+ }
+
+ /**
+ * 内部エラー処理。
+ * 例外を出力してVM終了する。
+ * @param ex 例外
+ */
+ private static void internalError(Throwable ex){
+ thPrintln(ex, true);
+ exit(EXIT_INTERR);
+ }
+
+ /**
+ * JREのバージョン判定を行う。
+ * 不適切ならVMごと終了。
+ */
+ private static void checkJRE(){
+ Package jrePackage = java.lang.Object.class.getPackage();
+ if( ! jrePackage.isCompatibleWith(REQUIRED_JRE)){
+ String msg = MessageFormat.format(MSG_OLDJRE, REQUIRED_JRE);
+ ERROUT.println(msg);
+ exit(EXIT_ENVERR);
+ }
+ return;
+ }
+
+ /**
+ * ヘルプメッセージを出力する。
+ */
+ private static void putHelp(){
+ String msg =
+ MessageFormat.format(MSG_HELP,
+ APPNAME, APPVER, APPLICENSE, APPURL);
+ ERROUT.println(msg);
+ ERROUT.println(OptSwitch.getConsoleHelp());
+ return;
+ }
+
+ /**
+ * ファイルサイズを0に切り詰める。
+ * <p>ファイルが存在しなければなにもしない。
+ * <p>通常ファイルでなければなにもしない。
+ * @param file ファイル
+ * @throws IOException 入出力エラー
+ */
+ private static void trunc(File file) throws IOException{
+ if( ! file.exists() ) return;
+ if( ! file.isFile() ) return;
+
+ if(file.length() <= 0L) return;
+
+ FileOutputStream foStream = new FileOutputStream(file);
+ try{
+ FileChannel channnel = foStream.getChannel();
+ try{
+ channnel.truncate(0L);
+ }finally{
+ channnel.close();
+ }
+ }finally{
+ foStream.close();
+ }
+
+ return;
+ }
+
+ /**
+ * 入力ストリームを準備する。
+ * <p>入力ファイルが通常ファイルとして存在しなければエラー終了。
+ * @param fileName 入力ファイル名
+ * @return 入力ストリーム
+ */
+ private static InputStream openInfile(String fileName){
+ File inFile = new File(fileName);
+
+ if( (! inFile.exists()) || (! inFile.isFile()) ){
+ String absPath = inFile.getAbsolutePath();
+ String msg = MessageFormat.format(MSG_NOINFILE, absPath);
+ errMsg(msg);
+ exit(EXIT_IOERR);
+ }
+
+ InputStream is;
+ try{
+ is = new FileInputStream(inFile);
+ }catch(FileNotFoundException e){
+ ioError(e);
+ assert false;
+ throw new AssertionError(e);
+ }
+
+ is = new BufferedInputStream(is);
+
+ return is;
+ }
+
+ /**
+ * 出力ストリームを準備する。
+ * <p>出力ファイルが通常ファイルでない場合はエラー終了。
+ * <p>既存の出力ファイルに上書き指示が伴っていなければエラー終了。
+ * @param fileName 出力ファイル名
+ * @param overWrite 頭から上書きして良ければtrue
+ * @return 出力ストリーム
+ */
+ private static OutputStream openOutfile(String fileName,
+ boolean overWrite) {
+ File outFile = new File(fileName);
+
+ if(outFile.exists()){
+ String absPath = outFile.getAbsolutePath();
+ if( ! outFile.isFile() ){
+ String msg = MessageFormat.format(MSG_ABNFILE, absPath);
+ errMsg(msg);
+ exit(EXIT_IOERR);
+ }else if( ! overWrite ){
+ String msg = MessageFormat.format(MSG_OWOUTFILE, absPath);
+ errMsg(msg);
+ exit(EXIT_IOERR);
+ }
+ }
+
+ try{
+ trunc(outFile);
+ }catch(IOException e){
+ ioError(e);
+ }
+
+ OutputStream os;
+ try{
+ os = new FileOutputStream(outFile);
+ }catch(FileNotFoundException e){
+ ioError(e);
+ assert false;
+ throw new AssertionError(e);
+ }
+
+ os = new BufferedOutputStream(os);
+
+ return os;
+ }
+
+ /**
+ * Mainエントリ。
+ * @param args コマンドパラメータ
+ */
+ public static void main(String[] args){
+ checkJRE();
+
+ OptInfo optInfo;
+ try{
+ optInfo = OptInfo.parseOption(args);
+ }catch(CmdLineException e){
+ String optErrMsg = e.getLocalizedMessage();
+ errMsg(optErrMsg);
+ exit(EXIT_OPTERR);
+ return;
+ }
+
+ if(optInfo.needHelp()){
+ putHelp();
+ exit(EXIT_OK);
+ }
+
+ String inputFile = optInfo.getInFilename();
+ String outputFile = optInfo.getOutFilename();
+ boolean overwrite = optInfo.overwriteMode();
+
+ InputStream is = openInfile(inputFile);
+ OutputStream os = openOutfile(outputFile, overwrite);
+
+ Vmd2XmlConv converter = new Vmd2XmlConv();
+
+ converter.setInType (optInfo.getInFileType());
+ converter.setOutType(optInfo.getOutFileType());
+
+ converter.setNewline(optInfo.getNewline());
+ converter.setGenerator(optInfo.getGenerator());
+ converter.setQuaterniomMode(optInfo.isQuaterniomMode());
+
+ try{
+ converter.convert(is, os);
+ }catch(IOException e){
+ ioError(e);
+ }catch(IllegalVmdDataException e){
+ internalError(e);
+ }catch(MmdFormatException e){
+ vmdError(e);
+ }catch(TogaXmlException e){
+ xmlError(e);
+ }catch(SAXException e){
+ xmlError(e);
+ }
+
+ try{
+ is.close();
+ try{
+ os.close();
+ }catch(IOException e){
+ ioError(e);
+ }
+ }catch(IOException e){
+ ioError(e);
+ }
+
+ exit(EXIT_OK);
+
+ return;
+ }
+
+}
* Copyright(c) 2013 MikuToga Partners
*/
-package jp.sourceforge.mikutoga.vmd2xml;
+package jp.sfjp.mikutoga.vmd2xml;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.validation.Schema;
import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.vmd.IllegalVmdDataException;
-import jp.sourceforge.mikutoga.vmd.model.VmdMotion;
-import jp.sourceforge.mikutoga.vmd.model.binio.VmdExporter;
-import jp.sourceforge.mikutoga.vmd.model.binio.VmdLoader;
+import jp.sfjp.mikutoga.vmd.IllegalVmdDataException;
+import jp.sfjp.mikutoga.vmd.model.VmdMotion;
+import jp.sfjp.mikutoga.vmd.model.binio.VmdExporter;
+import jp.sfjp.mikutoga.vmd.model.binio.VmdLoader;
import jp.sourceforge.mikutoga.vmd.model.xml.Schema110820;
import jp.sourceforge.mikutoga.vmd.model.xml.VmdXmlExporter;
import jp.sourceforge.mikutoga.vmd.model.xml.Xml2VmdLoader;
import jp.sourceforge.mikutoga.xml.BotherHandler;
-import jp.sourceforge.mikutoga.xml.LocalSchema;
+import jp.sourceforge.mikutoga.xml.SchemaUtil;
import jp.sourceforge.mikutoga.xml.TogaXmlException;
import jp.sourceforge.mikutoga.xml.XmlResourceResolver;
import org.xml.sax.InputSource;
private MotionFileType outTypes = MotionFileType.NONE;
private String newLine = "\r\n";
private String generator = null;
+ private boolean isQuaternionMode = true;
/**
XmlResourceResolver resolver = new XmlResourceResolver();
Schema schema;
- schema = LocalSchema.newSchema(resolver, new Schema110820());
+ schema = SchemaUtil.newSchema(resolver, Schema110820.SINGLETON);
DocumentBuilderFactory builderFactory =
DocumentBuilderFactory.newInstance();
* @param type ファイル種別
* @throws IllegalArgumentException 具体的な種別を渡さなかった
*/
- public void setInType(MotionFileType type){
+ public void setInType(MotionFileType type)
+ throws IllegalArgumentException {
if(type == null) throw new NullPointerException();
if(type == MotionFileType.NONE) throw new IllegalArgumentException();
this.inTypes = type;
* @param type ファイル種別
* @throws IllegalArgumentException 具体的な種別を渡さなかった
*/
- public void setOutType(MotionFileType type){
+ public void setOutType(MotionFileType type)
+ throws IllegalArgumentException {
if(type == null) throw new NullPointerException();
if(type == MotionFileType.NONE) throw new IllegalArgumentException();
this.outTypes = type;
* XML出力用改行文字列を返す。
* @return 改行文字
*/
- public String getNewLine(){
+ public String getNewline(){
return this.newLine;
}
}
/**
+ * 回転情報をクォータニオン形式でXML出力するか設定する。
+ * @param sw クォータニオン形式ならtrue、
+ * YXZオイラー角で出力したければfalse。
+ */
+ public void setQuaterniomMode(boolean sw){
+ this.isQuaternionMode = sw;
+ return;
+ }
+
+ /**
+ * 回転情報のXML出力形式を得る。
+ * @return クォータニオン形式ならtrue、YXZオイラー角形式ならfalse。
+ */
+ public boolean isQuaterniomMode(){
+ return this.isQuaternionMode;
+ }
+
+ /**
* ファイル変換を行う。
* @param is 入力ストリーム
* @param os 出力ストリーム
TogaXmlException,
IllegalVmdDataException {
VmdMotion motion = readMotion(is);
+ motion.frameSort();
writeMotion(motion, os);
return;
}
* @throws MmdFormatException フォーマットエラー
* @throws SAXException XMLエラー
* @throws TogaXmlException XMLエラー
- * @throws IllegalStateException ファイル種別がまた指定されていない
*/
public VmdMotion readMotion(InputStream is)
throws IOException,
* @param os 出力ストリーム
* @throws IOException 出力エラー
* @throws IllegalVmdDataException データの不備
- * @throws IllegalStateException ファイル種別がまた指定されていない
*/
public void writeMotion(VmdMotion motion, OutputStream os)
throws IOException,
*/
private VmdMotion vmdRead(InputStream is)
throws IOException, MmdFormatException{
- VmdMotion motion = VmdLoader.load(is);
+ VmdLoader loader = new VmdLoader();
+
+ loader.setIgnoreName(true);
+ loader.setRedundantCheck(false);
+
+ VmdMotion motion = loader.load(is);
+
return motion;
}
*/
private void vmdOut(VmdMotion motion, OutputStream ostream)
throws IOException, IllegalVmdDataException{
- VmdExporter exporter = new VmdExporter(ostream);
- exporter.dumpVmdMotion(motion);
+ VmdExporter exporter = new VmdExporter();
+ exporter.dumpVmdMotion(motion, ostream);
ostream.close();
return;
}
exporter.setNewLine(this.newLine);
exporter.setGenerator(this.generator);
+ exporter.setQuaternionMode(this.isQuaternionMode);
exporter.putVmdXml(motion);
--- /dev/null
+/*
+ * package information for Javadoc
+ *
+ * License : The MIT License
+ * Copyright(c) 2011 MikuToga Partners
+ */
+
+/**
+ * VMDモーションデータとXML間でのデータ交換を行うアプリケーション。
+ * Mainエントリは、クラスVmd2Xml。
+ */
+
+package jp.sfjp.mikutoga.vmd2xml;
+
+/* EOF */
+++ /dev/null
-/*
- * luminous motion
- *
- * License : The MIT License
- * Copyright(c) 2011 MikuToga Partners
- */
-
-package jp.sourceforge.mikutoga.vmd.model;
-
-import jp.sourceforge.mikutoga.vmd.AbstractNumbered;
-
-/**
- * 光源演出情報。
- */
-public class LuminousMotion extends AbstractNumbered {
-
- private final LuminousColor color = new LuminousColor();
- private final LuminousVector direction = new LuminousVector();
-
-
- /**
- * コンストラクタ。
- */
- public LuminousMotion(){
- super();
- return;
- }
-
-
- /**
- * 光源の色情報を返す。
- * @return 光源の色情報
- */
- public LuminousColor getColor(){
- return this.color;
- }
-
- /**
- * 光源からの照射方向情報を返す。
- * @return 光源からの照射方向情報
- */
- public LuminousVector getDirection(){
- return this.direction;
- }
-
- /**
- * {@inheritDoc}
- * @return {@inheritDoc}
- */
- @Override
- public String toString(){
- StringBuilder result = new StringBuilder();
-
- result.append("#").append(getFrameNumber());
- result.append(" luminous color : ").append(this.color);
- result.append(" direction : ").append(this.direction);
-
- return result.toString();
- }
-
-}
+++ /dev/null
-/*
- * luminous direction vector
- *
- * License : The MIT License
- * Copyright(c) 2011 MikuToga Partners
- */
-
-package jp.sourceforge.mikutoga.vmd.model;
-
-/**
- * 光源からの照射方向を表す方向ベクトル。
- * <p>照明方向は、
- * ワールド座標原点から伸びる方向ベクトルとして記述される。
- * この方向ベクトルに向けて、無限遠の光源から照明が当たる。
- * <p>MMDのスライダUI上では各軸成分の定義域は-1.0以上+1.0以下だが、
- * さらに絶対値の大きな値を指定することも可能。
- * <p>方向ベクトルの長さは演出上の意味を持たないが、
- * キーフレーム間の照明方向の補間に影響を及ぼすかもしれない。
- * <p>方向ベクトルが零ベクトル(0,0,0)の場合、MMDでは全ポリゴンに影が落ちる。
- */
-public class LuminousVector {
-
- /** デフォルトのX成分。 */
- public static final float DEF_VECX = -0.5f;
- /** デフォルトのY成分。 */
- public static final float DEF_VECY = -1.0f;
- /** デフォルトのZ成分。 */
- public static final float DEF_VECZ = +0.5f;
-
-
- private float vecX = DEF_VECX;
- private float vecY = DEF_VECY;
- private float vecZ = DEF_VECZ;
-
-
- /**
- * コンストラクタ。
- */
- public LuminousVector(){
- super();
- return;
- }
-
-
- /**
- * 照射方向ベクトルのX成分を設定する。
- * @param vecX ベクトルのX成分
- */
- public void setVecX(float vecX) {
- this.vecX = vecX;
- return;
- }
-
- /**
- * 照射方向ベクトルのY成分を設定する。
- * @param vecY ベクトルのY成分
- */
- public void setVecY(float vecY) {
- this.vecY = vecY;
- return;
- }
-
- /**
- * 照射方向ベクトルのZ成分を設定する。
- * @param vecZ ベクトルのZ成分
- */
- public void setVecZ(float vecZ) {
- this.vecZ = vecZ;
- return;
- }
-
- /**
- * 照射方向ベクトルのX成分を返す。
- * @return 方向ベクトルX成分
- */
- public float getVecX() {
- return this.vecX;
- }
-
- /**
- * 照射方向ベクトルのY成分を返す。
- * @return 方向ベクトルY成分
- */
- public float getVecY() {
- return this.vecY;
- }
-
- /**
- * 照射方向ベクトルのZ成分を返す。
- * @return 方向ベクトルZ成分
- */
- public float getVecZ() {
- return this.vecZ;
- }
-
- /**
- * {@inheritDoc}
- * @return {@inheritDoc}
- */
- @Override
- public String toString(){
- StringBuilder result = new StringBuilder();
-
- result.append("x=").append(this.vecX);
- result.append(" y=").append(this.vecY);
- result.append(" z=").append(this.vecZ);
-
- return result.toString();
- }
-
-}
+++ /dev/null
-/*
- * string named list map
- *
- * License : The MIT License
- * Copyright(c) 2011 MikuToga Partners
- */
-
-package jp.sourceforge.mikutoga.vmd.model;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 名前付けされたリストのマップ。
- * 登録名の追加順が保持される。
- * @param <E> リスト要素の型
- */
-public class NamedListMap<E> {
-
- private final List<String> nameList;
- private final Map<String, List<E>> listMap;
-
-
- /**
- * コンストラクタ。
- */
- public NamedListMap(){
- super();
- this.nameList = new LinkedList<String>();
- this.listMap = new HashMap<String, List<E>>();
- return;
- }
-
-
- /**
- * マップをクリアする。
- */
- public void clear(){
- this.nameList.clear();
- this.listMap.clear();
- return;
- }
-
- /**
- * マップが空か否か判定する。
- * @return 空ならtrue
- */
- public boolean isEmpty(){
- if(this.listMap.isEmpty()) return true;
- return false;
- }
-
- /**
- * 名前一覧を返す。
- * <p>名前は登録順に並ぶ。
- * <p>ここで返されるListへの修正操作は不可能。
- * @return 名前一覧のリスト
- */
- public List<String> getNames(){
- List<String> result = Collections.unmodifiableList(this.nameList);
- return result;
- }
-
- /**
- * 名前付けされたリストを返す。
- * @param name 名前
- * @return 名前付けされたリスト。リストが存在しなければnull。
- */
- public List<E> getNamedList(String name){
- List<E> result = this.listMap.get(name);
- return result;
- }
-
- /**
- * 名前付けされたリストを削除する。
- * 存在しない名前が渡された場合、何もしない。
- * @param name 名前
- */
- public void removeNamedList(String name){
- if(this.listMap.remove(name) == null) return;
- this.nameList.remove(name);
- return;
- }
-
- /**
- * 名前付けされたリストに新要素を追加する。
- * 未登録の名前であれば新たにリストが作成される。
- * @param name 名前
- * @param elem 新要素
- * @throws NullPointerException 引数がnull
- */
- public void addNamedElement(String name, E elem)
- throws NullPointerException{
- if(name == null || elem == null) throw new NullPointerException();
-
- List<E> list = this.listMap.get(name);
- if(list == null){
- list = new LinkedList<E>();
- this.listMap.put(name, list);
- this.nameList.add(name);
- }
-
- list.add(elem);
-
- return;
- }
-
-}
+++ /dev/null
-/*
- * vmd exporter
- *
- * License : The MIT License
- * Copyright(c) 2011 MikuToga Partners
- */
-
-package jp.sourceforge.mikutoga.vmd.model.binio;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import jp.sfjp.mikutoga.bin.export.BinaryExporter;
-import jp.sfjp.mikutoga.bin.export.IllegalTextExportException;
-import jp.sourceforge.mikutoga.vmd.IllegalVmdDataException;
-import jp.sourceforge.mikutoga.vmd.VmdConst;
-import jp.sourceforge.mikutoga.vmd.model.VmdMotion;
-
-/**
- * VMDファイルのエクスポーター。
- */
-public class VmdExporter extends BinaryExporter {
-
- private static final byte[] HEADFILLER = {
- (byte)'J',
- (byte)'K',
- (byte)'L',
- (byte)'M',
- };
-
- private static final byte[] FDFILLER =
- { (byte)0x00, (byte)0xfd };
-
-
- private final BasicExporter basicExporter;
- private final CameraExporter cameraExporter;
- private final LightingExporter lightingExporter;
-
-
- /**
- * コンストラクタ。
- * @param stream 出力ストリーム
- */
- public VmdExporter(OutputStream stream){
- super(stream);
-
- this.basicExporter = new BasicExporter(stream);
- this.cameraExporter = new CameraExporter(stream);
- this.lightingExporter = new LightingExporter(stream);
-
- return;
- }
-
- /**
- * モーションデータをVMDファイル形式で出力する。
- * <p>異常時には出力データのフラッシュが試みられる。
- * @param motion モーションデータ
- * @throws IOException 出力エラー
- * @throws IllegalVmdDataException モーションデータに不備が発見された
- */
- public void dumpVmdMotion(VmdMotion motion)
- throws IOException, IllegalVmdDataException{
- try{
- dumpVmdMotionImpl(motion);
- }finally{
- flush();
- }
-
- return;
- }
-
- /**
- * モーションデータをVMDファイル形式で出力する。
- * @param motion モーションデータ
- * @throws IOException 出力エラー
- * @throws IllegalVmdDataException モーションデータに不備が発見された
- */
- private void dumpVmdMotionImpl(VmdMotion motion)
- throws IOException, IllegalVmdDataException{
- dumpHeader();
-
- try{
- dumpModelName(motion);
- this.basicExporter.dumpBoneMotion(motion);
- this.basicExporter.dumpMorphMotion(motion);
- }catch(IllegalTextExportException e){
- throw new IllegalVmdDataException(e);
- }
-
- this.cameraExporter.dumpCameraMotion(motion);
- this.lightingExporter.dumpLuminousMotion(motion);
- this.lightingExporter.dumpShadowMotion(motion);
-
- return;
- }
-
- /**
- * ヘッダ情報を出力する。
- * @throws IOException 出力エラー
- */
- private void dumpHeader() throws IOException{
- byte[] header = VmdConst.createMagicHeader();
- dumpByteArray(header);
- dumpByteArray(HEADFILLER);
-
- assert header.length + HEADFILLER.length == VmdConst.HEADER_LENGTH;
-
- return;
- }
-
- /**
- * モデル名を出力する。
- * <p>演出データのモデル名には
- * 便宜的に{@link VmdConst.MODELNAME_STAGEACT}が使われる。
- * @param motion モーションデータ
- * @throws IOException 出力エラー
- * @throws IllegalTextExportException 不正なモデル名の出現
- */
- private void dumpModelName(VmdMotion motion)
- throws IOException, IllegalTextExportException{
- String modelName = motion.getModelName();
- if(modelName == null) modelName = VmdConst.MODELNAME_STAGEACT;
-
- dumpFixedW31j(modelName, VmdConst.MODELNAME_MAX, FDFILLER);
-
- return;
- }
-
-}
+++ /dev/null
-/*
- * VMD loader
- *
- * License : The MIT License
- * Copyright(c) 2011 MikuToga Partners
- */
-
-package jp.sourceforge.mikutoga.vmd.model.binio;
-
-import java.io.IOException;
-import java.io.InputStream;
-import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.vmd.model.VmdMotion;
-import jp.sourceforge.mikutoga.vmd.parser.VmdParser;
-
-/**
- * VMDモーションファイルを読み込むためのバイナリローダ。
- */
-public final class VmdLoader {
-
- /**
- * コンストラクタ。
- */
- private VmdLoader(){
- super();
- assert false;
- throw new AssertionError();
- }
-
-
- /**
- * VMDファイルの読み込みを行いモーション情報を返す。
- * @param source 入力ソース
- * @return モーション情報
- * @throws IOException 入力エラー
- * @throws MmdFormatException VMDファイルフォーマットの異常を検出
- */
- public static VmdMotion load(InputStream source)
- throws IOException,
- MmdFormatException {
- VmdParser parser = new VmdParser(source);
-
- VmdMotion result = new VmdMotion();
-
- BasicLoader basicBuilder = new BasicLoader(result);
- CameraLoader cameraBuilder = new CameraLoader(result);
- LightingLoader lightingBuilder = new LightingLoader(result);
-
- parser.setBasicHandler(basicBuilder);
- parser.setCameraHandler(cameraBuilder);
- parser.setLightingHandler(lightingBuilder);
-
- parser.setStrictMode(false);
-
- parser.parseVmd();
-
- return result;
- }
-
-}
--- /dev/null
+/*
+ * camera xml exporter
+ *
+ * License : The MIT License
+ * Copyright(c) 2013 MikuToga Partners
+ */
+
+package jp.sourceforge.mikutoga.vmd.model.xml;
+
+import java.io.IOException;
+import java.util.List;
+import jp.sfjp.mikutoga.math.MkPos3D;
+import jp.sfjp.mikutoga.vmd.model.BezierParam;
+import jp.sfjp.mikutoga.vmd.model.CameraMotion;
+import jp.sfjp.mikutoga.vmd.model.CameraRotation;
+import jp.sfjp.mikutoga.vmd.model.PosCurve;
+import jp.sfjp.mikutoga.vmd.model.VmdMotion;
+import jp.sourceforge.mikutoga.xml.ProxyXmlExporter;
+
+/**
+ *カメラ情報のXMLエクスポーター。
+ */
+class CameraXmlExporter extends ProxyXmlExporter{
+
+
+ /**
+ * コンストラクタ。
+ * @param proxy 委譲先
+ */
+ CameraXmlExporter(VmdXmlExporter proxy) {
+ super(proxy);
+ return;
+ }
+
+
+ /**
+ * カメラ演出データを出力する。
+ * @param vmdMotion 演出データ
+ * @throws IOException 出力エラー
+ */
+ void putCameraSequence(VmdMotion vmdMotion)
+ throws IOException{
+ List<CameraMotion> list = vmdMotion.getCameraMotionList();
+ if( ! list.isEmpty() ){
+ ind().putBlockComment(XmlSyms.CAMERA_COMMENT);
+ ind().putBlockComment(XmlSyms.BEZIER_COMMENT);
+ }
+
+ ind().putSimpleSTag(XmlSyms.TAG_CAMERA_SEQUENCE).ln();
+
+ pushNest();
+ if( ! list.isEmpty() ) ln();
+ for(CameraMotion camera : list){
+ putCameraMotion(camera);
+ }
+ popNest();
+
+ ind().putETag(XmlSyms.TAG_CAMERA_SEQUENCE).ln(2);
+
+ return;
+ }
+
+ /**
+ * カメラモーションを出力する。
+ * @param cameraMotion カメラモーション
+ * @throws IOException 出力エラー
+ */
+ private void putCameraMotion(CameraMotion cameraMotion)
+ throws IOException{
+ ind().putOpenSTag(XmlSyms.TAG_CAMERA_MOTION).sp();
+ int frameNo = cameraMotion.getFrameNumber();
+ putIntAttr(XmlSyms.ATTR_FRAME, frameNo).sp();
+ if( ! cameraMotion.hasPerspective() ){
+ putAttr(XmlSyms.ATTR_HAS_PERSPECTIVE, "false").sp();
+ }
+ putCloseSTag().ln();
+
+ pushNest();
+ putCameraTarget(cameraMotion);
+ putCameraRotation(cameraMotion);
+ putCameraRange(cameraMotion);
+ putProjection(cameraMotion);
+ popNest();
+
+ ind().putETag(XmlSyms.TAG_CAMERA_MOTION).ln(2);
+
+ return;
+ }
+
+ /**
+ * カメラターゲット情報を出力する。
+ * @param cameraMotion カメラモーション
+ * @throws IOException 出力エラー
+ */
+ private void putCameraTarget(CameraMotion cameraMotion)
+ throws IOException{
+ ind().putOpenSTag(XmlSyms.TAG_CAMERA_TARGET).sp();
+ MkPos3D position = cameraMotion.getCameraTarget();
+ putFloatAttr(XmlSyms.ATTR_X_POS, (float) position.getXpos()).sp();
+ putFloatAttr(XmlSyms.ATTR_Y_POS, (float) position.getYpos()).sp();
+ putFloatAttr(XmlSyms.ATTR_Z_POS, (float) position.getZpos()).sp();
+
+ PosCurve posCurve = cameraMotion.getTargetPosCurve();
+ if(posCurve.isDefaultLinear()){
+ putCloseEmpty().ln();
+ }else{
+ putCloseSTag().ln();
+
+ pushNest();
+ putPositionCurve(posCurve);
+ popNest();
+
+ ind().putETag(XmlSyms.TAG_CAMERA_TARGET).ln();
+ }
+
+ return;
+ }
+
+ /**
+ * 位置移動補間カーブを出力する。
+ * @param posCurve 移動補間情報
+ * @throws IOException 出力エラー
+ */
+ private void putPositionCurve(PosCurve posCurve)
+ throws IOException{
+ BezierParam xCurve = posCurve.getIntpltXpos();
+ BezierParam yCurve = posCurve.getIntpltYpos();
+ BezierParam zCurve = posCurve.getIntpltZpos();
+
+ ind().putLineComment("X-Y-Z interpolation *3").ln();
+
+ ind();
+ putBezierCurve(xCurve);
+ ln();
+
+ ind();
+ putBezierCurve(yCurve);
+ ln();
+
+ ind();
+ putBezierCurve(zCurve);
+ ln();
+
+ return;
+ }
+
+ /**
+ * カメラ回転情報を出力する。
+ * @param cameraMotion カメラモーション
+ * @throws IOException 出力エラー
+ */
+ private void putCameraRotation(CameraMotion cameraMotion)
+ throws IOException{
+ ind().putOpenSTag(XmlSyms.TAG_CAMERA_ROTATION).sp();
+ CameraRotation rotation = cameraMotion.getCameraRotation();
+ float latitude = (float) rotation.getLatitude();
+ float longitude = (float) rotation.getLongitude();
+ float roll = (float) rotation.getRoll();
+ putFloatAttr(XmlSyms.ATTR_X_RAD, latitude).sp();
+ putFloatAttr(XmlSyms.ATTR_Y_RAD, longitude).sp();
+ putFloatAttr(XmlSyms.ATTR_Z_RAD, roll).sp();
+
+ BezierParam rotCurve = cameraMotion.getIntpltRotation();
+ if(rotCurve.isDefaultLinear()){
+ putCloseEmpty().ln();
+ }else{
+ putCloseSTag().ln();
+ pushNest();
+ ind();
+ putBezierCurve(rotCurve);
+ ln();
+ popNest();
+ ind().putETag(XmlSyms.TAG_CAMERA_ROTATION).ln();
+ }
+
+ return;
+ }
+
+ /**
+ * カメラ距離情報を出力する。
+ * @param cameraMotion カメラモーション
+ * @throws IOException 出力エラー
+ */
+ private void putCameraRange(CameraMotion cameraMotion)
+ throws IOException{
+ ind().putOpenSTag(XmlSyms.TAG_CAMERA_RANGE).sp();
+ float range = (float) cameraMotion.getRange();
+ putFloatAttr(XmlSyms.ATTR_RANGE, range).sp();
+
+ BezierParam rangeCurve = cameraMotion.getIntpltRange();
+ if(rangeCurve.isDefaultLinear()){
+ putCloseEmpty().ln();
+ }else{
+ putCloseSTag().ln();
+ pushNest();
+ ind();
+ putBezierCurve(rangeCurve);
+ ln();
+ popNest();
+ ind().putETag(XmlSyms.TAG_CAMERA_RANGE).ln();
+ }
+
+ return;
+ }
+
+ /**
+ * スクリーン投影情報を出力する。
+ * @param cameraMotion カメラモーション
+ * @throws IOException 出力エラー
+ */
+ private void putProjection(CameraMotion cameraMotion)
+ throws IOException{
+ ind().putOpenSTag(XmlSyms.TAG_PROJECTION).sp();
+ int angle = cameraMotion.getProjectionAngle();
+ putIntAttr(XmlSyms.ATTR_VERT_DEG, angle).sp();
+
+ BezierParam projCurve = cameraMotion.getIntpltProjection();
+ if(projCurve.isDefaultLinear()){
+ putCloseEmpty().ln();
+ }else{
+ putCloseSTag().ln();
+ pushNest();
+ ind();
+ putBezierCurve(projCurve);
+ ln();
+ popNest();
+ ind().putETag(XmlSyms.TAG_PROJECTION).ln();
+ }
+
+ return;
+ }
+
+ /**
+ * ベジェ曲線による補間曲線情報を出力する。
+ * @param bezier ベジェ曲線
+ * @throws IOException 出力エラー
+ */
+ private void putBezierCurve(BezierParam bezier)
+ throws IOException{
+ if(bezier.isDefaultLinear()){
+ putSimpleEmpty(XmlSyms.TAG_DEF_LINEAR);
+ }else if(bezier.isDefaultEaseInOut()){
+ putSimpleEmpty(XmlSyms.TAG_DEF_EASE_IN_OUT);
+ }else{
+ putOpenSTag(XmlSyms.TAG_BEZIER).sp();
+ putIntAttr(XmlSyms.ATTR_P1X, bezier.getP1x()).sp();
+ putIntAttr(XmlSyms.ATTR_P1Y, bezier.getP1y()).sp();
+ putIntAttr(XmlSyms.ATTR_P2X, bezier.getP2x()).sp();
+ putIntAttr(XmlSyms.ATTR_P2Y, bezier.getP2y()).sp();
+ putCloseEmpty();
+ }
+ return;
+ }
+
+}
--- /dev/null
+/*
+ * lighting xml exporter
+ *
+ * License : The MIT License
+ * Copyright(c) 2013 MikuToga Partners
+ */
+
+package jp.sourceforge.mikutoga.vmd.model.xml;
+
+import java.io.IOException;
+import java.util.List;
+import jp.sfjp.mikutoga.math.MkVec3D;
+import jp.sfjp.mikutoga.vmd.model.LuminousColor;
+import jp.sfjp.mikutoga.vmd.model.LuminousMotion;
+import jp.sfjp.mikutoga.vmd.model.ShadowMode;
+import jp.sfjp.mikutoga.vmd.model.ShadowMotion;
+import jp.sfjp.mikutoga.vmd.model.VmdMotion;
+import jp.sourceforge.mikutoga.xml.ProxyXmlExporter;
+import jp.sourceforge.mikutoga.xml.XmlExporter;
+
+/**
+ * ライティング情報のXMLエクスポーター。
+ */
+class LightingXmlExpoter extends ProxyXmlExporter {
+
+ /**
+ * コンストラクタ。
+ * @param proxy 委譲先
+ */
+ LightingXmlExpoter(XmlExporter proxy) {
+ super(proxy);
+ return;
+ }
+
+ /**
+ * 照明演出データを出力する。
+ * @param vmdMotion 演出データ
+ * @throws IOException 出力エラー
+ */
+ void putLuminousSequence(VmdMotion vmdMotion)
+ throws IOException{
+ ind().putSimpleSTag(XmlSyms.TAG_LUMI_SEQUENCE).ln();
+
+ pushNest();
+ List<LuminousMotion> list = vmdMotion.getLuminousMotionList();
+ if( ! list.isEmpty() ) ln();
+ for(LuminousMotion luminous : list){
+ putLuminousMotion(luminous);
+ }
+ popNest();
+
+ ind().putETag(XmlSyms.TAG_LUMI_SEQUENCE).ln(2);
+
+ return;
+ }
+
+ /**
+ * 照明モーションを出力する。
+ * @param luminousMotion 照明モーション
+ * @throws IOException 出力エラー
+ */
+ private void putLuminousMotion(LuminousMotion luminousMotion)
+ throws IOException{
+ ind().putOpenSTag(XmlSyms.TAG_LUMINOUS_ACT).sp();
+ int frameNo = luminousMotion.getFrameNumber();
+ putIntAttr(XmlSyms.ATTR_FRAME, frameNo).sp();
+ putCloseSTag().ln();
+
+ LuminousColor color = luminousMotion.getColor();
+ MkVec3D vector = luminousMotion.getDirection();
+
+ pushNest();
+ putLuminousColor(color);
+ putLuminousDirection(vector);
+ popNest();
+
+ ind().putETag(XmlSyms.TAG_LUMINOUS_ACT).ln(2);
+
+ return;
+ }
+
+ /**
+ * 光源色情報を出力する。
+ * @param color 光源色
+ * @throws IOException 出力エラー
+ */
+ private void putLuminousColor(LuminousColor color)
+ throws IOException{
+ ind().putOpenSTag(XmlSyms.TAG_LUMI_COLOR).sp();
+ putFloatAttr(XmlSyms.ATTR_R_COL, color.getColR()).sp();
+ putFloatAttr(XmlSyms.ATTR_G_COL, color.getColG()).sp();
+ putFloatAttr(XmlSyms.ATTR_B_COL, color.getColB()).sp();
+ putCloseEmpty().ln();
+
+ return;
+ }
+
+ /**
+ * 照明方向情報を出力する。
+ * @param vector 照明方向
+ * @throws IOException 出力エラー
+ */
+ private void putLuminousDirection(MkVec3D vector)
+ throws IOException{
+ ind().putOpenSTag(XmlSyms.TAG_LUMI_DIRECTION).sp();
+ putFloatAttr(XmlSyms.ATTR_X_VEC, (float) vector.getXVal()).sp();
+ putFloatAttr(XmlSyms.ATTR_Y_VEC, (float) vector.getYVal()).sp();
+ putFloatAttr(XmlSyms.ATTR_Z_VEC, (float) vector.getZVal()).sp();
+ putCloseEmpty().ln();
+
+ return;
+ }
+
+ /**
+ * シャドウ演出データを出力する。
+ * @param vmdMotion 演出データ
+ * @throws IOException 出力エラー
+ */
+ void putShadowSequence(VmdMotion vmdMotion)
+ throws IOException{
+ List<ShadowMotion> list = vmdMotion.getShadowMotionList();
+ if( ! list.isEmpty() ){
+ ind().putBlockComment(XmlSyms.SHADOW_COMMENT);
+ }
+
+ ind().putSimpleSTag(XmlSyms.TAG_SHADOW_SEQUENCE).ln();
+
+ pushNest();
+ for(ShadowMotion shadow : list){
+ putShadowMotion(shadow);
+ }
+ popNest();
+
+ ind().putETag(XmlSyms.TAG_SHADOW_SEQUENCE).ln(2);
+
+ return;
+ }
+
+ /**
+ * シャドウモーションを出力する。
+ * @param shadowMotion シャドウモーション
+ * @throws IOException 出力エラー
+ */
+ private void putShadowMotion(ShadowMotion shadowMotion)
+ throws IOException{
+ ind().putOpenSTag(XmlSyms.TAG_SHADOW_ACT).sp();
+
+ int frameNo = shadowMotion.getFrameNumber();
+ ShadowMode mode = shadowMotion.getShadowMode();
+ float rawParam = (float) shadowMotion.getRawScopeParam();
+
+ putIntAttr(XmlSyms.ATTR_FRAME, frameNo).sp();
+ putAttr(XmlSyms.ATTR_MODE, mode.name()).sp();
+ putFloatAttr(XmlSyms.ATTR_RAW_PARAM, rawParam).sp();
+
+ putCloseEmpty();
+
+ double uiVal = ShadowMotion.rawParamToScope(rawParam);
+ long lVal = Math.round(uiVal);
+ sp().putLineComment("UI:" + lVal).ln();
+
+ return;
+ }
+
+}
import java.net.URI;
import java.net.URISyntaxException;
-import jp.sourceforge.mikutoga.xml.LocalSchema;
+import jp.sourceforge.mikutoga.xml.LocalXmlResource;
/**
* 110820形式XML各種リソースの定義。
*/
-public class Schema110820 extends LocalSchema{
+public final class Schema110820 implements LocalXmlResource{
+
+ /** 唯一のシングルトン。 */
+ public static final Schema110820 SINGLETON;
/** XML名前空間識別子。 */
public static final String NS_VMDXML =
}catch(URISyntaxException e){
throw new ExceptionInInitializerError(e);
}
+
+ SINGLETON = new Schema110820();
}
/**
- * 隠しコンストラクタ。
+ * コンストラクタ。
*/
- public Schema110820(){
+ private Schema110820(){
super();
assert this.getClass() == THISCLASS;
return;
* @return {@inheritDoc}
*/
@Override
- public URI getOriginalSchema(){
+ public URI getOriginalResource(){
return URI_SCHEMA_VMDXML;
}
* @return {@inheritDoc}
*/
@Override
- public URI getLocalSchema(){
+ public URI getLocalResource(){
return RES_SCHEMA_VMDXML;
}
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
+import java.util.Map;
import jp.sfjp.mikutoga.math.EulerYXZ;
import jp.sfjp.mikutoga.math.MkPos3D;
import jp.sfjp.mikutoga.math.MkQuat;
import jp.sfjp.mikutoga.typical.TypicalBone;
import jp.sfjp.mikutoga.typical.TypicalMorph;
-import jp.sourceforge.mikutoga.vmd.IllegalVmdDataException;
-import jp.sourceforge.mikutoga.vmd.VmdConst;
-import jp.sourceforge.mikutoga.vmd.model.BezierParam;
-import jp.sourceforge.mikutoga.vmd.model.BoneMotion;
-import jp.sourceforge.mikutoga.vmd.model.CameraMotion;
-import jp.sourceforge.mikutoga.vmd.model.CameraRotation;
-import jp.sourceforge.mikutoga.vmd.model.LuminousColor;
-import jp.sourceforge.mikutoga.vmd.model.LuminousMotion;
-import jp.sourceforge.mikutoga.vmd.model.LuminousVector;
-import jp.sourceforge.mikutoga.vmd.model.MorphMotion;
-import jp.sourceforge.mikutoga.vmd.model.NamedListMap;
-import jp.sourceforge.mikutoga.vmd.model.PosCurve;
-import jp.sourceforge.mikutoga.vmd.model.ShadowMode;
-import jp.sourceforge.mikutoga.vmd.model.ShadowMotion;
-import jp.sourceforge.mikutoga.vmd.model.VmdMotion;
+import jp.sfjp.mikutoga.vmd.IllegalVmdDataException;
+import jp.sfjp.mikutoga.vmd.VmdUniq;
+import jp.sfjp.mikutoga.vmd.model.BezierParam;
+import jp.sfjp.mikutoga.vmd.model.BoneMotion;
+import jp.sfjp.mikutoga.vmd.model.MorphMotion;
+import jp.sfjp.mikutoga.vmd.model.PosCurve;
+import jp.sfjp.mikutoga.vmd.model.VmdMotion;
import jp.sourceforge.mikutoga.xml.BasicXmlExporter;
import jp.sourceforge.mikutoga.xml.XmlResourceResolver;
*/
public class VmdXmlExporter extends BasicXmlExporter {
- private static final String XSINS = "xsi";
+ private static final String XML_DECL =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
- private static final String TOP_COMMENT =
- " MikuMikuDance\n motion-data(*.vmd) on XML";
-
- private static final String QUATERNION_COMMENT =
- " bone-rotation has Quaternion parameters [boneRotQuat]\n"
- + " or YXZ-Euler angles [boneRotEyxz].\n"
- + " Quaternion is strongly recommended"
- + " if you are data-exchanging.";
-
- private static final String BEZIER_COMMENT =
- " motion interpolation is defined by Bezier-cubic-curve.\n"
- + " implicit bezier curve point : P0=(0,0) P3=(127,127)\n"
- + " defLinear : MMD default linear curve."
- + " P1=(20,20) P2=(107,107) [DEFAULT]\n"
- + " defEaseInOut : MMD default ease-in-out curve."
- + " P1=(64,0) P2=(64,127)";
-
- private static final String CAMERA_COMMENT =
- " camera-rotation has polar-coordinates parameters.\n"
- + " xRad = -radian(UI_X) [latitude]\n"
- + " yRad = radian(UI_Y) [longitude]\n"
- + " zRad = radian(UI_Z) [roll]\n"
- + " range = -(UI_RANGE)";
-
- private static final String SHADOW_COMMENT =
- " UI_VALUE = EFFECTIVE_RANGE * 100 ???\n"
- +" rawParam = 0.1 - (UI_VALUE / 1.0E+5)\n\n"
- +" NONE : no self-shadow\n"
- +" MODE_1 : reduce shadow-quality suddenly at range\n"
- +" MODE_2 : reduce shadow-quality gradually with range";
+ private static final String XSINS = "xsi";
private boolean isQuaternionMode = true;
private String generator = "";
+ private final CameraXmlExporter cameraXmlExporter;
+ private final LightingXmlExpoter lightingExporter;
+
/**
* コンストラクタ。
* 文字エンコーディングはUTF-8が用いられる。
- * @param stream 出力ストリーム
+ * @param ostream 出力ストリーム
*/
- public VmdXmlExporter(OutputStream stream){
- super(stream);
+ public VmdXmlExporter(OutputStream ostream){
+ super(ostream);
+ this.cameraXmlExporter = new CameraXmlExporter(this);
+ this.lightingExporter = new LightingXmlExpoter(this);
return;
}
}
/**
+ * ボーン回転量をクォータニオンで出力するか否か返す。
+ * @return クォータニオンで出力するならtrue
+ */
+ public boolean isQuaternionMode(){
+ return this.isQuaternionMode;
+ }
+
+ /**
* Generatorメタ情報を設定する。
- * @param generatorArg Generatorメタ情報
+ * @param generatorArg Generatorメタ情報。nullならXML出力しない。
*/
public void setGenerator(String generatorArg){
this.generator = generatorArg;
}
/**
+ * Generatorメタ情報を取得する。
+ * @return Generatorメタ情報。XML出力しないならnullを返す。
+ */
+ public String getGenerator(){
+ return this.generator;
+ }
+
+ /**
* VMDモーションデータをXML形式で出力する。
- * <p>モーションデータと演出データで振り分けられる。
* @param vmdMotion VMDモーションデータ
* @throws IOException 出力エラー
* @throws IllegalVmdDataException 不正なモーションデータを検出
/**
* VMDモーションデータをXML形式で出力する。
- * <p>モーションデータと演出データで振り分けられる。
* @param vmdMotion VMDモーションデータ
* @throws IOException 出力エラー
* @throws IllegalVmdDataException 不正なモーションデータを検出
*/
private void putVmdXmlImpl(VmdMotion vmdMotion)
throws IOException, IllegalVmdDataException{
- ind().putRawText("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>")
- .ln(2);
+ ind().putRawText(XML_DECL).ln(2);
- ind().putBlockComment(TOP_COMMENT).ln(2);
+ ind().putBlockComment(XmlSyms.TOP_COMMENT).ln(2);
- ind().putRawText("<vmdMotion").ln();
+ ind().putOpenSTag(XmlSyms.TAG_VMD_MOTION).ln();
pushNest();
- ind().putAttr("xmlns", VmdXmlResources.NS_VMDXML).ln();
+ ind().putAttr("xmlns", Schema110820.NS_VMDXML).ln();
ind().putAttr("xmlns:" + XSINS, XmlResourceResolver.NS_XSD).ln();
ind().putRawText(XSINS).putRawText(":schemaLocation=")
.putRawCh('"');
- putRawText(VmdXmlResources.NS_VMDXML).ln();
- ind().sp(2).putRawText(VmdXmlResources.SCHEMAURI_VMDXML)
+ putRawText(Schema110820.NS_VMDXML).ln();
+ ind().sp(2).putRawText(Schema110820.SCHEMA_VMDXML)
.putRawCh('"')
.ln();
- ind().putAttr("version", VmdXmlResources.VER_VMDXML).ln();
+ ind().putAttr(XmlSyms.ATTR_VERSION, Schema110820.VER_VMDXML).ln();
popNest();
- putRawText(">").ln(2);
+ putCloseSTag().ln(2);
if(this.generator != null && this.generator.length() > 0){
- ind().putRawText("<meta ");
- putAttr("name", "generator").putRawCh(' ');
- putAttr("content", this.generator);
- putRawText(" />").ln(2);
+ ind().putOpenSTag(XmlSyms.TAG_META).sp();
+ putAttr(XmlSyms.ATTR_NAME, "generator").sp();
+ putAttr(XmlSyms.ATTR_CONTENT, this.generator).sp();
+ putCloseEmpty().ln(2);
}
if(vmdMotion.isModelMotion()){
putBoneMotionSequence(vmdMotion);
putMorphSequence(vmdMotion);
}else{
- putCameraSequence(vmdMotion);
- putLuminousSequence(vmdMotion);
- putShadowSequence(vmdMotion);
+ this.cameraXmlExporter.putCameraSequence(vmdMotion);
+ this.lightingExporter.putLuminousSequence(vmdMotion);
+ this.lightingExporter.putShadowSequence(vmdMotion);
}
- ind().putRawText("</vmdMotion>").ln(2);
- ind().putRawText("<!-- EOF -->").ln();
+ ind().putETag(XmlSyms.TAG_VMD_MOTION).ln(2);
+ ind().putLineComment("EOF").ln();
return;
}
private void putBezierCurve(BezierParam bezier)
throws IOException{
if(bezier.isDefaultLinear()){
- putRawText("<defLinear />");
+ putSimpleEmpty(XmlSyms.TAG_DEF_LINEAR);
}else if(bezier.isDefaultEaseInOut()){
- putRawText("<defEaseInOut />");
+ putSimpleEmpty(XmlSyms.TAG_DEF_EASE_IN_OUT);
}else{
- putRawText("<bezier ");
- putIntAttr("p1x", bezier.getP1x()).sp();
- putIntAttr("p1y", bezier.getP1y()).sp();
- putIntAttr("p2x", bezier.getP2x()).sp();
- putIntAttr("p2y", bezier.getP2y()).sp();
- putRawText("/>");
+ putOpenSTag(XmlSyms.TAG_BEZIER).sp();
+ putIntAttr(XmlSyms.ATTR_P1X, bezier.getP1x()).sp();
+ putIntAttr(XmlSyms.ATTR_P1Y, bezier.getP1y()).sp();
+ putIntAttr(XmlSyms.ATTR_P2X, bezier.getP2x()).sp();
+ putIntAttr(XmlSyms.ATTR_P2Y, bezier.getP2y()).sp();
+ putCloseEmpty();
}
return;
}
throws IOException{
String modelName = vmdMotion.getModelName();
- ind().putLineComment(modelName).ln();
- ind().putRawText("<modelName ");
- putAttr("name", modelName).sp();
- putRawText("/>").ln(2);
+ String modelComm;
+ if(modelName != null && modelName.length() > 0){
+ modelComm = modelName;
+ }else{
+ modelComm = "[NAMELESS]";
+ }
+
+ ind().putLineComment(modelComm).ln();
+ ind().putOpenSTag(XmlSyms.TAG_MODEL_NAME).sp();
+ putAttr(XmlSyms.ATTR_NAME, modelName).sp();
+ putCloseEmpty().ln(2);
return;
}
*/
private void putBoneMotionSequence(VmdMotion vmdMotion)
throws IOException{
- ind().putBlockComment(QUATERNION_COMMENT);
- ind().putBlockComment(BEZIER_COMMENT);
+ Map<String, List<BoneMotion>> boneMap = vmdMotion.getBonePartMap();
- ind().putRawText("<boneMotionSequence>").ln();
+ if( ! boneMap.isEmpty() ){
+ ind().putBlockComment(XmlSyms.QUATERNION_COMMENT);
+ ind().putBlockComment(XmlSyms.BEZIER_COMMENT);
+ }
+
+ ind().putSimpleSTag(XmlSyms.TAG_BONE_M_SEQUENCE).ln();
pushNest();
- NamedListMap<BoneMotion> listmap = vmdMotion.getBonePartMap();
- if( ! listmap.isEmpty() ) ln();
- for(String boneName : listmap.getNames()){
- List<BoneMotion> list = listmap.getNamedList(boneName);
- putBonePart(boneName, list);
+ if( ! boneMap.isEmpty() ) ln();
+ for(Map.Entry<String, List<BoneMotion>> entry : boneMap.entrySet()){
+ putBonePart(entry.getKey(), entry.getValue());
}
popNest();
- ind().putRawText("</boneMotionSequence>").ln(2);
+ ind().putETag(XmlSyms.TAG_BONE_M_SEQUENCE).ln(2);
return;
}
}
ln();
- ind().putRawText("<bonePart ");
- putAttr("name", boneName).sp();
- putRawText(">").ln(2);
+ ind().putOpenSTag(XmlSyms.TAG_BONE_PART).sp();
+ putAttr(XmlSyms.ATTR_NAME, boneName).sp();
+ putCloseSTag().ln(2);
pushNest();
for(BoneMotion bone : list){
}
popNest();
- ind().putRawText("</bonePart>").ln(2);
+ ind().putETag(XmlSyms.TAG_BONE_PART).ln(2);
return;
}
*/
private void putBoneMotion(BoneMotion boneMotion)
throws IOException{
- ind().putRawText("<boneMotion ");
+ ind().putOpenSTag(XmlSyms.TAG_BONE_MOTION).sp();
int frameNo = boneMotion.getFrameNumber();
- putIntAttr("frame", frameNo).sp();
- putRawText(">").ln();
+ putIntAttr(XmlSyms.ATTR_FRAME, frameNo).sp();
+ putCloseSTag().ln();
pushNest();
putBonePosition(boneMotion);
}
popNest();
- ind().putRawText("</boneMotion>").ln(2);
+ ind().putETag(XmlSyms.TAG_BONE_MOTION).ln(2);
return;
}
return;
}
- ind().putRawText("<bonePosition ");
+ ind().putOpenSTag(XmlSyms.TAG_BONE_POSITION).sp();
MkPos3D position = boneMotion.getPosition();
float xPos = (float) position.getXpos();
float yPos = (float) position.getYpos();
float zPos = (float) position.getZpos();
- putFloatAttr("xPos", xPos).sp();
- putFloatAttr("yPos", yPos).sp();
- putFloatAttr("zPos", zPos).sp();
+ putFloatAttr(XmlSyms.ATTR_X_POS, xPos).sp();
+ putFloatAttr(XmlSyms.ATTR_Y_POS, yPos).sp();
+ putFloatAttr(XmlSyms.ATTR_Z_POS, zPos).sp();
PosCurve posCurve = boneMotion.getPosCurve();
if(posCurve.isDefaultLinear()){
- putRawText("/>").ln();
+ putCloseEmpty().ln();
}else{
- putRawText(">").ln();
+ putCloseSTag().ln();
pushNest();
putPositionCurve(posCurve);
popNest();
- ind().putRawText("</bonePosition>").ln();
+ ind().putETag(XmlSyms.TAG_BONE_POSITION).ln();
}
return;
MkQuat rotation = boneMotion.getRotation();
BezierParam rotCurve = boneMotion.getIntpltRotation();
- ind().putRawText("<boneRotQuat").ln();
+ ind().putOpenSTag(XmlSyms.TAG_BONE_ROT_QUAT).ln();
pushNest();
- ind().putFloatAttr("qx", (float) rotation.getQ1()).ln();
- ind().putFloatAttr("qy", (float) rotation.getQ2()).ln();
- ind().putFloatAttr("qz", (float) rotation.getQ3()).ln();
- ind().putFloatAttr("qw", (float) rotation.getQW()).ln();
+ ind().putFloatAttr(XmlSyms.ATTR_QX, (float) rotation.getQ1()).ln();
+ ind().putFloatAttr(XmlSyms.ATTR_QY, (float) rotation.getQ2()).ln();
+ ind().putFloatAttr(XmlSyms.ATTR_QZ, (float) rotation.getQ3()).ln();
+ ind().putFloatAttr(XmlSyms.ATTR_QW, (float) rotation.getQW()).ln();
popNest();
ind();
if(rotCurve.isDefaultLinear()){
- putRawText("/>").ln();
+ putCloseEmpty().ln();
}else{
- putRawText(">").ln();
+ putCloseSTag().ln();
pushNest();
ind();
putBezierCurve(rotCurve);
ln();
popNest();
- ind().putRawText("</boneRotQuat>").ln();
+ ind().putETag(XmlSyms.TAG_BONE_ROT_QUAT).ln();
}
return;
float yDeg = (float)StrictMath.toDegrees(euler.getYRot());
float zDeg = (float)StrictMath.toDegrees(euler.getZRot());
- ind().putRawText("<boneRotEyxz").ln();
+ ind().putOpenSTag(XmlSyms.TAG_BONE_ROT_EYXZ).ln();
pushNest();
- ind().putFloatAttr("xDeg", xDeg).ln();
- ind().putFloatAttr("yDeg", yDeg).ln();
- ind().putFloatAttr("zDeg", zDeg).ln();
+ ind().putFloatAttr(XmlSyms.ATTR_X_DEG, xDeg).ln();
+ ind().putFloatAttr(XmlSyms.ATTR_Y_DEG, yDeg).ln();
+ ind().putFloatAttr(XmlSyms.ATTR_Z_DEG, zDeg).ln();
popNest();
ind();
if(rotCurve.isDefaultLinear()){
- putRawText("/>").ln();
+ putCloseEmpty().ln();
}else{
- putRawText(">").ln();
+ putCloseSTag().ln();
pushNest();
ind();
putBezierCurve(rotCurve);
ln();
popNest();
- ind().putRawText("</boneRotEyxz>").ln();
+ ind().putETag(XmlSyms.TAG_BONE_ROT_EYXZ).ln();
}
return;
*/
private void putMorphSequence(VmdMotion vmdMotion)
throws IOException{
- ind().putRawText("<morphSequence>").ln();
+ ind().putSimpleSTag(XmlSyms.TAG_MORPH_SEQUENCE).ln();
pushNest();
- NamedListMap<MorphMotion> listmap = vmdMotion.getMorphPartMap();
- if( ! listmap.isEmpty() ) ln();
- putMorphPartList(listmap);
+ Map<String, List<MorphMotion>> listMap = vmdMotion.getMorphPartMap();
+ if( ! listMap.isEmpty() ) ln();
+ putMorphPartList(listMap);
popNest();
- ind().putRawText("</morphSequence>").ln(2);
+ ind().putETag(XmlSyms.TAG_MORPH_SEQUENCE).ln(2);
return;
}
/**
* 箇所別モーフデータを出力する。
- * @param listmap モーフデータの名前付きリストマップ
+ * @param listMap モーフデータの名前付きリストマップ
* @throws IOException 出力エラー
*/
- private void putMorphPartList(NamedListMap<MorphMotion> listmap)
+ private void putMorphPartList(Map<String, List<MorphMotion>> listMap)
throws IOException{
- for(String morphName : listmap.getNames()){
- if(VmdConst.isBaseMorphName(morphName)) continue;
+ for(Map.Entry<String, List<MorphMotion>> entry : listMap.entrySet()){
+ String morphName = entry.getKey();
+ List<MorphMotion> list = entry.getValue();
+
+ if(VmdUniq.isBaseMorphName(morphName)) continue;
ind().putLineComment(morphName);
String globalName = TypicalMorph.primary2global(morphName);
}
ln();
- ind().putRawText("<morphPart ");
- putAttr("name", morphName).sp();
- putRawText(">").ln();
+ ind().putOpenSTag(XmlSyms.TAG_MORPH_PART).sp();
+ putAttr(XmlSyms.ATTR_NAME, morphName).sp();
+ putCloseSTag().ln();
pushNest();
- List<MorphMotion> list = listmap.getNamedList(morphName);
for(MorphMotion morph : list){
putMorphMotion(morph);
}
popNest();
- ind().putRawText("</morphPart>").ln(2);
+ ind().putETag(XmlSyms.TAG_MORPH_PART).ln(2);
}
return;
*/
private void putMorphMotion(MorphMotion morphMotion)
throws IOException{
- ind().putRawText("<morphMotion ");
+ ind().putOpenSTag(XmlSyms.TAG_MORPH_MOTION).sp();
int frameNo = morphMotion.getFrameNumber();
float flex = morphMotion.getFlex();
- putIntAttr("frame", frameNo).sp();
- putFloatAttr("flex", flex).sp();
-
- putRawText("/>").ln();
-
- return;
- }
-
- /**
- * カメラ演出データを出力する。
- * @param vmdMotion 演出データ
- * @throws IOException 出力エラー
- */
- private void putCameraSequence(VmdMotion vmdMotion)
- throws IOException{
- ind().putBlockComment(BEZIER_COMMENT);
- ind().putBlockComment(CAMERA_COMMENT);
-
- ind().putRawText("<cameraSequence>").ln();
-
- pushNest();
- List<CameraMotion> list = vmdMotion.getCameraMotionList();
- if( ! list.isEmpty() ) ln();
- for(CameraMotion camera : list){
- putCameraMotion(camera);
- }
- popNest();
-
- ind().putRawText("</cameraSequence>").ln(2);
-
- return;
- }
-
- /**
- * カメラモーションを出力する。
- * @param cameraMotion カメラモーション
- * @throws IOException 出力エラー
- */
- private void putCameraMotion(CameraMotion cameraMotion)
- throws IOException{
- ind().putRawText("<cameraMotion ");
- int frameNo = cameraMotion.getFrameNumber();
- putIntAttr("frame", frameNo).sp();
- if( ! cameraMotion.hasPerspective() ){
- putAttr("hasPerspective", "false").sp();
- }
- putRawText(">").ln();
-
- pushNest();
- putCameraTarget(cameraMotion);
- putCameraRotation(cameraMotion);
- putCameraRange(cameraMotion);
- putProjection(cameraMotion);
- popNest();
-
- ind().putRawText("</cameraMotion>").ln(2);
-
- return;
- }
-
- /**
- * カメラターゲット情報を出力する。
- * @param cameraMotion カメラモーション
- * @throws IOException 出力エラー
- */
- private void putCameraTarget(CameraMotion cameraMotion)
- throws IOException{
- ind().putRawText("<cameraTarget ");
- MkPos3D position = cameraMotion.getCameraTarget();
- putFloatAttr("xPos", (float) position.getXpos()).sp();
- putFloatAttr("yPos", (float) position.getYpos()).sp();
- putFloatAttr("zPos", (float) position.getZpos()).sp();
-
- PosCurve posCurve = cameraMotion.getTargetPosCurve();
- if(posCurve.isDefaultLinear()){
- putRawText("/>").ln();
- }else{
- putRawText(">").ln();
-
- pushNest();
- putPositionCurve(posCurve);
- popNest();
-
- ind().putRawText("</cameraTarget>").ln();
- }
-
- return;
- }
-
- /**
- * カメラ回転情報を出力する。
- * @param cameraMotion カメラモーション
- * @throws IOException 出力エラー
- */
- private void putCameraRotation(CameraMotion cameraMotion)
- throws IOException{
- ind().putRawText("<cameraRotation ");
- CameraRotation rotation = cameraMotion.getCameraRotation();
- putFloatAttr("xRad", rotation.getLatitude()).sp();
- putFloatAttr("yRad", rotation.getLongitude()).sp();
- putFloatAttr("zRad", rotation.getRoll()).sp();
-
- BezierParam rotCurve = cameraMotion.getIntpltRotation();
- if(rotCurve.isDefaultLinear()){
- putRawText("/>").ln();
- }else{
- putRawText(">").ln();
- pushNest();
- ind();
- putBezierCurve(rotCurve);
- ln();
- popNest();
- ind().putRawText("</cameraRotation>").ln();
- }
-
- return;
- }
-
- /**
- * カメラ距離情報を出力する。
- * @param cameraMotion カメラモーション
- * @throws IOException 出力エラー
- */
- private void putCameraRange(CameraMotion cameraMotion)
- throws IOException{
- ind().putRawText("<cameraRange ");
- float range = cameraMotion.getRange();
- putFloatAttr("range", range).sp();
-
- BezierParam rangeCurve = cameraMotion.getIntpltRange();
- if(rangeCurve.isDefaultLinear()){
- putRawText("/>").ln();
- }else{
- putRawText(">").ln();
- pushNest();
- ind();
- putBezierCurve(rangeCurve);
- ln();
- popNest();
- ind().putRawText("</cameraRange>").ln();
- }
-
- return;
- }
-
- /**
- * スクリーン投影情報を出力する。
- * @param cameraMotion カメラモーション
- * @throws IOException 出力エラー
- */
- private void putProjection(CameraMotion cameraMotion)
- throws IOException{
- ind().putRawText("<projection ");
- putIntAttr("vertDeg", cameraMotion.getProjectionAngle()).sp();
-
- BezierParam projCurve = cameraMotion.getIntpltProjection();
- if(projCurve.isDefaultLinear()){
- putRawText("/>").ln();
- }else{
- putRawText(">").ln();
- pushNest();
- ind();
- putBezierCurve(projCurve);
- ln();
- popNest();
- ind().putRawText("</projection>").ln();
- }
-
- return;
- }
-
- /**
- * 照明演出データを出力する。
- * @param vmdMotion 演出データ
- * @throws IOException 出力エラー
- */
- private void putLuminousSequence(VmdMotion vmdMotion)
- throws IOException{
- ind().putRawText("<luminousSequence>").ln();
-
- pushNest();
- List<LuminousMotion> list = vmdMotion.getLuminousMotionList();
- if( ! list.isEmpty() ) ln();
- for(LuminousMotion luminous : list){
- putLuminousMotion(luminous);
- }
- popNest();
-
- ind().putRawText("</luminousSequence>").ln(2);
-
- return;
- }
-
- /**
- * 照明モーションを出力する。
- * @param luminousMotion 照明モーション
- * @throws IOException 出力エラー
- */
- private void putLuminousMotion(LuminousMotion luminousMotion)
- throws IOException{
- ind().putRawText("<luminousAct ");
- int frameNo = luminousMotion.getFrameNumber();
- putIntAttr("frame", frameNo);
- putRawText(" >").ln();
-
- LuminousColor color = luminousMotion.getColor();
- LuminousVector vector = luminousMotion.getDirection();
-
- pushNest();
- putLuminousColor(color);
- putLuminousDirection(vector);
- popNest();
-
- ind().putRawText("</luminousAct>").ln(2);
-
- return;
- }
-
- /**
- * 光源色情報を出力する。
- * @param color 光源色
- * @throws IOException 出力エラー
- */
- private void putLuminousColor(LuminousColor color)
- throws IOException{
- ind().putRawText("<lumiColor ");
- putFloatAttr("rCol", color.getColR()).sp();
- putFloatAttr("gCol", color.getColG()).sp();
- putFloatAttr("bCol", color.getColB()).sp();
- putRawText("/>").ln();
-
- return;
- }
-
- /**
- * 照明方向情報を出力する。
- * @param vector 照明方向
- * @throws IOException 出力エラー
- */
- private void putLuminousDirection(LuminousVector vector)
- throws IOException{
- ind().putRawText("<lumiDirection ");
- putFloatAttr("xVec", vector.getVecX()).sp();
- putFloatAttr("yVec", vector.getVecY()).sp();
- putFloatAttr("zVec", vector.getVecZ()).sp();
- putRawText("/>").ln();
-
- return;
- }
-
- /**
- * シャドウ演出データを出力する。
- * @param vmdMotion 演出データ
- * @throws IOException 出力エラー
- */
- private void putShadowSequence(VmdMotion vmdMotion)
- throws IOException{
- ind().putBlockComment(SHADOW_COMMENT);
-
- ind().putRawText("<shadowSequence>").ln();
-
- pushNest();
- List<ShadowMotion> list = vmdMotion.getShadowMotionList();
- for(ShadowMotion shadow : list){
- putShadowMotion(shadow);
- }
- popNest();
-
- ind().putRawText("</shadowSequence>").ln(2);
-
- return;
- }
-
- /**
- * シャドウモーションを出力する。
- * @param shadowMotion シャドウモーション
- * @throws IOException 出力エラー
- */
- private void putShadowMotion(ShadowMotion shadowMotion)
- throws IOException{
- ind().putRawText("<shadowAct ");
-
- int frameNo = shadowMotion.getFrameNumber();
- ShadowMode mode = shadowMotion.getShadowMode();
- float rawParam = shadowMotion.getRawScopeParam();
-
- putIntAttr("frame", frameNo).sp();
- putAttr("mode", mode.name()).sp();
- putFloatAttr("rawParam", rawParam).sp();
-
- putRawText("/>");
+ putIntAttr(XmlSyms.ATTR_FRAME, frameNo).sp();
+ putFloatAttr(XmlSyms.ATTR_FLEX, flex).sp();
- double uiVal = ShadowMotion.rawParamToScope(rawParam);
- long lVal = Math.round(uiVal);
- sp().putLineComment("UI:" + lVal).ln();
+ putCloseEmpty().ln();
return;
}
+++ /dev/null
-/*
- * xml resources for VMD-XML
- *
- * License : The MIT License
- * Copyright(c) 2011 MikuToga Partners
- */
-
-package jp.sourceforge.mikutoga.vmd.model.xml;
-
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import jp.sourceforge.mikutoga.xml.XmlResourceResolver;
-import org.w3c.dom.ls.LSResourceResolver;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-
-/**
- * モーションデータ用各種XMLリソースの定義。
- */
-public final class VmdXmlResources {
-
- /** 定義の版数。 */
- public static final String VER_VMDXML =
- "110820";
- /** XML名前空間識別子。 */
- public static final String NS_VMDXML =
- "http://mikutoga.sourceforge.jp/xml/ns/vmdxml/110820";
- /** XMLスキーマURI名。 */
- public static final String SCHEMAURI_VMDXML =
- "http://mikutoga.sourceforge.jp/xml/xsd/vmdxml-110820.xsd";
- /** ローカルなスキーマファイル名。 */
- public static final String LOCAL_SCHEMA_VMDXML =
- "resources/vmdxml-110820.xsd";
-
- /** XMLスキーマURI。 */
- public static final URI URI_SCHEMA_VMDXML;
- /** XMLスキーマのローカルリソース。 */
- public static final URI RES_SCHEMA_VMDXML;
-
-
- private static final Class<?> THISCLASS = VmdXmlResources.class;
-
-
- static{
- try{
- URI_SCHEMA_VMDXML = URI.create(SCHEMAURI_VMDXML);
- RES_SCHEMA_VMDXML =
- THISCLASS.getResource(LOCAL_SCHEMA_VMDXML).toURI();
- }catch(URISyntaxException e){
- throw new ExceptionInInitializerError(e);
- }
-
- new VmdXmlResources().hashCode();
- }
-
-
- /**
- * 隠しコンストラクタ。
- */
- private VmdXmlResources(){
- super();
- assert this.getClass().equals(THISCLASS);
- return;
- }
-
-
- /**
- * ビルダの生成。
- * @param handler エラーハンドラ
- * @return ビルダ
- */
- public static DocumentBuilder newBuilder(ErrorHandler handler){
- XmlResourceResolver resolver = createResolver();
-
- Schema schema = createSchema(resolver);
-
- DocumentBuilderFactory builderFactory = createBuilderFactory();
- builderFactory.setSchema(schema);
-
- DocumentBuilder builder;
- try{
- builder = builderFactory.newDocumentBuilder();
- }catch(ParserConfigurationException e){
- assert false;
- throw new AssertionError(e);
- }
- builder.setEntityResolver(resolver);
- builder.setErrorHandler(handler);
-
- return builder;
- }
-
- /**
- * URI参照をローカルなリソースアクセスへとリダイレクトするリゾルバを生成する。
- * @return リゾルバ
- */
- private static XmlResourceResolver createResolver(){
- XmlResourceResolver resolver = new XmlResourceResolver();
- resolver.putRedirected(URI_SCHEMA_VMDXML, RES_SCHEMA_VMDXML);
-// resolver.putRedirected(URI_DTD_VMDXML, RES_DTD_VMDXML);
-
- return resolver;
- }
-
- /**
- * 検証用スキーマ(XML schema)を生成する。
- * @param resolver リゾルバ
- * @return スキーマ
- */
- private static Schema createSchema(LSResourceResolver resolver){
- SchemaFactory schemaFactory =
- SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- schemaFactory.setResourceResolver(resolver);
-
- URL localXsd;
- try{
- localXsd = RES_SCHEMA_VMDXML.toURL();
- }catch(MalformedURLException e){
- assert false;
- throw new AssertionError(e);
- }
-
- Schema schema;
- try{
- schema = schemaFactory.newSchema(localXsd);
- }catch(SAXException e){
- assert false;
- throw new AssertionError(e);
- }
-
- return schema;
- }
-
- /**
- * DocumentBuilderFavtoryを生成する。
- * @return ファクトリ
- */
- private static DocumentBuilderFactory createBuilderFactory(){
- DocumentBuilderFactory builderFactory =
- DocumentBuilderFactory.newInstance();
-
- builderFactory.setNamespaceAware(true);
- builderFactory.setValidating(false); // DTD validation off
- builderFactory.setIgnoringComments(true);
- try{
- builderFactory.setXIncludeAware(true);
- }catch(UnsupportedOperationException e){
- // NOTHING
- assert true;
- }
-
- return builderFactory;
- }
-
-}
package jp.sourceforge.mikutoga.vmd.model.xml;
import java.util.Iterator;
-import jp.sourceforge.mikutoga.vmd.model.BezierParam;
-import jp.sourceforge.mikutoga.vmd.model.PosCurve;
+import jp.sfjp.mikutoga.vmd.model.BezierParam;
+import jp.sfjp.mikutoga.vmd.model.PosCurve;
import jp.sourceforge.mikutoga.xml.DomNsUtils;
import jp.sourceforge.mikutoga.xml.SiblingElemIterator;
import jp.sourceforge.mikutoga.xml.TogaXmlException;
static boolean hasNsLocalNameElem(Element elem,
String localName ){
return DomNsUtils.hasNsLocalNameElem(elem,
- VmdXmlResources.NS_VMDXML,
+ Schema110820.NS_VMDXML,
localName );
}
*/
static Element pickChild(Element parent, String localName){
return DomNsUtils.pickFirstChild(parent,
- VmdXmlResources.NS_VMDXML,
+ Schema110820.NS_VMDXML,
localName );
}
static Element getChild(Element parent, String localName)
throws TogaXmlException{
return DomNsUtils.getFirstChild(parent,
- VmdXmlResources.NS_VMDXML,
+ Schema110820.NS_VMDXML,
localName );
}
*/
static Iterable<Element> eachChild(Element parent, String localName){
return DomNsUtils.getEachChild(parent,
- VmdXmlResources.NS_VMDXML,
+ Schema110820.NS_VMDXML,
localName );
}
*/
static void buildPosCurve(Element positionElem, PosCurve curve)
throws TogaXmlException{
- Iterator<Element> it =
+ Iterator<Element> itElem =
new SiblingElemIterator(positionElem,
- VmdXmlResources.NS_VMDXML, null);
+ Schema110820.NS_VMDXML, null);
+ Iterator<BezierParam> itBez = curve.iterator();
int ct = 0;
- while(it.hasNext()){
- Element curveElem = it.next();
- BezierParam bz = curve.item(ct);
+ while(itElem.hasNext()){
+ Element curveElem = itElem.next();
+ BezierParam bz = itBez.next();
setBezier(curveElem, bz);
ct++;
}
import javax.xml.parsers.DocumentBuilder;
import jp.sfjp.mikutoga.math.MkPos3D;
import jp.sfjp.mikutoga.math.MkQuat;
-import jp.sourceforge.mikutoga.vmd.model.BezierParam;
-import jp.sourceforge.mikutoga.vmd.model.BoneMotion;
-import jp.sourceforge.mikutoga.vmd.model.MorphMotion;
-import jp.sourceforge.mikutoga.vmd.model.NamedListMap;
-import jp.sourceforge.mikutoga.vmd.model.PosCurve;
-import jp.sourceforge.mikutoga.vmd.model.VmdMotion;
+import jp.sfjp.mikutoga.vmd.model.BezierParam;
+import jp.sfjp.mikutoga.vmd.model.BoneMotion;
+import jp.sfjp.mikutoga.vmd.model.MorphMotion;
+import jp.sfjp.mikutoga.vmd.model.PosCurve;
+import jp.sfjp.mikutoga.vmd.model.VmdMotion;
import jp.sourceforge.mikutoga.xml.TogaXmlException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
* @throws TogaXmlException 構文エラー
*/
private static void buildModelName(Element vmdMotionElem,
- VmdMotion vmdMotion)
+ VmdMotion vmdMotion)
throws TogaXmlException{
Element modelNameElem = Xml.getChild(vmdMotionElem, "modelName");
String modelName = Xml.getStringAttr(modelNameElem, "name");
* @throws TogaXmlException 構文エラー
*/
private static void buildBoneSeq(Element vmdMotionElem,
- VmdMotion vmdMotion )
+ VmdMotion vmdMotion )
throws TogaXmlException{
- NamedListMap<BoneMotion> boneMap = vmdMotion.getBonePartMap();
-
Element boneSeqElem =
Xml.getChild(vmdMotionElem, "boneMotionSequence");
for(Element bonePartElem : Xml.eachChild(boneSeqElem, "bonePart")){
- buildBonePart(bonePartElem, boneMap);
+ buildBonePart(bonePartElem, vmdMotion);
}
return;
/**
* ボーンパートを読み込む。
* @param bonePartElem bonePart要素
- * @param boneMap 名前マップ
+ * @param vmdMotion モーション
* @throws TogaXmlException 構文エラー
*/
private static void buildBonePart(Element bonePartElem,
- NamedListMap<BoneMotion> boneMap )
+ VmdMotion vmdMotion )
throws TogaXmlException{
String boneName = Xml.getStringAttr(bonePartElem, "name");
Xml.eachChild(bonePartElem, "boneMotion")){
BoneMotion boneMotion = buildBoneMotion(boneMotionElem);
boneMotion.setBoneName(boneName);
- boneMap.addNamedElement(boneName, boneMotion);
+ vmdMotion.addBoneMotion(boneMotion);
}
return;
* @throws TogaXmlException 構文エラー
*/
private static void buildMorphSeq(Element vmdMotionElem,
- VmdMotion vmdMotion )
+ VmdMotion vmdMotion )
throws TogaXmlException{
- NamedListMap<MorphMotion> morphMap = vmdMotion.getMorphPartMap();
-
Element morphSeqElem = Xml.getChild(vmdMotionElem, "morphSequence");
for(Element morphPartElem :
Xml.eachChild(morphSeqElem, "morphPart")){
- buildMorphPart(morphPartElem, morphMap);
+ buildMorphPart(morphPartElem, vmdMotion);
}
return;
/**
* モーフパートを読み込む。
* @param morphPartElem morphPart要素
- * @param morphMap 名前マップ
+ * @param vmdMotion モーション
* @throws TogaXmlException 構文エラー
*/
private static void buildMorphPart(Element morphPartElem,
- NamedListMap<MorphMotion> morphMap )
+ VmdMotion vmdMotion )
throws TogaXmlException{
String morphName = Xml.getStringAttr(morphPartElem, "name");
for(Element morphMotionElem : childs){
MorphMotion morphMotion = buildMorphMotion(morphMotionElem);
morphMotion.setMorphName(morphName);
- morphMap.addNamedElement(morphName, morphMotion);
+ vmdMotion.addMorphMotion(morphMotion);
}
return;
import java.util.List;
import jp.sfjp.mikutoga.math.MkPos3D;
-import jp.sourceforge.mikutoga.vmd.model.BezierParam;
-import jp.sourceforge.mikutoga.vmd.model.CameraMotion;
-import jp.sourceforge.mikutoga.vmd.model.CameraRotation;
-import jp.sourceforge.mikutoga.vmd.model.PosCurve;
-import jp.sourceforge.mikutoga.vmd.model.VmdMotion;
+import jp.sfjp.mikutoga.vmd.model.BezierParam;
+import jp.sfjp.mikutoga.vmd.model.CameraMotion;
+import jp.sfjp.mikutoga.vmd.model.CameraRotation;
+import jp.sfjp.mikutoga.vmd.model.PosCurve;
+import jp.sfjp.mikutoga.vmd.model.VmdMotion;
import jp.sourceforge.mikutoga.xml.TogaXmlException;
import org.w3c.dom.Element;
package jp.sourceforge.mikutoga.vmd.model.xml;
import java.util.List;
-import jp.sourceforge.mikutoga.vmd.model.LuminousColor;
-import jp.sourceforge.mikutoga.vmd.model.LuminousMotion;
-import jp.sourceforge.mikutoga.vmd.model.LuminousVector;
-import jp.sourceforge.mikutoga.vmd.model.ShadowMode;
-import jp.sourceforge.mikutoga.vmd.model.ShadowMotion;
-import jp.sourceforge.mikutoga.vmd.model.VmdMotion;
+import jp.sfjp.mikutoga.math.MkVec3D;
+import jp.sfjp.mikutoga.vmd.model.LuminousColor;
+import jp.sfjp.mikutoga.vmd.model.LuminousMotion;
+import jp.sfjp.mikutoga.vmd.model.ShadowMode;
+import jp.sfjp.mikutoga.vmd.model.ShadowMotion;
+import jp.sfjp.mikutoga.vmd.model.VmdMotion;
import jp.sourceforge.mikutoga.xml.TogaXmlException;
import org.w3c.dom.Element;
Element lumiDirectionElem =
Xml.getChild(luminousActElem, "lumiDirection");
- LuminousVector vec = luminousMotion.getDirection();
+ MkVec3D vec = luminousMotion.getDirection();
float xVec = Xml.getFloatAttr(lumiDirectionElem, "xVec");
float yVec = Xml.getFloatAttr(lumiDirectionElem, "yVec");
float zVec = Xml.getFloatAttr(lumiDirectionElem, "zVec");
- vec.setVecX(xVec);
- vec.setVecY(yVec);
- vec.setVecZ(zVec);
+ vec.setXVal(xVec);
+ vec.setYVal(yVec);
+ vec.setZVal(zVec);
luminousList.add(luminousMotion);
--- /dev/null
+/*
+ * xml symbols
+ *
+ * License : The MIT License
+ * Copyright(c) 2013 MikuToga Partners
+ */
+
+package jp.sourceforge.mikutoga.vmd.model.xml;
+
+/**
+ * XML 各種シンボル名。
+ */
+final class XmlSyms {
+
+ static final String TOP_COMMENT =
+ " MikuMikuDance\n motion-data(*.vmd) on XML";
+
+ static final String QUATERNION_COMMENT =
+ " bone-rotation has Quaternion parameters [boneRotQuat]\n"
+ + " or YXZ-Euler angles [boneRotEyxz].\n"
+ + " Quaternion form is strongly recommended"
+ + " if you are data-exchanging.";
+
+ static final String BEZIER_COMMENT =
+ " motion-interpolation is described with Bezier-cubic-curve.\n"
+ + " implicit bezier curve point : P0=(0,0) P3=(127,127)\n"
+ + " defLinear : MMD default linear curve."
+ + " P1=(20,20) P2=(107,107) [DEFAULT]\n"
+ + " defEaseInOut : MMD default ease-in-out curve."
+ + " P1=(64,0) P2=(64,127)";
+
+ static final String CAMERA_COMMENT =
+ " camera-rotation has polar-coordinates parameters.\n"
+ + " xRad = -radian(UI_X) [latitude]\n"
+ + " yRad = radian(UI_Y) [longitude]\n"
+ + " zRad = radian(UI_Z) [roll]\n"
+ + " range = -(UI_RANGE)";
+
+ static final String SHADOW_COMMENT =
+ " UI_VALUE = EFFECTIVE_RANGE * 100 ???\n"
+ +" rawParam = 0.1 - (UI_VALUE / 1.0E+5)\n\n"
+ +" NONE : no self-shadow\n"
+ +" MODE_1 : reduce shadow-quality suddenly at range\n"
+ +" MODE_2 : reduce shadow-quality gradually with range";
+
+ static final String TAG_VMD_MOTION = "vmdMotion";
+ static final String TAG_META = "meta";
+ static final String TAG_MODEL_NAME = "modelName";
+ static final String TAG_BONE_M_SEQUENCE = "boneMotionSequence";
+ static final String TAG_BONE_PART = "bonePart";
+ static final String TAG_BONE_MOTION = "boneMotion";
+ static final String TAG_BONE_POSITION = "bonePosition";
+ static final String TAG_BONE_ROT_QUAT = "boneRotQuat";
+ static final String TAG_BONE_ROT_EYXZ = "boneRotEyxz";
+ static final String TAG_BEZIER = "bezier";
+ static final String TAG_DEF_LINEAR = "defLinear";
+ static final String TAG_DEF_EASE_IN_OUT = "defEaseInOut";
+ static final String TAG_MORPH_SEQUENCE = "morphSequence";
+ static final String TAG_MORPH_PART = "morphPart";
+ static final String TAG_MORPH_MOTION = "morphMotion";
+ static final String TAG_CAMERA_SEQUENCE = "cameraSequence";
+ static final String TAG_CAMERA_MOTION = "cameraMotion";
+ static final String TAG_CAMERA_TARGET = "cameraTarget";
+ static final String TAG_CAMERA_ROTATION = "cameraRotation";
+ static final String TAG_CAMERA_RANGE = "cameraRange";
+ static final String TAG_PROJECTION = "projection";
+ static final String TAG_LUMI_SEQUENCE = "luminousSequence";
+ static final String TAG_LUMINOUS_ACT = "luminousAct";
+ static final String TAG_LUMI_COLOR = "lumiColor";
+ static final String TAG_LUMI_DIRECTION = "lumiDirection";
+ static final String TAG_SHADOW_SEQUENCE = "shadowSequence";
+ static final String TAG_SHADOW_ACT = "shadowAct";
+
+ static final String ATTR_VERSION = "version";
+ static final String ATTR_CONTENT = "content";
+ static final String ATTR_FRAME = "frame";
+ static final String ATTR_NAME = "name";
+ static final String ATTR_P1X = "p1x";
+ static final String ATTR_P1Y = "p1y";
+ static final String ATTR_P2X = "p2x";
+ static final String ATTR_P2Y = "p2y";
+ static final String ATTR_QX = "qx";
+ static final String ATTR_QY = "qy";
+ static final String ATTR_QZ = "qz";
+ static final String ATTR_QW = "qw";
+ static final String ATTR_X_DEG = "xDeg";
+ static final String ATTR_Y_DEG = "yDeg";
+ static final String ATTR_Z_DEG = "zDeg";
+ static final String ATTR_X_POS = "xPos";
+ static final String ATTR_Y_POS = "yPos";
+ static final String ATTR_Z_POS = "zPos";
+ static final String ATTR_FLEX = "flex";
+ static final String ATTR_RANGE = "range";
+ static final String ATTR_X_RAD = "xRad";
+ static final String ATTR_Y_RAD = "yRad";
+ static final String ATTR_Z_RAD = "zRad";
+ static final String ATTR_VERT_DEG = "vertDeg";
+ static final String ATTR_HAS_PERSPECTIVE = "hasPerspective";
+ static final String ATTR_X_VEC = "xVec";
+ static final String ATTR_Y_VEC = "yVec";
+ static final String ATTR_Z_VEC = "zVec";
+ static final String ATTR_R_COL = "rCol";
+ static final String ATTR_G_COL = "gCol";
+ static final String ATTR_B_COL = "bCol";
+ static final String ATTR_MODE = "mode";
+ static final String ATTR_RAW_PARAM = "rawParam";
+
+
+ /**
+ * 隠しコンストラクタ。
+ */
+ private XmlSyms(){
+ assert false;
+ throw new AssertionError();
+ }
+
+}
+++ /dev/null
-/*
- * command argument information
- *
- * License : The MIT License
- * Copyright(c) 2011 MikuToga Partners
- */
-
-package jp.sourceforge.mikutoga.vmd2xml;
-
-import java.util.Arrays;
-import java.util.Iterator;
-
-/**
- * コマンドライン引数情報。
- */
-final class ArgInfo {
-
- /** ヘルプ文字列。 */
- public static final String CMD_HELP =
- "-h : put help massage\n\n"
- + "-vmd2xml : convert *.vmd to *.xml\n"
- + "-xml2vmd : convert *.xml to *.vmd\n\n"
- + "-i file : specify input file\n"
- + "-o file : specify output file\n"
- + "-f : force overwriting\n\n"
- + "-quat : Quaternion output mode [default]\n"
- + "-eyxz : YXZ-Euler output mode\n";
-
- private static final String ERRMSG_UNKNOWN = "Unknown option : ";
- private static final String ERRMSG_INCOMP_I = "You need -i argument.";
- private static final String ERRMSG_INCOMP_O = "You need -o argument.";
- private static final String ERRMSG_EXCLUSIVE =
- "You must specify -vmd2xml or -xml2vmd.";
- private static final String ERRMSG_NOINPUT =
- "You must specify input file with -i.";
- private static final String ERRMSG_NOOUTPUT =
- "You must specify output file with -o.";
-
-
- private String inputFile = null;
- private String outputFile = null;
- private boolean vmd2xml = false;
- private boolean xml2vmd = false;
- private boolean force = false;
- private boolean helpMode = false;
- private boolean quaternionMode = true;
-
- private boolean hasOptionError = false;
- private String errorMessage = null;
-
-
- /**
- * コンストラクタ。
- */
- private ArgInfo(){
- super();
- return;
- }
-
-
- /**
- * コマンドライン引数を解析する。
- * @param args コマンドライン引数
- * @return 解析結果
- */
- public static ArgInfo buildArgInfo(String[] args){
- return buildArgInfo(Arrays.asList(args));
- }
-
- /**
- * コマンドライン引数を解析する。
- * @param args コマンドライン引数
- * @return 解析結果
- */
- public static ArgInfo buildArgInfo(Iterable<String> args){
- return buildArgInfo(args.iterator());
- }
-
- /**
- * コマンドライン引数を解析する。
- * @param argIter コマンドライン引数
- * @return 解析結果
- */
- public static ArgInfo buildArgInfo(Iterator<String> argIter){
- ArgInfo result = new ArgInfo();
-
- while(argIter.hasNext()){
- String arg = argIter.next();
- OptSwitch option = OptSwitch.parse(arg);
- if(option == null){
- result.setOptionError(ERRMSG_UNKNOWN + arg);
- break;
- }
-
- result.parseOption(option, argIter);
-
- if(result.hasOptionError()) break;
- if(result.isHelpMode()) break;
- }
-
- result.checkOptionError();
-
- return result;
- }
-
- /**
- * 単一もしくは引数を持つオプション種別を解析する。
- * @param argIter コマンドライン引数
- * @param option オプション種別
- */
- private void parseOption(OptSwitch option, Iterator<String> argIter){
- switch(option){
- case HELP:
- this.helpMode = true;
- break;
- case VMD2XML:
- this.vmd2xml = true;
- this.xml2vmd = false;
- break;
- case XML2VMD:
- this.vmd2xml = false;
- this.xml2vmd = true;
- break;
- case FORCE:
- this.force = true;
- break;
- case INPUTFILE:
- if( ! argIter.hasNext() ){
- this.setOptionError(ERRMSG_INCOMP_I);
- break;
- }
- this.inputFile = argIter.next();
- break;
- case OUTPUTFILE:
- if( ! argIter.hasNext() ){
- this.setOptionError(ERRMSG_INCOMP_O);
- break;
- }
- this.outputFile = argIter.next();
- break;
- case QUATERNION:
- this.quaternionMode = true;
- break;
- case EULERYXZ:
- this.quaternionMode = false;
- break;
- default:
- assert false;
- throw new AssertionError();
- }
-
- return;
- }
-
- /**
- * オプション指定の整合性をチェックする。
- * <p>必要に応じてエラーの有無とメッセージが登録される。
- */
- private void checkOptionError(){
- if( hasOptionError() || isHelpMode() ) return;
-
- if( ( ! isVmd2XmlMode() ) && ( ! isXml2VmdMode() ) ){
- setOptionError(ERRMSG_EXCLUSIVE);
- }else if(getInputFile() == null){
- setOptionError(ERRMSG_NOINPUT);
- }else if(getOutputFile() == null){
- setOptionError(ERRMSG_NOOUTPUT);
- }
-
- return;
- }
-
- /**
- * オプションエラーを設定する。
- * @param text メッセージ
- */
- private void setOptionError(CharSequence text){
- if(text == null){
- this.errorMessage = null;
- this.hasOptionError = false;
- }else{
- this.errorMessage = text.toString();
- this.hasOptionError = true;
- }
-
- return;
- }
-
- /**
- * 入力ファイル名を返す。
- * @return 入力ファイル名
- */
- public String getInputFile(){
- return this.inputFile;
- }
-
- /**
- * 出力ファイル名を返す。
- * @return 出力ファイル名
- */
- public String getOutputFile(){
- return this.outputFile;
- }
-
- /**
- * 強制上書きモードか判定を返す。
- * @return 強制上書きモードならtrue
- */
- public boolean isForceMode(){
- return this.force;
- }
-
- /**
- * VMD-XML変換モードか判定を返す。
- * @return VMD-XML変換モードならtrue
- */
- public boolean isVmd2XmlMode(){
- return this.vmd2xml;
- }
-
- /**
- * XML-VMD変換モードか判定を返す。
- * @return XML-VMD変換モードならtrue
- */
- public boolean isXml2VmdMode(){
- return this.xml2vmd;
- }
-
- /**
- * ヘルプモードか否か判定を返す。
- * @return ヘルプモードならtrue
- */
- public boolean isHelpMode(){
- return this.helpMode;
- }
-
- /**
- * クォータニオン出力モードか否か判定を返す。
- * @return クォータニオン出力モードならtrue
- */
- public boolean isQuaternionMode(){
- return this.quaternionMode;
- }
-
- /**
- * コマンドライン解析中にエラーが検出されたか判定する。
- * @return エラーが検出されればtrue
- */
- public boolean hasOptionError(){
- return this.hasOptionError;
- }
-
- /**
- * コマンドライン解析中のエラーメッセージを返す。
- * @return エラーメッセージ。エラーが無ければnull
- */
- public String getErrorMessage(){
- return this.errorMessage;
- }
-
- /**
- * オプション列挙子。
- */
- private static enum OptSwitch implements Iterable<String> {
-
- HELP ("-h", "-help", "-?"),
- VMD2XML ("-vmd2xml"),
- XML2VMD ("-xml2vmd"),
- FORCE ("-f"),
- INPUTFILE ("-i"),
- OUTPUTFILE ("-o"),
- QUATERNION ("-quat"),
- EULERYXZ ("-eyxz"),
- ;
-
- private final Iterable<String> optLines;
-
- /**
- * コンストラクタ。
- * @param optLines オプション文字列候補群。
- */
- private OptSwitch(String... optLines){
- this.optLines = Arrays.asList(optLines);
- return;
- }
-
- /**
- * 文字列候補群を返す。
- * @return 文字列候補群
- */
- @Override
- public Iterator<String> iterator(){
- return this.optLines.iterator();
- }
-
- /**
- * 文字列に合致する列挙子を返す。
- * @param arg 文字列
- * @return 列挙子。見つからなければnull
- */
- private static OptSwitch parse(String arg){
- for(OptSwitch opt : values()){
- for(String optLine : opt){
- if(optLine.equals(arg)) return opt;
- }
- }
- return null;
- }
-
- }
-
-}
+++ /dev/null
-/*
- * custom error-handler for validation
- *
- * License : The MIT License
- * Copyright(c) 2011 MikuToga Partners
- */
-
-package jp.sourceforge.mikutoga.vmd2xml;
-
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * 妥当性検証用エラーハンドラ。
- * <p>XML SchemaによるXML文書検証を目的とするエラーハンドラ。
- */
-final class ValidationHandler implements ErrorHandler {
-
- /**
- * 唯一のシングルトン。
- */
- static final ErrorHandler HANDLER = new ValidationHandler();
-
- /**
- * 隠しコンストラクタ。
- */
- private ValidationHandler(){
- super();
- return;
- }
-
- /**
- * {@inheritDoc}
- * @param exception {@inheritDoc}
- * @throws SAXException {@inheritDoc}
- */
- @Override
- public void error(SAXParseException exception) throws SAXException{
- throw exception;
- }
-
- /**
- * {@inheritDoc}
- * @param exception {@inheritDoc}
- * @throws SAXException {@inheritDoc}
- */
- @Override
- public void fatalError(SAXParseException exception) throws SAXException{
- throw exception;
- }
-
- /**
- * {@inheritDoc}
- * @param exception {@inheritDoc}
- * @throws SAXException {@inheritDoc}
- */
- @Override
- public void warning(SAXParseException exception) throws SAXException{
- throw exception;
- }
-
-}
+++ /dev/null
-/*
- * vmd to xml converter main entry
- *
- * License : The MIT License
- * Copyright(c) 2011 MikuToga Partners
- */
-
-package jp.sourceforge.mikutoga.vmd2xml;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.nio.channels.FileChannel;
-import java.text.MessageFormat;
-import java.util.Properties;
-import javax.xml.parsers.DocumentBuilder;
-import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.vmd.IllegalVmdDataException;
-import jp.sourceforge.mikutoga.vmd.model.VmdMotion;
-import jp.sourceforge.mikutoga.vmd.model.binio.VmdExporter;
-import jp.sourceforge.mikutoga.vmd.model.binio.VmdLoader;
-import jp.sourceforge.mikutoga.vmd.model.xml.VmdXmlExporter;
-import jp.sourceforge.mikutoga.vmd.model.xml.VmdXmlResources;
-import jp.sourceforge.mikutoga.vmd.model.xml.Xml2VmdLoader;
-import jp.sourceforge.mikutoga.xml.TogaXmlException;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-
-/**
- * VMDモーションファイルとXMLとの間で変換を行うアプリケーション。
- */
-public final class Vmd2Xml {
-
- private static final int EXIT_OK = 0;
- private static final int EXIT_IOERR = 1;
- private static final int EXIT_ENVERR = 4;
- private static final int EXIT_OPTERR = 5;
- private static final int EXIT_INTERR = 6;
- private static final int EXIT_VMDERR = 7;
- private static final int EXIT_XMLERR = 8;
-
- /** アプリ名。 */
- public static final String APPNAME;
- /** バージョン識別子。 */
- public static final String APPVER;
- /** ライセンス種別。 */
- public static final String APPLICENSE;
-
- private static final String APPURL;
-
- private static final Class<?> THISCLASS;
-
- private static final String ERRMSG_TXTONLY =
- "ERROR : {0}\n";
- private static final String ERRMSG_SAXPARSE =
- "ERROR : {0}\nline={1}, columun={2}\n";
-
- private static final PrintStream ERROUT = System.err;
-
- static{
- THISCLASS = Vmd2Xml.class;
- InputStream ver =
- THISCLASS.getResourceAsStream("resources/version.properties");
- Properties verProps = new Properties();
- try{
- try{
- verProps.load(ver);
- }finally{
- ver.close();
- }
- }catch(IOException e){
- throw new ExceptionInInitializerError(e);
- }
-
- APPNAME = verProps.getProperty("app.name");
- APPVER = verProps.getProperty("app.version");
- APPLICENSE = verProps.getProperty("app.license");
- APPURL = verProps.getProperty("app.url");
-
- new Vmd2Xml().hashCode();
- }
-
-
- /**
- * ダミーコンストラクタ。
- */
- private Vmd2Xml(){
- super();
- assert this.getClass().equals(THISCLASS);
- return;
- }
-
-
- /**
- * VMを終了させる。
- * @param code 終了コード
- */
- private static void exit(int code){
- System.exit(code);
- assert false;
- throw new AssertionError();
- }
-
- /**
- * 標準エラー出力に文字列出力を行う。
- * @param obj 文字列
- */
- @SuppressWarnings("PMD.SystemPrintln")
- private static void errprint(Object obj){
- ERROUT.print(obj.toString());
- return;
- }
-
- /**
- * エラーを表示した後VMを終了させる。
- * @param code 終了コード
- * @param text メッセージ
- */
- private static void errExit(int code, CharSequence text){
- errprint("ERROR:\n");
- errprint(text);
- exit(code);
- return;
- }
-
- /**
- * 入出力エラー処理。
- * 例外を出力してVM終了する。
- * @param ex 例外
- */
- private static void ioError(IOException ex){
- errprint(ex);
- errprint('\n');
- exit(EXIT_IOERR);
-
- return;
- }
-
- /**
- * XML構文エラー処理。
- * 例外を出力してVM終了する。
- * @param ex 例外
- */
- private static void xmlError(SAXException ex){
- if(ex instanceof SAXParseException){
- xmlError((SAXParseException)ex);
- }
-
- String txt = ex.getLocalizedMessage();
- String message = MessageFormat.format(ERRMSG_TXTONLY, txt);
- errprint(message);
-
- exit(EXIT_XMLERR);
-
- return;
- }
-
- /**
- * XML構文エラー処理。
- * 例外を出力してVM終了する。
- * @param ex 例外
- */
- private static void xmlError(SAXParseException ex){
- String txt = ex.getLocalizedMessage();
- int line = ex.getLineNumber();
- int col = ex.getColumnNumber();
-
- String message =
- MessageFormat.format(ERRMSG_SAXPARSE, txt, line, col);
- errprint(message);
-
- exit(EXIT_XMLERR);
-
- return;
- }
-
- /**
- * XML構文エラー処理。
- * 例外を出力してVM終了する。
- * @param ex 例外
- */
- private static void xmlError(TogaXmlException ex){
- String txt = ex.getLocalizedMessage();
- String message = MessageFormat.format(ERRMSG_TXTONLY, txt);
- errprint(message);
-
- exit(EXIT_XMLERR);
-
- return;
- }
-
- /**
- * VMDファイルフォーマットエラー処理。
- * 例外を出力してVM終了する。
- * @param ex 例外
- */
- private static void vmdError(MmdFormatException ex){
- errprint(ex);
- errprint('\n');
- ex.printStackTrace(ERROUT);
- exit(EXIT_VMDERR);
-
- return;
- }
-
- /**
- * 内部エラー処理。
- * 例外を出力してVM終了する。
- * @param ex 例外
- */
- private static void internalError(Throwable ex){
- errprint(ex);
- errprint('\n');
- ex.printStackTrace(ERROUT);
- exit(EXIT_INTERR);
-
- return;
- }
-
- /**
- * JREのバージョン判定を行う。
- * 不適切ならVMごと終了。
- */
- private static void checkJRE(){
- Package jrePackage = java.lang.Object.class.getPackage();
- if( ! jrePackage.isCompatibleWith("1.6")){
- errExit(EXIT_ENVERR, "You need JRE 1.6 or later.\n");
- }
- return;
- }
-
- /**
- * ヘルプメッセージを出力する。
- */
- private static void putHelp(){
- StringBuilder text = new StringBuilder();
-
- text.append(APPNAME).append(' ').append(APPVER).append('\n');
- text.append(" License : ").append(APPLICENSE).append('\n');
- text.append(" ").append(APPURL).append('\n');
- text.append('\n');
- text.append(ArgInfo.CMD_HELP);
-
- errprint(text);
-
- return;
- }
-
- /**
- * ファイルサイズを0に切り詰める。
- * @param file ファイル
- * @throws IOException 入出力エラー
- */
- private static void trunc(File file) throws IOException{
- if( ! file.exists() ) return;
- if( ! file.isFile() ) return;
-
- if(file.length() <= 0L) return;
-
- FileOutputStream foStream = new FileOutputStream(file);
- try{
- FileChannel channnel = foStream.getChannel();
- try{
- channnel.truncate(0L);
- }finally{
- channnel.close();
- }
- }finally{
- foStream.close();
- }
-
- return;
- }
-
- /**
- * 入力ストリームを得る。
- * @param fileName 入力ファイル名
- * @return 入力ストリーム
- * @throws FileNotFoundException 入力ファイルが見つからない。
- */
- private static InputStream openInputStream(String fileName)
- throws FileNotFoundException {
- File file = new File(fileName);
- InputStream result = new FileInputStream(file);
- result = new BufferedInputStream(result);
- return result;
- }
-
- /**
- * 出力ストリームを得る。
- * @param fileName 出力ファイル名
- * @return 出力ストリーム
- * @throws FileNotFoundException 出力ファイルが見つからない
- * @throws IOException 出力エラー
- */
- private static OutputStream openTruncatedOutputStream(String fileName)
- throws FileNotFoundException, IOException {
- File file = new File(fileName);
- trunc(file);
- OutputStream result = new FileOutputStream(file, false);
- result = new BufferedOutputStream(result);
- return result;
- }
-
- /**
- * Mainエントリ。
- * @param args コマンドパラメータ
- */
- public static void main(String[] args){
- checkJRE();
-
- ArgInfo argInfo = ArgInfo.buildArgInfo(args);
- if(argInfo.hasOptionError()){
- String message = argInfo.getErrorMessage() + "\n"
- + "(-h for help)\n";
- errExit(EXIT_OPTERR, message);
- }
-
- if(argInfo.isHelpMode()){
- putHelp();
- exit(EXIT_OK);
- }
-
- checkFiles(argInfo);
-
- String input = argInfo.getInputFile();
- String output = argInfo.getOutputFile();
-
- InputStream is = null;
- OutputStream os = null;
- try{
- is = openInputStream(input);
- os = openTruncatedOutputStream(output);
- }catch(FileNotFoundException e){
- ioError(e);
- }catch(IOException e){
- ioError(e);
- }
-
- if(argInfo.isVmd2XmlMode()) vmd2xml(is, os, argInfo);
- else xml2vmd(is, os);
-
- exit(EXIT_OK);
-
- return;
- }
-
- /**
- * 既に存在する通常ファイルか否か判定する。
- * @param file 判定対象
- * @return 既に存在する通常ファイルならtrue
- */
- private static boolean isExistsNormalFile(File file){
- if( ! file.exists() ) return false;
- if( ! file.isFile() ) return false;
- return true;
- }
-
- /**
- * 既に存在する特殊ファイルか否か判定する。
- * @param file 判定対象
- * @return 既に存在する特殊ファイルならtrue
- */
- private static boolean isExistsUnnormalFile(File file){
- if( ! file.exists() ) return false;
- if( file.isFile() ) return false;
- return true;
- }
-
- /**
- * ファイルの各種状態を事前にチェックする。
- * @param argInfo コマンドライン引数
- */
- private static void checkFiles(ArgInfo argInfo){
- String input = argInfo.getInputFile();
- String output = argInfo.getOutputFile();
- File iFile = new File(input);
- File oFile = new File(output);
-
- if( ! isExistsNormalFile(iFile) ){
- errExit(EXIT_IOERR, "Can't find input file:"
- + iFile.getAbsolutePath() + '\n');
- }
-
- if(argInfo.isForceMode()){
- if(isExistsUnnormalFile(oFile)){
- errExit(EXIT_IOERR, oFile.getAbsolutePath()
- + " is not file.\n");
- }
- }else if(oFile.exists()){
- errExit(EXIT_IOERR, oFile.getAbsolutePath()
- + " already exists.\n"
- + "If you want to overwrite, use -f.\n");
- }
-
- return;
- }
-
- /**
- * VMD->XML変換を行う。
- * @param istream 入力ストリーム
- * @param ostream 出力ストリーム
- * @param argInfo オプション設定
- */
- private static void vmd2xml(InputStream istream, OutputStream ostream,
- ArgInfo argInfo ){
- try{
- vmd2xmlImpl(istream, ostream, argInfo);
- }catch(IOException e){
- ioError(e);
- }catch(MmdFormatException e){
- vmdError(e);
- }catch(IllegalVmdDataException e){
- internalError(e);
- }
-
- return;
- }
-
- /**
- * VMD->XML変換を行う。
- * @param istream 入力ストリーム
- * @param ostream 出力ストリーム
- * @param argInfo オプション設定
- * @throws IOException 入出力エラー
- * @throws MmdFormatException 不正なVMDファイル
- * @throws IllegalVmdDataException 不正なモーションデータ
- */
- private static void vmd2xmlImpl(InputStream istream, OutputStream ostream,
- ArgInfo argInfo )
- throws IOException, MmdFormatException, IllegalVmdDataException{
- VmdMotion motion;
- try{
- motion = vmdRead(istream);
- }finally{
- istream.close();
- }
-
- motion.frameSort();
-
- try{
- xmlOut(motion, ostream, argInfo);
- }finally{
- ostream.close();
- }
-
- return;
- }
-
- /**
- * XML->VMD変換を行う。
- * @param istream 入力ストリーム
- * @param ostream 出力ストリーム
- */
- private static void xml2vmd(InputStream istream, OutputStream ostream){
- try{
- xml2vmdImpl(istream, ostream);
- }catch(IOException e){
- ioError(e);
- }catch(SAXException e){
- xmlError(e);
- }catch(TogaXmlException e){
- xmlError(e);
- }catch(IllegalVmdDataException e){
- internalError(e);
- }
-
- return;
- }
-
- /**
- * XML->VMD変換を行う。
- * @param istream 入力ストリーム
- * @param ostream 出力ストリーム
- * @throws IOException 入出力エラー
- * @throws SAXException 不正なXMLファイル
- * @throws TogaXmlException 不正なXMLファイル
- * @throws IllegalVmdDataException 不正なVMDモーションデータ
- */
- private static void xml2vmdImpl(InputStream istream, OutputStream ostream)
- throws IOException,
- SAXException,
- TogaXmlException,
- IllegalVmdDataException {
- InputSource source = new InputSource(istream);
- VmdMotion motion;
- try{
- motion = xmlRead(source);
- }finally{
- istream.close();
- }
-
- motion.frameSort();
-
- try{
- vmdOut(motion, ostream);
- }finally{
- ostream.close();
- }
-
- return;
- }
-
- /**
- * VMDファイルからモーションデータを読み込む。
- * @param is 入力ストリーム
- * @return モーションデータ
- * @throws IOException 入力エラー
- * @throws MmdFormatException 不正なVMDファイルフォーマット
- */
- private static VmdMotion vmdRead(InputStream is)
- throws IOException, MmdFormatException{
- VmdMotion vmdMotion = VmdLoader.load(is);
- return vmdMotion;
- }
-
- /**
- * モーションデータをXMLファイルに出力する。
- * @param motion モーションデータ
- * @param ostream 出力ストリーム
- * @param argInfo オプション設定
- * @throws IOException 出力エラー
- * @throws IllegalVmdDataException 不正なモーションデータ
- */
- private static void xmlOut(VmdMotion motion, OutputStream ostream,
- ArgInfo argInfo)
- throws IOException, IllegalVmdDataException{
- VmdXmlExporter exporter = new VmdXmlExporter(ostream);
-
- exporter.setNewLine("\r\n");
- exporter.setGenerator(APPNAME + ' ' + APPVER);
-
- boolean isQuaternionMode = argInfo.isQuaternionMode();
- exporter.setQuaternionMode(isQuaternionMode);
-
- exporter.putVmdXml(motion);
- exporter.close();
-
- return;
- }
-
- /**
- * XMLファイルからモーションデータを読み込む。
- * @param source 入力ソース
- * @return モーションデータ
- * @throws IOException 入力エラー
- * @throws SAXException XML構文エラー
- * @throws TogaXmlException 不正なXMLデータ
- */
- private static VmdMotion xmlRead(InputSource source)
- throws IOException,
- SAXException,
- TogaXmlException {
- DocumentBuilder builder =
- VmdXmlResources.newBuilder(ValidationHandler.HANDLER);
- Xml2VmdLoader loader = new Xml2VmdLoader(builder);
-
- VmdMotion motion = loader.parse(source);
-
- return motion;
- }
-
- /**
- * モーションデータをVMDファイルに出力する。
- * @param motion モーションデータ
- * @param ostream 出力ストリーム
- * @throws IOException 出力エラー
- * @throws IllegalVmdDataException 不正なモーションデータ
- */
- private static void vmdOut(VmdMotion motion, OutputStream ostream)
- throws IOException, IllegalVmdDataException{
- VmdExporter exporter = new VmdExporter(ostream);
- exporter.dumpVmdMotion(motion);
- ostream.close();
- return;
- }
-
-}
+++ /dev/null
-/*
- * package information for Javadoc
- *
- * License : The MIT License
- * Copyright(c) 2011 MikuToga Partners
- */
-
-/**
- * VMD-XML変換ユーティリティ、およびそのmainエントリ。
- */
-
-package jp.sourceforge.mikutoga.vmd2xml;
-
-/* EOF */
--- /dev/null
+/*
+ */
+
+package jp.sfjp.mikutoga.vmd.model;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class BezierParamTest {
+
+ public BezierParamTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of setP2 method, of class BezierParam.
+ */
+ @Test
+ public void testSetP() {
+ System.out.println("getsetP");
+
+ BezierParam bez;
+
+ bez = new BezierParam();
+ assertEquals(20, bez.getP1x());
+ assertEquals(20, bez.getP1y());
+ assertEquals(107, bez.getP2x());
+ assertEquals(107, bez.getP2y());
+
+ bez.setP1x((byte)21);
+ assertEquals(21, bez.getP1x());
+ assertEquals(20, bez.getP1y());
+ assertEquals(107, bez.getP2x());
+ assertEquals(107, bez.getP2y());
+
+ bez.setP1y((byte)22);
+ assertEquals(21, bez.getP1x());
+ assertEquals(22, bez.getP1y());
+ assertEquals(107, bez.getP2x());
+ assertEquals(107, bez.getP2y());
+
+ bez.setP2x((byte)108);
+ assertEquals(21, bez.getP1x());
+ assertEquals(22, bez.getP1y());
+ assertEquals(108, bez.getP2x());
+ assertEquals(107, bez.getP2y());
+
+ bez.setP2y((byte)109);
+ assertEquals(21, bez.getP1x());
+ assertEquals(22, bez.getP1y());
+ assertEquals(108, bez.getP2x());
+ assertEquals(109, bez.getP2y());
+
+ bez.setP1((byte)23, (byte)24);
+ assertEquals(23, bez.getP1x());
+ assertEquals(24, bez.getP1y());
+ assertEquals(108, bez.getP2x());
+ assertEquals(109, bez.getP2y());
+
+ bez.setP2((byte)110, (byte)111);
+ assertEquals(23, bez.getP1x());
+ assertEquals(24, bez.getP1y());
+ assertEquals(110, bez.getP2x());
+ assertEquals(111, bez.getP2y());
+
+ return;
+ }
+
+ /**
+ * Test of isLinear method, of class BezierParam.
+ */
+ @Test
+ public void testIsLinear() {
+ System.out.println("isLinear");
+
+ BezierParam bez;
+
+ bez = new BezierParam();
+ assertTrue(bez.isLinear());
+
+ bez.setP1((byte)10, (byte)10);
+ assertTrue(bez.isLinear());
+
+ bez.setP2((byte)120, (byte)120);
+ assertTrue(bez.isLinear());
+
+ bez.setP1((byte)0, (byte)0);
+ assertTrue(bez.isLinear());
+
+ bez.setP2((byte)127, (byte)127);
+ assertTrue(bez.isLinear());
+
+ bez.setP1((byte)1, (byte)2);
+ assertFalse(bez.isLinear());
+
+ bez.setP1((byte)0, (byte)0);
+ bez.setP2((byte)126, (byte)127);
+ assertFalse(bez.isLinear());
+
+ return;
+ }
+
+ /**
+ * Test of isDefaultLinear method, of class BezierParam.
+ */
+ @Test
+ public void testIsDefaultLinear() {
+ System.out.println("isDefaultLinear");
+
+ BezierParam bez;
+
+ bez = new BezierParam();
+ assertTrue(bez.isDefaultLinear());
+ assertTrue(bez.isLinear());
+
+ bez.setP1((byte)30, (byte)30);
+ assertFalse(bez.isDefaultLinear());
+ assertTrue(bez.isLinear());
+
+ bez.setDefaultEaseInOut();
+ assertFalse(bez.isDefaultLinear());
+
+ return;
+ }
+
+ /**
+ * Test of isDefaultEaseInOut method, of class BezierParam.
+ */
+ @Test
+ public void testIsDefaultEaseInOut() {
+ System.out.println("isDefaultEaseInOut");
+
+ BezierParam bez;
+
+ bez = new BezierParam();
+ assertFalse(bez.isDefaultEaseInOut());
+
+ bez.setDefaultEaseInOut();
+ assertTrue(bez.isDefaultEaseInOut());
+
+ return;
+ }
+
+ /**
+ * Test of setDefaultLinear method, of class BezierParam.
+ */
+ @Test
+ public void testSetDefaultLinear() {
+ System.out.println("setDefaultLinear");
+
+ BezierParam bez;
+
+ bez = new BezierParam();
+ bez.setDefaultLinear();
+ assertEquals(20, bez.getP1x());
+ assertEquals(20, bez.getP1y());
+ assertEquals(107, bez.getP2x());
+ assertEquals(107, bez.getP2y());
+
+ return;
+ }
+
+ /**
+ * Test of setDefaultEaseInOut method, of class BezierParam.
+ */
+ @Test
+ public void testSetDefaultEaseInOut() {
+ System.out.println("setDefaultEaseInOut");
+
+ BezierParam bez;
+
+ bez = new BezierParam();
+ bez.setDefaultEaseInOut();
+ assertEquals(64, bez.getP1x());
+ assertEquals(0, bez.getP1y());
+ assertEquals(64, bez.getP2x());
+ assertEquals(127, bez.getP2y());
+
+ return;
+ }
+
+ /**
+ * Test of toString method, of class BezierParam.
+ */
+ @Test
+ public void testToString() {
+ System.out.println("toString");
+
+ BezierParam bez;
+
+ bez = new BezierParam();
+ assertEquals("P1=(20, 20) P2=(107, 107)", bez.toString());
+
+ bez.setP1((byte)0, (byte)0);
+ assertEquals("P1=(0, 0) P2=(107, 107)", bez.toString());
+
+ bez.setP2((byte)127, (byte)127);
+ assertEquals("P1=(0, 0) P2=(127, 127)", bez.toString());
+
+ return;
+ }
+
+}
--- /dev/null
+/*
+ */
+
+package jp.sfjp.mikutoga.vmd.model;
+
+import jp.sfjp.mikutoga.math.MkPos3D;
+import jp.sfjp.mikutoga.math.MkQuat;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class BoneMotionTest {
+
+ public BoneMotionTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of get/setBoneName method, of class BoneMotion.
+ */
+ @Test
+ public void testGetSetBoneName() {
+ System.out.println("getBoneName");
+
+ BoneMotion motion;
+
+ motion = new BoneMotion();
+ assertNull(motion.getBoneName());
+
+ motion.setBoneName("");
+ assertEquals("", motion.getBoneName());
+
+ motion.setBoneName("bbbone");
+ assertEquals("bbbone", motion.getBoneName());
+
+ motion.setBoneName(null);
+ assertNull(motion.getBoneName());
+
+ return;
+ }
+
+ /**
+ * Test of getRotation method, of class BoneMotion.
+ */
+ @Test
+ public void testGetRotation() {
+ System.out.println("getRotation");
+
+ BoneMotion motion;
+ MkQuat rot;
+
+ motion = new BoneMotion();
+
+ rot = motion.getRotation();
+ assertNotNull(rot);
+
+ return;
+ }
+
+ /**
+ * Test of getIntpltRotation method, of class BoneMotion.
+ */
+ @Test
+ public void testGetIntpltRotation() {
+ System.out.println("getIntpltRotation");
+
+ BoneMotion motion;
+ BezierParam bez;
+
+ motion = new BoneMotion();
+
+ bez = motion.getIntpltRotation();
+ assertNotNull(bez);
+
+ return;
+ }
+
+ /**
+ * Test of getPosition method, of class BoneMotion.
+ */
+ @Test
+ public void testGetPosition() {
+ System.out.println("getPosition");
+
+ BoneMotion motion;
+ MkPos3D pos;
+
+ motion = new BoneMotion();
+
+ pos = motion.getPosition();
+ assertNotNull(pos);
+
+ return;
+ }
+
+ /**
+ * Test of getPosCurve method, of class BoneMotion.
+ */
+ @Test
+ public void testGetPosCurve() {
+ System.out.println("getPosCurve");
+
+ BoneMotion motion;
+ PosCurve curve;
+
+ motion = new BoneMotion();
+
+ curve = motion.getPosCurve();
+ assertNotNull(curve);
+
+ return;
+ }
+
+ /**
+ * Test of hasImplicitPosition method, of class BoneMotion.
+ */
+ @Test
+ public void testHasImplicitPosition() {
+ System.out.println("hasImplicitPosition");
+
+ BoneMotion motion;
+
+ motion = new BoneMotion();
+ assertTrue(motion.hasImplicitPosition());
+
+ motion = new BoneMotion();
+ motion.getPosition().setXpos(1.0);
+ assertFalse(motion.hasImplicitPosition());
+
+ motion = new BoneMotion();
+ motion.getPosCurve().getIntpltYpos().setP1((byte)21, (byte)21);
+ assertFalse(motion.hasImplicitPosition());
+
+ return;
+ }
+
+ /**
+ * Test of toString method, of class BoneMotion.
+ */
+ @Test
+ public void testToString() {
+ System.out.println("toString");
+
+ BoneMotion motion;
+
+ motion = new BoneMotion();
+ assertEquals(
+ "bone name : [null] #0\n"
+ + "rotation q1=0.0 q2=0.0 q3=0.0 w=1.0"
+ + " R-Bezier P1=(20, 20) P2=(107, 107)\n"
+ + "position x=0.0 y=0.0 z=0.0\n"
+ + "X-Bezier P1=(20, 20) P2=(107, 107)\n"
+ + "Y-Bezier P1=(20, 20) P2=(107, 107)\n"
+ + "Z-Bezier P1=(20, 20) P2=(107, 107)"
+ , motion.toString() );
+
+ motion.setBoneName("bbbone");
+ motion.setFrameNumber(99);
+ motion.getRotation().setQW(-1.0);
+ motion.getIntpltRotation().setP1((byte)1, (byte)2);
+ motion.getIntpltRotation().setP2((byte)3, (byte)4);
+ motion.getPosition().setPosition(1.0, 2.0, 3.0);
+ motion.getPosCurve().getIntpltXpos().setP1((byte)5, (byte)6);
+ motion.getPosCurve().getIntpltXpos().setP2((byte)7, (byte)8);
+ motion.getPosCurve().getIntpltYpos().setP1((byte)9, (byte)10);
+ motion.getPosCurve().getIntpltYpos().setP2((byte)11, (byte)12);
+ motion.getPosCurve().getIntpltZpos().setP1((byte)13, (byte)14);
+ motion.getPosCurve().getIntpltZpos().setP2((byte)15, (byte)16);
+
+ assertEquals(
+ "bone name : [bbbone] #99\n"
+ + "rotation q1=0.0 q2=0.0 q3=0.0 w=-1.0"
+ + " R-Bezier P1=(1, 2) P2=(3, 4)\n"
+ + "position x=1.0 y=2.0 z=3.0\n"
+ + "X-Bezier P1=(5, 6) P2=(7, 8)\n"
+ + "Y-Bezier P1=(9, 10) P2=(11, 12)\n"
+ + "Z-Bezier P1=(13, 14) P2=(15, 16)"
+ , motion.toString() );
+
+ return;
+ }
+
+}
--- /dev/null
+/*
+ */
+
+package jp.sfjp.mikutoga.vmd.model;
+
+import jp.sfjp.mikutoga.math.MkPos3D;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class CameraMotionTest {
+
+ public CameraMotionTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of getCameraTarget method, of class CameraMotion.
+ */
+ @Test
+ public void testGetCameraTarget() {
+ System.out.println("getCameraTarget");
+
+ CameraMotion motion;
+
+ motion = new CameraMotion();
+
+ MkPos3D pos = motion.getCameraTarget();
+ assertNotNull(pos);
+
+ return;
+ }
+
+ /**
+ * Test of getTargetPosCurve method, of class CameraMotion.
+ */
+ @Test
+ public void testGetTargetPosCurve() {
+ System.out.println("getTargetPosCurve");
+
+ CameraMotion motion;
+
+ motion = new CameraMotion();
+
+ PosCurve curve = motion.getTargetPosCurve();
+ assertNotNull(curve);
+
+ return;
+ }
+
+ /**
+ * Test of getCameraRotation method, of class CameraMotion.
+ */
+ @Test
+ public void testGetCameraRotation() {
+ System.out.println("getCameraRotation");
+
+ CameraMotion motion;
+
+ motion = new CameraMotion();
+
+ CameraRotation rot = motion.getCameraRotation();
+ assertNotNull(rot);
+
+ return;
+ }
+
+ /**
+ * Test of getIntpltRotation method, of class CameraMotion.
+ */
+ @Test
+ public void testGetIntpltRotation() {
+ System.out.println("getIntpltRotation");
+
+ CameraMotion motion;
+
+ motion = new CameraMotion();
+
+ BezierParam bez = motion.getIntpltRotation();
+ assertNotNull(bez);
+
+ return;
+ }
+
+ /**
+ * Test of get/setRange method, of class CameraMotion.
+ */
+ @Test
+ public void testGetSetRange() {
+ System.out.println("get/setRange");
+
+ CameraMotion motion;
+
+ motion = new CameraMotion();
+
+ assertEquals(0.0, motion.getRange(), 0.0);
+
+ motion.setRange(-35.0);
+ assertEquals(-35.0, motion.getRange(), 0.0);
+
+ return;
+ }
+
+ /**
+ * Test of getIntpltRange method, of class CameraMotion.
+ */
+ @Test
+ public void testGetIntpltRange() {
+ System.out.println("getIntpltRange");
+
+ CameraMotion motion;
+
+ motion = new CameraMotion();
+
+ BezierParam bez = motion.getIntpltRange();
+ assertNotNull(bez);
+
+ return;
+ }
+
+ /**
+ * Test of has/setPerspective method, of class CameraMotion.
+ */
+ @Test
+ public void testHasSetPerspective() {
+ System.out.println("has/setPerspective");
+
+ CameraMotion motion;
+
+ motion = new CameraMotion();
+ assertFalse(motion.hasPerspective());
+
+ motion.setPerspectiveMode(true);
+ assertTrue(motion.hasPerspective());
+
+ motion.setPerspectiveMode(false);
+ assertFalse(motion.hasPerspective());
+
+ return;
+ }
+
+ /**
+ * Test of get/set ProjectionAngle method, of class CameraMotion.
+ */
+ @Test
+ public void testGetSetProjectionAngle() {
+ System.out.println("get/setProjectionAngle");
+
+ CameraMotion motion;
+ int angle;
+
+ motion = new CameraMotion();
+
+ angle = motion.getProjectionAngle();
+ assertEquals(0, angle);
+
+ motion.setProjectionAngle(25);
+ angle = motion.getProjectionAngle();
+ assertEquals(25, angle);
+
+ return;
+ }
+
+ /**
+ * Test of getIntpltProjection method, of class CameraMotion.
+ */
+ @Test
+ public void testGetIntpltProjection() {
+ System.out.println("getIntpltProjection");
+
+ CameraMotion motion;
+
+ motion = new CameraMotion();
+ BezierParam bez = motion.getIntpltProjection();
+ assertNotNull(bez);
+
+ return;
+ }
+
+ /**
+ * Test of toString method, of class CameraMotion.
+ */
+ @Test
+ public void testToString() {
+ System.out.println("toString");
+
+ CameraMotion motion;
+
+ motion = new CameraMotion();
+
+ assertEquals(
+ "#0 latitude=0 longitude=0 roll=0 Rot-Bezier P1=(20, 20) P2=(107, 107)\n"
+ + "range : 0 Range-Bezier P1=(20, 20) P2=(107, 107)\n"
+ + "target-pos : x=0.0 y=0.0 z=0.0\n"
+ + "X-Bezier P1=(20, 20) P2=(107, 107)\n"
+ + "Y-Bezier P1=(20, 20) P2=(107, 107)\n"
+ + "Z-Bezier P1=(20, 20) P2=(107, 107)\n"
+ +"perspective : false\n"
+ +"projection angle : 0deg Bezier P1=(20, 20) P2=(107, 107)",
+ motion.toString() );
+
+ return;
+ }
+
+}
--- /dev/null
+/*
+ */
+
+package jp.sfjp.mikutoga.vmd.model;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class CameraRotationTest {
+
+ public CameraRotationTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of get/set method, of class CameraRotation.
+ */
+ @Test
+ public void testGetSetParams() {
+ System.out.println("getLatitude");
+
+ CameraRotation rotation;
+
+ rotation = new CameraRotation();
+
+ assertEquals(0.0, rotation.getLatitude(), 0.0);
+ assertEquals(0.0, rotation.getLongitude(), 0.0);
+ assertEquals(0.0, rotation.getRoll(), 0.0);
+
+ rotation.setLatitude(1.0);
+ rotation.setLongitude(2.0);
+ rotation.setRoll(3.0);
+
+ assertEquals(1.0, rotation.getLatitude(), 0.0);
+ assertEquals(2.0, rotation.getLongitude(), 0.0);
+ assertEquals(3.0, rotation.getRoll(), 0.0);
+
+ return;
+ }
+
+ /**
+ * Test of toString method, of class CameraRotation.
+ */
+ @Test
+ public void testToString() {
+ System.out.println("toString");
+
+ CameraRotation rotation;
+
+ rotation = new CameraRotation();
+
+ assertEquals("latitude=0 longitude=0 roll=0", rotation.toString());
+
+ rotation.setLatitude(1.1f);
+ rotation.setLongitude(2.2f);
+ rotation.setRoll(3.3f);
+ assertEquals("latitude=1.1 longitude=2.2 roll=3.3", rotation.toString());
+
+ return;
+ }
+
+}
--- /dev/null
+/*
+ */
+
+package jp.sfjp.mikutoga.vmd.model;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class LuminousColorTest {
+
+ public LuminousColorTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of get/setCol method, of class LuminousColor.
+ */
+ @Test
+ public void testGetSetCol() {
+ System.out.println("get/setCol");
+
+ LuminousColor color;
+
+ color = new LuminousColor();
+
+ assertEquals(0.602f, color.getColR(), 0.0f);
+ assertEquals(0.602f, color.getColG(), 0.0f);
+ assertEquals(0.602f, color.getColB(), 0.0f);
+
+ color.setColR(0.5f);
+ assertEquals(0.5f, color.getColR(), 0.0f);
+
+ color.setColG(0.5f);
+ assertEquals(0.5f, color.getColG(), 0.0f);
+
+ color.setColB(0.5f);
+ assertEquals(0.5f, color.getColB(), 0.0f);
+
+ return;
+ }
+
+ /**
+ * Test of toString method, of class LuminousColor.
+ */
+ @Test
+ public void testToString() {
+ System.out.println("toString");
+
+ LuminousColor color;
+
+ color = new LuminousColor();
+
+ assertEquals("r=0.602 g=0.602 b=0.602", color.toString());
+
+ return;
+ }
+
+}
--- /dev/null
+/*
+ */
+
+package jp.sfjp.mikutoga.vmd.model;
+
+import jp.sfjp.mikutoga.math.MkVec3D;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class LuminousMotionTest {
+
+ public LuminousMotionTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of getColor method, of class LuminousMotion.
+ */
+ @Test
+ public void testGetColor() {
+ System.out.println("getColor");
+
+ LuminousMotion motion;
+
+ motion = new LuminousMotion();
+
+ LuminousColor color = motion.getColor();
+ assertNotNull(color);
+
+ assertEquals(0.602f, color.getColR(), 0.0f);
+ assertEquals(0.602f, color.getColG(), 0.0f);
+ assertEquals(0.602f, color.getColB(), 0.0f);
+
+ return;
+ }
+
+ /**
+ * Test of getDirection method, of class LuminousMotion.
+ */
+ @Test
+ public void testGetDirection() {
+ System.out.println("getDirection");
+
+ LuminousMotion motion;
+
+ motion = new LuminousMotion();
+
+ MkVec3D vec = motion.getDirection();
+ assertNotNull(vec);
+
+ assertEquals(-0.5, vec.getXVal(), 0.0);
+ assertEquals(-1.0, vec.getYVal(), 0.0);
+ assertEquals( 0.5, vec.getZVal(), 0.0);
+
+ return;
+ }
+
+ /**
+ * Test of toString method, of class LuminousMotion.
+ */
+ @Test
+ public void testToString() {
+ System.out.println("toString");
+
+ LuminousMotion motion;
+
+ motion = new LuminousMotion();
+
+ assertEquals("#0 luminous color : r=0.602 g=0.602 b=0.602 direction : vec=[-0.5, -1.0, 0.5]",
+ motion.toString());
+
+ return;
+ }
+
+}
--- /dev/null
+/*
+ */
+
+package jp.sfjp.mikutoga.vmd.model;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class MorphMotionTest {
+
+ public MorphMotionTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of get/setMorphName method, of class MorphMotion.
+ */
+ @Test
+ public void testGetSetMorphName() {
+ System.out.println("get/setMorphName");
+
+ MorphMotion motion;
+
+ motion = new MorphMotion();
+ assertEquals("", motion.getMorphName());
+
+ motion.setMorphName("mmmorph");
+ assertEquals("mmmorph", motion.getMorphName());
+
+ return;
+ }
+
+ /**
+ * Test of get/setFlex method, of class MorphMotion.
+ */
+ @Test
+ public void testGetSetFlex() {
+ System.out.println("get/setFlex");
+
+ MorphMotion motion;
+
+ motion = new MorphMotion();
+ assertEquals(0.0f, motion.getFlex(), 0.0f);
+
+ motion.setFlex(0.5f);
+ assertEquals(0.5f, motion.getFlex(), 0.0f);
+
+ return;
+ }
+
+ /**
+ * Test of toString method, of class MorphMotion.
+ */
+ @Test
+ public void testToString() {
+ System.out.println("toString");
+
+ MorphMotion motion;
+
+ motion = new MorphMotion();
+
+ assertEquals("morph name : [] #0 flex = 0", motion.toString());
+
+ motion.setMorphName("mmmorph");
+ motion.setFrameNumber(99);
+ motion.setFlex(0.5f);
+ assertEquals("morph name : [mmmorph] #99 flex = 0.5", motion.toString());
+
+
+ return;
+ }
+
+}
--- /dev/null
+/*
+ */
+
+package jp.sfjp.mikutoga.vmd.model;
+
+import java.util.Iterator;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class PosCurveTest {
+
+ public PosCurveTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of getIntplt method, of class PosCurve.
+ */
+ @Test
+ public void testGetIntplt() {
+ System.out.println("getIntpltZpos");
+
+ PosCurve curve;
+
+ curve = new PosCurve();
+
+ BezierParam xbz = curve.getIntpltXpos();
+ BezierParam ybz = curve.getIntpltYpos();
+ BezierParam zbz = curve.getIntpltZpos();
+
+ assertNotNull(xbz);
+ assertNotNull(ybz);
+ assertNotNull(zbz);
+
+ assertNotSame(xbz, ybz);
+ assertNotSame(ybz, zbz);
+ assertNotSame(zbz, xbz);
+
+ return;
+ }
+
+ /**
+ * Test of isDefaultLinear method, of class PosCurve.
+ */
+ @Test
+ public void testIsDefaultLinear() {
+ System.out.println("isDefaultLinear");
+
+ PosCurve curve;
+
+ curve = new PosCurve();
+ assertTrue(curve.isDefaultLinear());
+
+ curve = new PosCurve();
+ curve.getIntpltXpos().setP1((byte)21, (byte)21);
+ assertFalse(curve.isDefaultLinear());
+ curve.getIntpltXpos().setP1((byte)20, (byte)20);
+ assertTrue(curve.isDefaultLinear());
+
+ curve = new PosCurve();
+ curve.getIntpltYpos().setP1((byte)21, (byte)21);
+ assertFalse(curve.isDefaultLinear());
+ curve.getIntpltYpos().setP1((byte)20, (byte)20);
+ assertTrue(curve.isDefaultLinear());
+
+ curve = new PosCurve();
+ curve.getIntpltZpos().setP1((byte)21, (byte)21);
+ assertFalse(curve.isDefaultLinear());
+ curve.getIntpltZpos().setP1((byte)20, (byte)20);
+ assertTrue(curve.isDefaultLinear());
+
+ return;
+ }
+
+ /**
+ * Test of toString method, of class PosCurve.
+ */
+ @Test
+ public void testToString() {
+ System.out.println("toString");
+
+ PosCurve curve;
+
+ curve = new PosCurve();
+ assertEquals(
+ "X-Bezier P1=(20, 20) P2=(107, 107)\n"
+ + "Y-Bezier P1=(20, 20) P2=(107, 107)\n"
+ + "Z-Bezier P1=(20, 20) P2=(107, 107)",
+ curve.toString() );
+
+ curve.getIntpltXpos().setP1x((byte)1);
+ curve.getIntpltYpos().setP1x((byte)2);
+ curve.getIntpltZpos().setP1x((byte)3);
+ assertEquals(
+ "X-Bezier P1=(1, 20) P2=(107, 107)\n"
+ + "Y-Bezier P1=(2, 20) P2=(107, 107)\n"
+ + "Z-Bezier P1=(3, 20) P2=(107, 107)",
+ curve.toString() );
+
+ return;
+ }
+
+ /**
+ * Test of iterator method, of class PosCurve.
+ */
+ @Test
+ public void testIterator() {
+ System.out.println("iterator");
+ PosCurve curve;
+
+ curve = new PosCurve();
+
+ Iterator<BezierParam> it = curve.iterator();
+
+ assertTrue(it.hasNext());
+ BezierParam bz1 = it.next();
+
+ assertTrue(it.hasNext());
+ BezierParam bz2 = it.next();
+
+ assertTrue(it.hasNext());
+ BezierParam bz3 = it.next();
+
+ assertFalse(it.hasNext());
+
+ assertSame(curve.getIntpltXpos(), bz1);
+ assertSame(curve.getIntpltYpos(), bz2);
+ assertSame(curve.getIntpltZpos(), bz3);
+
+ return;
+ }
+
+}
--- /dev/null
+/*
+ */
+
+package jp.sfjp.mikutoga.vmd.model;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class ShadowModeTest {
+
+ public ShadowModeTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of values method, of class ShadowMode.
+ */
+ @Test
+ public void testValues() {
+ System.out.println("values");
+
+ ShadowMode[] result = ShadowMode.values();
+ assertEquals(3, result.length);
+
+ assertSame(ShadowMode.NONE, result[0]);
+ assertSame(ShadowMode.MODE_1, result[1]);
+ assertSame(ShadowMode.MODE_2, result[2]);
+
+ return;
+ }
+
+ /**
+ * Test of valueOf method, of class ShadowMode.
+ */
+ @Test
+ public void testValueOf() {
+ System.out.println("valueOf");
+
+ assertSame(ShadowMode.NONE, ShadowMode.valueOf("NONE"));
+ assertSame(ShadowMode.MODE_1, ShadowMode.valueOf("MODE_1"));
+ assertSame(ShadowMode.MODE_2, ShadowMode.valueOf("MODE_2"));
+
+ return;
+ }
+
+ /**
+ * Test of getEncodedByte method, of class ShadowMode.
+ */
+ @Test
+ public void testGetEncodedByte() {
+ System.out.println("getEncodedByte");
+
+ assertEquals((byte)0x00, ShadowMode.NONE.getEncodedByte());
+ assertEquals((byte)0x01, ShadowMode.MODE_1.getEncodedByte());
+ assertEquals((byte)0x02, ShadowMode.MODE_2.getEncodedByte());
+
+ return;
+ }
+
+ /**
+ * Test of decode method, of class ShadowMode.
+ */
+ @Test
+ public void testDecode_byte() {
+ System.out.println("decode");
+
+ assertSame(ShadowMode.NONE, ShadowMode.decode((byte)0x00));
+ assertSame(ShadowMode.MODE_1, ShadowMode.decode((byte)0x01));
+ assertSame(ShadowMode.MODE_2, ShadowMode.decode((byte)0x02));
+
+ assertNull(ShadowMode.decode((byte)-1));
+ assertNull(ShadowMode.decode((byte)0x03));
+
+ return;
+ }
+
+ /**
+ * Test of decode method, of class ShadowMode.
+ */
+ @Test
+ public void testDecode_int() {
+ System.out.println("decode");
+
+ assertSame(ShadowMode.NONE, ShadowMode.decode(0x00));
+ assertSame(ShadowMode.MODE_1, ShadowMode.decode(0x01));
+ assertSame(ShadowMode.MODE_2, ShadowMode.decode(0x02));
+
+ assertNull(ShadowMode.decode(-1));
+ assertNull(ShadowMode.decode(0x03));
+
+ return;
+ }
+
+}
--- /dev/null
+/*
+ */
+
+package jp.sfjp.mikutoga.vmd.model;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public strictfp class ShadowMotionTest {
+
+ public ShadowMotionTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of rawParamToScope method, of class ShadowMotion.
+ */
+ @Test
+ public void testRawParamToScope() {
+ System.out.println("rawParamToScope");
+
+ assertEquals(10000.0, ShadowMotion.rawParamToScope(0.0), 0.0);
+ assertEquals(8875.0, ShadowMotion.rawParamToScope(0.01125), 1e-11);
+
+ return;
+ }
+
+ /**
+ * Test of scopeToRawParam method, of class ShadowMotion.
+ */
+ @Test
+ public void testScopeToRawParam() {
+ System.out.println("scopeToRawParam");
+
+ assertEquals(0.1, ShadowMotion.scopeToRawParam(0.0), 0.0);
+ assertEquals(0.01125, ShadowMotion.scopeToRawParam(8875.0), 1e-16);
+
+ return;
+ }
+
+ /**
+ * Test of set/getRawScopeParam method, of class ShadowMotion.
+ */
+ @Test
+ public void testSetGetRawScopeParam() {
+ System.out.println("set/getRawScopeParam");
+
+ ShadowMotion motion;
+
+ motion = new ShadowMotion();
+ assertEquals(0.01125, motion.getRawScopeParam(), 0.0);
+
+ motion.setRawScopeParam(0.1);
+ assertEquals(0.1, motion.getRawScopeParam(), 0.0);
+
+ return;
+ }
+
+ /**
+ * Test of set/getScope method, of class ShadowMotion.
+ */
+ @Test
+ public void testSetGetScope() {
+ System.out.println("set/getScope");
+
+ ShadowMotion motion;
+
+ motion = new ShadowMotion();
+
+ assertEquals(8875.0, motion.getScope(), 1e-11);
+
+ motion.setScope(10000.0);
+ assertEquals(10000.0, motion.getScope(), 0.0);
+
+ return;
+ }
+
+ /**
+ * Test of set/getShadowMode method, of class ShadowMotion.
+ */
+ @Test
+ public void testSetGetShadowMode() {
+ System.out.println("set/getShadowMode");
+
+ ShadowMotion motion;
+
+ motion = new ShadowMotion();
+
+ assertSame(ShadowMode.MODE_1, motion.getShadowMode());
+
+ motion.setShadowMode(ShadowMode.MODE_2);
+ assertSame(ShadowMode.MODE_2, motion.getShadowMode());
+
+ motion.setShadowMode(ShadowMode.NONE);
+ assertSame(ShadowMode.NONE, motion.getShadowMode());
+
+ return;
+ }
+
+ /**
+ * Test of toString method, of class ShadowMotion.
+ */
+ @Test
+ public void testToString() {
+ System.out.println("toString");
+
+ ShadowMotion motion;
+
+ motion = new ShadowMotion();
+
+ assertEquals("#0 shadow mode : MODE_1 rawparam=0.01125", motion.toString());
+
+ return;
+ }
+
+}
--- /dev/null
+/*
+ */
+
+package jp.sfjp.mikutoga.vmd.model;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class VmdMotionTest {
+
+ public VmdMotionTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of getせtModelName method, of class VmdMotion.
+ */
+ @Test
+ public void testGetSetModelName() {
+ System.out.println("get/setModelName");
+
+ VmdMotion motion;
+
+ motion = new VmdMotion();
+
+ assertEquals("カメラ・照明", motion.getModelName());
+
+ motion.setModelName("");
+ assertEquals("", motion.getModelName());
+
+ motion.setModelName("model");
+ assertEquals("model", motion.getModelName());
+
+ try{
+ motion.setModelName(null);
+ fail();
+ }catch(NullPointerException e){
+ // GOOD
+ }
+
+ return;
+ }
+
+ /**
+ * Test of isModelMotion method, of class VmdMotion.
+ */
+ @Test
+ public void testIsModelMotion() {
+ System.out.println("isModelMotion");
+
+ VmdMotion motion;
+
+ motion = new VmdMotion();
+
+ assertFalse(motion.isModelMotion());
+
+ motion.setModelName("model");
+ assertTrue(motion.isModelMotion());
+
+ motion.setModelName("カメラ・照明");
+ assertFalse(motion.isModelMotion());
+
+ return;
+ }
+
+ /**
+ * Test of getBonePartMap method, of class VmdMotion.
+ */
+ @Test
+ public void testGetBonePartMap() {
+ System.out.println("getBonePartMap");
+
+ VmdMotion motion;
+ Map<String, List<BoneMotion>> map;
+
+ motion = new VmdMotion();
+
+ map = motion.getBonePartMap();
+ assertNotNull(map);
+ assertTrue(map.isEmpty());
+
+ return;
+ }
+
+ /**
+ * Test of getMorphPartMap method, of class VmdMotion.
+ */
+ @Test
+ public void testGetMorphPartMap() {
+ System.out.println("getMorphPartMap");
+
+ VmdMotion motion;
+ Map<String, List<MorphMotion>> map;
+
+ motion = new VmdMotion();
+
+ map = motion.getMorphPartMap();
+ assertNotNull(map);
+ assertTrue(map.isEmpty());
+
+ return;
+ }
+
+ /**
+ * Test of getCameraMotionList method, of class VmdMotion.
+ */
+ @Test
+ public void testGetCameraMotionList() {
+ System.out.println("getCameraMotionList");
+
+ VmdMotion motion;
+ List<CameraMotion> list;
+
+ motion = new VmdMotion();
+
+ list = motion.getCameraMotionList();
+ assertNotNull(list);
+ assertTrue(list.isEmpty());
+
+ return;
+ }
+
+ /**
+ * Test of getLuminousMotionList method, of class VmdMotion.
+ */
+ @Test
+ public void testGetLuminousMotionList() {
+ System.out.println("getLuminousMotionList");
+
+ VmdMotion motion;
+ List<LuminousMotion> list;
+
+ motion = new VmdMotion();
+
+ list = motion.getLuminousMotionList();
+ assertNotNull(list);
+ assertTrue(list.isEmpty());
+
+ return;
+ }
+
+ /**
+ * Test of getShadowMotionList method, of class VmdMotion.
+ */
+ @Test
+ public void testGetShadowMotionList() {
+ System.out.println("getShadowMotionList");
+
+ VmdMotion motion;
+ List<ShadowMotion> list;
+
+ motion = new VmdMotion();
+
+ list = motion.getShadowMotionList();
+ assertNotNull(list);
+ assertTrue(list.isEmpty());
+
+ return;
+ }
+
+ /**
+ * Test of addBoneMotion method, of class VmdMotion.
+ */
+ @Test
+ public void testAddBoneMotion() {
+ System.out.println("addBoneMotion");
+
+ VmdMotion motion;
+ BoneMotion bone;
+
+ motion = new VmdMotion();
+
+ bone = new BoneMotion();
+ bone.setBoneName("X");
+ bone.setFrameNumber(99);
+ motion.addBoneMotion(bone);
+
+ bone = new BoneMotion();
+ bone.setBoneName("Y");
+ bone.setFrameNumber(9);
+ motion.addBoneMotion(bone);
+
+ bone = new BoneMotion();
+ bone.setBoneName("A");
+ bone.setFrameNumber(10);
+ motion.addBoneMotion(bone);
+
+ bone = new BoneMotion();
+ bone.setBoneName("Y");
+ bone.setFrameNumber(1);
+ motion.addBoneMotion(bone);
+
+ Map<String, List<BoneMotion>> map = motion.getBonePartMap();
+
+ Set<String> keySet = map.keySet();
+ assertEquals(3, keySet.size());
+ Iterator<String> it;
+ it = keySet.iterator();
+ assertEquals("X", it.next());
+ assertEquals("Y", it.next());
+ assertEquals("A", it.next());
+
+ assertEquals(1, map.get("X").size());
+ assertEquals(2, map.get("Y").size());
+ assertEquals(1, map.get("A").size());
+
+ assertEquals(99, map.get("X").get(0).getFrameNumber());
+ assertEquals(9, map.get("Y").get(0).getFrameNumber());
+ assertEquals(1, map.get("Y").get(1).getFrameNumber());
+ assertEquals(10, map.get("A").get(0).getFrameNumber());
+
+ return;
+ }
+
+ /**
+ * Test of addMorphMotion method, of class VmdMotion.
+ */
+ @Test
+ public void testAddMorphMotion() {
+ System.out.println("addMorphMotion");
+
+ VmdMotion motion;
+ MorphMotion morph;
+
+ motion = new VmdMotion();
+
+ morph = new MorphMotion();
+ morph.setMorphName("X");
+ morph.setFrameNumber(99);
+ motion.addMorphMotion(morph);
+
+ morph = new MorphMotion();
+ morph.setMorphName("Y");
+ morph.setFrameNumber(9);
+ motion.addMorphMotion(morph);
+
+ morph = new MorphMotion();
+ morph.setMorphName("A");
+ morph.setFrameNumber(10);
+ motion.addMorphMotion(morph);
+
+ morph = new MorphMotion();
+ morph.setMorphName("Y");
+ morph.setFrameNumber(1);
+ motion.addMorphMotion(morph);
+
+ Map<String, List<MorphMotion>> map = motion.getMorphPartMap();
+
+ Set<String> keySet = map.keySet();
+ assertEquals(3, keySet.size());
+ Iterator<String> it;
+ it = keySet.iterator();
+ assertEquals("X", it.next());
+ assertEquals("Y", it.next());
+ assertEquals("A", it.next());
+
+ assertEquals(1, map.get("X").size());
+ assertEquals(2, map.get("Y").size());
+ assertEquals(1, map.get("A").size());
+
+ assertEquals(99, map.get("X").get(0).getFrameNumber());
+ assertEquals(9, map.get("Y").get(0).getFrameNumber());
+ assertEquals(1, map.get("Y").get(1).getFrameNumber());
+ assertEquals(10, map.get("A").get(0).getFrameNumber());
+
+ return;
+ }
+
+ /**
+ * Test of frameSort method, of class VmdMotion.
+ */
+ @Test
+ public void testFrameSort() {
+ System.out.println("frameSort");
+
+ VmdMotion motion;
+
+ motion = new VmdMotion();
+
+ BoneMotion bmotion;
+
+ bmotion = new BoneMotion();
+ bmotion.setBoneName("bone");
+ bmotion.setFrameNumber(2);
+ motion.addBoneMotion(bmotion);
+
+ bmotion = new BoneMotion();
+ bmotion.setBoneName("bone");
+ bmotion.setFrameNumber(1);
+ motion.addBoneMotion(bmotion);
+
+ MorphMotion mmotion;
+
+ mmotion = new MorphMotion();
+ mmotion.setMorphName("morph");
+ mmotion.setFrameNumber(20);
+ motion.addMorphMotion(mmotion);
+
+ mmotion = new MorphMotion();
+ mmotion.setMorphName("morph");
+ mmotion.setFrameNumber(10);
+ motion.addMorphMotion(mmotion);
+
+ CameraMotion cmotion;
+
+ cmotion = new CameraMotion();
+ cmotion.setFrameNumber(200);
+ motion.getCameraMotionList().add(cmotion);
+
+ cmotion = new CameraMotion();
+ cmotion.setFrameNumber(100);
+ motion.getCameraMotionList().add(cmotion);
+
+ LuminousMotion lmotion;
+
+ lmotion = new LuminousMotion();
+ lmotion.setFrameNumber(2000);
+ motion.getLuminousMotionList().add(lmotion);
+
+ lmotion = new LuminousMotion();
+ lmotion.setFrameNumber(1000);
+ motion.getLuminousMotionList().add(lmotion);
+
+ ShadowMotion smotion;
+
+ smotion = new ShadowMotion();
+ smotion.setFrameNumber(20000);
+ motion.getShadowMotionList().add(smotion);
+
+ smotion = new ShadowMotion();
+ smotion.setFrameNumber(10000);
+ motion.getShadowMotionList().add(smotion);
+
+ motion.frameSort();
+
+ assertEquals(2, motion.getBonePartMap().get("bone").size());
+ assertEquals(1, motion.getBonePartMap().get("bone").get(0).getFrameNumber());
+ assertEquals(2, motion.getBonePartMap().get("bone").get(1).getFrameNumber());
+
+ assertEquals(2, motion.getMorphPartMap().get("morph").size());
+ assertEquals(10, motion.getMorphPartMap().get("morph").get(0).getFrameNumber());
+ assertEquals(20, motion.getMorphPartMap().get("morph").get(1).getFrameNumber());
+
+ assertEquals(2, motion.getCameraMotionList().size());
+ assertEquals(100, motion.getCameraMotionList().get(0).getFrameNumber());
+ assertEquals(200, motion.getCameraMotionList().get(1).getFrameNumber());
+
+ assertEquals(2, motion.getLuminousMotionList().size());
+ assertEquals(1000, motion.getLuminousMotionList().get(0).getFrameNumber());
+ assertEquals(2000, motion.getLuminousMotionList().get(1).getFrameNumber());
+
+ assertEquals(2, motion.getShadowMotionList().size());
+ assertEquals(10000, motion.getShadowMotionList().get(0).getFrameNumber());
+ assertEquals(20000, motion.getShadowMotionList().get(1).getFrameNumber());
+
+ return;
+ }
+
+ /**
+ * Test of toString method, of class VmdMotion.
+ */
+ @Test
+ public void testToString() {
+ System.out.println("toString");
+
+ VmdMotion motion;
+
+ motion = new VmdMotion();
+
+ assertEquals(
+ "model name : カメラ・照明\n"
+ +"bone#0 morph#0 camera#0 luminous#0 shadow#0",
+ motion.toString());
+
+ motion.setModelName("model");
+ motion.addBoneMotion(new BoneMotion());
+ motion.addMorphMotion(new MorphMotion());
+ motion.addMorphMotion(new MorphMotion());
+ motion.getCameraMotionList().add(new CameraMotion());
+ motion.getCameraMotionList().add(new CameraMotion());
+ motion.getCameraMotionList().add(new CameraMotion());
+ motion.getLuminousMotionList().add(new LuminousMotion());
+ motion.getLuminousMotionList().add(new LuminousMotion());
+ motion.getLuminousMotionList().add(new LuminousMotion());
+ motion.getLuminousMotionList().add(new LuminousMotion());
+ motion.getShadowMotionList().add(new ShadowMotion());
+ motion.getShadowMotionList().add(new ShadowMotion());
+ motion.getShadowMotionList().add(new ShadowMotion());
+ motion.getShadowMotionList().add(new ShadowMotion());
+ motion.getShadowMotionList().add(new ShadowMotion());
+
+ assertEquals(
+ "model name : model\n"
+ +"bone#1 morph#2 camera#3 luminous#4 shadow#5",
+ motion.toString());
+
+ return;
+ }
+
+}
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import jp.sourceforge.mikutoga.vmd2xml.MotionFileType;
-import jp.sourceforge.mikutoga.vmd2xml.Vmd2XmlConv;
+import jp.sfjp.mikutoga.vmd2xml.MotionFileType;
+import jp.sfjp.mikutoga.vmd2xml.Vmd2XmlConv;
import static org.junit.Assert.*;
--- /dev/null
+/*
+ */
+
+package testdata.vmd110820.morph;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static testdata.CnvAssert.*;
+
+/**
+ *
+ */
+public class MorphTest {
+
+ static Class<?> THISCLASS = MorphTest.class;
+
+ public MorphTest() {
+ assert this.getClass() == THISCLASS;
+ return;
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ @Test
+ public void vmd2xml() throws Exception{
+ System.out.println("vmd2xml");
+ assertVmd2Xml(THISCLASS, "morph.vmd", "morph.xml");
+ return;
+ }
+
+ @Test
+ public void xml2vmd() throws Exception{
+ System.out.println("xml2vmd");
+ assertXml2Vmd(THISCLASS, "morph.xml", "morph.vmd");
+ return;
+ }
+
+}
--- /dev/null
+/*
+ */
+
+package testdata.vmd110820.motion;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static testdata.CnvAssert.*;
+
+/**
+ *
+ */
+public class MotionTest {
+
+ static Class<?> THISCLASS = MotionTest.class;
+
+ public MotionTest() {
+ assert this.getClass() == THISCLASS;
+ return;
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ @Test
+ public void vmd2xml() throws Exception{
+ System.out.println("vmd2xml");
+ assertVmd2Xml(THISCLASS, "motion.vmd", "motion.xml");
+ return;
+ }
+
+ @Test
+ public void xml2vmd() throws Exception{
+ System.out.println("xml2vmd");
+ assertXml2Vmd(THISCLASS, "motion.xml", "motion.vmd");
+ return;
+ }
+
+}
>
<!--
- motion interpolation is defined by Bezier-cubic-curve.
- implicit bezier curve point : P0=(0,0) P3=(127,127)
- defLinear : MMD default linear curve. P1=(20,20) P2=(107,107) [DEFAULT]
- defEaseInOut : MMD default ease-in-out curve. P1=(64,0) P2=(64,127)
--->
-<!--
camera-rotation has polar-coordinates parameters.
xRad = -radian(UI_X) [latitude]
yRad = radian(UI_Y) [longitude]
zRad = radian(UI_Z) [roll]
range = -(UI_RANGE)
-->
+<!--
+ motion-interpolation is described with Bezier-cubic-curve.
+ implicit bezier curve point : P0=(0,0) P3=(127,127)
+ defLinear : MMD default linear curve. P1=(20,20) P2=(107,107) [DEFAULT]
+ defEaseInOut : MMD default ease-in-out curve. P1=(64,0) P2=(64,127)
+-->
<cameraSequence>
<cameraMotion frame="0" >
<luminousSequence>
</luminousSequence>
-<!--
- UI_VALUE = EFFECTIVE_RANGE * 100 ???
- rawParam = 0.1 - (UI_VALUE / 1.0E+5)
-
- NONE : no self-shadow
- MODE_1 : reduce shadow-quality suddenly at range
- MODE_2 : reduce shadow-quality gradually with range
--->
<shadowSequence>
</shadowSequence>
version="110820"
>
-<!--
- motion interpolation is defined by Bezier-cubic-curve.
- implicit bezier curve point : P0=(0,0) P3=(127,127)
- defLinear : MMD default linear curve. P1=(20,20) P2=(107,107) [DEFAULT]
- defEaseInOut : MMD default ease-in-out curve. P1=(64,0) P2=(64,127)
--->
-<!--
- camera-rotation has polar-coordinates parameters.
- xRad = -radian(UI_X) [latitude]
- yRad = radian(UI_Y) [longitude]
- zRad = radian(UI_Z) [roll]
- range = -(UI_RANGE)
--->
<cameraSequence>
</cameraSequence>
</luminousSequence>
-<!--
- UI_VALUE = EFFECTIVE_RANGE * 100 ???
- rawParam = 0.1 - (UI_VALUE / 1.0E+5)
-
- NONE : no self-shadow
- MODE_1 : reduce shadow-quality suddenly at range
- MODE_2 : reduce shadow-quality gradually with range
--->
<shadowSequence>
</shadowSequence>
version="110820"
>
-<!--
- motion interpolation is defined by Bezier-cubic-curve.
- implicit bezier curve point : P0=(0,0) P3=(127,127)
- defLinear : MMD default linear curve. P1=(20,20) P2=(107,107) [DEFAULT]
- defEaseInOut : MMD default ease-in-out curve. P1=(64,0) P2=(64,127)
--->
-<!--
- camera-rotation has polar-coordinates parameters.
- xRad = -radian(UI_X) [latitude]
- yRad = radian(UI_Y) [longitude]
- zRad = radian(UI_Z) [roll]
- range = -(UI_RANGE)
--->
<cameraSequence>
</cameraSequence>
<luminousSequence>
</luminousSequence>
-<!--
- UI_VALUE = EFFECTIVE_RANGE * 100 ???
- rawParam = 0.1 - (UI_VALUE / 1.0E+5)
-
- NONE : no self-shadow
- MODE_1 : reduce shadow-quality suddenly at range
- MODE_2 : reduce shadow-quality gradually with range
--->
<shadowSequence>
</shadowSequence>
version="110820"
>
-<!-- -->
+<!-- [NAMELESS] -->
<modelName name="" />
-<!--
- bone-rotation has Quaternion parameters [boneRotQuat]
- or YXZ-Euler angles [boneRotEyxz].
- Quaternion is strongly recommended if you are data-exchanging.
--->
-<!--
- motion interpolation is defined by Bezier-cubic-curve.
- implicit bezier curve point : P0=(0,0) P3=(127,127)
- defLinear : MMD default linear curve. P1=(20,20) P2=(107,107) [DEFAULT]
- defEaseInOut : MMD default ease-in-out curve. P1=(64,0) P2=(64,127)
--->
<boneMotionSequence>
</boneMotionSequence>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!--
+ MikuMikuDance
+ motion-data(*.vmd) on XML
+-->
+
+
+<vmdMotion
+ xmlns="http://mikutoga.sourceforge.jp/xml/ns/vmdxml/110820"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://mikutoga.sourceforge.jp/xml/ns/vmdxml/110820
+ http://mikutoga.sourceforge.jp/xml/xsd/vmdxml-110820.xsd"
+ version="110820"
+>
+
+<!-- model -->
+<modelName name="model" />
+
+<boneMotionSequence>
+</boneMotionSequence>
+
+<morphSequence>
+
+ <!-- あ --> <!-- Perhaps : [a] -->
+ <morphPart name="あ" >
+ <morphMotion frame="0" flex="0.0" />
+ <morphMotion frame="5" flex="0.5" />
+ <morphMotion frame="10" flex="1.0" />
+ </morphPart>
+
+ <!-- ぃ -->
+ <morphPart name="ぃ" >
+ <morphMotion frame="0" flex="0.9" />
+ <morphMotion frame="5" flex="0.7" />
+ <morphMotion frame="10" flex="0.1" />
+ </morphPart>
+
+</morphSequence>
+
+</vmdMotion>
+
+<!-- EOF -->
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!--
+ MikuMikuDance
+ motion-data(*.vmd) on XML
+-->
+
+
+<vmdMotion
+ xmlns="http://mikutoga.sourceforge.jp/xml/ns/vmdxml/110820"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://mikutoga.sourceforge.jp/xml/ns/vmdxml/110820
+ http://mikutoga.sourceforge.jp/xml/xsd/vmdxml-110820.xsd"
+ version="110820"
+>
+
+<!-- model -->
+<modelName name="model" />
+
+<!--
+ bone-rotation has Quaternion parameters [boneRotQuat]
+ or YXZ-Euler angles [boneRotEyxz].
+ Quaternion form is strongly recommended if you are data-exchanging.
+-->
+<!--
+ motion-interpolation is described with Bezier-cubic-curve.
+ implicit bezier curve point : P0=(0,0) P3=(127,127)
+ defLinear : MMD default linear curve. P1=(20,20) P2=(107,107) [DEFAULT]
+ defEaseInOut : MMD default ease-in-out curve. P1=(64,0) P2=(64,127)
+-->
+<boneMotionSequence>
+
+ <!-- センター --> <!-- Perhaps : [center] -->
+ <bonePart name="センター" >
+
+ <boneMotion frame="0" >
+ <boneRotQuat
+ qx="0.0"
+ qy="0.0"
+ qz="0.0"
+ qw="1.0"
+ />
+ </boneMotion>
+
+ <boneMotion frame="5" >
+ <bonePosition xPos="1.0" yPos="2.0" zPos="3.0" >
+ <!-- X-Y-Z interpolation *3 -->
+ <bezier p1x="10" p1y="20" p2x="107" p2y="107" />
+ <defLinear />
+ <defEaseInOut />
+ </bonePosition>
+ <boneRotQuat
+ qx="0.0"
+ qy="0.0"
+ qz="0.0"
+ qw="1.0"
+ >
+ <bezier p1x="30" p1y="20" p2x="107" p2y="107" />
+ </boneRotQuat>
+ </boneMotion>
+
+ </bonePart>
+
+ <!-- 下半身 --> <!-- Perhaps : [lower body] -->
+ <bonePart name="下半身" >
+
+ <boneMotion frame="0" >
+ <boneRotQuat
+ qx="0.0"
+ qy="0.0"
+ qz="0.0"
+ qw="1.0"
+ />
+ </boneMotion>
+
+ </bonePart>
+
+</boneMotionSequence>
+
+<morphSequence>
+</morphSequence>
+
+</vmdMotion>
+
+<!-- EOF -->
version="110820"
>
-<!--
- motion interpolation is defined by Bezier-cubic-curve.
- implicit bezier curve point : P0=(0,0) P3=(127,127)
- defLinear : MMD default linear curve. P1=(20,20) P2=(107,107) [DEFAULT]
- defEaseInOut : MMD default ease-in-out curve. P1=(64,0) P2=(64,127)
--->
-<!--
- camera-rotation has polar-coordinates parameters.
- xRad = -radian(UI_X) [latitude]
- yRad = radian(UI_Y) [longitude]
- zRad = radian(UI_Z) [roll]
- range = -(UI_RANGE)
--->
<cameraSequence>
</cameraSequence>
<!--
bone-rotation has Quaternion parameters [boneRotQuat]
or YXZ-Euler angles [boneRotEyxz].
- Quaternion is strongly recommended if you are data-exchanging.
+ Quaternion form is strongly recommended if you are data-exchanging.
-->
<!--
- motion interpolation is defined by Bezier-cubic-curve.
+ motion-interpolation is described with Bezier-cubic-curve.
implicit bezier curve point : P0=(0,0) P3=(127,127)
defLinear : MMD default linear curve. P1=(20,20) P2=(107,107) [DEFAULT]
defEaseInOut : MMD default ease-in-out curve. P1=(64,0) P2=(64,127)
>
<!--
- motion interpolation is defined by Bezier-cubic-curve.
- implicit bezier curve point : P0=(0,0) P3=(127,127)
- defLinear : MMD default linear curve. P1=(20,20) P2=(107,107) [DEFAULT]
- defEaseInOut : MMD default ease-in-out curve. P1=(64,0) P2=(64,127)
--->
-<!--
camera-rotation has polar-coordinates parameters.
xRad = -radian(UI_X) [latitude]
yRad = radian(UI_Y) [longitude]
zRad = radian(UI_Z) [roll]
range = -(UI_RANGE)
-->
+<!--
+ motion-interpolation is described with Bezier-cubic-curve.
+ implicit bezier curve point : P0=(0,0) P3=(127,127)
+ defLinear : MMD default linear curve. P1=(20,20) P2=(107,107) [DEFAULT]
+ defEaseInOut : MMD default ease-in-out curve. P1=(64,0) P2=(64,127)
+-->
<cameraSequence>
<cameraMotion frame="0" >
<luminousSequence>
</luminousSequence>
-<!--
- UI_VALUE = EFFECTIVE_RANGE * 100 ???
- rawParam = 0.1 - (UI_VALUE / 1.0E+5)
-
- NONE : no self-shadow
- MODE_1 : reduce shadow-quality suddenly at range
- MODE_2 : reduce shadow-quality gradually with range
--->
<shadowSequence>
</shadowSequence>
version="110820"
>
-<!--
- motion interpolation is defined by Bezier-cubic-curve.
- implicit bezier curve point : P0=(0,0) P3=(127,127)
- defLinear : MMD default linear curve. P1=(20,20) P2=(107,107) [DEFAULT]
- defEaseInOut : MMD default ease-in-out curve. P1=(64,0) P2=(64,127)
--->
-<!--
- camera-rotation has polar-coordinates parameters.
- xRad = -radian(UI_X) [latitude]
- yRad = radian(UI_Y) [longitude]
- zRad = radian(UI_Z) [roll]
- range = -(UI_RANGE)
--->
<cameraSequence>
</cameraSequence>
</luminousSequence>
-<!--
- UI_VALUE = EFFECTIVE_RANGE * 100 ???
- rawParam = 0.1 - (UI_VALUE / 1.0E+5)
-
- NONE : no self-shadow
- MODE_1 : reduce shadow-quality suddenly at range
- MODE_2 : reduce shadow-quality gradually with range
--->
<shadowSequence>
</shadowSequence>
<!-- model -->
<modelName name="model" />
-<!--
- bone-rotation has Quaternion parameters [boneRotQuat]
- or YXZ-Euler angles [boneRotEyxz].
- Quaternion is strongly recommended if you are data-exchanging.
--->
-<!--
- motion interpolation is defined by Bezier-cubic-curve.
- implicit bezier curve point : P0=(0,0) P3=(127,127)
- defLinear : MMD default linear curve. P1=(20,20) P2=(107,107) [DEFAULT]
- defEaseInOut : MMD default ease-in-out curve. P1=(64,0) P2=(64,127)
--->
<boneMotionSequence>
</boneMotionSequence>
version="110820"
>
-<!--
- motion interpolation is defined by Bezier-cubic-curve.
- implicit bezier curve point : P0=(0,0) P3=(127,127)
- defLinear : MMD default linear curve. P1=(20,20) P2=(107,107) [DEFAULT]
- defEaseInOut : MMD default ease-in-out curve. P1=(64,0) P2=(64,127)
--->
-<!--
- camera-rotation has polar-coordinates parameters.
- xRad = -radian(UI_X) [latitude]
- yRad = radian(UI_Y) [longitude]
- zRad = radian(UI_Z) [roll]
- range = -(UI_RANGE)
--->
<cameraSequence>
</cameraSequence>