-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComponentCamera.cpp
More file actions
34 lines (30 loc) · 854 Bytes
/
ComponentCamera.cpp
File metadata and controls
34 lines (30 loc) · 854 Bytes
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
#include "ComponentCamera.h"
#include "GameObject.h"
ComponentCamera::ComponentCamera()
{
type = CAMERA_COMPONENT;
frustum_culling_active = true;
form_changed = false;
position_changed = false;
camera.type = FrustumType::PerspectiveFrustum;
camera.pos = float3(0.0f, 0.0f, 0.0f);
camera.front = float3(0.0f, 0.0f, 1.0f);
camera.up = float3(0.0f, 1.0f, 0.0f);
camera.nearPlaneDistance = 0.5f;
camera.farPlaneDistance = 100.0f;
camera.verticalFov = DegToRad(60.0f);
camera.horizontalFov = 2.0f * atanf(tanf(camera.verticalFov / 2.0f) * (16.0f / 9.0f));
}
ComponentCamera::~ComponentCamera()
{
}
void ComponentCamera::Update(GameObject* parent)
{
float4x4 pos = parent->GetGlobalTransform();
if (!pos.TranslatePart().Equals(camera.pos))
{
camera.pos = pos.TranslatePart();
camera.front = pos.WorldZ();
camera.up = pos.WorldY();
}
}