mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
1000th commit! 🎉 - Added .Mesh thumbnail preview + outlines now scales with resolution scaling
This commit is contained in:
@@ -155,6 +155,38 @@ Ref<Nuake::Texture> ThumbnailManager::GenerateThumbnail(const std::string& path,
|
||||
//}
|
||||
//m_ShadedFramebuffer->Unbind();
|
||||
}
|
||||
else if (file->GetFileType() == FileType::Mesh)
|
||||
{
|
||||
Ref<Scene> scene = Scene::New();
|
||||
Ref<Environment> env = scene->GetEnvironment();
|
||||
env->CurrentSkyType = SkyType::ClearColor;
|
||||
env->ProceduralSkybox->SunDirection = { 0.88f, 0.34f, -0.14f };
|
||||
|
||||
Entity camera = scene->CreateEntity("Camera");
|
||||
TransformComponent& camTransform = camera.GetComponent<TransformComponent>();
|
||||
camTransform.SetLocalPosition({ 0.0f, 0.5f, 2.0f });
|
||||
|
||||
CameraComponent& camComponent = camera.AddComponent<CameraComponent>();
|
||||
camComponent.CameraInstance->Fov = 45.0f;
|
||||
camComponent.CameraInstance->AspectRatio = 1.0f;
|
||||
|
||||
LightComponent& previewLight = scene->CreateEntity("_directionalLight").AddComponent<LightComponent>();
|
||||
previewLight.SetCastShadows(false);
|
||||
previewLight.Type = LightType::Directional;
|
||||
previewLight.Strength = 5.0f;
|
||||
previewLight.SyncDirectionWithSky = true;
|
||||
|
||||
m_ShadedFramebuffer->SetTexture(texture);
|
||||
|
||||
ModelComponent& modelComp = scene->CreateEntity("Mesh").AddComponent<ModelComponent>();
|
||||
modelComp.ModelResource = ResourceLoader::LoadModel(file->GetRelativePath());
|
||||
|
||||
AABB aabb = modelComp.ModelResource->GetMeshes()[0]->GetAABB();
|
||||
Vector3 middlePoint = aabb.Max / 2.0f;
|
||||
|
||||
scene->Update(0.01f);
|
||||
scene->Draw(*m_ShadedFramebuffer.get());
|
||||
}
|
||||
else if (file->GetFileType() == FileType::Material)
|
||||
{
|
||||
// Gbuffer pass
|
||||
|
||||
@@ -365,6 +365,14 @@ namespace Nuake
|
||||
textureImage = image;
|
||||
}
|
||||
}
|
||||
else if (fileType == FileType::Mesh)
|
||||
{
|
||||
auto image = ThumbnailManager::Get().GetThumbnail(file->GetRelativePath());
|
||||
if (image)
|
||||
{
|
||||
textureImage = image;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::SetCursorPos(prevCursor);
|
||||
ImGui::Image(reinterpret_cast<ImTextureID>(textureImage->GetID()), ImVec2(100, 100), ImVec2(0, 1), ImVec2(1, 0));
|
||||
|
||||
@@ -58,6 +58,7 @@ namespace Nuake
|
||||
Unkown,
|
||||
Image,
|
||||
Material,
|
||||
Mesh,
|
||||
Script,
|
||||
NetScript,
|
||||
Project,
|
||||
@@ -140,11 +141,17 @@ namespace Nuake
|
||||
{
|
||||
return FileType::NetScript;
|
||||
}
|
||||
|
||||
if (ext == ".sln")
|
||||
{
|
||||
return FileType::Solution;
|
||||
}
|
||||
|
||||
if (ext == ".mesh")
|
||||
{
|
||||
return FileType::Mesh;
|
||||
}
|
||||
|
||||
return FileType::Unkown;
|
||||
}
|
||||
|
||||
|
||||
@@ -213,6 +213,7 @@ namespace Nuake
|
||||
);
|
||||
|
||||
m_Vertices = result.get();
|
||||
CalculateAABB();
|
||||
|
||||
SetupMesh();
|
||||
return true;
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace Nuake
|
||||
shader->SetUniformTex("u_EntityTexture", mGBuffer->GetTexture(GL_COLOR_ATTACHMENT3).get(), 0);
|
||||
shader->SetUniformVec4("u_OutlineColor", projectSettings.PrimaryColor);
|
||||
shader->SetUniformTex("u_Depth", mGBuffer->GetTexture(GL_DEPTH_ATTACHMENT), 1);
|
||||
shader->SetUniform1f("u_Radius", projectSettings.OutlineRadius);
|
||||
shader->SetUniform1f("u_Radius", projectSettings.OutlineRadius * projectSettings.ResolutionScale);
|
||||
Renderer::DrawQuad();
|
||||
}
|
||||
mOutlineBuffer->Unbind();
|
||||
|
||||
Reference in New Issue
Block a user