OSDN Git Service

モデルデータ不備の異常系を別パッケージに
[mikutoga/TogaGem.git] / src / main / java / jp / sourceforge / mikutoga / vmd / model / CameraMotion.java
1 /*
2  * camera 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.vmd.AbstractNumbered;
12
13 /**
14  * カメラモーション情報。
15  * <p>カメラの回転は極座標で表される。
16  * <p>カメラ-ターゲット間の距離は球座標(極座標)の動径に相当する。
17  * 通常はターゲットより手前に位置するカメラまでの距離が負の値で表される。
18  * カメラ位置がターゲットを突き抜けた場合は正の値もとりうる。
19  * ※MMDのUIと符号が逆なので注意。
20  * <p>パースペクティブモードがOFFの場合、
21  * 画角は無視され遠近感処理が行われなくなる。(平行投影?)
22  */
23 public class CameraMotion extends AbstractNumbered {
24
25     private final MkPos3D cameraTarget = new MkPos3D();
26     private final PosCurve posCurve = new PosCurve();
27
28     private final CameraRotation cameraRotation = new CameraRotation();
29     private final BezierParam intpltRotation = new BezierParam();
30
31     private float range;
32     private final BezierParam intpltRange = new BezierParam();
33
34     private boolean hasPerspective;
35     private int projectionAngle;
36     private final BezierParam intpltProjection = new BezierParam();
37
38
39     /**
40      * コンストラクタ。
41      */
42     public CameraMotion(){
43         super();
44         return;
45     }
46
47
48     /**
49      * ターゲット位置情報を返す。
50      * @return ターゲット位置情報
51      */
52     public MkPos3D getCameraTarget(){
53         return this.cameraTarget;
54     }
55
56     /**
57      * ターゲット位置移動の補間情報を返す。
58      * @return ターゲット位置移動の補間情報
59      */
60     public PosCurve getTargetPosCurve(){
61         return this.posCurve;
62     }
63
64     /**
65      * カメラ回転情報を返す。
66      * @return カメラ回転情報
67      */
68     public CameraRotation getCameraRotation(){
69         return this.cameraRotation;
70     }
71
72     /**
73      * カメラ回転の補間曲線情報を返す。
74      * @return カメラ回転の補間曲線情報
75      */
76     public BezierParam getIntpltRotation(){
77         return this.intpltRotation;
78     }
79
80     /**
81      * カメラ-ターゲット間の距離を返す。
82      * @return カメラ-ターゲット間の距離
83      */
84     public float getRange(){
85         return this.range;
86     }
87
88     /**
89      * カメラ-ターゲット間の距離を設定する。
90      * @param range カメラ-ターゲット間の距離
91      */
92     public void setRange(float range){
93         this.range = range;
94         return;
95     }
96
97     /**
98      * カメラ-ターゲット間距離の補間曲線情報を返す。
99      * @return カメラ-ターゲット間距離の補間曲線情報
100      */
101     public BezierParam getIntpltRange(){
102         return this.intpltRange;
103     }
104
105     /**
106      * パースペクティブが有効か判定する。
107      * @return パースペクティブが有効ならtrue
108      */
109     public boolean hasPerspective(){
110         return this.hasPerspective;
111     }
112
113     /**
114      * パースペクティブモードを設定する。
115      * @param mode trueを渡すとパースペクティブが有効になる。
116      */
117     public void setPerspectiveMode(boolean mode){
118         this.hasPerspective = mode;
119         return;
120     }
121
122     /**
123      * 投影角度(スクリーン縦画角)を返す。
124      * @return 投影角度(度数法)
125      */
126     public int getProjectionAngle(){
127         return this.projectionAngle;
128     }
129
130     /**
131      * 投影角度(スクリーン縦画角)を設定する。
132      * @param angle 投影角度(度数法)
133      */
134     public void setProjectionAngle(int angle){
135         this.projectionAngle = angle;
136         return;
137     }
138
139     /**
140      * スクリーン投射の補間曲線情報を返す。
141      * @return スクリーン投射の補間曲線情報
142      */
143     public BezierParam getIntpltProjection(){
144         return this.intpltProjection;
145     }
146
147     /**
148      * {@inheritDoc}
149      * @return {@inheritDoc}
150      */
151     @Override
152     public String toString(){
153         StringBuilder result = new StringBuilder();
154
155         result.append("#").append(getFrameNumber()).append(' ');
156         result.append(this.cameraRotation);
157         result.append(" Rot-Bezier ")
158                 .append(this.intpltRotation).append('\n');
159
160         result.append("range : ").append(this.range);
161         result.append(" Range-Bezier ").append(this.intpltRange).append('\n');
162
163         result.append("target-pos : ").append(this.cameraTarget).append('\n');
164         result.append(this.posCurve).append('\n');
165
166         result.append("perspective : ");
167         if(this.hasPerspective) result.append("ON");
168         else                    result.append("OFF");
169         result.append('\n');
170
171         result.append("projection angle : ").append(this.projectionAngle);
172         result.append("deg Bezier ").append(this.intpltProjection);
173
174         return result.toString();
175     }
176
177 }