OSDN Git Service

vmdパッケージ導入
[mikutoga/TogaGem.git] / src / main / java / jp / sourceforge / mikutoga / vmd / model / PosCurve.java
1 /*
2  * position curve
3  *
4  * License : The MIT License
5  * Copyright(c) 2011 MikuToga Partners
6  */
7
8 package jp.sourceforge.mikutoga.vmd.model;
9
10 /**
11  * 3次元位置移動の補間情報。
12  * <p>XYZ3軸それぞれに対応するベジェ曲線を3本持つ。
13  */
14 public class PosCurve {
15
16     private final BezierParam intpltXpos = new BezierParam();
17     private final BezierParam intpltYpos = new BezierParam();
18     private final BezierParam intpltZpos = new BezierParam();
19
20
21     /**
22      * コンストラクタ。
23      */
24     public PosCurve(){
25         super();
26         return;
27     }
28
29
30     /**
31      * ボーンX軸移動の補間曲線情報を返す。
32      * @return ボーンX軸移動の補間曲線情報
33      */
34     public BezierParam getIntpltXpos(){
35         return this.intpltXpos;
36     }
37
38     /**
39      * ボーンY軸移動の補間曲線情報を返す。
40      * @return ボーンY軸移動の補間曲線情報
41      */
42     public BezierParam getIntpltYpos(){
43         return this.intpltYpos;
44     }
45
46     /**
47      * ボーンZ軸移動の補間曲線情報を返す。
48      * @return ボーンZ軸移動の補間曲線情報
49      */
50     public BezierParam getIntpltZpos(){
51         return this.intpltZpos;
52     }
53
54     /**
55      * インデックス指定された各軸の補間曲線情報を返す。
56      * <p>インデックス値0がX軸、1がY軸、2がZ軸に対応する。
57      * @param no インデックス値[0-2]
58      * @return 各軸の補間曲線情報
59      * @throws IllegalArgumentException インデックス値が範囲外
60      */
61     public BezierParam item(int no) throws IllegalArgumentException {
62         BezierParam result;
63         switch(no){
64         case 0: result = this.intpltXpos; break;
65         case 1: result = this.intpltYpos; break;
66         case 2: result = this.intpltZpos; break;
67         default:
68             throw new IllegalArgumentException();
69         }
70         return result;
71     }
72
73     /**
74      * 3軸ともMMDデフォルトの直線補間か判定する。
75      * @return 3軸ともMMDデフォルトの直線補間ならtrue
76      */
77     public boolean isDefaultLinear(){
78         if( ! this.intpltXpos.isDefaultLinear() ) return false;
79         if( ! this.intpltYpos.isDefaultLinear() ) return false;
80         if( ! this.intpltZpos.isDefaultLinear() ) return false;
81
82         return true;
83     }
84
85     /**
86      * {@inheritDoc}
87      * @return {@inheritDoc}
88      */
89     @Override
90     public String toString(){
91         StringBuilder result = new StringBuilder();
92
93         result.append("X-Bezier ").append(this.intpltXpos).append('\n');
94         result.append("Y-Bezier ").append(this.intpltYpos).append('\n');
95         result.append("Z-Bezier ").append(this.intpltZpos);
96
97         return result.toString();
98     }
99
100 }