OSDN Git Service

モデルデータ不備の異常系を別パッケージに
[mikutoga/TogaGem.git] / src / main / java / jp / sourceforge / mikutoga / vmd / model / BoneMotion.java
1 /*
2  * bone motion
3  *
4  * License : The MIT License
5  * Copyright(c) 2011 MikuToga Partners
6  */
7
8 package jp.sourceforge.mikutoga.vmd.model;
9
10 import jp.sourceforge.mikutoga.math.MkPos3D;
11 import jp.sourceforge.mikutoga.math.MkQuat;
12 import jp.sourceforge.mikutoga.vmd.AbstractNumbered;
13
14 /**
15  * ボーンのモーション情報。
16  * <p>ボーン名、ボーン位置、ボーン回転量、及び補間カーブ情報を持つ。
17  */
18 public class BoneMotion extends AbstractNumbered {
19
20     private String boneName;
21
22     private final MkQuat rotation = new MkQuat();
23     private final BezierParam intpltRotation = new BezierParam();
24
25     private final MkPos3D position = new MkPos3D();
26     private final PosCurve posCurve = new PosCurve();
27
28
29     /**
30      * コンストラクタ。
31      */
32     public BoneMotion(){
33         super();
34         return;
35     }
36
37
38     /**
39      * ボーン名を返す。
40      * @return ボーン名
41      */
42     public String getBoneName(){
43         return this.boneName;
44     }
45
46     /**
47      * ボーン名を設定する。
48      * @param boneName ボーン名
49      */
50     public void setBoneName(String boneName){
51         this.boneName = boneName;
52         return;
53     }
54
55     /**
56      * ボーン回転量を返す。
57      * @return ボーン回転量
58      */
59     public MkQuat getRotation(){
60         return this.rotation;
61     }
62
63     /**
64      * ボーン回転の補間曲線情報を返す。
65      * @return ボーン回転の補間曲線情報
66      */
67     public BezierParam getIntpltRotation(){
68         return this.intpltRotation;
69     }
70
71     /**
72      * ボーン位置を返す。
73      * @return ボーン位置
74      */
75     public MkPos3D getPosition(){
76         return this.position;
77     }
78
79     /**
80      * ボーン位置移動の補間情報を返す。
81      * @return ボーン位置移動の補間情報
82      */
83     public PosCurve getPosCurve(){
84         return this.posCurve;
85     }
86
87     /**
88      * このモーションが暗黙の位置情報を持つか判定する。
89      * <p>ボーン位置が原点(0,0,0)にあり、
90      * XYZ3軸の移動補間カーブがデフォルト直線補間の場合、
91      * 暗黙の位置情報と見なされる。
92      * <p>MMDは、位置情報を持たないボーンのモーションに対し
93      * 便宜的にこの暗黙の位置情報を割り当てる。
94      * <p>通常の位置モーションが暗黙の位置情報と一致する場合もありうる。
95      * @return 暗黙の位置情報であるならtrue
96      */
97     public boolean hasImplicitPosition(){
98         if(this.position.isOriginPoint() && this.posCurve.isDefaultLinear()){
99             return true;
100         }
101         return false;
102     }
103
104     /**
105      * {@inheritDoc}
106      * @return {@inheritDoc}
107      */
108     @Override
109     public String toString(){
110         StringBuilder result = new StringBuilder();
111
112         result.append("bone name : [").append(this.boneName);
113         result.append("] #").append(getFrameNumber()).append('\n');
114
115         result.append("rotation ").append(this.rotation);
116         result.append(" R-Bezier ").append(this.intpltRotation).append('\n');
117
118         result.append("position ").append(this.position).append('\n');
119         result.append(this.posCurve);
120
121         return result.toString();
122     }
123
124 }