-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamera.cpp
More file actions
94 lines (81 loc) · 2.07 KB
/
Camera.cpp
File metadata and controls
94 lines (81 loc) · 2.07 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "stdafx.h"
#include "Scene.h"
#include "Camera.h"
//소현 TO DO : 11.24 카메라 설정
CCamera::CCamera()
{
m_vRotateAngle = Vector3D{ 0.0f, 0.0f, 0.0f };
m_mtxLocal.r1 = Vector3D{ 0.0f, 0.0f, 100.0f };
m_mtxLocal.r2 = Vector3D{ 0.0f, 0.0f, -1.0f };
m_mtxLocal.r3 = Vector3D{ 0.0f, 1.0f, 0.0f };
//m_mtxLocal.r1.z = -500;
}
GLvoid CCamera::CameraZoom(int away)
{
m_mtxLocal.r1.z += (away * MOVE_FACTOR);
//1: 확대 3:축소
return GLvoid();
}
GLvoid CCamera::CameraMove(int away)
{
int sign = 1;
switch (away) {
case 0:
case 1:
away == 0 ? sign = sign : sign = -sign;
m_mtxLocal.r1.x += (sign * MOVE_FACTOR);
m_mtxLocal.r2.x += (sign * MOVE_FACTOR);
break;
case 2:
case 3:
away == 2 ? sign = sign : sign = -sign;
m_mtxLocal.r1.y += (sign * MOVE_FACTOR);
m_mtxLocal.r2.y += (sign * MOVE_FACTOR);
break;
case 4://z축
away == 3 ? sign = sign : sign = -sign;
m_mtxLocal.r1.z -= (sign * MOVE_FACTOR);
m_mtxLocal.r2.z -= (sign * MOVE_FACTOR);
break;
case 5://z축
away == 3 ? sign = sign : sign = -sign;
m_mtxLocal.r1.z += (sign * MOVE_FACTOR);
m_mtxLocal.r2.z += (sign * MOVE_FACTOR);
break;
}
return GLvoid();
}
GLvoid CCamera::CameraRotate(int away)
{
int sign = 1;
switch (away) {
case 0:
case 1:
away == 0 ? sign = sign : sign = -sign;
m_vRotateAngle.y += (sign * ROTATE_FACTOR)/3;
break;
case 2:
case 3:
//if (m_vRotateAngle.x > -55&& m_vRotateAngle.x<20)
{
away == 2 ? sign = sign : sign = -sign;
m_vRotateAngle.x += (sign * ROTATE_FACTOR)/3;
}
break;
}
cout << "angle: " << m_vRotateAngle.x << endl;
//GLfloat normalize = sqrt(pow(m_mtxLocal.r1.x, 2) + pow(m_mtxLocal.r1.y, 2) + pow(m_mtxLocal.r1.z, 2));
//
//m_mtxLocal.r2.x = -m_mtxLocal.r1.x / normalize;
//m_mtxLocal.r2.y = -m_mtxLocal.r1.y / normalize;
//m_mtxLocal.r2.z = -m_mtxLocal.r1.z / normalize;
return GLvoid();
}
GLvoid CCamera::CameraReset()
{
m_vRotateAngle = Vector3D{ 0.0f, 0.0f, 0.0f };
m_mtxLocal.r1 = Vector3D{ 0.0f, 0.0f, -280.0f };
m_mtxLocal.r2 = Vector3D{ 0.0f, 0.0f, -1.0f };
m_mtxLocal.r3 = Vector3D{ 0.0f, 1.0f, 0.0f };
return GLvoid();
}