SpiecsEngine
 
Loading...
Searching...
No Matches

◆ OnRender()

void Spices::ImguiMaterialPanel::OnRender ( )
overridevirtual

This interface is called On SlateRenderer Render.

Begin render Property.

Search String.

Begin render Search Input Text.

End if not a select entity.

Render Datails.

Render All Parameter.

End render Property.

Begin render Property.

Search String.

Begin render Search Input Text.

End if not a select entity.

Render Datails.

Render All Parameter.

End render Property.

Implements Spices::ImguiSlate.

Definition at line 12 of file ImguiMaterialPanel.cpp.

13 {
15
19 Begin();
20
21 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2.0f, 4.0f));
22
26 static std::string searchString;
27 static bool isEnableSearch = false;
28
32 {
33 SPICES_PROFILE_ZONEN("ImguiMaterialPanel::Search");
34
35 ImGui::Spacing();
36 ImGui::PushItemWidth(m_PanelSize.x - ImGuiH::GetLineItemSize().x * 2.0f - ImGui::GetStyle().WindowPadding.x);
37 static char search[256] = {};
38 if (ImGui::InputTextWithHint("##", ICON_TEXT(ICON_MD_SEARCH, Search), search, 128))
39 {
40 searchString = std::string(search);
41 if (searchString.size() == 0) isEnableSearch = false;
42 else isEnableSearch = true;
43 }
44 ImGui::PopItemWidth();
45
46 ImGui::SameLine(m_PanelSize.x - ImGuiH::GetLineItemSize().x * 2.0f);
47 ImGui::Button(ICON_MD_FILTER_ALT, ImGuiH::GetLineItemSize());
48 ImGui::SameLine(m_PanelSize.x - ImGuiH::GetLineItemSize().x * 1.0f);
49 ImGui::Button(ICON_MD_REORDER, ImGuiH::GetLineItemSize());
50 ImGui::Spacing();
51 }
52
54 {
55 ImGui::PopStyleVar();
56 End();
57 return;
58 }
59
60 Entity entity(static_cast<entt::entity>(*m_FrameInfo.m_PickEntityID.end_k()), m_FrameInfo.m_World.get());
61 if(!entity.HasComponent<MeshComponent>())
62 {
63 ImGui::PopStyleVar();
64 End();
65 return;
66 }
67
68 MeshComponent meshComp = entity.GetComponent<MeshComponent>();
69 const uint32_t materialIndex = FrameInfo::Get().m_PickMaterial;
70
71 if(!meshComp.GetMesh()->GetPacks().has_key(materialIndex))
72 {
73 ImGui::PopStyleVar();
74 End();
75 return;
76 }
77
78 float columeWidth = ImGuiH::GetLineItemSize().x * 6.5f;
79 ImGuiTreeNodeFlags treeNodeFlags =
80 ImGuiTreeNodeFlags_DefaultOpen |
81 ImGuiTreeNodeFlags_AllowItemOverlap |
82 ImGuiTreeNodeFlags_Framed |
83 ImGuiTreeNodeFlags_FramePadding ;
84 //ImGuiTreeNodeFlags_Bullet ;
85
86 const std::shared_ptr<MeshPack>& meshPack = *meshComp.GetMesh()->GetPacks().find_value(materialIndex);
87 std::shared_ptr<Material> material = meshPack->GetMaterial();
88
93 {
94 SPICES_PROFILE_ZONEN("ImguiMaterialPanel::End");
95
96 ImGui::PopStyleVar();
97 End();
98
99 return;
100 }
101
105 {
106 SPICES_PROFILE_ZONEN("ImguiMaterialPanel::Datails");
107
108 {
109 ImGui::PushID("ImguiMaterialPanel::Add");
110
111 ImGui::Columns(2, 0, false);
112 ImGui::SetColumnWidth(0, ImGuiH::GetLineItemSize().x * 4.0f);
113 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.16f, 0.16f, 0.16f, 1.0f));
114 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.619f, 0.619f, 0.619f, 1.0f));
115 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.408f, 0.451f, 0.18f, 1.0f));
116 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.341f, 0.486f, 0.353f, 1.0f));
117 ImGui::Button(ICON_TEXT(ICON_MD_ADD, Add));
118 ImGui::PopStyleColor(4);
119 ImGui::NextColumn();
120
121 ImGui::PushItemWidth(m_PanelSize.x - ImGuiH::GetLineItemSize().x * 4.0f);
122 char text[128] = "";
123 if (ImGui::InputTextWithHint("##", ICON_TEXT_ROW(" ", material->GetName().c_str()), text, 128)) {}
124 ImGui::PopItemWidth();
125
126 ImGui::Columns(1);
127 ImGui::PopID();
128 }
129
130 {
131 ImGui::PushID("ImguiMaterialPanel::Prim Path");
132 ImGui::Columns(2, 0, false);
133 ImGui::SetColumnWidth(0, ImGuiH::GetLineItemSize().x * 4.0f);
134 ImGui::Text("Prim Path");
135 ImGui::NextColumn();
136
137 std::stringstream ss;
138 ss << "/" << material->GetName();
139 ImGui::PushItemWidth(m_PanelSize.x - ImGuiH::GetLineItemSize().x * 4.0f);
140 char textpath[128] = "";
141 if (ImGui::InputTextWithHint("##", ICON_TEXT_ROW(" ", ss.str().c_str()), textpath, 128)) {}
142 ImGui::PopItemWidth();
143
144 ImGui::Columns(1);
145 ImGui::PopID();
146 }
147
148 {
149 ImGui::PushID("ImguiMaterialPanel::Instanceable");
150 ImGui::Columns(2, 0, false);
151 ImGui::SetColumnWidth(0, ImGuiH::GetLineItemSize().x * 4.0f);
152 ImGui::Text("Instanceable");
153 ImGui::NextColumn();
154
155 static bool isChecked;
156 ImGuiH::Checkbox(&isChecked);
157 ImGui::Columns(1);
158 ImGui::PopID();
159 }
160 }
161
162
166 {
167 SPICES_PROFILE_ZONEN("ImguiMaterialPanel::Parameter");
168
169 {
170 SPICES_PROFILE_ZONEN("ImguiMaterialPanel::ShaderParameter");
171
172 ImGuiH::DrawTreeTitle("Shader", nullptr, [&](){
173 for(auto& pair : material->GetShaderPath())
174 {
175 ImGuiH::DrawPropertyItem(pair.first, columeWidth, nullptr, [&](){
176
177 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
178 char buffer[128] = {};
179 ImGui::InputTextWithHint("##", ICON_TEXT_ROW(" ", pair.second[0].c_str()), buffer, sizeof(buffer));
180 ImGui::PopItemWidth();
181
182 ImGui::SameLine();
184 });
185 }
186 });
187 }
188
189 {
190 SPICES_PROFILE_ZONEN("ImguiMaterialPanel::TextureParameter");
191
192 ImGuiH::DrawTreeTitle("Texture", nullptr, [&](){
193 material->GetTextureParams().for_each([&](const auto& k, const auto& v) {
194
195 ImGuiH::DrawPropertyItem(k, columeWidth, nullptr, [&](){
196
197 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
198 char buffer[128] = {};
199 ImGui::InputTextWithHint("##", ICON_TEXT_ROW(" ", v.texturePath.c_str()), buffer, sizeof(buffer));
200 ImGui::PopItemWidth();
201
202 ImGui::SameLine();
204 });
205 return false;
206 });
207 });
208 }
209
210 {
211 SPICES_PROFILE_ZONEN("ImguiMaterialPanel::ConstantParameter");
212
213 ImGuiH::DrawTreeTitle("Parameter", nullptr, [&](){
214 material->GetConstantParams().for_each([&](const std::string& k, ConstantParams& v){
215 ImGuiH::DrawPropertyItem(k, columeWidth, nullptr, [&](){
216 if (v.value.paramType == "float")
217 {
218 if (ImGuiH::DrawMaterialConstParams<float>(material, ImGuiDataType_Float, 1, "%.3f", v))
219 {
220 FrameInfo::Get().m_World->Mark(World::NeedUpdateTLAS | World::FrushStableFrame);
221 }
222 }
223 else if (v.value.paramType == "float2")
224 {
225 if (ImGuiH::DrawMaterialConstParams<glm::vec2>(material, ImGuiDataType_Float, 2, "%.3f", v))
226 {
227 FrameInfo::Get().m_World->Mark(World::NeedUpdateTLAS | World::FrushStableFrame);
228 }
229 }
230 else if (v.value.paramType == "float3")
231 {
232 if (ImGuiH::DrawMaterialConstParams<glm::vec3>(material, ImGuiDataType_Float, 3, "%.3f", v))
233 {
234 FrameInfo::Get().m_World->Mark(World::NeedUpdateTLAS | World::FrushStableFrame);
235 }
236 }
237 else if (v.value.paramType == "float4")
238 {
239 if (ImGuiH::DrawMaterialConstParams<glm::vec4>(material, ImGuiDataType_Float, 4, "%.3f", v))
240 {
241 FrameInfo::Get().m_World->Mark(World::NeedUpdateTLAS | World::FrushStableFrame);
242 }
243 }
244 else if (v.value.paramType == "int")
245 {
246 if (ImGuiH::DrawMaterialConstParams<int>(material, ImGuiDataType_S32, 1, "%d", v))
247 {
248 FrameInfo::Get().m_World->Mark(World::NeedUpdateTLAS | World::FrushStableFrame);
249 }
250 }
251 else if (v.value.paramType == "bool")
252 {
253
254 }
255 });
256 return false;
257 });
258 });
259 }
260
261 {
262 SPICES_PROFILE_ZONEN("ImguiMaterialPanel::Property");
263
264
265 }
266 }
267
271 ImGui::PopStyleVar();
272 End();
273 }
#define ICON_TEXT(icon, text)
Definition ImguiHelper.h:24
#define ICON_TEXT_ROW(icon, text)
Definition ImguiHelper.h:25
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
uint32_t m_PickMaterial
Identify of selected material.
Definition FrameInfo.h:89
static FrameInfo & Get()
Get FrameInfo.
Definition FrameInfo.cpp:14
std::shared_ptr< World > m_World
The shared pointer of specific world.
Definition FrameInfo.h:94
scl::linked_unordered_map< int, std::string > m_PickEntityID
Definition FrameInfo.h:82
static ImVec2 GetLineItemSize()
Get Line Width's Square Size.
static bool DrawResetIcon(const bool &isMove)
Draw Reset Icon.
static void DrawPropertyItem(const std::string &itemName, float columeWidth, std::function< void()> nameFunc, std::function< void()> valFunc)
Draw a single property.
static void Checkbox(bool *isChecked)
ImGuiHelper Style Checkbox.
static void DrawTreeTitle(const std::string &treeName, std::function< void()> optionFunc, std::function< void()> treeFunc)
Draw a stylized tree title bar.
void Begin(float alpha=1.0f, ImGuiWindowFlags flags=0)
Begin a common slate.
FrameInfo & m_FrameInfo
The FrameData reference.
Definition ImguiUtils.h:166
void End()
End a slate.
ImVec2 m_PanelSize
This slate's size.
Definition ImguiUtils.h:151
size_t size()
The container's element size.

References Spices::ImGuiH::Checkbox(), Spices::ImGuiH::DrawTreeTitle(), Spices::ImguiSlate::End(), Spices::FrameInfo::Get(), Spices::ImguiSlate::m_FrameInfo, and Spices::FrameInfo::m_PickMaterial.