OSDN Git Service

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