-
Notifications
You must be signed in to change notification settings - Fork 0
/
Camera.cpp
62 lines (48 loc) · 1006 Bytes
/
Camera.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "Camera.h"
Camera::Camera()
{
pos = D3DXVECTOR3(0, 8, -5);
target =D3DXVECTOR3(0, 0, 10);
upVec = D3DXVECTOR3(0, 1, 0);
angle = 60;
aspect = (float)WINDOW_WIDTH / WINDOW_HEIGHT;
nearClip = 0.1f;
farClip = 1000.0f;
}
Camera::~Camera()
{
}
HRESULT Camera::SetView()
{
D3DXMatrixLookAtLH(&view, &pos, &target, &upVec);
if (FAILED(g_pDevice->SetTransform(D3DTS_VIEW, &view)))
{
MessageBox(0, "ビュー行列の設定に失敗しました", "Camera", MB_OK);
return E_FAIL;
}
return S_OK;
}
HRESULT Camera::SetProjection()
{
D3DXMatrixPerspectiveFovLH(&proj,
D3DXToRadian(angle), aspect,
nearClip, farClip);
if (FAILED(g_pDevice->SetTransform(D3DTS_PROJECTION, &proj)))
{
MessageBox(0, "射影行列の設定に失敗しました", "Camera", MB_OK);
return E_FAIL;
}
return S_OK;
}
HRESULT Camera::Update()
{
if (FAILED(SetView()))
{
return E_FAIL;
}
if (FAILED(SetProjection()))
{
return E_FAIL;
}
return S_OK;
}