2 * camera information builder
4 * License : The MIT License
5 * Copyright(c) 2011 MikuToga Partners
8 package jp.sourceforge.mikutoga.vmd.model.binio;
10 import java.util.List;
11 import jp.sourceforge.mikutoga.parser.MmdFormatException;
12 import jp.sourceforge.mikutoga.parser.ParseStage;
13 import jp.sourceforge.mikutoga.vmd.model.BezierParam;
14 import jp.sourceforge.mikutoga.vmd.model.CameraMotion;
15 import jp.sourceforge.mikutoga.vmd.model.CameraRotation;
16 import jp.sourceforge.mikutoga.vmd.model.PosCurve;
17 import jp.sourceforge.mikutoga.vmd.model.VmdMotion;
18 import jp.sourceforge.mikutoga.vmd.parser.VmdCameraHandler;
23 class CameraLoader implements VmdCameraHandler {
25 private final List<CameraMotion> cameraMotionList;
27 private CameraMotion currentCameraMotion;
32 * @param vmdMotion モーションデータ。
34 CameraLoader(VmdMotion vmdMotion){
36 this.cameraMotionList = vmdMotion.getCameraMotionList();
37 this.currentCameraMotion = null;
44 * @param stage {@inheritDoc}
45 * @param loops {@inheritDoc}
46 * @throws MmdFormatException {@inheritDoc}
49 public void loopStart(ParseStage stage, int loops)
50 throws MmdFormatException{
51 this.currentCameraMotion = new CameraMotion();
57 * @param stage {@inheritDoc}
58 * @throws MmdFormatException {@inheritDoc}
61 public void loopNext(ParseStage stage)
62 throws MmdFormatException{
63 this.cameraMotionList.add(this.currentCameraMotion);
64 this.currentCameraMotion = new CameraMotion();
70 * @param stage {@inheritDoc}
71 * @throws MmdFormatException {@inheritDoc}
74 public void loopEnd(ParseStage stage)
75 throws MmdFormatException{
76 this.currentCameraMotion = null;
82 * @param keyFrameNo {@inheritDoc}
83 * @throws MmdFormatException {@inheritDoc}
86 public void vmdCameraMotion(int keyFrameNo) throws MmdFormatException{
87 this.currentCameraMotion.setFrameNumber(keyFrameNo);
93 * @param xPos {@inheritDoc}
94 * @param yPos {@inheritDoc}
95 * @param zPos {@inheritDoc}
96 * @throws MmdFormatException {@inheritDoc}
99 public void vmdCameraPosition(float xPos, float yPos, float zPos)
100 throws MmdFormatException{
101 this.currentCameraMotion.getCameraTarget()
102 .setPosition(xPos, yPos, zPos);
108 * @param latitude {@inheritDoc}
109 * @param longitude {@inheritDoc}
110 * @param roll {@inheritDoc}
111 * @throws MmdFormatException {@inheritDoc}
114 public void vmdCameraRotation(float latitude,
117 throws MmdFormatException{
118 CameraRotation rotation =
119 this.currentCameraMotion.getCameraRotation();
120 rotation.setLatitude(latitude);
121 rotation.setLongitude(longitude);
122 rotation.setRoll(roll);
128 * @param range {@inheritDoc}
129 * @throws MmdFormatException {@inheritDoc}
132 public void vmdCameraRange(float range) throws MmdFormatException{
133 this.currentCameraMotion.setRange(range);
139 * @param angle {@inheritDoc}
140 * @param hasPerspective {@inheritDoc}
141 * @throws MmdFormatException {@inheritDoc}
144 public void vmdCameraProjection(int angle, boolean hasPerspective)
145 throws MmdFormatException{
146 this.currentCameraMotion.setProjectionAngle(angle);
147 this.currentCameraMotion.setPerspectiveMode(hasPerspective);
153 * @param p1x {@inheritDoc}
154 * @param p1y {@inheritDoc}
155 * @param p2x {@inheritDoc}
156 * @param p2y {@inheritDoc}
157 * @throws MmdFormatException {@inheritDoc}
160 public void vmdCameraIntpltXpos(byte p1x, byte p1y, byte p2x, byte p2y)
161 throws MmdFormatException{
162 PosCurve posCurve = this.currentCameraMotion.getTargetPosCurve();
163 BezierParam bezier = posCurve.getIntpltXpos();
164 bezier.setP1(p1x, p1y);
165 bezier.setP2(p2x, p2y);
171 * @param p1x {@inheritDoc}
172 * @param p1y {@inheritDoc}
173 * @param p2x {@inheritDoc}
174 * @param p2y {@inheritDoc}
175 * @throws MmdFormatException {@inheritDoc}
178 public void vmdCameraIntpltYpos(byte p1x, byte p1y, byte p2x, byte p2y)
179 throws MmdFormatException{
180 PosCurve posCurve = this.currentCameraMotion.getTargetPosCurve();
181 BezierParam bezier = posCurve.getIntpltYpos();
182 bezier.setP1(p1x, p1y);
183 bezier.setP2(p2x, p2y);
189 * @param p1x {@inheritDoc}
190 * @param p1y {@inheritDoc}
191 * @param p2x {@inheritDoc}
192 * @param p2y {@inheritDoc}
193 * @throws MmdFormatException {@inheritDoc}
196 public void vmdCameraIntpltZpos(byte p1x, byte p1y, byte p2x, byte p2y)
197 throws MmdFormatException{
198 PosCurve posCurve = this.currentCameraMotion.getTargetPosCurve();
199 BezierParam bezier = posCurve.getIntpltZpos();
200 bezier.setP1(p1x, p1y);
201 bezier.setP2(p2x, p2y);
207 * @param p1x {@inheritDoc}
208 * @param p1y {@inheritDoc}
209 * @param p2x {@inheritDoc}
210 * @param p2y {@inheritDoc}
211 * @throws MmdFormatException {@inheritDoc}
214 public void vmdCameraIntpltRotation(byte p1x, byte p1y,
216 throws MmdFormatException{
217 BezierParam bezier = this.currentCameraMotion.getIntpltRotation();
218 bezier.setP1(p1x, p1y);
219 bezier.setP2(p2x, p2y);
225 * @param p1x {@inheritDoc}
226 * @param p1y {@inheritDoc}
227 * @param p2x {@inheritDoc}
228 * @param p2y {@inheritDoc}
229 * @throws MmdFormatException {@inheritDoc}
232 public void vmdCameraIntpltRange(byte p1x, byte p1y, byte p2x, byte p2y)
233 throws MmdFormatException{
234 BezierParam bezier = this.currentCameraMotion.getIntpltRange();
235 bezier.setP1(p1x, p1y);
236 bezier.setP2(p2x, p2y);
242 * @param p1x {@inheritDoc}
243 * @param p1y {@inheritDoc}
244 * @param p2x {@inheritDoc}
245 * @param p2y {@inheritDoc}
246 * @throws MmdFormatException {@inheritDoc}
249 public void vmdCameraIntpltProjection(byte p1x, byte p1y,
251 throws MmdFormatException{
252 BezierParam bezier = this.currentCameraMotion.getIntpltProjection();
253 bezier.setP1(p1x, p1y);
254 bezier.setP2(p2x, p2y);