32 static const char AddComponentComboItemsCames[7][64];
33 std::vector<std::string> SubmeshSelectComboItems {};
34 int CurrentSubmeshIndex {};
35 int GBufferPreviewColorAttachment {};
36 int CurrentAddingComponentIndex {};
37 int CameraProjectionTypeIndex {};
39 char NameTextBuffer[128] {};
47 bool IsTransformComponent {};
48 bool IsMeshComponent {};
49 bool IsCameraComponent {};
50 bool IsPointLightComponent {};
51 bool IsDirectionalLightComponent {};
52 bool IsSpotLightComponent {};
75 template <
typename Tcomponent>
76 void DrawComponentPanel() {}
79 void DrawComponentPanel<name_component>()
82 if (strcmp(NameTextBuffer, name.Name.c_str()) != 0) strcpy_s(NameTextBuffer, name.Name.c_str());
83 if (ImGui::InputText(
"Name", NameTextBuffer, 128))
84 name.
Name = std::string(NameTextBuffer);
89 void DrawComponentPanel<transform_component>()
91 ImGui::Text(
"Transformation");
92 if (DrawDeleteComponentButton<transform_component>())
return;
96 if (ImGui::DragFloat3(
"Scale", transform.Scale, 0.05f, 0.005f, 10.0f))
98 if (ImGui::DragFloat3(
"Rotation", transform.Angles, 0.25f, -180.0f, 180.0f))
99 transform.InvalidateRotation();
100 if (ImGui::DragFloat3(
"Position", transform.Position, 0.1f, -50.0f, 50.0f))
101 transform.InvalidatePosition();
106 void DrawComponentPanel<native_script_component>()
108 ImGui::Text(
"Native script");
109 if (DrawDeleteComponentButton<native_script_component>())
return;
113 ImGui::Text(
"Name \"%s\"", native_script.Name.c_str());
114 ImGui::Checkbox(
"Is active", &native_script.IsActive);
119 void DrawComponentPanel<mesh_component>()
122 if (DrawDeleteComponentButton<mesh_component>())
return;
126 if (
mesh ==
nullptr)
return;
128 ImGui::SetNextItemWidth(PanelWidth * 0.7f - 5);
129 if (ImGui::Button(
"Load model", { PanelWidth - 10, 0 }));
131 if (ImGui::BeginCombo(
"Select Submesh", SubmeshSelectComboItems[CurrentSubmeshIndex].c_str()))
133 for (
int i = 0; i < SubmeshSelectComboItems.size(); ++i)
135 const bool isSelected = (CurrentSubmeshIndex == i);
136 if (ImGui::Selectable(SubmeshSelectComboItems[i].c_str(), isSelected))
137 CurrentSubmeshIndex = i;
139 ImGui::SetItemDefaultFocus();
148 ImGui::Text(
"Submesh Data");
149 ImGui::Text(
"Vertice count: %d", submesh.VertexBuffer->GetCount());
150 ImGui::Text(
"Indices count: %d", submesh.IndexBuffer->GetCount());
153 auto material_ph = std::dynamic_pointer_cast<material_phong>(submesh.Material);
154 auto material_single = std::dynamic_pointer_cast<material_single_color>(submesh.Material);
156 ImGui::SetNextItemWidth(PanelWidth * 0.7f - 5);
157 ImGui::Text(
"Shader \"%s\"", submesh.Material->Shader->DebugName.c_str()); ImGui::SameLine(PanelWidth * 0.7f + 5);
161 ImGui::BeginDisabled();
164 if (material_ph->GetIsDiffuseMap()) {
165 ImGui::Text(
"Diffuse");
167 ImGui::Image((ImTextureID)texture->GetHandle(), { PanelWidth, PanelWidth * texture->GetHeight() / texture->GetWidth() }, { 0, 1 }, { 1, 0 });
170 ImGui::ColorEdit3(
"Diffuse",
color);
174 if (material_ph->GetIsSpecularMap()) {
175 ImGui::Text(
"Specular");
177 ImGui::Image((ImTextureID)texture->GetHandle(), { PanelWidth, PanelWidth * texture->GetHeight() / texture->GetWidth() }, { 0, 1 }, { 1, 0 });
179 color = material_ph->GetSpecular();
180 ImGui::ColorEdit3(
"Specular",
color);
183 float shininess = material_ph->GetShininess();
184 ImGui::DragFloat(
"Shininess", &shininess, 0.05, 0.001, 512);
188 if (material_ph->GetIsEmissionMap()) {
189 ImGui::Text(
"Emission map");
191 ImGui::Image((ImTextureID)texture->GetHandle(), { PanelWidth, PanelWidth * texture->GetHeight() / texture->GetWidth() }, { 0, 1 }, { 1, 0 });
196 if (material_ph->GetIsNormalMap()) {
197 ImGui::Text(
"Normal map");
199 ImGui::Image((ImTextureID)texture->GetHandle(), { PanelWidth, PanelWidth * texture->GetHeight() / texture->GetWidth() }, { 0, 1 }, { 1, 0 });
202 }
else if (material_single) {
203 if (material_single->GetIsTexture()) {
205 ImGui::Text(
"Texture");
206 ImGui::Image((ImTextureID)texture->GetHandle(), { PanelWidth, PanelWidth * texture->GetHeight() / texture->GetWidth() }, { 0, 1 }, { 1, 0 });
208 vec3 color = material_single->GetColor();
209 ImGui::ColorEdit3(
"Color",
color, 0.001);
211 ImGui::EndDisabled();
216 void DrawComponentPanel<camera_component>()
218 ImGui::Text(
"Camera");
219 if (DrawDeleteComponentButton<camera_component>())
return;
223 auto &
camera = camera_comp.Camera;
224 ImGui::Checkbox(
"Is primary", &camera_comp.IsPrimary);
226 if (ImGui::Combo(
"Projection type", &CameraProjectionTypeIndex,
"Orthographic\0Perspective"))
233 if (ImGui::DragFloat3(
"Camera Position", position, 0.05, -100, 100))
camera.
SetPosition(position);
235 if (ImGui::DragFloat3(
"Focus point", focus, 0.05, -100, 100))
camera.
SetFocus(focus);
240 ImGui::Combo(
"GBuffer", &GBufferPreviewColorAttachment,
"None\0Position\0Normals\0Color\0Diffuse\0Specular\0Shininess");
241 if (GBufferPreviewColorAttachment > 0)
242 ImGui::Image((ImTextureID)
camera.
GetGBuffer()->GetColorAttachment(GBufferPreviewColorAttachment - 1)->GetHandle(),
243 { PanelWidth, PanelWidth * camera.GetViewportHeight() / camera.GetViewportWidth() }, { 0, 1 }, { 1, 0 });
246 ImGui::Text(
"Camera effects");
261 void DrawComponentPanel<point_light_component>()
263 ImGui::Text(
"Point Light");
264 if (DrawDeleteComponentButton<point_light_component>())
return;
268 ImGui::ColorEdit3(
"Light color", light.Color);
269 ImGui::SliderFloat(
"Light strength", &light.Strength, 0.001, 10);
272 ImGui::DragFloat(
"Constant attitution", &light.Constant, 0.01, 0.001, 3);
273 ImGui::DragFloat(
"Linear attitution", &light.Linear, 0.01, 0.001, 2);
274 ImGui::DragFloat(
"Quadratic attitution", &light.Quadratic, 0.0001, 0.00000001, 2,
"%.8f");
280 void DrawComponentPanel<directional_light_component>()
282 ImGui::Text(
"Directiona Light");
283 if (DrawDeleteComponentButton<directional_light_component>())
return;
287 ImGui::ColorEdit3(
"Light color", light.Color);
288 ImGui::SliderFloat(
"Light strength", &light.Strength, 0.001, 10);
291 bool is_shadows = light.GetIsShadow();
292 if (ImGui::Checkbox(
"Is casting shadows", &is_shadows)) light.SetIsShadows(is_shadows);
295 float size = light.GetBoxSize(), depth = light.GetBoxDepth();
296 if (ImGui::DragFloat(
"Projection box size", &size, 0.01, 5, 500)) light.SetBoxSize(size);
297 if (ImGui::DragFloat(
"Projection box depth", &depth, 0.01, 5, 500)) light.SetBoxDepth(depth);
300 auto &depth_texture = light.GetShadowMap()->GetDepthAttachment();
301 int w = depth_texture->GetWidth(), h = depth_texture->GetHeight();
302 ImGui::Text(
"Shadow map");
303 if (ImGui::DragInt(
"Shadow map width", &w, 5, 100, 10000)) light.SetShadowMapWidth(w);
304 if (ImGui::DragInt(
"Shadow map height", &h, 5, 100, 10000)) light.SetShadowMapHeight(h);
305 ImGui::Image((ImTextureID)depth_texture->GetHandle(),
306 { PanelWidth, PanelWidth * h / w }, {0, 1}, {1, 0});
314 void DrawComponentPanel<spot_light_component>()
317 ImGui::Text(
"Spot Light");
318 if (DrawDeleteComponentButton<spot_light_component>())
return;
322 ImGui::ColorEdit3(
"Light color", light.Color);
323 ImGui::SliderFloat(
"Light strength", &light.Strength, 0.001, 10);
326 float inner_cutoff = light.GetInnerCutoff();
327 float outer_cutoff = light.GetOuterCutoff();
328 if (ImGui::DragFloat(
"Inner cutoff angle", &inner_cutoff)) light.SetInnerCutoff(inner_cutoff);
329 if (ImGui::DragFloat(
"Outer cutoff angle", &outer_cutoff)) light.SetOuterCutoff(outer_cutoff);
333 void DrawAddComponentComboItem(
int ComponentIndex)
335 const bool isSelected = (CurrentAddingComponentIndex == ComponentIndex);
336 if (ImGui::Selectable(AddComponentComboItemsCames[ComponentIndex], isSelected))
337 CurrentAddingComponentIndex = ComponentIndex;
339 ImGui::SetItemDefaultFocus();
342 void DrawAddComponentPanel()
344 ImGui::SetNextItemWidth(PanelWidth * 0.7f - 5);
345 if (ImGui::BeginCombo(
"##adding_component_selection", AddComponentComboItemsCames[CurrentAddingComponentIndex]))
347 if (!IsTransformComponent) DrawAddComponentComboItem(1);
348 if (!IsCameraComponent) DrawAddComponentComboItem(2);
349 if (!IsPointLightComponent) DrawAddComponentComboItem(3);
350 if (!IsDirectionalLightComponent) DrawAddComponentComboItem(4);
351 if (!IsSpotLightComponent) DrawAddComponentComboItem(5);
356 ImGui::SameLine(PanelWidth * 0.7f + 5);
357 if (ImGui::Button(
"Add component", { PanelWidth * 0.3f - 10, 0 }))
359 switch (CurrentAddingComponentIndex)
372 template <
typename Tcomponent>
373 bool DrawDeleteComponentButton()
375 static std::string button_name = std::string(
"Delete##") +
typeid(Tcomponent).name();
377 ImGui::SameLine(PanelWidth * 0.7f + 5);
378 if (ImGui::Button(button_name.c_str(), { PanelWidth * 0.3f - 5, 0}))
const vec3 & GetUpDirection() const
const vec3 & GetFocus() const
camera_projection_type GetProjectionType() const
void SetProjectionType(camera_projection_type ProjectionType)
void SetFieldOfView(float FieldOfView)
float GetFieldOfView() const
const vec3 & GetPosition() const
const shared< frame_buffer > & GetGBuffer() const
void SetPosition(const vec3 &Position)
void SetUpDirection(const vec3 &UpDirection)
void SetFocus(const vec3 &Focus)
std::vector< submesh_data > SubMeshes
void SetConfiguringObject(scene_object ConfiguringObject)
scene_object_config_window()=default
scene_object GetConfiguringObject() const
decltype(auto) AddComponent(Targs &&... Args)
Application scene objects system components include module.
Mesh material for bling-phone lighting model class deinition module.
Mesh interfaces definition module. Mesh stores vertex and index buffer and implement their binding du...
void UpdateShader(shared< shader_program > ShaderProgram)
std::shared_ptr< T > shared
Application scene object class defintion module.
Topology sphere object class implementation module.
Assets manager texture load function defintion modulule.