Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/CCamera.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11 - (show annotations) (download) (as text)
Sun Sep 9 04:21:31 2012 UTC (11 years, 8 months ago) by okadu
File MIME type: text/x-c++src
File size: 16913 byte(s)
[okadu] Version 2.14a バグ修正いろいろ

1 #include "stdafx.h"
2 #include "CCamera.h"
3 #include "CInterface.h"
4 #include "CScene.h"
5 #include "CSurfacePlugin.h"
6 #include "CSkinPlugin.h"
7 #include "CNeutralMode.h"
8
9 // 外部定数
10 extern const float CLIP_PLANE_NEAR;
11 extern const float CLIP_PLANE_FAR;
12 extern const float FOV_DEF;
13
14 // 内部定数
15 extern const float CAM_PAN = 0.001f; // カメラパン
16 const float CAM_HEAD = 0.001f; // ヘッド感度
17 const float CAM_PITCH = 0.001f; // ピッチ感度
18 //const float CAM_BANK = 0.001f; // バンク感度
19 const float CAM_FOWARD = 0.0001f; // 前後感度
20 const float CAM_ZOOM = 0.00002f; // ズーム感度
21 const float FOV_MIN = D3DXToRadian(0.1f); // 最小視野角
22 const float FOV_MAX = D3DXToRadian(179.0f); // 最大視野角
23 const int CAM_EDGE_MOVE = 20; // 画面端移動速度
24
25 // 外部グローバル
26 extern bool g_HidefCaptureFlag;
27 extern int g_HidefBufferSize;
28 extern int g_HidefQuality;
29 extern float g_HidefLeft, g_HidefRight;
30 extern float g_HidefBottom, g_HidefTop;
31
32 // 内部グローバル
33 float g_FovRatio; // 視野角率
34 float g_StereoInterval = 0.0f;
35 D3DCOLORVALUE g_LightColor = {1.0f, 1.0f, 1.0f, 0.0f}; // 光源色
36 MTX4 g_BoldLineMtx[8][8];
37
38 // static メンバ
39 CCamera *CCamera::ms_CurrentCamera = NULL;
40
41 /*
42 * 初期化
43 */
44 void CCamera::Init(
45 float defdist, // 既定距離
46 float mindist, // 最小距離
47 float maxdist, // 最大距離
48 bool clip // クリップ設定
49 ){
50 m_LeftState = m_MiddleState = m_RightState = 0;
51 m_DefDist = defdist;
52 m_MinDist = mindist;
53 m_MaxDist = maxdist;
54 m_ClipRect = clip;
55 m_LockPos = false;
56 m_AutoZoom = false;
57 m_LocalFocus = false;
58 m_FocusSpeed = 0.0f;
59 ResetCamera();
60 ResetLight();
61 }
62
63 /*
64 * カメラをリセット
65 */
66 void CCamera::ResetCamera(
67 float head, float pitch, float bank, // 角度
68 float dist // 距離
69 ){
70 m_PrintInfoTime = 0;
71 m_Head = head;
72 m_Pitch = pitch;
73 // m_Bank = bank;
74 m_Dist = dist<0.0f ? m_DefDist : dist;
75 m_FieldOfView = 0.25f*D3DX_PI;
76 m_Wheel = 0.0f;
77 SetCenter();
78 }
79
80 /*
81 * フォーカス移動先設定
82 */
83 void CCamera::SetFocusTarget(
84 VEC3 f, float s
85 ){
86 m_FocusTarget = f;
87 m_FocusSpeed = s;
88 }
89
90 /*
91 * フォーカスインスタンス設定
92 */
93 void CCamera::SetFocusInfo(
94 CDetectInfo &info // フォーカス情報
95 ){
96 bool flag;
97 if(flag = !GetFocusInst() && info.GetModelInst()){
98 m_AutoZoomBaseDist = V3Len(&(GetVPos()-info.GetPartsInst()->GetCenter()));
99 }else if(flag = GetFocusInst() && !info.GetModelInst()){
100 m_FieldOfView = m_FieldOfViewEffect;
101 }
102 m_FocusInfo = info;
103 if(flag || GetFocusInst()) InvCalcParam();
104 }
105
106 /*
107 * オートズーム設定
108 */
109 void CCamera::SetAutoZoom(
110 bool z // フラグ
111 ){
112 if(m_AutoZoom = z) m_AutoZoomBaseDist = m_Dist;
113 else m_FieldOfView = m_FieldOfViewEffect;
114 BeginPrint();
115 }
116
117 /*
118 * ローカル制御設定
119 */
120 void CCamera::SetLocalFocus(
121 int l, // 制御モード
122 CObject *tlocal // ローカル系直接指定
123 ){
124 m_LocalFocus = l;
125 InvCalcParam(tlocal);
126 BeginPrint();
127 }
128
129 /*
130 * ライトをリセット
131 */
132 void CCamera::ResetLight(){
133 m_LightSwitch = true;
134 m_LinkLight = false;
135 m_LightDir = VEC3(1.5f, -2.0f, -1.0f);
136 }
137
138 /*
139 * ライトを連動
140 */
141 void CCamera::LinkLight(
142 bool link // リンクフラグ
143 ){
144 if(link==m_LinkLight) return;
145 if(link){
146 m_LinkLight = true;
147 m_LightDir = V3WorldToLocal(
148 &m_LightDir, &GetVRight(), &GetVUp(), &GetVDir());
149 }else{
150 m_LinkLight = false;
151 m_LightDir = V3LocalToWorld(
152 &m_LightDir, &GetVRight(), &GetVUp(), &GetVDir());
153 }
154 }
155
156 /*
157 * パラメータを逆計算
158 */
159 void CCamera::InvCalcParam(
160 CObject *tlocal // ローカル系直接指定
161 ){
162 VEC3 dir = m_Focus-m_CameraPos;
163 V3Norm(&dir, &dir);
164 if((GetFocusInst() || tlocal) && m_LocalFocus){
165 VEC3 tr, tu = V3UP, td;
166 CObject *fobj = tlocal ? tlocal : GetFocusParts()->GetObject();
167 if(!tlocal && GetFocusObject()->GetType()==1){
168 tr = fobj->GetRight(); td = VEC3(-tr.z, 0.0f, tr.x);
169 V3NormAxis(&tr, &tu, &td);
170 V3Norm(&dir, &V3WorldToLocal(&dir, &tr, &tu, &td));
171 }else{
172 switch(m_LocalFocus){
173 case 1:
174 td = fobj->GetDir();
175 td.y = 0.0f;
176 V3NormAxis(&tr, &tu, &td);
177 V3Norm(&dir, &V3WorldToLocal(&dir, &tr, &tu, &td));
178 break;
179 case 2:
180 V3Norm(&dir, &V3WorldToLocal(&dir, fobj));
181 break;
182 }
183 }
184 }
185 m_Pitch = -asinf(dir.y);
186 dir.y = 0.0f;
187 V3Norm(&dir, &dir);
188 m_Head = acosf(dir.x);
189 if(dir.z<0.0f) m_Head = 2.0f*D3DX_PI-m_Head;
190 m_Dist = V3Len(&(m_Focus-m_CameraPos));
191 }
192
193 /*
194 * 選択
195 */
196 void CCamera::Select(){
197 ms_CurrentCamera = this;
198 m_LeftState = m_MiddleState = m_RightState = 0;
199 m_Wheel = m_UpDown = 0.0f;
200 g_Cursor.Release();
201 Apply(true);
202 }
203
204 /*
205 * カメラ設定
206 */
207 void CCamera::Apply(
208 bool light, // ライト設定フラグ
209 CObject *tlocal // ローカル系直接指定
210 ){
211 if(GetFocusInst()){
212 if(GetFocusInst()->GetScene()){
213 if(GetFocusInst()->GetScene()!=g_Scene){
214 g_Scene = GetFocusInst()->GetScene();
215 *g_Scene->GetCamera() = *this;
216 g_Scene->Enter(true);
217 *g_Scene->GetCamera() = *this;
218 g_NeutralMode->SetFocusInfo(m_FocusInfo);
219 return;
220 }
221 g_NeutralMode->SetFocusInfo(m_FocusInfo);
222 }else{
223 CDetectInfo tmp_detect_info;
224 g_NeutralMode->SetFocusInfo(tmp_detect_info);
225 }
226 if(GetFocusInst()->IsWarping()) return;
227 }else{
228 CDetectInfo tmp_detect_info;
229 g_NeutralMode->SetFocusInfo(tmp_detect_info);
230 }
231 float sinpitch = sinf(m_Pitch), cospitch = cosf(m_Pitch);
232 VEC3 pos, up = V3UP;
233 VEC3 dir = VEC3(cos(m_Head)*cospitch, -sinpitch, sin(m_Head)*cospitch);
234 if(m_LocalFocus){
235 VEC3 tr, tu = V3UP, td;
236 if(GetFocusInst() || tlocal){
237 CObject *fobj = tlocal ? tlocal : GetFocusParts()->GetObject();
238 if(!tlocal && GetFocusObject()->GetType()==1){
239 tr = fobj->GetRight(); td = VEC3(-tr.z, 0.0f, tr.x);
240 V3NormAxis(&tr, &tu, &td);
241 V3Norm(&dir, &V3LocalToWorld(&dir, &tr, &tu, &td));
242 }else{
243 switch(m_LocalFocus){
244 case 1:
245 td = fobj->GetDir();
246 td.y = 0.0f;
247 V3NormAxis(&tr, &tu, &td);
248 V3Norm(&dir, &V3LocalToWorld(&dir, &tr, &tu, &td));
249 break;
250 case 2:
251 up = fobj->GetUp();
252 if(up.y<0.0f) up = -up;
253 V3Norm(&dir, &V3LocalToWorld(&dir, fobj));
254 break;
255 }
256 }
257 }
258 }
259 if(m_LockPos && (GetFocusInst() || tlocal)){
260 pos = m_CameraPos;
261 m_Focus = tlocal ? tlocal->GetPos() : GetFocusParts()->GetCenter();
262 SetView(pos, m_Focus, V3UP);
263 if(g_StereoInterval) MoveVW(g_StereoInterval*GetVRight());
264 InvCalcParam(tlocal);
265 dir = GetVDir();
266 }else{
267 if(GetFocusInst()) m_Focus = GetFocusParts()->GetCenter();
268 else if(tlocal) m_Focus = tlocal->GetPos();
269 else if(m_FocusSpeed)
270 m_Focus = (1.0f-m_FocusSpeed)*m_Focus+m_FocusSpeed*m_FocusTarget;
271 pos = m_Focus-m_Dist*dir;
272 SetView(pos, m_Focus, up);
273 if(g_StereoInterval) MoveVW(g_StereoInterval*GetVRight());
274 m_CameraPos = GetVPos();
275 }
276 ValueArea(&m_FieldOfViewEffect, FOV_MIN, FOV_MAX);
277 // RotVZ(m_Bank);
278 if(light){
279 if(m_LightSwitch){
280 devSetAmbient(0xff808080);
281 SetDirLight(m_LinkLight ? V3LocalToWorld(
282 &m_LightDir, &GetVRight(), &GetVUp(), &GetVDir()) : m_LightDir,
283 g_LightColor = MAKE_CV(1.0f, 1.0f, 1.0f, 0.0f));
284 }else{
285 devSetAmbient(0xff202020);
286 SetDirLight(V3DIR, g_LightColor = MAKE_CV(0.0f, 0.0f, 0.0f, 1.0f));
287 }
288 }
289 ApplyProjection(CLIP_PLANE_NEAR, tlocal);
290 }
291
292 /*
293 * プロジェクション設定
294 */
295 void CCamera::ApplyProjection(
296 float nearclip, // 近距離クリップ
297 CObject *tlocal // ローカル系直接指定
298 ){
299 D3DVIEWPORT8 vp;
300 sv3.pDev->GetViewport(&vp);
301
302 m_FieldOfViewEffect = (GetFocusInst() || tlocal) && m_AutoZoom
303 ? 2.0f*atanf(m_AutoZoomBaseDist*tanf(0.5f*m_FieldOfView)
304 /V3Len(&(m_CameraPos-m_Focus))) : m_FieldOfView;
305 g_FovRatio = tanf(0.5f*m_FieldOfViewEffect)/tanf(0.5f*FOV_DEF);
306 float cliptmp = 1.0f/g_FovRatio;
307 ValueArea(&cliptmp, 0.1f, 1.0f);
308 float zn = nearclip*cliptmp, zf = CLIP_PLANE_FAR*cliptmp;
309 if(g_HidefCaptureFlag){
310 float vph = 2.0f*zn*tanf(0.5f*m_FieldOfViewEffect);
311 float vpw = (vph*vp.Width)/vp.Height;
312 D3DXMatrixPerspectiveOffCenterLH(&sv3.mtxProj,
313 g_HidefLeft*vpw, g_HidefRight*vpw, g_HidefBottom*vph, g_HidefTop*vph, zn, zf);
314 int bx, by;
315 for(by = 0; by<g_HidefQuality; ++by){
316 float ofsy = (g_HidefTop-g_HidefBottom)
317 /g_HidefBufferSize*(by-(g_HidefQuality-1)*0.5f);
318 for(bx = 0; bx<g_HidefQuality; ++bx){
319 float ofsx = (g_HidefRight-g_HidefLeft)
320 /g_HidefBufferSize*(bx-(g_HidefQuality-1)*0.5f);
321 D3DXMatrixPerspectiveOffCenterLH(&g_BoldLineMtx[by][bx],
322 (g_HidefLeft+ofsx)*vpw, (g_HidefRight+ofsx)*vpw,
323 (g_HidefBottom+ofsy)*vph, (g_HidefTop+ofsy)*vph, zn, zf);
324 }
325 }
326 }else{
327 D3DXMatrixPerspectiveFovLH(&sv3.mtxProj, m_FieldOfViewEffect,
328 (float)vp.Width/vp.Height, zn, zf);
329 }
330 sv3.pDev->SetTransform(D3DTS_PROJECTION, &sv3.mtxProj);
331 }
332
333 /*
334 * 情報表示
335 */
336 void CCamera::PrintInfo(
337 bool ext // 拡張制御情報表示
338 ){
339 if(m_PrintInfoTime<=0) return;
340 static char *onoff[2] = {"OFF", "ON"};
341 static char *local[3] = {"OFF", "HORZ", "ALL"};
342 const int ERASE = MAXFPS/3;
343 float alpha = m_PrintInfoTime>=ERASE ? 1.0f : (float)m_PrintInfoTime/ERASE;
344 m_PrintInfoTime--;
345 int ix = g_DispWidth*60/100, iy = g_DispHeight;
346 int cx = ix+50, cy = iy-TILE_UNIT*2-TILE_HALF;
347 int fx = Round(50*sinf(0.5f*m_FieldOfViewEffect));
348 int fy = Round(50*cosf(0.5f*m_FieldOfViewEffect));
349 devSetTexture(0, NULL);
350 D3DCOLOR white = ScaleColor(0xffffffff, alpha), black = ScaleColor(0xff000000, alpha);
351 D3DCOLOR white2 = ScaleColor(0x80ffffff, alpha), black2 = ScaleColor(0x80000000, alpha);
352 int deg;
353 for(deg = 0; deg<=180; deg += 15){
354 float rad = D3DXToRadian(deg);
355 int dx1 = Round(50*cosf(rad)), dy1 = Round(50*sinf(rad));
356 int dx2 = Round(40*cosf(rad)), dy2 = Round(40*sinf(rad));
357 Draw2DLine(cx+dx1+1, cy-dy1+1, cx+dx2+1, cy-dy2+1, black2, 0x01000000);
358 Draw2DLine(cx+dx1, cy-dy1, cx+dx2, cy-dy2, white2, 0x01ffffff);
359 }
360 Draw2DLine(cx+1, cy+1, cx+fx+1, cy-fy+1, black, 0x01000000);
361 Draw2DLine(cx+1, cy+1, cx-fx+1, cy-fy+1, black, 0x01000000);
362 Draw2DLine(cx, cy, cx+fx, cy-fy, white, 0x01ffffff);
363 Draw2DLine(cx, cy, cx-fx, cy-fy, white, 0x01ffffff);
364 g_StrTex->RenderLeft(ix, iy-TILE_UNIT*2, white, black,
365 FlashIn("%s: %.1f [deg]", lang(FieldOfView), D3DXToDegree(m_FieldOfViewEffect)));
366 g_StrTex->RenderLeft(ix, iy-TILE_UNIT, white, black,
367 FlashIn("%s: %.1f [m]", lang(Distance), m_Dist));
368 if(ext){
369 g_StrTex->RenderLeft(ix+110, iy-TILE_UNIT*3, white, black,
370 FlashIn("%s: %s", lang(FixViewpoint), onoff[m_LockPos]));
371 g_StrTex->RenderLeft(ix+110, iy-TILE_UNIT*2, white, black,
372 FlashIn("%s: %s", lang(AutoZoom), onoff[m_AutoZoom]));
373 g_StrTex->RenderLeft(ix+110, iy-TILE_UNIT, white, black,
374 FlashIn("%s: %s", lang(Local), local[m_LocalFocus]));
375 }
376 }
377
378 /*
379 * ローカル切替入力チェック
380 */
381 void CCamera::ControlLocal(
382 CObject *tlocal // ローカル系直接指定
383 ){
384 if(GetKey(DIK_HOME)==S_PUSH){
385 if(CheckCtrl()) SetLockPos(!GetLockPos());
386 else SetLocalFocus((GetLocalFocus()+(CheckShift() ? 2 : 1))%3, tlocal);
387 }
388 if(GetKey(DIK_END)==S_PUSH) SetAutoZoom(!GetAutoZoom());
389 }
390
391 /*
392 * 入力チェック
393 */
394 int CCamera::ScanInput(
395 int mode, // モード (0: pan, 1: slide, 2: arrow, 3: slide(middle), 4: zoom only)
396 CObject *tlocal // ローカル系直接指定
397 ){
398 bool clipping = false;
399 int ret = 0, wh = CInterface::GetFocus() ? 0 : GetWheel();
400 if(wh){
401 if(wh*m_Wheel<0.0f) m_Wheel = 0.0f;
402 m_Wheel = m_Wheel*1.5f+wh;
403 ret = 1;
404 }else{
405 if(GetKey(DIK_PRIOR)>=S_PUSH) wh += 5;
406 if(GetKey(DIK_NEXT)>=S_PUSH) wh -= 5;
407 if(wh){
408 if(wh*m_Wheel<0.0f) m_Wheel = 0.0f;
409 m_Wheel = m_Wheel*1.1f+wh;
410 ret = 1;
411 }else{
412 m_Wheel *= 0.5f;
413 }
414 }
415 float ratio = CheckFast();
416 if(wh) BeginPrint();
417 if(CheckShift()){
418 if(CheckCtrl()){
419 m_FieldOfView = 5.f*Round(D3DXToDegree(m_FieldOfView/5));
420 if(wh) m_FieldOfView += wh>0 ? -5.0f : 5.0f;
421 m_FieldOfView = D3DXToRadian(m_FieldOfView);
422 }else{
423 m_FieldOfView -= m_Wheel*CAM_ZOOM*ratio*sqrtf(m_FieldOfView);
424 }
425 ValueArea(&m_FieldOfView, FOV_MIN, FOV_MAX);
426 }else if((!m_LockPos || !GetFocusInst() && !tlocal) && mode!=4){
427 m_Dist -= m_Dist*m_Wheel*CAM_FOWARD*ratio;
428 ValueArea(&m_Dist, m_MinDist/g_FovRatio, m_MaxDist/g_FovRatio);
429 }
430 if(mode==4) return 0;
431 POINT delta = g_Cursor.GetDelta();
432 bool is_delta = delta.x || delta.y;
433 switch(GetButton(DIM_LEFT)){
434 case S_PUSH:
435 if(g_Cursor.IsLock()) break;
436 if(mode!=2){
437 m_LeftState = 2;
438 if(mode!=3) g_Cursor.Lock();
439 CInterface::SetFocus(NULL);
440 }
441 ret = 10;
442 break;
443 case S_HOLD:
444 if(m_MiddleState || m_RightState) break;
445 switch(m_LeftState){
446 case 2:
447 if(!g_Cursor.CheckDrag()){
448 ret = 11;
449 break;
450 }
451 m_LeftState = 1;
452 case 1:
453 ret = 11;
454 if(mode==3){
455 POINT pos = g_Cursor.GetPos(), tmp = {0, 0};
456 if(pos.x<=0) tmp.x = -CAM_EDGE_MOVE;
457 if(pos.x>=g_DispWidth-1) tmp.x = CAM_EDGE_MOVE;
458 if(pos.y<=0) tmp.y = -CAM_EDGE_MOVE;
459 if(pos.y>=g_DispHeight-1) tmp.y = CAM_EDGE_MOVE;
460 VEC3 fow = GetVFow();
461 fow = (GetVRight()*tmp.x-fow*tmp.y)*(ratio*m_Dist*CAM_PAN);
462 m_Focus += fow;
463 }else{
464 Slide(mode, tlocal);
465 }
466 break;
467 }
468 if(is_delta) clipping = true;
469 break;
470 default:
471 switch(m_LeftState){
472 case 2:
473 ret = 12;
474 case 1:
475 m_LeftState = 0;
476 if(!m_MiddleState && !m_RightState) g_Cursor.Release();
477 break;
478 }
479 break;
480 }
481 switch(GetButton(DIM_MIDDLE)){
482 case S_PUSH:
483 if(g_Cursor.IsLock()) break;
484 if(mode!=2){
485 m_MiddleState = 2;
486 g_Cursor.Lock();
487 CInterface::SetFocus(NULL);
488 }
489 ret = 20;
490 break;
491 case S_HOLD:
492 if(m_LeftState || m_RightState) break;
493 switch(m_MiddleState){
494 case 2:
495 if(!g_Cursor.CheckDrag()){
496 ret = 21;
497 break;
498 }
499 m_MiddleState = 1;
500 case 1:
501 ret = 21;
502 Slide(mode, tlocal);
503 break;
504 }
505 if(is_delta) clipping = true;
506 break;
507 default:
508 switch(m_MiddleState){
509 case 2:
510 ret = 22;
511 case 1:
512 m_MiddleState = 0;
513 if(!m_LeftState && !m_RightState) g_Cursor.Release();
514 break;
515 }
516 break;
517 }
518 switch(GetButton(DIM_RIGHT)){
519 case S_PUSH:
520 // if(g_Cursor.IsLock()) break;
521 m_RightState = 2;
522 g_Cursor.Lock();
523 CInterface::SetFocus(NULL);
524 ret = 30;
525 break;
526 case S_HOLD:
527 switch(m_RightState){
528 case 2:
529 if(!g_Cursor.CheckDrag()){
530 ret = 31;
531 break;
532 }
533 m_RightState = 1;
534 case 1:
535 ret = 31;
536 if(!m_LockPos || !GetFocusInst() && !tlocal){
537 m_Head -= delta.x*CAM_HEAD;
538 m_Pitch += delta.y*CAM_PITCH;
539 ValueCircular(&m_Head, 0.0f, 2.0f*D3DX_PI);
540 ValueArea(&m_Pitch, -0.49f*D3DX_PI, 0.49f*D3DX_PI);
541 }
542 break;
543 }
544 break;
545 default:
546 switch(m_RightState){
547 case 2:
548 ret = 32;
549 case 1:
550 m_RightState = 0;
551 if(!m_LeftState && !m_MiddleState) g_Cursor.Release();
552 break;
553 }
554 break;
555 }
556 if(m_ClipRect && clipping) Surface()->ClipRect(&m_Focus);
557 return ret;
558 }
559
560 /*
561 * スライド操作
562 */
563 void CCamera::Slide(
564 int mode, // モード (0: pan, 1: slide, 2: arrow, 3: slide(middle))
565 CObject *tlocal // ローカル系直接指定
566 ){
567 float ratio = CheckFast();
568 POINT delta = g_Cursor.GetDelta();
569 VEC3 *target = GetFocusInst() || tlocal ? &m_CameraPos : &m_Focus;
570 if(delta.x || delta.y) m_FocusSpeed = 0.0f;
571 switch(mode){
572 case 0: {
573 VEC3 mov = CheckShift() ? GetVDir()*(ratio*delta.y*m_Dist*CAM_PAN)
574 : -(GetVRight()*delta.x-GetVUp()*delta.y)*(ratio*m_Dist*CAM_PAN);
575 *target += mov;
576 break; }
577 case 1:
578 case 3:
579 if(CheckShift()){
580 float h = ratio*delta.y*m_Dist*CAM_PAN;
581 target->y -= h;
582 }else{
583 VEC3 fow = GetVFow();
584 fow = (GetVRight()*delta.x-fow*delta.y)*(ratio*m_Dist*CAM_PAN);
585 *target += fow;
586 }
587 break;
588 }
589 if((GetFocusInst() || tlocal) && !m_LockPos) InvCalcParam(tlocal);
590 }
591
592 /*
593 * 読込
594 */
595 char *CCamera::Read(
596 char *str // 対象文字列
597 ){
598 char *eee;
599 if(!(str = BeginBlock(str, "Camera"))) return NULL;
600 if(!(str = AsgnFloat(eee = str, "Head", &m_Head))) throw CSynErr(eee);
601 if(!(str = AsgnFloat(eee = str, "Pitch", &m_Pitch))) throw CSynErr(eee);
602 if(!(str = AsgnFloat(eee = str, "Dist", &m_Dist))) throw CSynErr(eee);
603 if(!(str = AsgnFloat(eee = str, "FieldOfView", &m_FieldOfView))) throw CSynErr(eee);
604 if(!(str = AsgnVector3D(eee = str, "Focus", &m_Focus))) throw CSynErr(eee);
605 if(!(str = EndBlock(eee = str))) throw CSynErr(eee, ERR_ENDBLOCK);
606 return str;
607 }
608
609 /*
610 * 保存
611 */
612 void CCamera::Save(
613 FILE *df, // ファイル
614 string indent // インデント
615 ){
616 fprintf(df, "%sCamera{\n", indent.c_str());
617 fprintf(df, "%s\tHead = %f;\n", indent.c_str(), m_Head);
618 fprintf(df, "%s\tPitch = %f;\n", indent.c_str(), m_Pitch);
619 fprintf(df, "%s\tDist = %f;\n", indent.c_str(), m_Dist);
620 fprintf(df, "%s\tFieldOfView = %f;\n", indent.c_str(), m_FieldOfView);
621 fprintf(df, "%s\tFocus = ", indent.c_str()); V3Save(df, m_Focus, ";\n");
622 fprintf(df, "%s}\n", indent.c_str());
623 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26