2
3
4
5
10#include "imgui_internal.h"
11#include "Render/FrameInfo.h"
12#include "World/Entity.h"
31 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 6.0f));
32 float columnWidth = ImGuiH::GetLineItemSize().x * 5.0f;
34 ImGuiTreeNodeFlags treeNodeFlags =
35 ImGuiTreeNodeFlags_DefaultOpen |
36 ImGuiTreeNodeFlags_AllowItemOverlap |
37 ImGuiTreeNodeFlags_Framed |
38 ImGuiTreeNodeFlags_FramePadding ;
44 ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0.196f, 0.204f, 0.2f, 1.0f));
45 ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(0.164f, 0.18f, 0.184f, 1.0f));
46 ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(0.164f, 0.18f, 0.184f, 1.0f));
47 ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.196f, 0.204f, 0.2f, 1.0f));
49 if(ImGui::TreeNodeEx(
"Geometries", treeNodeFlags))
51 for (uint64_t i = 0; i < m_Mesh->GetPacks().size(); i++)
57 ss <<
"MeshPack [" << i <<
"]";
58 if(ImGui::TreeNodeEx(ss.str().c_str(), treeNodeFlags | ImGuiTreeNodeFlags_Bullet))
60 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 2.0f));
61 const float imageIconSize = 3.0f * ImGuiH::GetLineItemSize().x + 2.0f * ImGui::GetStyle().ItemSpacing.y;
62 const float seperatorWidthS = ImGuiH::GetLineItemSize().x - 3.0f * ImGui::GetStyle().IndentSpacing;
68 ImGui::PushID(
"Geometries");
69 ImGui::Columns(2, 0,
false);
71 ImGui::SetColumnWidth(0, columnWidth);
72 ImGui::ColorButton(
"##", ImVec4(1.0f, 0.0f, 0.0f, 0.0f), 0, ImVec2(imageIconSize, imageIconSize));
77 const ImVec2 textSize = ImVec2(2.0f * ImGuiH::GetLineItemSize().x, ImGuiH::GetLineItemSize().y);
82 std::stringstream ss0;
83 ss0 <<
"/World/MeshComponent/Mesh/" << ss.str();
84 ImGui::CenteredText(
"Prim", textSize);
85 ImGui::SameLine(2.0f * ImGuiH::GetLineItemSize().x);
86 char buffer0[256] = {};
87 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
88 ImGui::InputTextWithHint(
"##_0",
ICON_TEXT_ROW(
" ", ss0.str().c_str()), buffer0,
sizeof(buffer0));
89 ImGui::PopItemWidth();
95 std::stringstream ss1;
96 ss1 <<
"/World/MeshComponent/" << ss.str();
97 char buffer1[256] = {};
98 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
99 ImGui::InputTextWithHint(
"##_2",
ICON_TEXT_ROW(
" ", ss1.str().c_str()), buffer1,
sizeof(buffer1));
100 ImGui::PopItemWidth();
106 auto meshPack = *m_Mesh->GetPacks().find_value(
static_cast<uint32_t>(i));
107 std::string type = meshPack->GetPackType();
108 ImGui::CenteredText(
"Type", textSize);
109 ImGui::SameLine(2.0f * ImGuiH::GetLineItemSize().x);
110 char buffer2[256] = {};
111 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
112 ImGui::InputTextWithHint(
"##_1",
ICON_TEXT_ROW(
" ", type.c_str()), buffer2,
sizeof(buffer2));
113 ImGui::PopItemWidth();
128 ImGuiH::DrawPropertyItem(
"Cast Shadows", columnWidth,
nullptr, [&]() {
129 static bool isCastShadow =
true;
130 ImGuiH::Checkbox(&isCastShadow);
132 ImGui::PushItemWidth(100.0f);
133 ImGui::SeparatorText(
"##");
134 ImGui::PopItemWidth();
135 ImGui::SameLine(ImGui::GetContentRegionAvail().x - seperatorWidthS);
136 if (ImGuiH::DrawResetIcon(isCastShadow !=
true))
139 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
147 ImGuiH::DrawPropertyItem(
"Visible", columnWidth,
nullptr, [&]() {
148 static bool isVisible =
true;
149 ImGuiH::Checkbox(&isVisible);
151 ImGui::SeparatorText(
"##");
152 ImGui::SameLine(ImGui::GetContentRegionAvail().x - seperatorWidthS);
153 if (ImGuiH::DrawResetIcon(isVisible !=
true))
156 FrameInfo::Get().m_World->Mark(World::FrushStableFrame);
163 ImGui::PopStyleVar();
174 ImGui::PopStyleColor(4);
180 ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0.196f, 0.204f, 0.2f, 1.0f));
181 ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(0.164f, 0.18f, 0.184f, 1.0f));
182 ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(0.164f, 0.18f, 0.184f, 1.0f));
183 ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.196f, 0.204f, 0.2f, 1.0f));
185 if(ImGui::TreeNodeEx(
"Materials", treeNodeFlags))
187 for (uint64_t i = 0; i < m_Mesh->GetPacks().size(); i++)
192 std::stringstream ss;
193 ss <<
"Materials [" << i <<
"]";
194 if(ImGui::TreeNodeEx(ss.str().c_str(), treeNodeFlags | ImGuiTreeNodeFlags_Bullet))
196 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 2.0f));
197 const float imageIconSize = 3.0f * ImGuiH::GetLineItemSize().x + 2.0f * ImGui::GetStyle().ItemSpacing.y;
198 const float seperatorWidthS = ImGuiH::GetLineItemSize().x - 3.0f * ImGui::GetStyle().IndentSpacing;
204 ImGui::PushID(
"Materials");
205 ImGui::Columns(2, 0,
false);
207 ImGui::SetColumnWidth(0, columnWidth);
208 if(ImGui::ColorButton(
"##", ImVec4(0.0f, 1.0f, 0.0f, 0.0f), 0, ImVec2(imageIconSize, imageIconSize)))
210 FrameInfo::Get().m_PickMaterial =
static_cast<uint32_t>(i);
216 const ImVec2 textSize = ImVec2(2.0f * ImGuiH::GetLineItemSize().x, ImGuiH::GetLineItemSize().y);
221 std::stringstream ss0;
222 ss0 <<
"/World/MeshComponent/Mesh/" << ss.str();
223 ImGui::CenteredText(
"Prim", textSize);
224 ImGui::SameLine(2.0f * ImGuiH::GetLineItemSize().x);
225 char buffer0[256] = {};
226 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
227 ImGui::InputTextWithHint(
"##_0",
ICON_TEXT_ROW(
" ", ss0.str().c_str()), buffer0,
sizeof(buffer0));
228 ImGui::PopItemWidth();
234 char buffer1[256] = {};
235 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
236 auto meshPack = *m_Mesh->GetPacks().find_value(
static_cast<uint32_t>(i));
237 ImGui::InputTextWithHint(
"##_2",
ICON_TEXT_ROW(
" ", meshPack->GetMaterial()->GetName().c_str()), buffer1,
sizeof(buffer1));
238 ImGui::PopItemWidth();
244 ImGui::CenteredText(
"Type", textSize);
245 ImGui::SameLine(2.0f * ImGuiH::GetLineItemSize().x);
246 char buffer2[256] = {};
247 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
248 ImGui::InputTextWithHint(
"##_1",
ICON_TEXT_ROW(
" ",
"PathTracing Material"), buffer2,
sizeof(buffer2));
249 ImGui::PopItemWidth();
258 ImGui::PopStyleVar();
267 ImGui::PopStyleColor(4);
270 ImGui::PopStyleVar();
278 auto& e = FrameInfo::Get().m_World->QueryEntitybyID((uint32_t)m_Owner);
281
282
286
287
288 mesh->GetPacks().for_each([&](
auto& k,
auto& v) {
289 v->GetMeshDesc().UpdatemodelAddress(e.GetComponent<TransformComponent>().GetModelBufferAddress());
290 v->GetMeshDesc().UpdateentityID((uint32_t)m_Owner);
#define ICON_TEXT_ROW(icon, text)
#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 OnSerialize() override
This interface defines how to serialize.
void SetMesh(std::shared_ptr< Mesh > mesh)
Set the Mesh this component handled.
virtual void OnDeSerialize() override
This interface defines how to deserialize.
MeshComponent Class. This class defines the specific behaves of MeshComponent.
MeshRenderer Class. This class is a wrapper of mashpack.