OSDN Git Service

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