SpiecsEngine
 
Loading...
Searching...
No Matches
PointLightComponent.cpp
Go to the documentation of this file.
1/**
2* @file PointLightComponent.cpp.
3* @brief The PointLightComponent Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
9#include "Render/FrameInfo.h"
10#include "World/World/World.h"
11
12#include <imgui_internal.h>
13#include <glm/gtc/type_ptr.hpp>
14
15namespace Spices {
16
18 {
19 }
20
22 {
23 }
24
26 {
28
29 ImGui::Spacing();
30 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2{ 0, 3.0f });
31 float columeWidth = ImGuiH::GetLineItemSize().x * 6.5f;
32
33 {
34 SPICES_PROFILE_ZONEN("PointLightComponent Color");
35
36 ImGuiH::DrawPropertyItem("Color", columeWidth, nullptr, [&]() {
37
38 float itemWidth = (ImGui::GetContentRegionAvail().x - 8.0f * ImGuiH::GetLineItemSize().x) / 3.0f;
39
40 {
41 SPICES_PROFILE_ZONEN("PointLightComponent Color R");
42 ImGui::PushID("PointLightComponent Color R");
43
44 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.8f, 0.1f, 0.15f, 1.0f });
45 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.9f, 0.2f, 0.2f, 1.0f });
46 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.8f, 0.1f, 0.15f, 1.0f });
47 if (ImGui::Button("R", ImGuiH::GetLineItemSize())) m_PointLight.color.x = 1.0f;
48 ImGui::PopStyleColor(3);
49 ImGui::SameLine();
50 ImGui::PushItemWidth(itemWidth);
51 if(ImGui::SliderFloat("##R", &m_PointLight.color.x, 0.0f, 1.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp))
52 {
53 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
54 }
55 ImGui::PopItemWidth();
56 ImGui::SameLine();
57 if (ImGuiH::DrawResetIcon(m_PointLight.color.x != 1.0f))
58 {
59 m_PointLight.color.x = 1.0f;
60 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
61 }
62 ImGui::SameLine();
63 ImGui::PopID();
64 }
65
66 {
67 SPICES_PROFILE_ZONEN("PointLightComponent Color G");
68 ImGui::PushID("PointLightComponent Color G");
69
70 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.2f, 0.7f, 0.2f, 1.0f });
71 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.3f, 0.8f, 0.3f, 1.0f });
72 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.2f, 0.7f, 0.2f, 1.0f });
73 if (ImGui::Button("G", ImGuiH::GetLineItemSize())) m_PointLight.color.y = 1.0f;
74 ImGui::PopStyleColor(3);
75 ImGui::SameLine();
76 ImGui::PushItemWidth(itemWidth);
77 if(ImGui::SliderFloat("##G", &m_PointLight.color.y, 0.0f, 1.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp))
78 {
79 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
80 }
81 ImGui::PopItemWidth();
82 ImGui::SameLine();
83 if (ImGuiH::DrawResetIcon(m_PointLight.color.y != 1.0f))
84 {
85 m_PointLight.color.y = 1.0f;
86 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
87 }
88 ImGui::SameLine();
89 ImGui::PopID();
90 }
91
92 {
93 SPICES_PROFILE_ZONEN("PointLightComponent Color B");
94 ImGui::PushID("PointLightComponent Color B");
95
96 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.1f, 0.25f, 0.8f, 1.0f });
97 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.2f, 0.35f, 0.9f, 1.0f });
98 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.1f, 0.25f, 0.8f, 1.0f });
99 if (ImGui::Button("B", ImGuiH::GetLineItemSize())) m_PointLight.color.z = 1.0f;
100 ImGui::PopStyleColor(3);
101 ImGui::SameLine();
102 ImGui::PushItemWidth(itemWidth);
103 if(ImGui::SliderFloat("##B", &m_PointLight.color.z, 0.0f, 1.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp))
104 {
105 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
106 }
107 ImGui::PopItemWidth();
108 ImGui::SameLine();
109 if (ImGuiH::DrawResetIcon(m_PointLight.color.z != 1.0f))
110 {
111 m_PointLight.color.z = 1.0f;
112 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
113 }
114 ImGui::SameLine();
115 ImGui::PopID();
116 }
117
118 {
119 SPICES_PROFILE_ZONEN("PointLightComponent Color Picker");
120 ImGui::PushID("PointLightComponent Color Picker");
121
122 ImGui::PushStyleColor(ImGuiCol_FrameBg, ImGui::GetStyle().Colors[ImGuiCol_WindowBg]);
123 if(ImGui::ColorEdit3("##", glm::value_ptr(m_PointLight.color), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_PickerHueBar))
124 {
125 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
126 }
127 ImGui::SameLine();
128 if (ImGuiH::DrawResetIcon(m_PointLight.color != glm::vec3(1.0f, 1.0f, 1.0f)))
129 {
130 m_PointLight.color = glm::vec3(1.0f, 1.0f, 1.0f);
131 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
132 }
133 ImGui::PopStyleColor();
134 ImGui::PopID();
135 }
136 });
137 }
138
139 {
140 SPICES_PROFILE_ZONEN("PointLightComponent Intensity");
141
142 ImGuiH::DrawPropertyItem("Intensity", columeWidth, nullptr, [&]() {
143 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
144 if(ImGui::DragFloat("##", &m_PointLight.intensity, 0.1f, 0.0f, 10000.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp))
145 {
146 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
147 }
148 ImGui::PopItemWidth();
149 ImGui::SameLine();
150 if (ImGuiH::DrawResetIcon(m_PointLight.intensity != 1.0f))
151 {
152 m_PointLight.intensity = 1.0f;
153 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
154 }
155 });
156 }
157
158 {
159 SPICES_PROFILE_ZONEN("PointLightComponent Constantf");
160
161 ImGuiH::DrawPropertyItem("Constantf", columeWidth, nullptr, [&]() {
162 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
163 if(ImGui::DragFloat("##", &m_PointLight.constantf, 0.1f, 0.0f, 10000.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp))
164 {
165 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
166 }
167 ImGui::PopItemWidth();
168 ImGui::SameLine();
169 if (ImGuiH::DrawResetIcon(m_PointLight.constantf != 1.0f))
170 {
171 m_PointLight.constantf = 1.0f;
172 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
173 }
174 });
175 }
176
177 {
178 SPICES_PROFILE_ZONEN("PointLightComponent Linear");
179
180 ImGuiH::DrawPropertyItem("Linear", columeWidth, nullptr, [&]() {
181 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
182 if(ImGui::DragFloat("##", &m_PointLight.linear, 0.1f, 0.0f, 10000.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp))
183 {
184 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
185 }
186 ImGui::PopItemWidth();
187 ImGui::SameLine();
188 if (ImGuiH::DrawResetIcon(m_PointLight.linear != 0.35f))
189 {
190 m_PointLight.linear = 0.35f;
191 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
192 }
193 });
194 }
195
196 {
197 SPICES_PROFILE_ZONEN("PointLightComponent Quadratic");
198
199 ImGuiH::DrawPropertyItem("Quadratic", columeWidth, nullptr, [&]() {
200 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
201 if(ImGui::DragFloat("##", &m_PointLight.quadratic, 0.1f, 0.0f, 10000.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp))
202 {
203 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
204 }
205 ImGui::PopItemWidth();
206 ImGui::SameLine();
207 if (ImGuiH::DrawResetIcon(m_PointLight.quadratic != 0.44f))
208 {
209 m_PointLight.quadratic = 0.44f;
210 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
211 }
212 });
213 }
214
215 ImGui::PopStyleVar();
216 ImGui::Spacing();
217 }
218}
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
virtual void OnDeSerialize() override
This interface defines how to deserialize.
virtual void DrawThis() override
This interface defines how to draw this component to property panel.
virtual void OnSerialize() override
This interface defines how to serialize.
PointLightComponent Class. This class defines the specific behaves of PointLightComponent.