-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCamera.cpp
42 lines (35 loc) · 995 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
#include "Camera.h"
#include "Vector3D.h"
using namespace Bladestick::Drawing;
Camera::Camera(Vector3D ^ position, Vector3D ^ target, double near, double far, double fov, bool perspective)
{
setPosition(position);
setTarget(target);
updateDirs();
this->near = near;
this->far = far;
this->fov = fov;
this->perspective = perspective;
}
void Camera::setPosition(double x, double y, double z)
{
this->position = gcnew Vector3D(x, y, z);
}
void Camera::setPosition(Vector3D ^ position)
{
setPosition(position->x, position->y, position->z);
}
void Camera::setTarget(double x, double y, double z)
{
this->target = gcnew Vector3D(x, y, z);
}
void Camera::setTarget(Vector3D ^ target)
{
setTarget(target->x, target->y, target->z);
}
void Camera::updateDirs()
{
backDir = (position - target)->normalized();
rightDir = (gcnew Vector3D(0, 1, 0))->vectorProduct(backDir)->normalized();
upDir = backDir->vectorProduct(rightDir)->normalized();
}