Skip to content

Commit

Permalink
camera component settings
Browse files Browse the repository at this point in the history
  • Loading branch information
maciadalmau committed Dec 3, 2020
1 parent f6911d3 commit b44f8c3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions TurboX-Engine/TurboX-Engine/Component_Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ C_Camera::~C_Camera()
{
}

Component::Type C_Camera::GetComponentType()
{
return Component::Type::Camera;
}

float* C_Camera::getViewMatrix()
{
static float4x4 matrix;
Expand Down
2 changes: 2 additions & 0 deletions TurboX-Engine/TurboX-Engine/Component_Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class C_Camera : public Component
C_Camera(Component::Type type, GameObject* owner);
~C_Camera();

Component::Type GetComponentType() override;

float* getViewMatrix();
float* getProjectionMatrix();

Expand Down
25 changes: 25 additions & 0 deletions TurboX-Engine/TurboX-Engine/W_Inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "MathGeoLib/MathGeoLib.h"
#include "MathGeoLib/Math/float3.h"
#include "GameObject.h"

W_Inspector::W_Inspector()
{
}
Expand Down Expand Up @@ -185,6 +186,30 @@ void W_Inspector::Draw()
ImGui::Checkbox("Default Texture", &material->defaultTex);

}

C_Camera* camera = (C_Camera*)gameObject->GetComponent(Component::Type::Camera);

if (ImGui::CollapsingHeader("Camera") && camera != nullptr)
{
ImGui::DragFloat("Near Plane", &camera->frustum.nearPlaneDistance, 0.05f, 0.f, 0.f, "%.2f");
ImGui::DragFloat("Far Plane", &camera->frustum.farPlaneDistance, 0.05f, 0.f, 0.f, "%.2f");

float aspectRatio = camera->frustum.AspectRatio();
float fov = camera->frustum.verticalFov * RADTODEG;

if (ImGui::DragFloat("FOV", &fov, 0.05f, 0.f, 0.f, "%.2f"))
{
camera->frustum.verticalFov = fov * DEGTORAD;
camera->setAspectRatio(aspectRatio);
}

if (ImGui::DragFloat("Aspect Ratio", &aspectRatio, 0.05f, 0.f, 0.f, "%.2f"))
{
camera->setAspectRatio(aspectRatio);
}

}

}

ImGui::End();
Expand Down

0 comments on commit b44f8c3

Please sign in to comment.