SpiecsEngine
 
Loading...
Searching...
No Matches
CameraComponent.cpp
Go to the documentation of this file.
1/**
2* @file CameraComponent.cpp.
3* @brief The CameraComponent Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
9#include "Render/FrameInfo.h"
10#include "World/World/World.h"
11
12namespace Spices {
13
15 : m_IsActive(isActive)
16 {}
17
19 {
20
21 }
22
24 {
25
26 }
27
29 {
31
32 ImGui::Spacing();
33 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2{ 0, 3.0f });
34 float columeWidth = ImGuiH::GetLineItemSize().x * 6.5f;
35
36 {
37 SPICES_PROFILE_ZONEN("CameraComponent FOV");
38
39 ImGuiH::DrawPropertyItem("FOV", columeWidth, nullptr, [&](){
40 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
41 if(ImGui::DragFloat("##", &m_Camera->GetPerspectiveParam().fov, 0.1f, 1.0f, 179.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp))
42 {
43 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
44 }
45 ImGui::PopItemWidth();
46 ImGui::SameLine();
47 if (ImGuiH::DrawResetIcon(m_Camera->GetPerspectiveParam().fov != 45.0f))
48 {
49 m_Camera->GetPerspectiveParam().fov = 45.0f;
50 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
51 }
52 });
53 }
54
55 {
56 SPICES_PROFILE_ZONEN("CameraComponent Near Plane");
57
58 ImGuiH::DrawPropertyItem("Near Plane", columeWidth, nullptr, [&]() {
59 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
60 if (ImGui::DragFloat("##", &m_Camera->GetPerspectiveParam().nearPlane, 0.1f, 0.01f, 1000.0f, "%.3f", ImGuiSliderFlags_AlwaysClamp))
61 {
62 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
63 }
64 ImGui::PopItemWidth();
65 ImGui::SameLine();
66 if (ImGuiH::DrawResetIcon(m_Camera->GetPerspectiveParam().nearPlane != 0.01f))
67 {
68 m_Camera->GetPerspectiveParam().nearPlane = 0.01f;
69 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
70 }
71 });
72 }
73
74 {
75 SPICES_PROFILE_ZONEN("CameraComponent AspectRatio");
76
77 ImGuiH::DrawPropertyItem("AspectRatio", columeWidth, nullptr, [&]() {
78 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
79 float aspectRatio = m_Camera->GetPerspectiveParam().aspectRatio;
80 ImGui::DragFloat("##", &aspectRatio, 10.0f, 0.0f, 100.0f, "%.3f", ImGuiSliderFlags_AlwaysClamp);
81 ImGui::PopItemWidth();
82 ImGui::SameLine();
83 ImGuiH::DrawResetIcon(m_Camera->GetPerspectiveParam().aspectRatio != 1.777f);
84 });
85 }
86
87 ImGui::PopStyleVar();
88 ImGui::Spacing();
89 }
90}
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
virtual void DrawThis() override
This interface defines how to draw this component to property panel.
virtual void OnDeSerialize() override
This interface defines how to deserialize.
bool m_IsActive
True if the camera is primary.
CameraComponent(bool isActive=false)
Constructor Function. Init class variable. Usually call it.
virtual void OnSerialize() override
This interface defines how to serialize.
CameraComponent Class. This class defines the specific behaves of CameraComponent.