Added Asset selection in Render3D component view (Not functional yet!)

main
Nigel Barink 2023-05-07 15:25:31 +02:00
parent 042dc3a457
commit ec8045c4f4
2 changed files with 48 additions and 7 deletions

View File

@ -8,24 +8,40 @@ void Inspector::Draw()
ShowComponents();
}
}
void AddComponent(YoggieEngine::Entity selected , int i) {
switch (i) {
case 0:
selected.AddComponent<YoggieEngine::ScriptComponent>();
break;
case 1:
selected.AddComponent<YoggieEngine::CameraComponent>();
break;
case 2:
selected.AddComponent<YoggieEngine::LightComponent>();
break;
case 3:
selected.AddComponent<YoggieEngine::Render3DComponent>();
default:
break;
}
}
void Inspector::AddComponentDropDown()
{
static char* names[] = { "Script Component", "Camera Component", "Light Component" };
static char* names[] = { "Script Component", "Camera Component", "Light Component", "Render3D"};
if (ImGui::Button("Add Component"))
ImGui::OpenPopup("Component picker");
ImGui::SameLine();
if (ImGui::BeginPopup("Component picker")) {
for (int i = 0; i < IM_ARRAYSIZE(names); i++)
if (ImGui::MenuItem(names[i])) {
std::cout << "Add a " << names[i] << " to "
<< selected.GetComponent<YoggieEngine::IdentifierComponent>().name << std::endl;
}
for (int i = 0; i < IM_ARRAYSIZE(names); i++) {
if (ImGui::MenuItem(names[i]))
AddComponent(selected, i);
}
ImGui::EndPopup();
}
ImGui::NewLine();
}
@ -63,13 +79,35 @@ void Inspector::ShowComponents()
if (selected.HasComponent<YoggieEngine::Render3DComponent>()) {
auto& render3d = selected.GetComponent<YoggieEngine::Render3DComponent>();
const char* AssetNames[]{ "Asset1" , "Asset2" };
if (ImGui::CollapsingHeader("Render3D", ImGuiTreeNodeFlags_DefaultOpen)) {
if (ImGui::Button("Select Renderable Asset"))
ImGui::OpenPopup("Renderable_list_popup");
ImGui::SameLine();
ImGui::TextUnformatted(render3d.mesh.elements.empty() ? "<None>" : "ASSET_GUID_OR_ID");
if (ImGui::BeginPopup("Renderable_list_popup")) {
ImGui::Text("None");
ImGui::Separator();
for (int i = 0; i < IM_ARRAYSIZE(AssetNames); i++) {
if(ImGui::Selectable(AssetNames[i]))
{ }
}
ImGui::EndPopup();
}
ImGui::ColorEdit3("Colour", glm::value_ptr(render3d.color));
ImGui::Checkbox("Use static rendering:", &render3d.isStatic);
}
}
static bool deferred = true;
if (selected.HasComponent<YoggieEngine::LightComponent>()) {
auto& light = selected.GetComponent<YoggieEngine::LightComponent>();
if (ImGui::CollapsingHeader("Light", ImGuiTreeNodeFlags_DefaultOpen)) {

View File

@ -187,6 +187,9 @@ void SubmitVegetationDemo() {
}
void Renderer::Submit( Render3DComponent& renderComponent, TransformComponent& transform) {
if (renderComponent.mesh.elements.empty())
return;
if (renderComponent.VAO == 0 || renderComponent.IBO == 0)
{
if (renderComponent.VAO != 0)