diff --git a/Engine/Auto/Scripts/editor.lua b/Engine/Auto/Scripts/editor.lua index 2b4b8486..74568e8e 100644 --- a/Engine/Auto/Scripts/editor.lua +++ b/Engine/Auto/Scripts/editor.lua @@ -112,18 +112,15 @@ project("Editor") staticruntime "on" filter { "configurations:Debug" } runtime "Debug" -- /MTd - libdirs { - BinariesPath, - path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Debug"), - } filter { "configurations:Release" } runtime "Release" -- /MT - libdirs { - BinariesPath, - path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Release"), - } filter {} + libdirs { + BinariesPath, + path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/%{cfg.buildcfg}"), + } + links { "Engine", "AssetPipelineCore", @@ -141,6 +138,18 @@ project("Editor") } end + if ENABLE_FBX_WORKFLOW then + links { + "FbxConsumer", + "FbxProducer", + } + + defines { + "ENABLE_FBX_CONSUMER", + "ENABLE_FBX_PRODUCER", + } + end + -- Disable these options can reduce the size of compiled binaries. justmycode("Off") editAndContinue("Off") diff --git a/Engine/Auto/Scripts/premake5.lua b/Engine/Auto/Scripts/premake5.lua index d74e1c53..269ca89f 100644 --- a/Engine/Auto/Scripts/premake5.lua +++ b/Engine/Auto/Scripts/premake5.lua @@ -25,24 +25,6 @@ function IsIOSPlatform() return ChoosePlatform == "IOS" end -USE_CLANG_TOOLSET = false -if os.getenv("USE_CLANG_TOOLSET") then - USE_CLANG_TOOLSET = true -end - -DDGI_SDK_PATH = os.getenv("DDGI_SDK_PATH") or "" -if not os.isdir(DDGI_SDK_PATH) then - DDGI_SDK_PATH = "" -end - -ENABLE_FREETYPE = not USE_CLANG_TOOLSET and not IsLinuxPlatform() and not IsAndroidPlatform() -ENABLE_SPDLOG = not USE_CLANG_TOOLSET and not IsLinuxPlatform() and not IsAndroidPlatform() -ENABLE_SUBPROCESS = not USE_CLANG_TOOLSET and not IsLinuxPlatform() and not IsAndroidPlatform() -ENABLE_TRACY = not USE_CLANG_TOOLSET and not IsLinuxPlatform() and not IsAndroidPlatform() -ENABLE_DDGI = DDGI_SDK_PATH ~= "" - -ShouldTreatWaringAsError = not (ENABLE_DDGI or USE_CLANG_TOOLSET) - PlatformSettings = {} PlatformSettings["Windows"] = { DisplayName = "Win64", @@ -77,6 +59,33 @@ function GetPlatformMacroName() return PlatformSettings[ChoosePlatform].MacroName end +dofile("path.lua") + +-------------------------------------------------------------------------------------------------------- +-- Build Options +-------------------------------------------------------------------------------------------------------- +USE_CLANG_TOOLSET = false +if os.getenv("USE_CLANG_TOOLSET") then + USE_CLANG_TOOLSET = true +end + +DDGI_SDK_PATH = os.getenv("DDGI_SDK_PATH") or "" +if not os.isdir(DDGI_SDK_PATH) then + DDGI_SDK_PATH = "" +end + +FBX_SDK_DEBUG_PATH = path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Debug/libfbxsdk.dll") +FBX_SDK_RELEASE_PATH = path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Release/libfbxsdk.dll") + +ENABLE_DDGI = DDGI_SDK_PATH ~= "" +ENABLE_FBX_WORKFLOW = os.isfile(FBX_SDK_DEBUG_PATH) and os.isfile(FBX_SDK_RELEASE_PATH) +ENABLE_FREETYPE = not USE_CLANG_TOOLSET and not IsLinuxPlatform() and not IsAndroidPlatform() +ENABLE_SPDLOG = not USE_CLANG_TOOLSET and not IsLinuxPlatform() and not IsAndroidPlatform() +ENABLE_SUBPROCESS = not USE_CLANG_TOOLSET and not IsLinuxPlatform() and not IsAndroidPlatform() +ENABLE_TRACY = not USE_CLANG_TOOLSET and not IsLinuxPlatform() and not IsAndroidPlatform() + +ShouldTreatWaringAsError = not (ENABLE_DDGI or USE_CLANG_TOOLSET) + IDEConfigs = {} IDEConfigs.BuildIDEName = os.getenv("BUILD_IDE_NAME") @@ -92,8 +101,7 @@ function SetLanguageAndToolset(projectName) targetdir(BinariesPath) end --- Parse folder path -dofile("path.lua") +-- Information about make print("================================================================") print("EngineBuildLibKind = "..EngineBuildLibKind) print("CurrentWorkingDirectory = "..CurrentWorkingDirectory) @@ -105,7 +113,12 @@ print("EngineSourcePath = "..EngineSourcePath) print("GameSourcePath = "..GameSourcePath) print("RuntimeSourcePath = "..RuntimeSourcePath) print("IDEConfigs.BuildIDEName = "..IDEConfigs.BuildIDEName) -print("DDGI_SDK_PATH = "..DDGI_SDK_PATH) +print("================================================================") +print("ENABLE_FBX_WORKFLOW = "..tostring(ENABLE_FBX_WORKFLOW)) +print("ENABLE_FREETYPE = "..tostring(ENABLE_FREETYPE)) +print("ENABLE_SPDLOG = "..tostring(ENABLE_SPDLOG)) +print("ENABLE_SUBPROCESS = "..tostring(ENABLE_SUBPROCESS)) +print("ENABLE_TRACY = "..tostring(ENABLE_TRACY)) print("================================================================") -- workspace means solution in Visual Studio @@ -156,53 +169,27 @@ function CopyDllAutomatically() end -- copy dll into binary folder automatically. - filter { "configurations:Debug" } - if IsAndroidPlatform() then - postbuildcommands { - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "sdl/build/Debug/SDL2d.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/ARM64/Debug/AssetPipelineCore.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/ARM64/Debug/CDProducer.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/ARM64/Debug/CDConsumer.*").."\" \""..BinariesPath.."\"", - } - else - postbuildcommands { - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "sdl/build/Debug/SDL2d.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Debug/AssetPipelineCore.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Debug/CDProducer.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Debug/CDConsumer.*").."\" \""..BinariesPath.."\"", - } - end - - if not USE_CLANG_TOOLSET then - postbuildcommands { - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Debug/GenericProducer.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Debug/assimp-*-mtd.*").."\" \""..BinariesPath.."\"", - } - end - filter { "configurations:Release" } - if IsAndroidPlatform() then - postbuildcommands { - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "sdl/build/Release/SDL2.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/ARM64/Release/AssetPipelineCore.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/ARM64/Release/CDProducer.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/ARM64/Release/CDConsumer.*").."\" \""..BinariesPath.."\"", - } - else - postbuildcommands { - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "sdl/build/Release/SDL2.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Release/AssetPipelineCore.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Release/CDProducer.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Release/CDConsumer.*").."\" \""..BinariesPath.."\"", - } - end - - if not USE_CLANG_TOOLSET then - postbuildcommands { - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Release/GenericProducer.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Release/assimp-*-mt.*").."\" \""..BinariesPath.."\"", - } - end - filter {} + postbuildcommands { + "{COPYFILE} \""..path.join(ThirdPartySourcePath, "sdl/build/%{cfg.buildcfg}/SDL2*.*").."\" \""..BinariesPath.."\"", + "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/%{cfg.buildcfg}/AssetPipelineCore.*").."\" \""..BinariesPath.."\"", + "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/%{cfg.buildcfg}/CDProducer.*").."\" \""..BinariesPath.."\"", + "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/%{cfg.buildcfg}/CDConsumer.*").."\" \""..BinariesPath.."\"", + } + + if not USE_CLANG_TOOLSET then + postbuildcommands { + "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/%{cfg.buildcfg}/GenericProducer.*").."\" \""..BinariesPath.."\"", + "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/%{cfg.buildcfg}/assimp-*-mt*.*").."\" \""..BinariesPath.."\"", + } + end + + if ENABLE_FBX_WORKFLOW then + postbuildcommands { + "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/%{cfg.buildcfg}/FbxConsumer.*").."\" \""..BinariesPath.."\"", + "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/%{cfg.buildcfg}/FbxProducer.*").."\" \""..BinariesPath.."\"", + "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/%{cfg.buildcfg}/libfbxsdk.*").."\" \""..BinariesPath.."\"", + } + end if ENABLE_DDGI then postbuildcommands { diff --git a/Engine/Source/Editor/ECWorld/ECWorldConsumer.cpp b/Engine/Source/Editor/ECWorld/ECWorldConsumer.cpp index c4a94ae4..91d313c0 100644 --- a/Engine/Source/Editor/ECWorld/ECWorldConsumer.cpp +++ b/Engine/Source/Editor/ECWorld/ECWorldConsumer.cpp @@ -205,15 +205,20 @@ void ECWorldConsumer::AddAnimation(engine::Entity entity, const cd::Animation& a void ECWorldConsumer::AddMaterial(engine::Entity entity, const cd::Material* pMaterial, engine::MaterialType* pMaterialType, const cd::SceneDatabase* pSceneDatabase) { - std::set compiledTextureSlot; - std::vector> outputTypeToData; - engine::MaterialComponent& materialComponent = m_pSceneWorld->GetWorld()->CreateComponent(entity); materialComponent.Init(); materialComponent.SetMaterialType(pMaterialType); materialComponent.SetMaterialData(pMaterial); materialComponent.ActivateShaderFeature(engine::GetSkyTypeShaderFeature(m_pSceneWorld->GetSkyComponent(m_pSceneWorld->GetSkyEntity())->GetSkyType())); + if (!pMaterial) + { + return; + } + + std::set compiledTextureSlot; + std::vector> outputTypeToData; + // Expected textures are ready to build. Add more optional texture data. for (cd::MaterialTextureType optionalTextureType : pMaterialType->GetOptionalTextureTypes()) { diff --git a/Engine/Source/Editor/UILayers/AssetBrowser.cpp b/Engine/Source/Editor/UILayers/AssetBrowser.cpp index 1ace5dd1..023cd7ed 100644 --- a/Engine/Source/Editor/UILayers/AssetBrowser.cpp +++ b/Engine/Source/Editor/UILayers/AssetBrowser.cpp @@ -1,6 +1,9 @@ #include "AssetBrowser.h" #include "Consumers/CDConsumer/CDConsumer.h" +#ifdef ENABLE_FBX_CONSUMER +#include "Consumers/FbxConsumer/FbxConsumer.h" +#endif #include "ECWorld/ECWorldConsumer.h" #include "ECWorld/MaterialComponent.h" #include "ECWorld/SceneWorld.h" @@ -14,15 +17,17 @@ #include "Material/MaterialType.h" #include "Producers/CDProducer/CDProducer.h" #include "Producers/EffekseerProducer/EffekseerProducer.h" +#ifdef ENABLE_FBX_PRODUCER +#include "Producers/FbxProducer/FbxProducer.h" +#endif +#ifdef ENABLE_GENERIC_PRODUCER +#include "Producers/GenericProducer/GenericProducer.h" +#endif #include "Rendering/WorldRenderer.h" #include "Rendering/RenderContext.h" #include "Resources/ResourceBuilder.h" #include "Resources/ResourceLoader.h" -#ifdef ENABLE_GENERIC_PRODUCER -#include "Producers/GenericProducer/GenericProducer.h" -#endif - #include #include @@ -942,15 +947,28 @@ void AssetBrowser::ImportModelFile(const char* pFilePath) // Step 1 : Convert model file to cd::SceneDatabase std::filesystem::path inputFilePath(pFilePath); std::filesystem::path inputFileExtension = inputFilePath.extension(); + bool importedModel = false; + auto newSceneDatabase = std::make_unique(); if (0 == inputFileExtension.compare(".cdbin")) { cdtools::CDProducer cdProducer(pFilePath); - cd::SceneDatabase newSceneDatabase; - cdtools::Processor processor(&cdProducer, nullptr, &newSceneDatabase); + cdtools::Processor processor(&cdProducer, nullptr, newSceneDatabase.get()); processor.Run(); - pSceneDatabase->Merge(cd::MoveTemp(newSceneDatabase)); + importedModel = true; } - else + else if (0 == inputFileExtension.compare(".fbx")) + { +#ifdef ENABLE_FBX_PRODUCER + cdtools::FbxProducer fbxProducer(pFilePath); + fbxProducer.EnableOption(cdtools::FbxProducerOptions::Triangulate); + cdtools::Processor processor(&fbxProducer, nullptr, newSceneDatabase.get()); + processor.Run(); + importedModel = true; +#endif + } + + // Try generic producer only if specialized import workflow is not ready. + if (!importedModel) { #ifdef ENABLE_GENERIC_PRODUCER cdtools::GenericProducer genericProducer(pFilePath); @@ -963,16 +981,19 @@ void AssetBrowser::ImportModelFile(const char* pFilePath) genericProducer.EnableOption(cdtools::GenericProducerOptions::FlattenTransformHierarchy); } - cd::SceneDatabase newSceneDatabase; - cdtools::Processor processor(&genericProducer, nullptr, &newSceneDatabase); + cdtools::Processor processor(&genericProducer, nullptr, newSceneDatabase.get()); processor.EnableOption(cdtools::ProcessorOptions::Dump); processor.Run(); - pSceneDatabase->Merge(cd::MoveTemp(newSceneDatabase)); #else assert("Unable to import this file format."); + return; #endif } + // Move contents in temp scene database to SceneWorld. + pSceneDatabase->Merge(cd::MoveTemp(*newSceneDatabase)); + newSceneDatabase.reset(); + // Step 2 : Process generated cd::SceneDatabase ProcessSceneDatabase(pSceneDatabase, m_importOptions.ImportMesh, m_importOptions.ImportMaterial, m_importOptions.ImportTexture, m_importOptions.ImportCamera, m_importOptions.ImportLight); diff --git a/Engine/Source/Editor/UILayers/EntityList.cpp b/Engine/Source/Editor/UILayers/EntityList.cpp index 560e599b..b72e301f 100644 --- a/Engine/Source/Editor/UILayers/EntityList.cpp +++ b/Engine/Source/Editor/UILayers/EntityList.cpp @@ -99,9 +99,9 @@ void EntityList::AddEntity(engine::SceneWorld* pSceneWorld) if (ImGui::MenuItem("Add Cube Mesh")) { engine::Entity entity = AddNamedEntity("CubeMesh"); - // TODO : manage temp asset. - static std::optional optMesh = cd::MeshGenerator::Generate(cd::Box(cd::Point(-10.0f), cd::Point(10.0f)), pPBRMaterialType->GetRequiredVertexFormat()); + std::optional optMesh = cd::MeshGenerator::Generate(cd::Box(cd::Point(-10.0f), cd::Point(10.0f)), pPBRMaterialType->GetRequiredVertexFormat()); assert(optMesh.has_value()); + optMesh->SetName(pSceneWorld->GetNameComponent(entity)->GetName()); CreateShapeComponents(entity, cd::MoveTemp(optMesh.value()), pPBRMaterialType); } @@ -110,15 +110,16 @@ void EntityList::AddEntity(engine::SceneWorld* pSceneWorld) engine::Entity entity = AddNamedEntity("Celluloid Cube"); std::optional optMesh = cd::MeshGenerator::Generate(cd::Box(cd::Point(-10.0f), cd::Point(10.0f)), pCelluloidMaterialType->GetRequiredVertexFormat()); assert(optMesh.has_value()); + optMesh->SetName(pSceneWorld->GetNameComponent(entity)->GetName()); CreateShapeComponents(entity, cd::MoveTemp(optMesh.value()), pCelluloidMaterialType); } else if (ImGui::MenuItem("Add Sphere Mesh")) { engine::Entity entity = AddNamedEntity("Sphere"); - // TODO : manage temp asset. - static std::optional optMesh = cd::MeshGenerator::Generate(cd::Sphere(cd::Point(0.0f), 10.0f), 100U, 100U, pPBRMaterialType->GetRequiredVertexFormat()); + std::optional optMesh = cd::MeshGenerator::Generate(cd::Sphere(cd::Point(0.0f), 10.0f), 100U, 100U, pPBRMaterialType->GetRequiredVertexFormat()); assert(optMesh.has_value()); + optMesh->SetName(pSceneWorld->GetNameComponent(entity)->GetName()); CreateShapeComponents(entity, cd::MoveTemp(optMesh.value()), pPBRMaterialType); } @@ -127,6 +128,7 @@ void EntityList::AddEntity(engine::SceneWorld* pSceneWorld) engine::Entity entity = AddNamedEntity("Celluloid Sphere"); std::optional optMesh = cd::MeshGenerator::Generate(cd::Sphere(cd::Point(0.0f), 10.0f), 100U, 100U, pCelluloidMaterialType->GetRequiredVertexFormat()); assert(optMesh.has_value()); + optMesh->SetName(pSceneWorld->GetNameComponent(entity)->GetName()); CreateShapeComponents(entity, cd::MoveTemp(optMesh.value()), pCelluloidMaterialType); } else if (ImGui::MenuItem("Add Terrain Mesh")) diff --git a/Engine/Source/ThirdParty/AssetPipeline b/Engine/Source/ThirdParty/AssetPipeline index 4a5644f7..ccd965ba 160000 --- a/Engine/Source/ThirdParty/AssetPipeline +++ b/Engine/Source/ThirdParty/AssetPipeline @@ -1 +1 @@ -Subproject commit 4a5644f700720e95e425a415620d058a32dcf47a +Subproject commit ccd965ba15b46e4cbeb55effb2e4d15790762826