58 Commits

Author SHA1 Message Date
emerycp
89971b2d77 Added .project properties to Project Settings 2024-09-05 21:37:55 -04:00
Antoine Pilote
43e9d6e7fc rip 2024-09-05 20:01:12 -04:00
Antoine Pilote
2c2ed94eea Fixed other mix shader fail casting 2024-09-05 20:00:19 -04:00
Antoine Pilote
120af20237 Fix outline shader for AMD cards 2024-09-05 19:54:21 -04:00
Antoine Pilote
422331dec2 Automatically refresh filebrowser on window focus, and preserve path after scanning 2024-09-05 19:44:27 -04:00
Antoine Pilote
9e05e6883a Forgot to include functional header 2024-09-05 19:09:45 -04:00
Antoine Pilote
73c927fdaf Added window callbacks for focused and closed 2024-09-05 19:07:48 -04:00
Antoine Pilote
5e3472c256 Fixed Coral crash with base type classes, temp fix for logs crash + added light color param to C# api 2024-09-05 00:52:55 -04:00
Antoine Pilote
732e94899c Added Physics.Raycast and Transform shortcut on entity objects 2024-09-04 22:26:59 -04:00
Antoine Pilote
ea97133e94 Bumped coral 2024-09-04 22:26:34 -04:00
Antoine Pilote
e1550fbff9 Forgot premake45 2024-09-04 21:05:14 -04:00
Antoine Pilote
780b95fba7 Removed line 2024-09-04 21:02:58 -04:00
Antoine Pilote
a2f28c4c86 Added AMD code path 2024-09-04 20:50:57 -04:00
Antoine Pilote
9c5f05f224 Fixed camera preview wrong translation + made it smaller 2024-09-04 20:45:32 -04:00
Antoine Pilote
e607b99191 Added preview window when selecting a camera in the scene 2024-09-04 20:31:43 -04:00
Antoine Pilote
e1813870a2 Fixedruntime refact 2024-09-04 16:38:52 -04:00
Antoine Pilote
ec9748ecd7 Removed old documentation 2024-09-04 01:09:35 -04:00
Antoine Pilote
7140d2b4ff Reverted ImUI namespace to avoir unresolved errors 2024-09-04 01:07:33 -04:00
Antoine Pilote
8c620be479 Fixed compilation errors 2024-09-04 01:02:05 -04:00
Antoine Pilote
10b8c862e7 Applying code standard new window, job, jobsystem and imui 2024-09-04 00:51:43 -04:00
Antoine Pilote
dc3c993962 Refactor pass #3 2024-09-04 00:33:05 -04:00
Antoine Pilote
db0ec40948 Moved project out of engine.h 2024-09-04 00:30:35 -04:00
Antoine Pilote
f650f0485b Forgot to change usage of SetcurrentScene 2024-09-04 00:30:11 -04:00
Antoine Pilote
156bf8c5cc Renamed LoadScene to SetCurrentScene 2024-09-04 00:16:37 -04:00
Antoine Pilote
87f58d890e Moved FileDialog into its own class 2024-09-04 00:14:00 -04:00
Antoine Pilote
c91812c65e Moved FileSystem stuff into seprate files and a FileSystem Folder 2024-09-03 23:49:22 -04:00
Antoine Pilote
db21f342b5 Attempt at fixing AMD Driver crash 2024-09-03 20:28:51 -04:00
Antoine Pilote
adb90b4f42 Fixed typo preventing setting game mode 2024-09-03 20:02:05 -04:00
Antoine Pilote
112718d1ac Removed pch 2024-09-03 19:32:00 -04:00
Antoine Pilote
aaf553f8ba Fixed wrong include 2024-09-03 19:31:07 -04:00
Antoine Pilote
db8ec0fbfd Merge branch 'develop' of https://github.com/antopilo/Nuake into develop 2024-09-03 18:48:10 -04:00
Antoine Pilote
1ac0337863 Refactor pass #1 2024-09-03 18:47:45 -04:00
Antoine Pilote
be725f52f2 Check if .map file exists 2024-09-03 16:41:52 -04:00
Antoine Pilote
55a2403b88 Merge branch 'develop' of https://github.com/antopilo/nuake into develop
# Conflicts:
#	Nuake/src/Rendering/Renderer.cpp
2024-09-03 12:40:19 -04:00
Antoine Pilote
54e5787472 Merge branch 'develop' of https://github.com/antopilo/Nuake into develop 2024-09-02 18:12:49 -04:00
Antoine Pilote
8aef2aaff9 Removed some empty line 2024-09-02 18:12:42 -04:00
Antoine Pilote
ced74170c5 Merge pull request #70 from WiggleWizard/feature/tracy
Tracy MVP integration
2024-09-02 18:12:15 -04:00
Antoine Pilote
000a1d564e Added base 2024-09-02 18:10:36 -04:00
Antoine Pilote
d9237f83d2 Added ground normal & ground velocity C# API e 2024-09-02 18:09:02 -04:00
WiggleWizard
5a801e642c Tracy MVP integration 2024-09-02 20:37:47 +01:00
Antoine Pilote
01000b9d13 Added float type and default values for trenchbroom integration 2024-09-02 14:05:59 -04:00
Antoine Pilote
d20847b4e3 Moved audio update last 2024-09-02 13:03:49 -04:00
Antoine Pilote
c7a1c10ff0 Removed spinning audio thread 2024-09-02 12:59:49 -04:00
Antoine Pilote
5077b1b7f8 Changed to only use 1 file watcher 2024-09-02 12:56:02 -04:00
Antoine Pilote
8f72f1711d Merge branch 'develop' of https://github.com/antopilo/Nuake into develop 2024-09-02 11:34:26 -04:00
Antoine Pilote
7af703b5fc Now scaling depth in viewport Depth mode and removed debug windows 2024-09-02 11:34:23 -04:00
Antoine Pilote
178ad898b9 Merge pull request #68 from WiggleWizard/develop
Initial module architecture
2024-09-02 11:30:52 -04:00
Antoine Pilote
63578ced2d Merge pull request #69 from WiggleWizard/refactor/buildassets
Removed build asset bash script in favor of a pure Lua version to make it easier to maintain and cross-platform
2024-09-02 11:30:16 -04:00
WiggleWizard
5971e4f2d6 Removed build asset bash script in favor of a pure Lua version to make it easier to maintain and cross-platform 2024-09-02 12:33:30 +01:00
WiggleWizard
67a1406e1b Fixed trailing comma missing in list within build script 2024-09-02 11:11:05 +01:00
WiggleWizard
bcf3e9751a Initial module architecture 2024-09-02 10:50:41 +01:00
Antoine Pilote
636736f567 Fixed a bug where bsp wouldnt get serialized properly + displaying brush in darker in scene hierarchy 2024-09-01 23:50:00 -04:00
Antoine Pilote
b7ee13c0eb Fixed crash when live reloading a map and a brush was selected 2024-09-01 23:18:51 -04:00
Antoine Pilote
d289c5431d Added live reloading for quake maps 2024-09-01 23:04:34 -04:00
Antoine Pilote
63712edc6d Added C# Point entities + automatic export of FGD entities 2024-09-01 19:37:05 -04:00
Antoine Pilote
f59a7e931f Now renders func brush materials correclty 2024-08-31 12:33:48 -04:00
Antoine Pilote
8aa41a1bf8 Now diplaying links between brushes 2024-08-31 00:07:45 -04:00
Antoine Pilote
05096355be Fixed spot light transformation 2024-08-29 12:54:31 -04:00
159 changed files with 279144 additions and 278157 deletions

View File

@@ -1,59 +0,0 @@
#!/bin/bash
# Directory containing the files
input_directory="Resources"
# Output C++ header file for variable declarations
output_header="Nuake/src/Resource/StaticResources.h"
# Output C++ source file for data storage
output_source="Nuake/src/Resource/StaticResources.cpp"
# Remove existing header and source files (if any)
rm -f "$output_header" "$output_source"
# Create the C++ header file with an initial guard
echo "#ifndef FILES_DATA_H" >> "$output_header"
echo "#define FILES_DATA_H" >> "$output_header"
echo "#include <string> " >> "$output_header"
echo "namespace Nuake { " >> "$output_header"
echo " namespace StaticResources { " >> "$output_header"
# Create the C++ source file
echo "#include \"StaticResources.h\"" >> "$output_source"
echo "namespace Nuake { " >> "$output_source"
echo " namespace StaticResources { " >> "$output_source"
# Use find to search for files in the directory and its subdirectories
find "$input_directory" -type f -print0 | while IFS= read -r -d $'\0' file_path; do
# Get the relative path of the file within the input_directory
relative_path="${file_path/}"
# Sanitize the relative path to make it suitable for C++ variable names
sanitized_path="${relative_path//[^[:alnum:]_]/_}"
# Generate C++ variable declarations for file path and size
echo "extern const std::string ${sanitized_path}_path;" >> "$output_header"
echo "extern unsigned int ${sanitized_path}_len;" >> "$output_header"
echo "extern unsigned char ${sanitized_path}[];" >> "$output_header"
# Append C++ code to the source file for storing file data
echo -e "\n// Data for file: ${sanitized_path}_path" >> "$output_source"
echo "const std::string ${sanitized_path}_path = R\"(${relative_path})\";" >> "$output_source"
xxd -i "$file_path" | sed -e 's/^/ /' >> "$output_source"
done
echo " }" >> "$output_source"
echo "}">> "$output_source"
echo " }" >> "$output_header"
echo "}">> "$output_header"
# Close the header file guard
echo "#endif // FILES_DATA_H" >> "$output_header"
echo "Header file '$output_header' generated with variable declarations."
echo "Source file '$output_source' generated with file data."

1
.gitignore vendored
View File

@@ -864,3 +864,4 @@ Nuake/dependencies/glad/glad.vcxproj.filters
*.csproj
*.filters
cloc.exe
Nuake/src/Modules/Modules.cpp

3
.gitmodules vendored
View File

@@ -22,3 +22,6 @@
[submodule "Nuake/dependencies/recastnavigation"]
path = Nuake/dependencies/recastnavigation
url = https://github.com/antopilo/recastnavigation.git
[submodule "Nuake/dependencies/tracy"]
path = Nuake/dependencies/tracy
url = https://github.com/wolfpld/tracy.git

View File

@@ -1,20 +0,0 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
# Optionally build your docs in additional formats such as PDF
formats:
- pdf
# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
#install:
#- requirements: docs/requirements.txt

View File

@@ -5,15 +5,13 @@
#include <src/Core/Input.h>
#include <src/Scene/Scene.h>
#include <src/Scene/Entities/Entity.h>
#include <src/Scene/Components/Components.h>
#include <src/Scene/Components.h>
#include "src/Windows/EditorInterface.h"
#include <src/Scene/Components/QuakeMap.h>
#include <src/Vendors/imgui/imgui.h>
#include <src/Vendors/imgui/ImGuizmo.h>
#include <src/Physics/PhysicsManager.h>
#include "src/Scene/Components/BoxCollider.h"
#include <GLFW/glfw3.h>
#include <src/Vendors/glm/trigonometric.hpp>
@@ -21,7 +19,6 @@
#include <src/Resource/FGD/FGDFile.h>
#include <src/Rendering/Shaders/ShaderManager.h>
#include <src/Rendering/Renderer.h>
#include <src/Scene/Components/BSPBrushComponent.h>
#include "src/Actions/EditorSelection.h"
#include "src/Misc/GizmoDrawer.h"

View File

@@ -1,7 +1,10 @@
#include "Commands.h"
#include <Engine.h>
#include "src/Core/FileSystem.h"
#include "src/FileSystem/FileSystem.h"
#include <filesystem>
namespace NuakeEditor
{
@@ -39,6 +42,12 @@ namespace NuakeEditor
{
const std::string& cleanProjectName = String::Sanitize(mProject->Name);
const std::string& gameConfigFolderPath = mProject->TrenchbroomPath + "/../games/" + cleanProjectName + "/";
if (!FileSystem::DirectoryExists(gameConfigFolderPath))
{
FileSystem::MakeDirectory(gameConfigFolderPath);
}
const std::string& gameConfigFilePath = gameConfigFolderPath + "GameConfig.cfg";
FileSystem::BeginWriteFile(gameConfigFilePath, true);
@@ -69,8 +78,8 @@ namespace NuakeEditor
"name": "Trigger",
"attribs": [ "transparent" ],
"match": "classname",
"pattern": "trigger_*",
"texture": "trigger"
"pattern": "Trigger*",
"texture": "trigger.png"
}
],
"brushface": [
@@ -135,7 +144,7 @@ namespace NuakeEditor
// Copy Icon.png
if (FileSystem::FileExists("icon.png"))
{
std::filesystem::copy_file(FileSystem::RelativeToAbsolute("icon.png"), gameConfigFolderPath + "Icon.png");
std::filesystem::copy_file(FileSystem::RelativeToAbsolute("icon.png"), gameConfigFolderPath + "Icon.png", std::filesystem::copy_options::overwrite_existing);
}
return true;
}

View File

@@ -1,7 +1,7 @@
#pragma once
#include "ComponentPanel.h"
#include <src/Core/FileSystem.h>
#include "src/FileSystem/FileSystem.h"
#include <src/Core/Maths.h>
#include <src/Scene/Components/AudioEmitterComponent.h>
#include <src/Scene/Entities/ImGuiHelper.h>

View File

@@ -1,7 +1,7 @@
#pragma once
#include "ComponentPanel.h"
#include <src/Core/FileSystem.h>
#include "src/FileSystem/FileSystem.h"
#include <src/Core/Maths.h>
#include <src/Scene/Components/BoneComponent.h>
#include <src/Scene/Entities/ImGuiHelper.h>

View File

@@ -1,7 +1,7 @@
#pragma once
#include "ComponentPanel.h"
#include <src/Core/FileSystem.h>
#include "src/FileSystem/FileSystem.h"
#include <src/Core/Maths.h>
#include <src/Scene/Components/BoxCollider.h>
#include <src/Scene/Entities/ImGuiHelper.h>

View File

@@ -1,7 +1,7 @@
#pragma once
#include "ComponentPanel.h"
#include <src/Scene/Components/CameraComponent.h>
#include <src/Core/FileSystem.h>
#include "src/FileSystem/FileSystem.h"
class CameraPanel : ComponentPanel {

View File

@@ -1,7 +1,7 @@
#pragma once
#include "ComponentPanel.h"
#include <src/Scene/Components/CharacterControllerComponent.h>
#include <src/Core/FileSystem.h>
#include "src/FileSystem/FileSystem.h"
class CharacterControllerPanel : ComponentPanel {

View File

@@ -1,9 +1,12 @@
#include "MaterialEditor.h"
#include <imgui/imgui.h>
#include <src/Resource/FontAwesome5.h>
#include <src/Vendors/imgui/imgui_internal.h>
#include "../Misc/InterfaceFonts.h"
#include <src/Resource/FontAwesome5.h>
#include <src/Resource/ResourceManager.h>
#include <src/FileSystem/FileDialog.h>
#include <imgui/imgui.h>
#include <src/Vendors/imgui/imgui_internal.h>
void MaterialEditor::Draw(Ref<Nuake::Material> material)
{

View File

@@ -8,6 +8,8 @@
#include <src/Scene/Components/ModelComponent.h>
#include <src/Resource/ResourceLoader.h>
#include <src/Resource/ResourceManager.h>
#include <src/Core/String.h>
#include <src/Resource/ModelLoader.h>

View File

@@ -1,10 +1,14 @@
#include "NetScriptPanel.h"
#include "../Windows/FileSystemUI.h"
#include <src/Scene/Components/NetScriptComponent.h>
#include <src/Core/FileSystem.h>
#include <src/FileSystem/FileDialog.h>
#include "src/FileSystem/FileSystem.h"
#include <src/Scripting/ScriptingEngineNet.h>
#include <src/Scene/Components/NetScriptComponent.h>
#include <src/Scene/Entities/ImGuiHelper.h>
void NetScriptPanel::Draw(Nuake::Entity entity)
{
if (!entity.HasComponent<Nuake::NetScriptComponent>())
@@ -130,6 +134,11 @@ void NetScriptPanel::Draw(Nuake::Entity entity)
{
if (!field.Value.has_value())
{
if (!field.DefaultValue.has_value())
{
field.DefaultValue = 0.0f;
}
field.Value = field.DefaultValue;
}
@@ -143,6 +152,11 @@ void NetScriptPanel::Draw(Nuake::Entity entity)
{
if (!field.Value.has_value())
{
if (!field.DefaultValue.has_value())
{
field.DefaultValue = 0.0;
}
field.Value = field.DefaultValue;
}
@@ -156,6 +170,11 @@ void NetScriptPanel::Draw(Nuake::Entity entity)
{
if (!field.Value.has_value())
{
if (!field.DefaultValue.has_value())
{
field.DefaultValue = false;
}
field.Value = field.DefaultValue;
}
@@ -188,6 +207,11 @@ void NetScriptPanel::Draw(Nuake::Entity entity)
{
if (!field.Value.has_value())
{
if (!field.DefaultValue.has_value())
{
field.DefaultValue = Nuake::Vector2(0, 0);
}
field.Value = field.DefaultValue;
}
@@ -203,6 +227,11 @@ void NetScriptPanel::Draw(Nuake::Entity entity)
{
if (!field.Value.has_value())
{
if (!field.DefaultValue.has_value())
{
field.DefaultValue = Nuake::Vector3(0, 0, 0);
}
field.Value = field.DefaultValue;
}

View File

@@ -1,7 +1,7 @@
#pragma once
#include "ComponentPanel.h"
#include <src/Core/FileSystem.h>
#include "src/FileSystem/FileSystem.h"
#include <src/Core/Maths.h>
#include <src/Scene/Components/ParticleEmitterComponent.h>
#include <src/Scene/Entities/ImGuiHelper.h>

View File

@@ -2,7 +2,7 @@
#include "ComponentPanel.h"
#include <src/Scene/Components/QuakeMap.h>
#include "src/Scene/Systems/QuakeMapBuilder.h"
#include <src/Core/FileSystem.h>
#include "src/FileSystem/FileSystem.h"
#include <src/AI/NavManager.h>
#include <src/UI/ImUI.h>

View File

@@ -1,7 +1,7 @@
#pragma once
#include "ComponentPanel.h"
#include <src/Scene/Components/RigidbodyComponent.h>
#include <src/Core/FileSystem.h>
#include "src/FileSystem/FileSystem.h"
class RigidbodyPanel : ComponentPanel {

View File

@@ -1,7 +1,8 @@
#include "ScriptPanel.h"
#include "../Windows/FileSystemUI.h"
#include <src/Scene/Components/WrenScriptComponent.h>
#include <src/Core/FileSystem.h>
#include "src/FileSystem/FileDialog.h"
#include "src/FileSystem/FileSystem.h"
void ScriptPanel::Draw(Nuake::Entity entity)
{

View File

@@ -1,7 +1,7 @@
#pragma once
#include "ComponentPanel.h"
#include <src/Scene/Components/SphereCollider.h>
#include <src/Core/FileSystem.h>
#include "src/FileSystem/FileSystem.h"
#include <src/Scene/Entities/ImGuiHelper.h>
class SphereColliderPanel : ComponentPanel {

View File

@@ -1,7 +1,7 @@
#pragma once
#include "ComponentPanel.h"
#include <src/Core/FileSystem.h>
#include "src/FileSystem/FileSystem.h"
#include <src/Core/Maths.h>
#include <src/Scene/Components/SpriteComponent.h>
#include <src/Scene/Entities/ImGuiHelper.h>

View File

@@ -11,7 +11,7 @@
void EditorApplication::OnInit()
{
using namespace Nuake;
Engine::Init();
m_Window = Engine::GetCurrentWindow();
m_Window->SetSize({ m_Specification.WindowWidth, m_Specification.WindowHeight });
@@ -45,6 +45,32 @@ void EditorApplication::OnInit()
}
}
m_Window->SetOnWindowFocusedCallback([&](Window& window, bool focused)
{
if (!focused)
{
return;
}
for (auto& layer : m_LayerStack)
{
layer->OnWindowFocused();
}
});
m_Window->SetOnWindowClosedCallback([](Window& window)
{
if (Engine::GetProject())
{
Engine::GetProject()->Save();
}
if (Engine::GetCurrentScene())
{
Engine::GetCurrentScene()->Save();
}
});
PushLayer(CreateScope<EditorLayer>());
}

View File

@@ -75,4 +75,9 @@ void EditorLayer::OnUpdate()
void EditorLayer::OnDetach()
{
delete m_EditorInterface;
}
void EditorLayer::OnWindowFocused()
{
m_EditorInterface->OnWindowFocused();
}

View File

@@ -22,6 +22,8 @@ public:
virtual void OnUpdate() override;
virtual void OnDetach() override;
virtual void OnWindowFocused() override;
private:
CommandBuffer mCommandBuffer;
Nuake::EditorInterface* m_EditorInterface;

View File

@@ -22,7 +22,9 @@
#include <src/Scene/Components/ParticleEmitterComponent.h>
#include <src/Scene/Components/BoneComponent.h>
#include <src/Scene/Components/AudioEmitterComponent.h>
#include <src/Scene/Components/ParentComponent.h>
#include <DetourDebugDraw.h>
#include <src/Scene/Components/BSPBrushComponent.h>
GizmoDrawer::GizmoDrawer(EditorInterface* editor)
@@ -378,6 +380,35 @@ void GizmoDrawer::DrawGizmos(Ref<Scene> scene, bool occluded)
}
}
auto bspView = scene->m_Registry.view<TransformComponent, BSPBrushComponent>();
for (auto e : bspView)
{
auto [transform, brush] = scene->m_Registry.get<TransformComponent, BSPBrushComponent>(e);
if (brush.target.empty())
{
continue;
}
auto bspView2 = scene->m_Registry.view<TransformComponent, BSPBrushComponent>();
for (auto e2 : bspView2)
{
auto [transform2, brush2] = scene->m_Registry.get<TransformComponent, BSPBrushComponent>(e2);
if (brush2.TargetName.empty())
{
continue;
}
if (brush.target == brush2.TargetName)
{
Vector3 from = transform.GetGlobalTransform()[3];
Vector3 to = transform2.GetGlobalTransform()[3];
scene->m_SceneRenderer->DrawDebugLine(from, to, Color(1, 0, 0, 1), 0.f, 1.0f);
}
}
}
auto particleView = scene->m_Registry.view<TransformComponent, ParticleEmitterComponent>();
for (auto e : particleView)
{

View File

@@ -1,10 +1,19 @@
#include "ThumbnailManager.h"
#include <src/Vendors/glm/ext/matrix_clip_space.hpp>
#include <src/FileSystem/FileTypes.h>
#include <src/FileSystem/File.h>
#include <src/Scene/Components/CameraComponent.h>
#include <src/Scene/Components/ModelComponent.h>
#include <src/Rendering/SceneRenderer.h>
#include <src/Resource/ResourceLoader.h>
#include <glad/glad.h>
#include <src/Resource/Prefab.h>
#include <src/Resource/ResourceLoader.h>
#include <src/Vendors/glm/ext/matrix_clip_space.hpp>
#include <glad/glad.h>
#include <Tracy.hpp>
ThumbnailManager::ThumbnailManager()
@@ -39,6 +48,8 @@ bool ThumbnailManager::IsThumbnailLoaded(const std::string& path) const
Ref<Nuake::Texture> ThumbnailManager::GetThumbnail(const std::string& path)
{
ZoneScoped;
if (IsThumbnailLoaded(path))
{
return m_Thumbnails[path];
@@ -71,6 +82,9 @@ void ThumbnailManager::MarkThumbnailAsDirty(const std::string & path)
Ref<Nuake::Texture> ThumbnailManager::GenerateThumbnail(const std::string& path, Ref<Nuake::Texture> texture)
{
ZoneScopedN("GenerateThumbnail");
ZoneText(path.c_str(), path.size());
using namespace Nuake;
const Matrix4 ortho = glm::orthoLH(-0.6f, 0.6f, -0.6f, 0.6f, -100.0f, 100.0f);

View File

@@ -23,13 +23,10 @@
#include <glad/glad.h>
#include "src/Scene/Scene.h"
#include "src/Scene/Components/Components.h"
#include "src/Scene/Components/BoxCollider.h"
#include "src/Scene/Components.h"
#include "src/Scene/Systems/QuakeMapBuilder.h"
#include "src/Scene/Components/LightComponent.h"
#include "../UIComponents/Viewport.h"
#include <src/Resource/Prefab.h>
#include <src/Scene/Components/PrefabComponent.h>
#include <src/Rendering/Shaders/ShaderManager.h>
#include "src/Rendering/Renderer.h"
#include "src/Core/Input.h"
@@ -37,6 +34,8 @@
#include "../Actions/EditorSelection.h"
#include "FileSystemUI.h"
#include <src/FileSystem/Directory.h>
#include "../Misc/InterfaceFonts.h"
#include "WelcomeWindow.h"
@@ -49,12 +48,17 @@
#include <src/Audio/AudioManager.h>
#include <src/UI/ImUI.h>
#include "src/Core/FileSystem.h"
#include "src/FileSystem/FileSystem.h"
#include <src/Resource/StaticResources.h>
#include <src/Threading/JobSystem.h>
#include "../Commands/Commands/Commands.h"
#include <src/Resource/ModelLoader.h>
#include "../ScriptingContext/ScriptingContext.h"
#include <src/Scene/Components/BSPBrushComponent.h>
#include <src/FileSystem/FileDialog.h>
#include <Tracy.hpp>
namespace Nuake {
@@ -66,6 +70,8 @@ namespace Nuake {
EditorSelection EditorInterface::Selection;
int SelectedViewport = 0;
bool displayVirtualCameraOverlay = false;
Ref<FrameBuffer> virtualCamera;
glm::vec3 DepthToWorldPosition(const glm::vec2& pixelPos, float depth, const glm::mat4& projectionMatrix, const glm::mat4& viewMatrix, const glm::vec2& viewportSize)
{
@@ -118,7 +124,9 @@ namespace Nuake {
using namespace Nuake::StaticResources;
ImGui::LoadIniSettingsFromMemory((const char*)StaticResources::Resources_default_layout_ini);
ScriptingContext::Get().Initialize();
virtualCamera = CreateRef<FrameBuffer>(true, Vector2{ 640, 360 });
virtualCamera->SetTexture(CreateRef<Texture>(Vector2{ 640, 360 }, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE), GL_COLOR_ATTACHMENT0);
//ScriptingContext::Get().Initialize();
}
void EditorInterface::Init()
@@ -165,7 +173,7 @@ namespace Nuake {
}
else if (SelectedViewport == 3)
{
texture = Engine::GetCurrentScene()->m_SceneRenderer->GetGBuffer().GetTexture(GL_DEPTH_ATTACHMENT);
texture = Engine::GetCurrentScene()->m_SceneRenderer->GetScaledDepthTexture();
}
ImVec2 imagePos = ImGui::GetWindowPos() + ImGui::GetCursorPos();
@@ -267,67 +275,76 @@ namespace Nuake {
glm::value_ptr(glm::identity<glm::mat4>()), 100.f);
}
if (Selection.Type == EditorSelectionType::Entity && !Engine::IsPlayMode())
{
TransformComponent& tc = Selection.Entity.GetComponent<TransformComponent>();
Matrix4 transform = tc.GetGlobalTransform();
const auto& editorCam = Engine::GetCurrentScene()->GetCurrentCamera();
Matrix4 cameraView = editorCam->GetTransform();
Matrix4 cameraProjection = editorCam->GetPerspective();
// Imguizmo calculates the delta from the gizmo,
ImGuizmo::Manipulate(
glm::value_ptr(cameraView),
glm::value_ptr(cameraProjection),
CurrentOperation, CurrentMode,
glm::value_ptr(transform), NULL,
UseSnapping ? &CurrentSnapping.x : NULL
);
if (ImGuizmo::IsUsing())
if (!Selection.Entity.IsValid())
{
// Since imguizmo returns a transform in global space and we want the local transform,
// we need to multiply by the inverse of the parent's global transform in order to revert
// the changes from the parent transform.
Matrix4 localTransform = Matrix4(transform);
ParentComponent& parent = Selection.Entity.GetComponent<ParentComponent>();
if (parent.HasParent)
Selection = EditorSelection();
}
else
{
TransformComponent& tc = Selection.Entity.GetComponent<TransformComponent>();
Matrix4 transform = tc.GetGlobalTransform();
const auto& editorCam = Engine::GetCurrentScene()->GetCurrentCamera();
Matrix4 cameraView = editorCam->GetTransform();
Matrix4 cameraProjection = editorCam->GetPerspective();
// Imguizmo calculates the delta from the gizmo,
ImGuizmo::Manipulate(
glm::value_ptr(cameraView),
glm::value_ptr(cameraProjection),
CurrentOperation, CurrentMode,
glm::value_ptr(transform), NULL,
UseSnapping ? &CurrentSnapping.x : NULL
);
if (ImGuizmo::IsUsing())
{
const auto& parentTransformComponent = parent.Parent.GetComponent<TransformComponent>();
const Matrix4& parentTransform = parentTransformComponent.GetGlobalTransform();
localTransform = glm::inverse(parentTransform) * localTransform;
// Since imguizmo returns a transform in global space and we want the local transform,
// we need to multiply by the inverse of the parent's global transform in order to revert
// the changes from the parent transform.
Matrix4 localTransform = Matrix4(transform);
ParentComponent& parent = Selection.Entity.GetComponent<ParentComponent>();
if (parent.HasParent)
{
const auto& parentTransformComponent = parent.Parent.GetComponent<TransformComponent>();
const Matrix4& parentTransform = parentTransformComponent.GetGlobalTransform();
localTransform = glm::inverse(parentTransform) * localTransform;
}
// Decompose local transform
float decomposedPosition[3];
float decomposedEuler[3];
float decomposedScale[3];
ImGuizmo::DecomposeMatrixToComponents(glm::value_ptr(localTransform), decomposedPosition, decomposedEuler, decomposedScale);
const auto& localPosition = Vector3(decomposedPosition[0], decomposedPosition[1], decomposedPosition[2]);
const auto& localScale = Vector3(decomposedScale[0], decomposedScale[1], decomposedScale[2]);
localTransform[0] /= localScale.x;
localTransform[1] /= localScale.y;
localTransform[2] /= localScale.z;
const auto& rotationMatrix = Matrix3(localTransform);
const Quat& localRotation = glm::normalize(Quat(rotationMatrix));
const Matrix4& rotationMatrix4 = glm::mat4_cast(localRotation);
const Matrix4& scaleMatrix = glm::scale(Matrix4(1.0f), localScale);
const Matrix4& translationMatrix = glm::translate(Matrix4(1.0f), localPosition);
const Matrix4& newLocalTransform = translationMatrix * rotationMatrix4 * scaleMatrix;
tc.Translation = localPosition;
if (CurrentOperation != ImGuizmo::SCALE)
{
tc.Rotation = localRotation;
}
tc.Scale = localScale;
tc.LocalTransform = newLocalTransform;
tc.Dirty = true;
}
// Decompose local transform
float decomposedPosition[3];
float decomposedEuler[3];
float decomposedScale[3];
ImGuizmo::DecomposeMatrixToComponents(glm::value_ptr(localTransform), decomposedPosition, decomposedEuler, decomposedScale);
const auto& localPosition = Vector3(decomposedPosition[0], decomposedPosition[1], decomposedPosition[2]);
const auto& localScale = Vector3(decomposedScale[0], decomposedScale[1], decomposedScale[2]);
localTransform[0] /= localScale.x;
localTransform[1] /= localScale.y;
localTransform[2] /= localScale.z;
const auto& rotationMatrix = Matrix3(localTransform);
const Quat& localRotation = glm::normalize(Quat(rotationMatrix));
const Matrix4& rotationMatrix4 = glm::mat4_cast(localRotation);
const Matrix4& scaleMatrix = glm::scale(Matrix4(1.0f), localScale);
const Matrix4& translationMatrix = glm::translate(Matrix4(1.0f), localPosition);
const Matrix4& newLocalTransform = translationMatrix * rotationMatrix4 * scaleMatrix;
tc.Translation = localPosition;
if (CurrentOperation != ImGuizmo::SCALE)
{
tc.Rotation = localRotation;
}
tc.Scale = localScale;
tc.LocalTransform = newLocalTransform;
tc.Dirty = true;
}
}
@@ -511,6 +528,7 @@ namespace Nuake {
{
playButtonPressed = ImGui::Button(ICON_FA_PLAY, ImVec2(30, 30)) || Input::IsKeyPressed(Key::F5);
tooltip = "Build & Play (F5)";
}
if (playButtonPressed)
@@ -527,6 +545,7 @@ namespace Nuake {
{
this->SceneSnapshot = Engine::GetCurrentScene()->Copy();
std::string statusMessage = ICON_FA_HAMMER + std::string(" Building .Net solution...");
SetStatusMessage(statusMessage);
@@ -553,6 +572,8 @@ namespace Nuake {
}
else
{
Engine::GetProject()->ExportEntitiesToTrenchbroom();
SetStatusMessage("Entering play mode...");
PushCommand(SetGameState(GameState::Playing));
@@ -583,7 +604,7 @@ namespace Nuake {
{
Engine::ExitPlayMode();
Engine::LoadScene(SceneSnapshot);
Engine::SetCurrentScene(SceneSnapshot);
Selection = EditorSelection();
SetStatusMessage("Ready");
}
@@ -733,6 +754,10 @@ namespace Nuake {
{
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255));
}
else if (e.HasComponent<BSPBrushComponent>())
{
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 120));
}
if (!m_IsRenaming && m_ShouldUnfoldEntityTree && Selection.Type == EditorSelectionType::Entity && e.GetScene()->EntityIsParent(Selection.Entity, e))
{
@@ -762,7 +787,7 @@ namespace Nuake {
}
bool isDragging = false;
if (nameComponent.IsPrefab && e.HasComponent<PrefabComponent>())
if (nameComponent.IsPrefab && e.HasComponent<PrefabComponent>() || e.HasComponent<BSPBrushComponent>())
{
ImGui::PopStyleColor();
}
@@ -814,7 +839,7 @@ namespace Nuake {
m_IsRenaming = true;
}
if (!m_IsRenaming && Selection.Type == EditorSelectionType::Entity && Input::IsKeyPressed(Key::DELETE))
if (!m_IsRenaming && Selection.Type == EditorSelectionType::Entity && Input::IsKeyPressed(Key::DELETE_KEY))
{
QueueDeletion = Selection.Entity;
}
@@ -2589,6 +2614,62 @@ namespace Nuake {
ImGui::PopStyleVar();
ImGui::End();
corner = 2;
if (Selection.Type == EditorSelectionType::Entity && Selection.Entity.IsValid() && Selection.Entity.HasComponent<CameraComponent>())
{
window_flags |= ImGuiWindowFlags_NoMove;
viewport = ImGui::GetWindowViewport();
work_area_pos = ImGui::GetCurrentWindow()->Pos; // Instead of using viewport->Pos we use GetWorkPos() to avoid menu bars, if any!
work_area_size = ImGui::GetCurrentWindow()->Size;
window_pos = ImVec2((corner & 1) ? (work_area_pos.x + work_area_size.x - DISTANCE) : (work_area_pos.x + DISTANCE), (corner & 2) ? (work_area_pos.y + work_area_size.y - DISTANCE) : (work_area_pos.y + DISTANCE));
window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f);
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
ImGui::SetNextWindowViewport(viewport->ID);
ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 32.0f);
if (ImGui::Begin("VirtualViewport", &m_ShowOverlay, window_flags))
{
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2, 2));
ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 0));
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 100);
ImGui::PushStyleColor(ImGuiCol_FrameBg, IM_COL32(20, 20, 20, 0));
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, IM_COL32(20, 20, 20, 60));
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, IM_COL32(33, 33, 33, 45));
CameraComponent& camera = Selection.Entity.GetComponent<CameraComponent>();
Ref<Camera> cam = camera.CameraInstance;
auto& transform = Selection.Entity.GetComponent<TransformComponent>();
const Quat& globalRotation = transform.GetGlobalRotation();
const Matrix4& translationMatrix = glm::translate(Matrix4(1.0f), transform.GetGlobalPosition());
const Matrix4& rotationMatrix = glm::mat4_cast(globalRotation);
const Vector4& forward = Vector4(0, 0, -1, 1);
const Vector4& globalForward = rotationMatrix * forward;
const Vector4& right = Vector4(1, 0, 0, 1);
const Vector4& globalRight = rotationMatrix * right;
cam->Direction = globalForward;
cam->Right = globalRight;
cam->Translation = transform.GetGlobalPosition();
cam->SetTransform(glm::inverse(transform.GetGlobalTransform()));
auto sceneRenderer = Engine::GetCurrentScene()->m_SceneRenderer;
sceneRenderer->BeginRenderScene(cam->GetPerspective(), cam->GetTransform(), cam->Translation);
sceneRenderer->RenderScene(*Engine::GetCurrentScene().get(), *virtualCamera.get());
virtualCamera->Clear();
ImGui::Image((void*)virtualCamera->GetTexture()->GetID(), { 640, 360 }, { 0, 1 }, {1, 0});
ImGui::PopStyleVar(2);
ImGui::PopStyleColor(4);
}
ImGui::PopStyleVar();
ImGui::End();
}
}
void NewProject()
@@ -2621,7 +2702,7 @@ namespace Nuake {
Ref<Project> project = Project::New(String::Split(fileName, '.')[0], "no description", finalPath);
Engine::LoadProject(project);
Engine::LoadScene(Scene::New());
Engine::SetCurrentScene(Scene::New());
Engine::GetCurrentWindow()->SetTitle("Nuake Engine - Editing " + project->Name);
}
@@ -2670,7 +2751,7 @@ namespace Nuake {
}
scene->Path = FileSystem::AbsoluteToRelative(projectPath);
Engine::LoadScene(scene);
Engine::SetCurrentScene(scene);
}
void EditorInterface::DrawMenuBar()
@@ -2716,7 +2797,7 @@ namespace Nuake {
ImGui::Separator();
if (ImGui::MenuItem("New scene"))
{
Engine::LoadScene(Scene::New());
Engine::SetCurrentScene(Scene::New());
Selection = EditorSelection();
SetStatusMessage("New scene created.");
}
@@ -2882,6 +2963,8 @@ namespace Nuake {
int frameCount = 2;
void EditorInterface::Draw()
{
ZoneScoped;
Init();
if (isCreatingNewProject && !_NewProjectWindow->HasCreatedProject())
@@ -2974,10 +3057,10 @@ namespace Nuake {
DrawMenuBars();
int i = 0;
if (Logger::GetLogCount() > 0 && Logger::GetLogs()[Logger::GetLogCount() - 1].type == COMPILATION)
{
SetStatusMessage(std::string(ICON_FA_EXCLAMATION_TRIANGLE) + " An unhandled exception occured in your script. See logs for more details.", Color(1.0f, 0.1f, 0.1f, 1.0f));
}
//if (Logger::GetLogCount() > 0 && Logger::GetLogs()[Logger::GetLogCount() - 1].type == COMPILATION)
//{
// SetStatusMessage(std::string(ICON_FA_EXCLAMATION_TRIANGLE) + " An unhandled exception occured in your script. See logs for more details.", Color(1.0f, 0.1f, 0.1f, 1.0f));
//}
DrawStatusBar();
@@ -2996,13 +3079,14 @@ namespace Nuake {
void EditorInterface::Update(float ts)
{
ZoneScoped;
if (!Engine::GetCurrentScene() || Engine::IsPlayMode())
{
return;
}
auto& editorCam = Engine::GetCurrentScene()->m_EditorCamera;
editorCam->Update(ts, m_IsHoveringViewport && m_IsViewportFocused);
const bool entityIsSelected = Selection.Type == EditorSelectionType::Entity && Selection.Entity.IsValid();
@@ -3012,6 +3096,15 @@ namespace Nuake {
editorCam->TargetPos = Selection.Entity.GetComponent<TransformComponent>().GetGlobalPosition();
}
if (entityIsSelected && Selection.Type == EditorSelectionType::Entity && Selection.Entity.IsValid() && Selection.Entity.HasComponent<CameraComponent>())
{
displayVirtualCameraOverlay = true;
}
else
{
displayVirtualCameraOverlay = false;
}
if (entityIsSelected && Input::IsKeyPressed(Key::ESCAPE))
{
Selection = EditorSelection();
@@ -3086,6 +3179,12 @@ namespace Nuake {
mCommandBuffer->PushCommand(command);
}
void EditorInterface::OnWindowFocused()
{
filesystem->Scan();
}
bool EditorInterface::LoadProject(const std::string& projectPath)
{
FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath));

View File

@@ -4,7 +4,7 @@
#include "src/Vendors/imgui/imgui.h"
#include <src/Vendors/imgui/ImGuizmo.h>
#include "src/Core/FileSystem.h"
#include "src/FileSystem/FileSystem.h"
#include "../Actions/EditorSelection.h"
#include "EditorSelectionPanel.h"
@@ -102,5 +102,8 @@ namespace Nuake
public:
std::string GetEntityTypeName(const Entity& entity) const;
static void PushCommand(ICommand&& command);
public:
void OnWindowFocused();
};
}

View File

@@ -2,18 +2,24 @@
#include "EditorSelectionPanel.h"
#include "../Misc/ImGuiTextHelper.h"
#include <src/Scene/Components/Components.h>
#include <src/Scene/Components.h>
#include <src/Rendering/Textures/Material.h>
#include <src/Resource/ResourceLoader.h>
#include <src/Resource/FontAwesome5.h>
#include <src/Scripting/WrenScript.h>
#include <src/FileSystem/FileDialog.h>
#include <Engine.h>
#include <src/Resource/Prefab.h>
using namespace Nuake;
EditorSelectionPanel::EditorSelectionPanel()
{
virtualScene = CreateRef<Scene>();
virtualScene->SetName("Virtual Scene");
virtualScene->CreateEntity("Camera").AddComponent<CameraComponent>();
}
void EditorSelectionPanel::ResolveFile(Ref<Nuake::File> file)
@@ -58,7 +64,7 @@ void EditorSelectionPanel::Draw(EditorSelection selection)
ResolveFile(selection.File);
}
if (!selection.File->IsValid())
if (!selection.File->Exist())
{
std::string text = "File is invalid";
auto windowWidth = ImGui::GetWindowSize().x;
@@ -227,6 +233,11 @@ void EditorSelectionPanel::DrawResource(Nuake::Resource resource)
}
void EditorSelectionPanel::DrawPrefabPanel(Ref<Nuake::Prefab> prefab)
{
}
void EditorSelectionPanel::DrawMaterialPanel(Ref<Nuake::Material> material)
{
using namespace Nuake;

View File

@@ -2,7 +2,7 @@
#include "../Actions/EditorSelection.h"
#include "src/Scene/Entities/Entity.h"
#include "src/Core/FileSystem.h"
#include "src/FileSystem/FileSystem.h"
#include <src/Resource/Project.h>
#include "../ComponentsPanel/TransformPanel.h"
@@ -26,6 +26,15 @@
#include "../ComponentsPanel/NetScriptPanel.h"
#include "../ComponentsPanel/NavMeshVolumePanel.h"
#include <src/Scene/Components/WrenScriptComponent.h>
#include <src/Resource/Prefab.h>
namespace Nuake
{
class Scene;
}
class EditorSelectionPanel
{
private:
@@ -53,6 +62,7 @@ private:
Ref<Nuake::File> currentFile;
Ref<Nuake::Resource> selectedResource;
Ref<Nuake::Scene> virtualScene;
public:
EditorSelectionPanel();
@@ -64,7 +74,7 @@ public:
void DrawFile(Ref<Nuake::File> file);
void DrawResource(Nuake::Resource resource);
void DrawPrefabPanel(Ref<Nuake::Prefab> prefab);
private:
void ResolveFile(Ref<Nuake::File> file);
void DrawMaterialPanel(Ref<Nuake::Material> material);

View File

@@ -12,15 +12,18 @@
#include <src/Rendering/Textures/Material.h>
#include "../Misc/PopupHelper.h"
#include <src/FileSystem/FileDialog.h>
#include <src/FileSystem/Directory.h>
#include <src/FileSystem/File.h>
#include "src/Scene/Systems/WadConverter.h"
#include "../Misc/ThumbnailManager.h"
#include <Tracy.hpp>
namespace Nuake
{
Ref<Directory> FileSystemUI::m_CurrentDirectory;
// TODO: add filetree in same panel
void FileSystemUI::Draw()
{
@@ -64,6 +67,8 @@ namespace Nuake
void FileSystemUI::DrawDirectory(Ref<Directory> directory, uint32_t drawId)
{
ZoneScoped;
ImGui::PushFont(FontManager::GetFont(Icons));
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
const char* icon = ICON_FA_FOLDER;
@@ -226,6 +231,8 @@ namespace Nuake
void FileSystemUI::DrawFile(Ref<File> file, uint32_t drawId)
{
ZoneScoped;
ImGui::PushFont(EditorInterface::bigIconFont);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, {0.f, 0.f});
@@ -552,7 +559,7 @@ namespace Nuake
}
scene->Path = FileSystem::AbsoluteToRelative(projectPath);
Engine::LoadScene(scene);
Engine::SetCurrentScene(scene);
}
// Rename Popup
@@ -687,8 +694,28 @@ namespace Nuake
void FileSystemUI::RefreshFileBrowser()
{
Scan();
}
void FileSystemUI::Scan()
{
if (!m_CurrentDirectory)
{
return;
}
std::string previousPath = m_CurrentDirectory->FullPath;
FileSystem::Scan();
m_CurrentDirectory = FileSystem::RootDirectory;
if (FileSystem::DirectoryExists(previousPath, true))
{
m_CurrentDirectory = FileSystem::GetDirectory(FileSystem::AbsoluteToRelative(previousPath));
}
else
{
m_CurrentDirectory = FileSystem::RootDirectory;
}
}
float h = 200;

View File

@@ -1,5 +1,5 @@
#pragma once
#include <src/Core/FileSystem.h>
#include "src/FileSystem/FileSystem.h"
#include <src/Scene/Entities/Entity.h>
#include "EditorInterface.h"
@@ -32,5 +32,7 @@ namespace Nuake {
bool DeletePopup();
void DrawContextMenu();
void RefreshFileBrowser();
void Scan();
};
}

View File

@@ -1,11 +1,24 @@
#include "MapImporterWindow.h"
#include <imgui/imgui.h>
#include "../Misc/InterfaceFonts.h"
#include <src/UI/ImUI.h>
#include <src/Core/Logger.h>
#include <regex>
#include <src/Threading/JobSystem.h>
#include <Engine.h>
#include <src/Core/Logger.h>
#include <src/FileSystem/File.h>
#include <src/Threading/JobSystem.h>
#include <src/UI/ImUI.h>
#include <src/FileSystem/FileDialog.h>
#include <src/Core/String.h>
#include <src/Resource/Project.h>
#include <imgui/imgui.h>
#include <filesystem>
#include <fstream>
#include <sstream>
#include <regex>
using namespace Nuake;
void MapImporterWindow::Draw()
{

View File

@@ -1,7 +1,7 @@
#pragma once
#include <src/Core/FileSystem.h>
#include <src/Core/FileSystem.h>
#include "src/FileSystem/FileSystem.h"
#include "src/FileSystem/FileSystem.h"
#include <atomic>
class MapImporterWindow

View File

@@ -7,7 +7,8 @@
#include <src/Rendering/Textures/TextureManager.h>
#include <src/Rendering/Textures/Texture.h>
#include <src/Scene/Entities/ImGuiHelper.h>
#include <src/Core/FileSystem.h>
#include <src/FileSystem/FileDialog.h>
#include "src/FileSystem/FileSystem.h"
#include <src/UI/ImUI.h>
#include <src/Core/Logger.h>
#include <src/Resource/Project.h>
@@ -230,7 +231,7 @@ namespace Nuake
Nuake::FileSystem::SetRootDirectory(projectParentPath);
auto project = Nuake::Project::New(projectTitle, description, finalLocation);
Nuake::Engine::LoadProject(project);
Nuake::Engine::LoadScene(Nuake::Scene::New());
Nuake::Engine::SetCurrentScene(Nuake::Scene::New());
project->Settings.PrimaryColor = Nuake::Color(primaryColor.x, primaryColor.y, primaryColor.z, primaryColor.w);
project->Save();

View File

@@ -1,9 +1,12 @@
#include "ProjectInterface.h"
#include <src/Vendors/imgui/imgui.h>
#include "Engine.h"
#include "src/Core/FileSystem.h"
#include <src/FileSystem/FileDialog.h>
#include "src/FileSystem/FileSystem.h"
#include <src/Scripting/ScriptingEngineNet.h>
#include <src/Scripting/ScriptingEngineNet.h>
#include <src/Vendors/imgui/imgui.h>
//#include "ImGuiTextHelper.h"
namespace Nuake {

View File

@@ -1,7 +1,8 @@
#include "ProjectSettingsWindow.h"
#include <imgui/imgui.h>
#include "../../Misc/InterfaceFonts.h"
#include <src/Core/FileSystem.h>
#include <src/FileSystem/FileDialog.h>
#include "src/FileSystem/FileSystem.h"
#include "../EditorInterface.h"
#include "../../Commands/Commands/Commands.h"
#include <src/Audio/AudioManager.h>
@@ -14,23 +15,24 @@ ProjectSettingsCategoryWindowGeneral::ProjectSettingsCategoryWindowGeneral(Ref<N
void ProjectSettingsCategoryWindowGeneral::Draw()
{
using namespace Nuake;
//ImGui::InputText("Project Name", &m_Project->Name);
//ImGui::InputTextMultiline("Project Description", &m_Project->Description);
ImGui::InputText("Project Name", &m_Project->Name);
if (ImGui::Button("Locate"))
{
const std::string& locationPath = Nuake::FileDialog::OpenFile("TrenchBroom (.exe)\0TrenchBroom.exe\0");
ImGui::InputTextMultiline("Project Description", &m_Project->Description);
if (ImGui::Button("Locate"))
{
const std::string& locationPath = Nuake::FileDialog::OpenFile("TrenchBroom (.exe)\0TrenchBroom.exe\0");
if (!locationPath.empty())
{
m_Project->TrenchbroomPath = locationPath;
}
}
if (!locationPath.empty())
{
m_Project->TrenchbroomPath = locationPath;
}
}
ImGui::ColorEdit4("Primary Color", &m_Project->Settings.PrimaryColor.r);
//ImGui::InputText("Trenchbroom Path", &m_Project->TrenchbroomPath);
ImGui::SameLine();
ImGui::InputText("Trenchbroom Path", &m_Project->TrenchbroomPath);
ImGui::ColorEdit4("Primary Color", &m_Project->Settings.PrimaryColor.r);
}
ProjectSettingsWindow::ProjectSettingsWindow()
@@ -63,7 +65,7 @@ void ProjectSettingsWindow::Draw()
return;
}
ImGui::SetNextWindowSizeConstraints({600, 300}, {1280, 720});
ImGui::SetNextWindowSizeConstraints({800, 400}, {1280, 720});
if (ImGui::Begin("Project Settings", &m_DisplayWindow, ImGuiWindowFlags_NoDocking))
{
ImVec4* colors = ImGui::GetStyle().Colors;
@@ -121,7 +123,7 @@ ProjectSettingsCategoryWindowViewport::ProjectSettingsCategoryWindowViewport(Ref
void ProjectSettingsCategoryWindowViewport::Draw()
{
ImGui::DragFloat("Outline Radius", &m_Project->Settings.OutlineRadius, 0.1f, 1.0f, 10.0f);
ImGui::DragFloat("Outline Radius", &m_Project->Settings.OutlineRadius, 0.1f, 1.0f, 90.0f);
ImGui::DragFloat("Gizmo Size", &m_Project->Settings.GizmoSize, 0.01f, 0.05f, 0.5f);
ImGui::Separator();
ImGui::Checkbox("Smooth Camera", &m_Project->Settings.SmoothCamera);

View File

@@ -1,11 +1,13 @@
#include "TrenchbroomConfiguratorWindow.h"
#include <Engine.h>
#include <src/Resource/Project.h>
#include <src/UI/ImUI.h>
#include <src/Core/OS.h>
#include <src/Rendering/Textures/TextureManager.h>
#include <src/Resource/Prefab.h>
void TrenchbroomConfiguratorWindow::Update()
{

View File

@@ -5,7 +5,8 @@
#include "../Misc/InterfaceFonts.h"
#include <Engine.h>
#include <src/Core/FileSystem.h>
#include <src/FileSystem/FileDialog.h>
#include "src/FileSystem/FileSystem.h"
#include <src/Resource/Project.h>
#include <src/Core/Logger.h>
#include <src/Rendering/Textures/TextureManager.h>
@@ -308,7 +309,7 @@ namespace Nuake
// auto project = Project::New(String::Split(fileName, '.')[0], "no description", finalPath);
// Engine::LoadProject(project);
// Engine::LoadScene(Scene::New());
// Engine::SetCurrentScene(Scene::New());
// project->Save();
// auto projectPreview = ProjectPreview();

View File

@@ -1,35 +1,38 @@
#include "Engine.h"
#include "src/Scene/Scene.h"
#include "src/Resource/Project.h"
#include "src/Physics/PhysicsManager.h"
#include <GLFW/glfw3.h>
#include "src/AI/NavManager.h"
#include "src/Audio/AudioManager.h"
#include "src/Core/FileSystem.h"
#include "src/FileSystem/FileSystem.h"
#include "src/Core/Input.h"
#include "src/Rendering/Renderer.h"
#include "src/Rendering/Renderer2D.h"
#include "src/Scripting/ScriptingEngine.h"
#include "src/Scripting/ScriptingEngineNet.h"
#include "src/Threading/JobSystem.h"
#include "src/Modules/Modules.h"
#include <GLFW/glfw3.h>
#include <imgui/imgui_impl_glfw.h>
#include <imgui/imgui_impl_opengl3.h>
#include <Tracy.hpp>
namespace Nuake
{
Ref<Project> Engine::currentProject;
Ref<Window> Engine::currentWindow;
Ref<Project> Engine::s_CurrentProject;
Ref<Window> Engine::s_CurrentWindow;
GameState Engine::gameState = GameState::Stopped;
GameState Engine::s_GameState = GameState::Stopped;
float Engine::s_LastFrameTime = 0.0f;
float Engine::s_FixedUpdateRate = 1.0f / 90.0f;
float Engine::s_FixedUpdateDifference = 0.f;
float Engine::s_Time = 0.f;
Timestep Engine::s_TimeStep = 0.f;
float Engine::s_TimeScale = 1.0f;
float Engine::lastFrameTime = 0.0f;
float Engine::fixedUpdateRate = 1.0f / 90.0f;
float Engine::fixedUpdateDifference = 0.f;
float Engine::time = 0.f;
Timestep Engine::timeStep = 0.f;
float Engine::timeScale = 1.0f;
void Engine::Init()
{
@@ -38,26 +41,30 @@ namespace Nuake
NavManager::Get().Initialize();
// Creates the window
s_CurrentWindow = Window::Get();
currentWindow = Window::Get();
Input::Init();
Renderer2D::Init();
Logger::Log("Engine initialized");
Modules::StartupModules();
}
void Engine::Tick()
{
ZoneScoped;
JobSystem::Get().Update();
s_Time = static_cast<float>(glfwGetTime());
s_TimeStep = s_Time - s_LastFrameTime;
s_LastFrameTime = s_Time;
time = static_cast<float>(glfwGetTime());
timeStep = time - lastFrameTime;
lastFrameTime = time;
// Dont update if no scene is loaded.
if (s_CurrentWindow->GetScene())
if (currentWindow->GetScene())
{
float scaledTimeStep = s_TimeStep * s_TimeScale;
s_CurrentWindow->Update(scaledTimeStep);
float scaledTimeStep = timeStep * timeScale;
currentWindow->Update(scaledTimeStep);
// Play mode update all the entities, Editor does not.
if (!Engine::IsPlayMode())
@@ -65,25 +72,24 @@ namespace Nuake
GetCurrentScene()->EditorUpdate(scaledTimeStep);
}
s_FixedUpdateDifference += s_TimeStep;
fixedUpdateDifference += timeStep;
// Fixed update
while (s_FixedUpdateDifference >= s_FixedUpdateRate)
while (fixedUpdateDifference >= fixedUpdateRate)
{
s_CurrentWindow->FixedUpdate(s_FixedUpdateRate * s_TimeScale);
currentWindow->FixedUpdate(fixedUpdateRate * timeScale);
s_FixedUpdateDifference -= s_FixedUpdateRate;
fixedUpdateDifference -= fixedUpdateRate;
}
Input::Update();
AudioManager::Get().AudioUpdate();
}
}
void Engine::EnterPlayMode()
{
s_LastFrameTime = (float)glfwGetTime(); // Reset timestep timer.
lastFrameTime = (float)glfwGetTime(); // Reset timestep timer.
// Dont trigger init if already in player mode.
if (GetGameState() == GameState::Playing)
@@ -108,22 +114,28 @@ namespace Nuake
void Engine::ExitPlayMode()
{
// Dont trigger exit if already not in play mode.
if (s_GameState != GameState::Stopped)
if (gameState != GameState::Stopped)
{
GetCurrentScene()->OnExit();
Input::ShowMouse();
s_GameState = GameState::Stopped;
gameState = GameState::Stopped;
}
}
void Engine::Draw()
{
ZoneScoped;
RenderCommand::Clear();
// Start imgui frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
{
ZoneScopedN("ImGui New Frame");
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
}
// Draw scene
Window::Get()->Draw();
@@ -131,6 +143,7 @@ namespace Nuake
void Engine::EndDraw()
{
ZoneScoped;
Window::Get()->EndDraw();
}
@@ -141,34 +154,35 @@ namespace Nuake
Ref<Scene> Engine::GetCurrentScene()
{
if (s_CurrentWindow)
if (currentWindow)
{
return s_CurrentWindow->GetScene();
return currentWindow->GetScene();
}
return nullptr;
}
bool Engine::LoadScene(Ref<Scene> scene)
bool Engine::SetCurrentScene(Ref<Scene> scene)
{
return s_CurrentWindow->SetScene(scene);
return currentWindow->SetScene(scene);
}
Ref<Project> Engine::GetProject()
{
return s_CurrentProject;
return currentProject;
}
bool Engine::LoadProject(Ref<Project> project)
{
s_CurrentProject = project;
currentProject = project;
if (!Engine::LoadScene(s_CurrentProject->DefaultScene))
if (!Engine::SetCurrentScene(currentProject->DefaultScene))
{
return false;
}
FileSystem::SetRootDirectory(FileSystem::GetParentPath(project->FullPath));
ScriptingEngineNet::Get().Initialize();
ScriptingEngineNet::Get().LoadProjectAssembly(project);
return true;
@@ -176,6 +190,6 @@ namespace Nuake
Ref<Window> Engine::GetCurrentWindow()
{
return s_CurrentWindow;
return currentWindow;
}
}

View File

@@ -1,17 +1,14 @@
#pragma once
#include "src/Core/Core.h"
#include "src/Window.h"
#include "src/Scene/Scene.h"
#include "src/Resource/Project.h"
#include "src/Core/Logger.h"
/* TODOS:
*/
#include "src/Window.h"
// Welcome to the Nuake source code.
namespace Nuake
{
class Project;
class Scene;
enum GameState
{
Playing,
@@ -21,19 +18,6 @@ namespace Nuake
class Engine
{
private:
static Ref<Window> s_CurrentWindow;
static Ref<Project> s_CurrentProject;
static Ref<Scene> s_CurrentScene;
static GameState s_GameState;
static float s_LastFrameTime;
static float s_FixedUpdateRate;
static float s_FixedUpdateDifference;
static float s_Time;
static Timestep s_TimeStep;
static float s_TimeScale;
public:
static void Init(); // Initialize the engine.
static void Tick(); // Updates everything, called every frame.
@@ -46,23 +30,39 @@ namespace Nuake
static void Draw(); // Start new frame
static void EndDraw(); // Swap buffer
static void SetGameState(GameState gameState) { s_GameState = gameState; }
static GameState GetGameState() { return s_GameState; }
static bool IsPlayMode() { return s_GameState == GameState::Playing; }
static void SetGameState(GameState state) { gameState = state; }
static GameState GetGameState() { return gameState; }
static bool IsPlayMode() { return gameState == GameState::Playing; }
static inline float GetTime() { return s_Time; }
static inline Timestep GetTimestep() { return s_TimeStep; }
static inline void SetPhysicsStep(int amount) { s_FixedUpdateRate = 1.0f / static_cast<float>(amount); }
static inline void SetTimeScale(float timeScale) { s_TimeScale = timeScale; }
static inline float GetTimeScale() { return s_TimeScale; }
static inline float GetTime() { return time; }
static inline Timestep GetTimestep() { return timeStep; }
static inline void SetPhysicsStep(int amount) { fixedUpdateRate = 1.0f / static_cast<float>(amount); }
static inline float GetFixedTimeStep() { return fixedUpdateRate; }
static inline void SetTimeScale(float timeScale) { timeScale = timeScale; }
static inline float GetTimeScale() { return timeScale; }
static Ref<Window> GetCurrentWindow();
static bool LoadScene(Ref<Scene> scene);
static bool SetCurrentScene(Ref<Scene> scene);
static Ref<Scene> GetCurrentScene();
static bool LoadProject(Ref<Project> project);
static Ref<Project> GetProject();
private:
static Ref<Window> currentWindow;
static Ref<Project> currentProject;
static Ref<Scene> currentScene;
static GameState gameState;
static float lastFrameTime;
static float fixedUpdateRate;
static float fixedUpdateDifference;
static float time;
static Timestep timeStep;
static float timeScale;
};
}

View File

@@ -0,0 +1,30 @@
group "Dependencies"
project 'Tracy'
location "tracy"
kind "StaticLib"
staticruntime "on"
warnings 'Off'
includedirs {
"tracy/public/tracy"
}
files {
"tracy/public/tracy/Tracy.hpp",
"tracy/public/TracyClient.cpp"
}
defines {
"TRACY_ENABLE",
"TRACY_ON_DEMAND",
}
filter "configurations:Debug"
runtime "Debug"
symbols "on"
filter "configurations:Release"
runtime "Release"
optimize "on"
group ""

View File

@@ -3,6 +3,8 @@
#include <filesystem>
#include <Tracy.hpp>
namespace Nuake {
Application::Application(const ApplicationSpecification& appSpecification)
@@ -33,8 +35,11 @@ namespace Nuake {
{
while (!m_Window->ShouldClose())
{
ZoneScoped;
for (auto& layer : m_LayerStack)
{
ZoneScopedN("Layer Update");
layer->OnUpdate();
}
@@ -42,9 +47,12 @@ namespace Nuake {
{
for (auto& layer : m_LayerStack)
{
ZoneScopedN("Layer Draw");
layer->OnDraw();
}
}
FrameMark;
}
}
@@ -55,4 +63,4 @@ namespace Nuake {
layer->OnDetach();
}
}
}
}

View File

@@ -17,6 +17,7 @@ namespace Nuake {
virtual void OnDraw() {};
virtual void OnWindowFocused() {};
// TODO: OnEvent
inline const std::string& GetName() const { return m_Name; }

View File

@@ -1,6 +1,6 @@
#include "AudioManager.h"
#include "src/Core/Logger.h"
#include "src/Core/FileSystem.h"
#include "src/FileSystem/FileSystem.h"
#include <soloud.h>
#include "soloud_speech.h"
@@ -11,8 +11,7 @@
namespace Nuake {
AudioManager::AudioManager() :
m_AudioThreadRunning(true)
AudioManager::AudioManager()
{
}
@@ -20,9 +19,6 @@ namespace Nuake {
{
Deinitialize();
m_AudioThreadRunning = false;
m_AudioThread.join();
m_Soloud->deinit();
}
@@ -37,15 +33,6 @@ namespace Nuake {
m_Soloud->init(SoLoud::Soloud::CLIP_ROUNDOFF, SoLoud::Soloud::ALSA);
#endif
if (m_AudioThread.joinable())
{
m_AudioThreadRunning = false;
m_AudioThread.join();
}
m_AudioThreadRunning = true;
m_AudioThread = std::thread(&AudioManager::AudioThreadLoop, this);
Logger::Log("Audio manager initialized", "audio", VERBOSE);
}
@@ -79,9 +66,6 @@ namespace Nuake {
void AudioManager::QueueWavAudio(const AudioRequest& request)
{
// Acquire mutex lock and push to queue
const std::lock_guard<std::mutex> lock(m_AudioQueueMutex);
// Check if file exists and load
const bool fileExists = FileSystem::FileExists(request.audioFile, true);
if (fileExists && !IsWavLoaded(request.audioFile))
@@ -94,9 +78,6 @@ namespace Nuake {
void AudioManager::UpdateVoice(const AudioRequest& request)
{
// Acquire mutex lock
const std::lock_guard<std::mutex> lock(m_AudioQueueMutex);
auto& audioClip = m_ActiveClips[request.audioFile];
if (IsVoiceActive(request.audioFile))
{
@@ -125,8 +106,6 @@ namespace Nuake {
void AudioManager::StopVoice(const std::string& filePath)
{
const std::lock_guard<std::mutex> lock(m_AudioQueueMutex);
if (!IsVoiceActive(filePath))
{
return; // We can't stop a voice that isn't active.
@@ -153,7 +132,7 @@ namespace Nuake {
void AudioManager::LoadWavAudio(const std::string& filePath)
{
const bool STREAMING = true;
const bool STREAMING = false;
if (STREAMING)
{
Ref<SoLoud::WavStream> wavStream = CreateRef<SoLoud::WavStream>();
@@ -166,44 +145,37 @@ namespace Nuake {
wav->load(filePath.c_str());
m_WavSamples[filePath] = wav;
}
}
void AudioManager::AudioThreadLoop()
void AudioManager::AudioUpdate()
{
while(m_AudioThreadRunning)
// Check if we have audio queued
while (!m_AudioQueue.empty())
{
// Acquire mutex lock
const std::lock_guard<std::mutex> lock(m_AudioQueueMutex);
AudioRequest& audioRequest = m_AudioQueue.front();
Ref<SoLoud::AudioSource> audio = m_WavSamples[audioRequest.audioFile];
// Check if we have audio queued
while (!m_AudioQueue.empty())
SoLoud::handle soloudHandle;
if (!audioRequest.spatialized)
{
AudioRequest& audioRequest = m_AudioQueue.front();
Ref<SoLoud::AudioSource> audio = m_WavSamples[audioRequest.audioFile];
SoLoud::handle soloudHandle;
if (!audioRequest.spatialized)
{
soloudHandle = m_Soloud->play(*audio);
m_Soloud->setVolume(soloudHandle, audioRequest.volume);
m_Soloud->setPan(soloudHandle, audioRequest.pan);
}
else
{
const Vector3& position = audioRequest.position;
soloudHandle = m_Soloud->play3d(*audio, position.x, position.y, position.z);
m_Soloud->set3dSourceMinMaxDistance(soloudHandle, audioRequest.MinDistance, audioRequest.MaxDistance);
m_Soloud->set3dSourceAttenuation(soloudHandle, SoLoud::AudioSource::ATTENUATION_MODELS::EXPONENTIAL_DISTANCE, audioRequest.AttenuationFactor);
}
m_Soloud->setRelativePlaySpeed(soloudHandle, audioRequest.speed);
m_Soloud->setLooping(soloudHandle, audioRequest.Loop);
m_ActiveClips[audioRequest.audioFile] = soloudHandle;
m_AudioQueue.pop();
soloudHandle = m_Soloud->play(*audio);
m_Soloud->setVolume(soloudHandle, audioRequest.volume);
m_Soloud->setPan(soloudHandle, audioRequest.pan);
}
else
{
const Vector3& position = audioRequest.position;
soloudHandle = m_Soloud->play3d(*audio, position.x, position.y, position.z);
m_Soloud->set3dSourceMinMaxDistance(soloudHandle, audioRequest.MinDistance, audioRequest.MaxDistance);
m_Soloud->set3dSourceAttenuation(soloudHandle, SoLoud::AudioSource::ATTENUATION_MODELS::EXPONENTIAL_DISTANCE, audioRequest.AttenuationFactor);
}
m_Soloud->setRelativePlaySpeed(soloudHandle, audioRequest.speed);
m_Soloud->setLooping(soloudHandle, audioRequest.Loop);
m_ActiveClips[audioRequest.audioFile] = soloudHandle;
m_AudioQueue.pop();
}
}

View File

@@ -39,10 +39,7 @@ namespace Nuake
Ref<SoLoud::Soloud> m_Soloud;
bool m_AudioThreadRunning;
std::thread m_AudioThread;
std::mutex m_AudioQueueMutex;
std::atomic<bool> m_AudioQueued = { false };
bool m_AudioQueued = false;
std::queue<AudioRequest> m_AudioQueue;
Vector3 m_ListenerPosition;
@@ -87,8 +84,9 @@ namespace Nuake
bool IsVoiceActive(const std::string & voice) const;
void LoadWavAudio(const std::string& filePath);
void AudioUpdate();
private:
void AudioThreadLoop();
void CleanupInactiveVoices();
};

View File

@@ -1,404 +0,0 @@
#include "FileSystem.h"
#include "Engine.h"
#include "OS.h"
#include <GLFW/glfw3.h>
#ifdef NK_WIN
#define GLFW_EXPOSE_NATIVE_WIN32
#include "GLFW/glfw3native.h"
#include <commdlg.h>
#endif
#ifdef NK_LINUX
#include "gtk/gtk.h"
#endif
#include <fstream>
#include <iostream>
#include <ShlObj.h>
namespace Nuake
{
namespace fs = std::filesystem;
std::string FileDialog::OpenFile(const char* filter)
{
std::string filePath;
#ifdef NK_WIN
OPENFILENAMEA ofn;
CHAR szFile[260] = { 0 };
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = glfwGetWin32Window(Engine::GetCurrentWindow()->GetHandle());
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
if (GetOpenFileNameA(&ofn) == TRUE)
{
filePath = std::string(ofn.lpstrFile);
}
#endif
#ifdef NK_LINUX
GtkWidget *dialog;
GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
gint res;
dialog = gtk_file_chooser_dialog_new("Open File",
NULL,
action,
"_Cancel",
GTK_RESPONSE_CANCEL,
"_Open",
GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
if (filter) {
GtkFileFilter *file_filter = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter, "Filter Name");
gtk_file_filter_add_pattern(file_filter, filter);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), file_filter);
}
res = gtk_dialog_run(GTK_DIALOG(dialog));
if (res == GTK_RESPONSE_ACCEPT) {
char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
filePath = filename;
g_free(filename);
}
gtk_widget_destroy(dialog);
#endif
return filePath;
}
std::string FileDialog::SaveFile(const char* filter)
{
#ifdef NK_WIN
OPENFILENAMEA ofn;
CHAR szFile[260] = { 0 };
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = glfwGetWin32Window(Engine::GetCurrentWindow()->GetHandle());
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_OVERWRITEPROMPT;
if (GetSaveFileNameA(&ofn) == TRUE)
{
return ofn.lpstrFile;
}
#endif
#ifdef NK_LINUX
GtkWidget *dialog;
GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SAVE;
gint res;
gtk_init(NULL, NULL);
dialog = gtk_file_chooser_dialog_new("Save File",
NULL,
action,
"_Cancel",
GTK_RESPONSE_CANCEL,
"_Save",
GTK_RESPONSE_ACCEPT,
NULL);
GtkFileFilter *file_filter = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter, filter);
gtk_file_filter_add_pattern(file_filter, "*.*"); // You can customize this pattern
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), file_filter);
res = gtk_dialog_run(GTK_DIALOG(dialog));
if (res == GTK_RESPONSE_ACCEPT)
{
char *filename;
GtkFileChooser *chooser = GTK_FILE_CHOOSER(dialog);
filename = gtk_file_chooser_get_filename(chooser);
std::string result(filename);
g_free(filename);
gtk_widget_destroy(dialog);
return result;
}
else
{
gtk_widget_destroy(dialog);
return std::string();
}
#endif
return std::string();
}
std::string FileDialog::OpenFolder()
{
std::string folderPath;
#ifdef NK_WIN
BROWSEINFOA bi;
CHAR szFolder[260] = { 0 };
ZeroMemory(&bi, sizeof(BROWSEINFO));
bi.lpszTitle = "Select a Folder";
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
bi.hwndOwner = glfwGetWin32Window(Engine::GetCurrentWindow()->GetHandle());
bi.pszDisplayName = szFolder;
LPITEMIDLIST pidl = SHBrowseForFolderA(&bi);
if (pidl != NULL)
{
SHGetPathFromIDListA(pidl, szFolder);
folderPath = std::string(szFolder);
CoTaskMemFree(pidl);
}
#endif
#ifdef NK_LINUX
GtkWidget* dialog;
GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
gint res;
dialog = gtk_file_chooser_dialog_new("Select Folder",
NULL,
action,
"_Cancel",
GTK_RESPONSE_CANCEL,
"_Select",
GTK_RESPONSE_ACCEPT,
NULL);
res = gtk_dialog_run(GTK_DIALOG(dialog));
if (res == GTK_RESPONSE_ACCEPT) {
char* foldername = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
folderPath = foldername;
g_free(foldername);
}
gtk_widget_destroy(dialog);
#endif
return folderPath;
}
std::string FileSystem::Root = "";
Ref<Directory> FileSystem::RootDirectory;
void FileSystem::ScanDirectory(Ref<Directory> directory)
{
for (const auto& entry : std::filesystem::directory_iterator(directory->FullPath))
{
if (entry.is_directory())
{
Ref<Directory> newDir = CreateRef<Directory>();
newDir->FullPath = entry.path().string();
newDir->Name = entry.path().filename().string();
newDir->Parent = directory;
ScanDirectory(newDir);
directory->Directories.push_back(newDir);
}
else if (entry.is_regular_file())
{
std::filesystem::path currentPath = entry.path();
std::string absolutePath = currentPath.string();
std::string name = currentPath.filename().string();
std::string extension = currentPath.extension().string();
Ref<File> newFile = CreateRef<File>(directory, absolutePath, name, extension);
directory->Files.push_back(newFile);
}
}
}
bool FileSystem::DirectoryExists(const std::string& path, bool absolute)
{
const std::string& finalPath = absolute ? path : Root + path;
return std::filesystem::exists(finalPath) && std::filesystem::is_directory(finalPath);
}
bool FileSystem::MakeDirectory(const std::string& path, bool absolute)
{
return std::filesystem::create_directories(absolute ? path : FileSystem::Root + path);
}
bool FileSystem::FileExists(const std::string& path, bool absolute)
{
std::string fullPath = absolute ? path : FileSystem::Root + path;
return std::filesystem::exists(fullPath);
}
void FileSystem::SetRootDirectory(const std::string path)
{
Root = path;
Scan();
}
void FileSystem::Scan()
{
RootDirectory = CreateRef<Directory>(Root);
ScanDirectory(RootDirectory);
}
std::string FileSystem::AbsoluteToRelative(const std::string& path)
{
const fs::path rootPath(Root);
const fs::path absolutePath(path);
return fs::relative(absolutePath, rootPath).generic_string();
}
std::string FileSystem::RelativeToAbsolute(const std::string& path)
{
return Root + path;
}
std::string FileSystem::GetParentPath(const std::string& fullPath)
{
std::filesystem::path pathObj(fullPath);
auto returnvalue = pathObj.parent_path().string();
return returnvalue + "/";
}
std::string FileSystem::ReadFile(const std::string& path, bool absolute)
{
std::string finalPath = path;
if (!absolute)
finalPath = Root + path;
std::ifstream myReadFile(finalPath, std::ios::in | std::ios::binary);
std::string fileContent = "";
std::string allFile = "";
char bom[3];
myReadFile.read(bom, 3);
// Check for UTF-8 BOM (EF BB BF)
if (bom[0] == 0xEF && bom[1] == 0xBB && bom[2] == 0xBF)
{
myReadFile.seekg(3);
}
else
{
myReadFile.seekg(0);
}
// Use a while loop together with the getline() function to read the file line by line
while (getline(myReadFile, fileContent))
{
allFile.append(fileContent + "\n");
}
// Close the file
myReadFile.close();
return allFile;
}
std::ofstream FileSystem::fileWriter;
bool FileSystem::BeginWriteFile(const std::string path, bool absolute)
{
fileWriter = std::ofstream();
fileWriter.open(absolute ? path : FileSystem::Root + path);
return false;
}
bool FileSystem::WriteLine(const std::string line)
{
fileWriter << line.c_str();
return true;
}
void FileSystem::EndWriteFile()
{
fileWriter.close();
}
uintmax_t FileSystem::DeleteFileFromPath(const std::string& path)
{
return std::remove(path.c_str());
}
uintmax_t FileSystem::DeleteFolder(const std::string& path)
{
return std::filesystem::remove_all(path.c_str());
}
std::string FileSystem::GetConfigFolderPath()
{
std::string subFolderPath = OS::GetConfigFolderPath().append("/Nuake/");
if (!DirectoryExists(subFolderPath, true))
{
MakeDirectory(subFolderPath);
}
return subFolderPath;
}
Ref<Directory> FileSystem::GetFileTree()
{
return RootDirectory;
}
Ref<File> FileSystem::GetFile(const std::string& path)
{
// Note, Might be broken on other platforms.
auto splits = String::Split(path, '/');
int currentDepth = -1;
std::string currentDirName = ".";
Ref<Directory> currentDirComparator = RootDirectory;
while (currentDirName == currentDirComparator->Name)
{
currentDepth++;
currentDirName = splits[currentDepth];
// Find next directory
for (auto& d : currentDirComparator->Directories)
{
if (d->Name == currentDirName)
{
currentDirComparator = d;
}
}
// Find in files if can't find in directories.
for (auto& f : currentDirComparator->Files)
{
if (f->GetName() == currentDirName)
{
return f;
}
}
}
return nullptr;
}
std::string FileSystem::GetFileNameFromPath(const std::string& path)
{
const auto& split = String::Split(path, '/');
return String::Split(split[split.size() - 1], '.')[0];
}
Directory::Directory(const std::string& path)
{
Files = std::vector<Ref<File>>();
Directories = std::vector<Ref<Directory>>();
Name = FileSystem::AbsoluteToRelative(path);
FullPath = path;
}
}

View File

@@ -1,248 +0,0 @@
#pragma once
#include "Core.h"
#include "String.h"
#include <string>
#include <filesystem>
#include <iostream>
#include <fstream>
namespace Nuake
{
class FileDialog
{
public:
static std::string OpenFile(const char* filter);
static std::string SaveFile(const char* filter);
static std::string OpenFolder();
};
class Directory;
class File;
class FileSystem
{
public:
static std::string Root;
static Ref<Directory> RootDirectory;
static void SetRootDirectory(const std::string path);
static void Scan();
static std::string AbsoluteToRelative(const std::string& path);
static std::string RelativeToAbsolute(const std::string& path);
static std::string GetParentPath(const std::string& fullPath);
static Ref<Directory> GetFileTree();
static Ref<File> GetFile(const std::string& path);
static std::string GetFileNameFromPath(const std::string& path);
static void ScanDirectory(Ref<Directory> directory);
static void GetDirectories();
static bool MakeDirectory(const std::string& path, bool absolute = false);
static bool DirectoryExists(const std::string& path, bool absolute = false);
static bool FileExists(const std::string& path, bool absolute = false);
static std::string ReadFile(const std::string& path, bool absolute = false);
static std::ofstream fileWriter;
static bool BeginWriteFile(const std::string path, bool absolute = false);
static bool WriteLine(const std::string line);
static void EndWriteFile();
static uintmax_t DeleteFileFromPath(const std::string& path);
static uintmax_t DeleteFolder(const std::string& path);
static std::string GetConfigFolderPath();
};
enum class FileType
{
Unkown,
Image,
Material,
Mesh,
Script,
NetScript,
Project,
Prefab,
Scene,
Wad,
Map,
Assembly,
Solution,
Audio
};
class File
{
private:
std::string Type;
std::string Name;
std::string RelativePath;
std::string AbsolutePath;
Ref<Directory> Parent;
public:
std::string GetExtension() const { return Type; }
std::string GetName() const { return Name; }
std::string GetRelativePath() const { return RelativePath; }
std::string GetAbsolutePath() const { return AbsolutePath; }
Ref<Directory> GetParent() const { return Parent; }
FileType GetFileType() const
{
std::string ext = GetExtension();
if (ext == ".png" || ext == ".jpg")
{
return FileType::Image;
}
if (ext == ".ogg" || ext == ".wav")
{
return FileType::Audio;
}
if (ext == ".material")
{
return FileType::Material;
}
if (ext == ".scene")
{
return FileType::Scene;
}
if (ext == ".project")
{
return FileType::Project;
}
if (ext == ".script")
{
return FileType::Script;
}
if (ext == ".prefab")
{
return FileType::Prefab;
}
if (ext == ".wad")
{
return FileType::Wad;
}
if (ext == ".map")
{
return FileType::Map;
}
if (ext == ".dll")
{
return FileType::Assembly;
}
if (ext == ".cs")
{
return FileType::NetScript;
}
if (ext == ".sln")
{
return FileType::Solution;
}
if (ext == ".mesh")
{
return FileType::Mesh;
}
return FileType::Unkown;
}
std::string GetFileTypeAsString() const
{
std::string ext = GetExtension();
if (ext == ".png" || ext == "jpg")
{
return "Image";
}
if (ext == ".material")
{
return "Material";
}
if (ext == ".scene")
{
return "Scene";
}
if (ext == ".project")
{
return "Project";
}
if (ext == ".script")
{
return "Script";
}
if (ext == ".prefab")
{
return "Prefab";
}
if (ext == ".wad")
{
return "Wad";
}
if (ext == ".map")
{
return "Map";
}
if (ext == ".map")
{
return "Assembly";
}
if (ext == ".cs")
{
return "C# Script";
}
return "File";
}
std::string Read()
{
return FileSystem::ReadFile(AbsolutePath, true);
}
bool IsValid()
{
return FileSystem::FileExists(AbsolutePath, true);
}
File(Ref<Directory> parentDir, const std::string& absolutePath, const std::string& name, const std::string& type)
{
AbsolutePath = absolutePath;
Parent = parentDir;
RelativePath = FileSystem::AbsoluteToRelative(absolutePath);
Name = name;
Type = type;
}
};
class Directory
{
public:
std::string Name;
std::string FullPath;
Ref<Directory> Parent;
std::vector<Ref<Directory>> Directories;
std::vector<Ref<File>> Files;
Directory(const std::string& path);
Directory() = default;
~Directory() = default;
};
}

View File

@@ -3,6 +3,7 @@
#include <imgui/imgui_impl_glfw.h>
#include <GLFW/glfw3.h>
#include <Tracy.hpp>
namespace Nuake
{
@@ -167,6 +168,8 @@ namespace Nuake
void Input::Update()
{
ZoneScoped;
// Reset all input to false.
for (auto& k : m_Keys)
{

View File

@@ -65,7 +65,7 @@ namespace Nuake
TAB = 258,
BACKSPACE = 259,
INSERT = 260,
DELETE = 261,
DELETE_KEY = 261,
RIGHT = 262,
LEFT = 263,
DOWN = 264,

View File

@@ -1,7 +1,9 @@
#include "OS.h"
#include "src/Window.h"
#include "Engine.h"
#include "src/Resource/Project.h"
#include "src/Window.h"
#include "src/Core/String.h"
#ifdef NK_WIN
#define GLFW_EXPOSE_NATIVE_WIN32
@@ -18,13 +20,17 @@
#include <X11/Xlib.h>
#endif
#include "src/FileSystem/File.h"
#include "src/FileSystem/Directory.h"
#include "GLFW/glfw3.h"
#include "GLFW/glfw3native.h"
#include "imgui/imgui.h"
#include <chrono>
#include <imgui/imgui.h>
#include <Subprocess.hpp>
#include <codecvt>
#include <filesystem>
#include <Subprocess.hpp>
namespace Nuake {

View File

@@ -1,7 +1,7 @@
#pragma once
#include <string>
#include "FileSystem.h"
#include "src/FileSystem/FileSystem.h"
namespace Nuake
{

View File

@@ -1,8 +0,0 @@
#pragma once
namespace Nuake {
class ResourceManager
{
};
}

View File

@@ -0,0 +1,3 @@
#include "Directory.h"
using namespace Nuake;

View File

@@ -0,0 +1,26 @@
#pragma once
#include "src/Core/Core.h"
namespace Nuake
{
class File;
class Directory
{
public:
std::string Name;
std::string FullPath;
Ref<Directory> Parent;
std::vector<Ref<Directory>> Directories;
std::vector<Ref<File>> Files;
public:
Directory(const std::string& path);
Directory() = default;
~Directory() = default;
std::string GetName() const;
std::string GetFullPath() const;
};
}

View File

@@ -0,0 +1,149 @@
#include "File.h"
#include "src/FileSystem/FileSystem.h"
using namespace Nuake;
File::File(Ref<Directory> parentDir, const std::string& fullPath, const std::string& fileName, const std::string& fileType) :
name(fileName),
type(fileType),
absolutePath(fullPath),
relativePath(FileSystem::AbsoluteToRelative(fullPath)),
modified(false)
{ }
FileType File::GetFileType() const
{
const std::string ext = GetExtension();
if (ext == ".png" || ext == ".jpg")
{
return FileType::Image;
}
if (ext == ".ogg" || ext == ".wav")
{
return FileType::Audio;
}
if (ext == ".material")
{
return FileType::Material;
}
if (ext == ".scene")
{
return FileType::Scene;
}
if (ext == ".project")
{
return FileType::Project;
}
if (ext == ".script")
{
return FileType::Script;
}
if (ext == ".prefab")
{
return FileType::Prefab;
}
if (ext == ".wad")
{
return FileType::Wad;
}
if (ext == ".map")
{
return FileType::Map;
}
if (ext == ".dll")
{
return FileType::Assembly;
}
if (ext == ".cs")
{
return FileType::NetScript;
}
if (ext == ".sln")
{
return FileType::Solution;
}
if (ext == ".mesh")
{
return FileType::Mesh;
}
return FileType::Unkown;
}
std::string File::GetFileTypeAsString() const
{
std::string ext = GetExtension();
if (ext == ".png" || ext == "jpg")
{
return "Image";
}
if (ext == ".material")
{
return "Material";
}
if (ext == ".scene")
{
return "Scene";
}
if (ext == ".project")
{
return "Project";
}
if (ext == ".script")
{
return "Script";
}
if (ext == ".prefab")
{
return "Prefab";
}
if (ext == ".wad")
{
return "Wad";
}
if (ext == ".map")
{
return "Map";
}
if (ext == ".map")
{
return "Assembly";
}
if (ext == ".cs")
{
return "C# Script";
}
return "File";
}
std::string File::Read() const
{
return FileSystem::ReadFile(absolutePath, true);
}
bool File::Exist() const
{
return FileSystem::FileExists(absolutePath, true);
}

View File

@@ -0,0 +1,43 @@
#pragma once
#include "src/Core/Core.h"
#include "FileTypes.h"
namespace Nuake
{
class Directory;
class File
{
public:
File(Ref<Directory> parentDir, const std::string& absolutePath, const std::string& name, const std::string& type);
~File() = default;
public:
std::string GetName() const { return name; }
std::string GetExtension() const { return type; }
std::string GetRelativePath() const { return relativePath; }
std::string GetAbsolutePath() const { return absolutePath; }
Ref<Directory> GetParent() const { return parent; }
bool GetHasBeenModified() const { return modified; }
void SetHasBeenModified(bool value) { modified = value; }
FileType GetFileType() const;
std::string GetFileTypeAsString() const;
std::string Read() const;
bool Exist() const;
private:
std::string type;
std::string name;
std::string relativePath;
std::string absolutePath;
bool modified;
Ref<Directory> parent;
};
}

View File

@@ -0,0 +1,189 @@
#include "FileDialog.h"
#include "Engine.h"
#include <GLFW/glfw3.h>
// Platform specific stuff
// Windows
#ifdef NK_WIN
#define GLFW_EXPOSE_NATIVE_WIN32
#include "GLFW/glfw3native.h"
#include <commdlg.h>
#include <ShlObj.h>
#endif
// Linux
#ifdef NK_LINUX
#include "gtk/gtk.h"
#endif
using namespace Nuake;
std::string FileDialog::OpenFile(const std::string_view& filter)
{
std::string filePath;
#ifdef NK_WIN
OPENFILENAMEA ofn;
CHAR szFile[260] = { 0 };
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = glfwGetWin32Window(Engine::GetCurrentWindow()->GetHandle());
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = filter.data();
ofn.nFilterIndex = 1;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
if (GetOpenFileNameA(&ofn) == TRUE)
{
filePath = std::string(ofn.lpstrFile);
}
#endif
#ifdef NK_LINUX
GtkWidget *dialog;
GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
gint res;
dialog = gtk_file_chooser_dialog_new("Open File",
NULL,
action,
"_Cancel",
GTK_RESPONSE_CANCEL,
"_Open",
GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
if (filter) {
GtkFileFilter *file_filter = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter, "Filter Name");
gtk_file_filter_add_pattern(file_filter, filter);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), file_filter);
}
res = gtk_dialog_run(GTK_DIALOG(dialog));
if (res == GTK_RESPONSE_ACCEPT) {
char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
filePath = filename;
g_free(filename);
}
gtk_widget_destroy(dialog);
#endif
return filePath;
}
std::string FileDialog::SaveFile(const std::string_view& filter)
{
#ifdef NK_WIN
OPENFILENAMEA ofn;
CHAR szFile[260] = { 0 };
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = glfwGetWin32Window(Engine::GetCurrentWindow()->GetHandle());
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = filter.data();
ofn.nFilterIndex = 1;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_OVERWRITEPROMPT;
if (GetSaveFileNameA(&ofn) == TRUE)
{
return ofn.lpstrFile;
}
#endif
#ifdef NK_LINUX
GtkWidget *dialog;
GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SAVE;
gint res;
gtk_init(NULL, NULL);
dialog = gtk_file_chooser_dialog_new("Save File",
NULL,
action,
"_Cancel",
GTK_RESPONSE_CANCEL,
"_Save",
GTK_RESPONSE_ACCEPT,
NULL);
GtkFileFilter *file_filter = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter, filter);
gtk_file_filter_add_pattern(file_filter, "*.*"); // You can customize this pattern
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), file_filter);
res = gtk_dialog_run(GTK_DIALOG(dialog));
if (res == GTK_RESPONSE_ACCEPT)
{
char *filename;
GtkFileChooser *chooser = GTK_FILE_CHOOSER(dialog);
filename = gtk_file_chooser_get_filename(chooser);
std::string result(filename);
g_free(filename);
gtk_widget_destroy(dialog);
return result;
}
else
{
gtk_widget_destroy(dialog);
return std::string();
}
#endif
return std::string();
}
std::string FileDialog::OpenFolder()
{
std::string folderPath;
#ifdef NK_WIN
BROWSEINFOA bi;
CHAR szFolder[260] = { 0 };
ZeroMemory(&bi, sizeof(BROWSEINFO));
bi.lpszTitle = "Select a Folder";
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
bi.hwndOwner = glfwGetWin32Window(Engine::GetCurrentWindow()->GetHandle());
bi.pszDisplayName = szFolder;
LPITEMIDLIST pidl = SHBrowseForFolderA(&bi);
if (pidl != NULL)
{
SHGetPathFromIDListA(pidl, szFolder);
folderPath = std::string(szFolder);
CoTaskMemFree(pidl);
}
#endif
#ifdef NK_LINUX
GtkWidget* dialog;
GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
gint res;
dialog = gtk_file_chooser_dialog_new("Select Folder",
NULL,
action,
"_Cancel",
GTK_RESPONSE_CANCEL,
"_Select",
GTK_RESPONSE_ACCEPT,
NULL);
res = gtk_dialog_run(GTK_DIALOG(dialog));
if (res == GTK_RESPONSE_ACCEPT) {
char* foldername = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
folderPath = foldername;
g_free(foldername);
}
gtk_widget_destroy(dialog);
#endif
return folderPath;
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include "src/Core/Core.h"
namespace Nuake
{
class FileDialog
{
public:
static std::string OpenFile(const std::string_view& filter);
static std::string SaveFile(const std::string_view& filter);
static std::string OpenFolder();
};
}

View File

@@ -0,0 +1,291 @@
#include "FileSystem.h"
#include "Engine.h"
#include "src/Core/OS.h"
#include "src/Core/String.h"
#include "Directory.h"
#include "File.h"
#include "filewatch/FileWatch.hpp"
#include <filesystem>
using namespace Nuake;
std::string FileSystem::Root = "";
Ref<Directory> FileSystem::RootDirectory;
Ref<filewatch::FileWatch<std::string>> FileSystem::RootFileWatch;
void FileSystem::ScanDirectory(Ref<Directory> directory)
{
for (const auto& entry : std::filesystem::directory_iterator(directory->FullPath))
{
if (entry.is_directory())
{
Ref<Directory> newDir = CreateRef<Directory>();
newDir->FullPath = entry.path().string();
newDir->Name = entry.path().filename().string();
newDir->Parent = directory;
ScanDirectory(newDir);
directory->Directories.push_back(newDir);
}
else if (entry.is_regular_file())
{
std::filesystem::path currentPath = entry.path();
std::string absolutePath = currentPath.string();
std::string name = currentPath.filename().string();
std::string extension = currentPath.extension().string();
Ref<File> newFile = CreateRef<File>(directory, absolutePath, name, extension);
directory->Files.push_back(newFile);
}
}
}
bool FileSystem::DirectoryExists(const std::string& path, bool absolute)
{
const std::string& finalPath = absolute ? path : Root + path;
return std::filesystem::exists(finalPath) && std::filesystem::is_directory(finalPath);
}
bool FileSystem::MakeDirectory(const std::string& path, bool absolute)
{
return std::filesystem::create_directories(absolute ? path : FileSystem::Root + path);
}
bool FileSystem::FileExists(const std::string& path, bool absolute)
{
std::string fullPath = absolute ? path : FileSystem::Root + path;
return std::filesystem::exists(fullPath) && std::filesystem::is_regular_file(fullPath);
}
void FileSystem::SetRootDirectory(const std::string path)
{
Root = path;
RootFileWatch = CreateRef<filewatch::FileWatch<std::string>>(
path, [&](const std::string& path, const filewatch::Event& event)
{
std::string normalizedPath = String::ReplaceSlash(path);
// Detect if its a file and not a folder.
if (!FileSystem::FileExists(normalizedPath))
{
return;
}
if(Ref<File> file = GetFile(normalizedPath); file)
{
if (file->GetFileType() == FileType::Unkown)
{
return;
}
Logger::Log(normalizedPath + " event: " + filewatch::event_to_string(event), "filewatcher", VERBOSE);
if (event == filewatch::Event::modified)
{
file->SetHasBeenModified(true);
}
}
}
);
Scan();
}
void FileSystem::Scan()
{
RootDirectory = CreateRef<Directory>(Root);
ScanDirectory(RootDirectory);
}
std::string FileSystem::AbsoluteToRelative(const std::string& path)
{
const std::filesystem::path rootPath(Root);
const std::filesystem::path absolutePath(path);
return std::filesystem::relative(absolutePath, rootPath).generic_string();
}
std::string FileSystem::RelativeToAbsolute(const std::string& path)
{
return Root + path;
}
std::string FileSystem::GetParentPath(const std::string& fullPath)
{
std::filesystem::path pathObj(fullPath);
auto returnvalue = pathObj.parent_path().string();
return returnvalue + "/";
}
std::string FileSystem::ReadFile(const std::string& path, bool absolute)
{
std::string finalPath = path;
if (!absolute)
finalPath = Root + path;
std::ifstream myReadFile(finalPath, std::ios::in | std::ios::binary);
std::string fileContent = "";
std::string allFile = "";
char bom[3];
myReadFile.read(bom, 3);
// Check for UTF-8 BOM (EF BB BF)
if (bom[0] == 0xEF && bom[1] == 0xBB && bom[2] == 0xBF)
{
myReadFile.seekg(3);
}
else
{
myReadFile.seekg(0);
}
// Use a while loop together with the getline() function to read the file line by line
while (getline(myReadFile, fileContent))
{
allFile.append(fileContent + "\n");
}
// Close the file
myReadFile.close();
return allFile;
}
std::ofstream FileSystem::fileWriter;
bool FileSystem::BeginWriteFile(const std::string path, bool absolute)
{
fileWriter = std::ofstream();
fileWriter.open(absolute ? path : FileSystem::Root + path);
return false;
}
bool FileSystem::WriteLine(const std::string line)
{
fileWriter << line.c_str();
return true;
}
void FileSystem::EndWriteFile()
{
fileWriter.close();
}
uintmax_t FileSystem::DeleteFileFromPath(const std::string& path)
{
return std::remove(path.c_str());
}
uintmax_t FileSystem::DeleteFolder(const std::string& path)
{
return std::filesystem::remove_all(path.c_str());
}
std::string FileSystem::GetConfigFolderPath()
{
std::string subFolderPath = OS::GetConfigFolderPath().append("/Nuake/");
if (!DirectoryExists(subFolderPath, true))
{
MakeDirectory(subFolderPath);
}
return subFolderPath;
}
Ref<Directory> FileSystem::GetFileTree()
{
return RootDirectory;
}
Ref<File> FileSystem::GetFile(const std::string& path)
{
// Note, Might be broken on other platforms.
auto splits = String::Split(path, '/');
int currentDepth = -1;
std::string currentDirName = ".";
Ref<Directory> currentDirComparator = RootDirectory;
while (currentDirName == currentDirComparator->Name)
{
currentDepth++;
currentDirName = splits[currentDepth];
// Find next directory
for (auto& d : currentDirComparator->Directories)
{
if (d->Name == currentDirName)
{
currentDirComparator = d;
}
}
// Find in files if can't find in directories.
for (auto& f : currentDirComparator->Files)
{
if (f->GetName() == currentDirName)
{
return f;
}
}
}
return nullptr;
}
Ref<Directory> FileSystem::GetDirectory(const std::string& path)
{
// Note, Might be broken on other platforms.
auto splits = String::Split(path, '/');
int currentDepth = -1;
std::string currentDirName = ".";
Ref<Directory> currentDirComparator = RootDirectory;
while (currentDirName == currentDirComparator->Name)
{
currentDepth++;
if (currentDepth >= splits.size())
{
return currentDirComparator;
}
currentDirName = splits[currentDepth];
// Find next directory
for (auto& d : currentDirComparator->Directories)
{
if (d->Name == currentDirName)
{
currentDirComparator = d;
continue;
}
}
}
return currentDirComparator;
}
std::string FileSystem::GetFileNameFromPath(const std::string& path)
{
const auto& split = String::Split(path, '/');
return String::Split(split[split.size() - 1], '.')[0];
}
Directory::Directory(const std::string& path)
{
Files = std::vector<Ref<File>>();
Directories = std::vector<Ref<Directory>>();
Name = FileSystem::AbsoluteToRelative(path);
FullPath = path;
}
std::string Directory::GetName() const
{
return Name;
}

View File

@@ -0,0 +1,49 @@
#pragma once
#include "src/Core/Core.h"
namespace filewatch
{
template<typename T>
class FileWatch;
}
namespace Nuake
{
class Directory;
class File;
class FileSystem
{
public:
static std::string Root;
static Ref<Directory> RootDirectory;
static Ref<filewatch::FileWatch<std::string>> RootFileWatch;
static void SetRootDirectory(const std::string path);
static void Scan();
static std::string AbsoluteToRelative(const std::string& path);
static std::string RelativeToAbsolute(const std::string& path);
static std::string GetParentPath(const std::string& fullPath);
static Ref<Directory> GetFileTree();
static Ref<File> GetFile(const std::string& path);
static Ref<Directory> GetDirectory(const std::string& path);
static std::string GetFileNameFromPath(const std::string& path);
static void ScanDirectory(Ref<Directory> directory);
static void GetDirectories();
static bool MakeDirectory(const std::string& path, bool absolute = false);
static bool DirectoryExists(const std::string& path, bool absolute = false);
static bool FileExists(const std::string& path, bool absolute = false);
static std::string ReadFile(const std::string& path, bool absolute = false);
static std::ofstream fileWriter;
static bool BeginWriteFile(const std::string path, bool absolute = false);
static bool WriteLine(const std::string line);
static void EndWriteFile();
static uintmax_t DeleteFileFromPath(const std::string& path);
static uintmax_t DeleteFolder(const std::string& path);
static std::string GetConfigFolderPath();
};
}

View File

@@ -0,0 +1,22 @@
#pragma once
namespace Nuake
{
enum class FileType
{
Unkown,
Image,
Material,
Mesh,
Script,
NetScript,
Project,
Prefab,
Scene,
Wad,
Map,
Assembly,
Solution,
Audio
};
}

View File

@@ -0,0 +1,11 @@
#pragma once
namespace Nuake
{
class Modules
{
public:
static void StartupModules();
static void ShutdownModules();
};
}

View File

@@ -0,0 +1,74 @@
-- Function to scan the "Modules" directory and load all module definitions
function loadModules(modulesDir)
local modules = {}
-- Get all folders in the Modules directory
local dirs = os.matchdirs(path.join(modulesDir, "*"))
for _, dir in ipairs(dirs) do
local moduleName = path.getname(dir)
local moduleFile = path.join(dir, "Module.lua")
if os.isfile(moduleFile) then
-- Load the module data
local moduleData = dofile(moduleFile)
-- Set the module name from the directory
moduleData._name = moduleName
print("Found module \"".. moduleData.name .."\" (".. moduleData._name ..")")
table.insert(modules, moduleData)
end
end
return modules
end
-- Function to generate the final C++ file with startup and shutdown functions
function generateModulesFile(modules, outputFilePath, sourceDir)
local outputFile = io.open(outputFilePath, "w")
if not outputFile then
print("Error: Could not write to file ".. outputFilePath)
return
end
outputFile:write("// Auto-generated modules management file\n")
outputFile:write("#include \"Modules.h\"\n\n")
-- Include module header files
for _, module in ipairs(modules) do
outputFile:write("#include \"".. module._name .."/".. module.module_header .."\"\n")
end
outputFile:write("\n")
outputFile:write("#include \"src/Core/Logger.h\"\n\n")
-- Generate StartupModules function
outputFile:write("void Nuake::Modules::StartupModules()\n{\n")
for _, module in ipairs(modules) do
outputFile:write(" Logger::Log(\"Starting ".. module._name .."\", \"modules\");\n")
outputFile:write(" Module_".. module._name .."_Startup();\n")
end
outputFile:write("}\n\n")
-- Generate ShutdownModules function
outputFile:write("void Nuake::Modules::ShutdownModules()\n{\n")
for _, module in ipairs(modules) do
outputFile:write(" Logger::Log(\"Shutting down ".. module._name .."\", \"modules\");\n")
outputFile:write(" Module_".. module._name .."_Shutdown();\n")
end
outputFile:write("}\n")
outputFile:close()
local sources = {}
for _, module in ipairs(modules) do
table.insert(sources, sourceDir .. "/" .. module._name .. "/" .. module.module_header)
for _, v in ipairs(module.sources) do
table.insert(sources, sourceDir .. "/" .. module._name .. "/" .. v)
end
end
return sources
end

View File

@@ -4,7 +4,8 @@
#include "src/Core/Core.h"
#include "src/Core/Logger.h"
#include "src/Core/Maths.h"
#include <src/Physics/PhysicsShapes.h>
#include "src/Resource/Project.h"
#include "src/Physics/PhysicsShapes.h"
#include "src/Scene/Components/TransformComponent.h"
#include "src/Scene/Components/CharacterControllerComponent.h"
@@ -352,6 +353,12 @@ namespace Nuake
layer = Layers::MOVING;
}
if (rb->GetForceKinematic())
{
motionType = JPH::EMotionType::Kinematic;
layer = Layers::MOVING;
}
const std::string name = rb->GetEntity().GetComponent<NameComponent>().Name;
if (rb->IsTrigger())
{
@@ -400,28 +407,15 @@ namespace Nuake
bodySettings.mMassPropertiesOverride.mMass = mass;
}
if (rb->GetEntity().GetID() == 0)
if (int entityId = rb->GetEntity().GetHandle(); rb->GetEntity().IsValid())
{
Logger::Log("Entity with ID 0 detected. Name: " + rb->GetEntity().GetComponent<NameComponent>().Name, "DEBUG");
bodySettings.mUserData = rb->GetEntity().GetHandle();
// Create the actual rigid body
JPH::BodyID body = _JoltBodyInterface->CreateAndAddBody(bodySettings, JPH::EActivation::Activate); // Note that if we run out of bodies this can return nullptr
uint32_t bodyIndex = (uint32_t)body.GetIndexAndSequenceNumber();
_registeredBodies.push_back(bodyIndex);
}
int entityId = rb->GetEntity().GetHandle();
if (entityId == 0)
{
Logger::Log("ERROR");
}
bodySettings.mUserData = entityId;
// Create the actual rigid body
JPH::BodyID body = _JoltBodyInterface->CreateAndAddBody(bodySettings, JPH::EActivation::Activate); // Note that if we run out of bodies this can return nullptr
uint32_t bodyIndex = (uint32_t)body.GetIndexAndSequenceNumber();
_registeredBodies.push_back(bodyIndex);
}
void DynamicWorld::AddGhostbody(Ref<GhostObject> gb)
{
}
void DynamicWorld::AddCharacterController(Ref<CharacterController> cc)
@@ -482,6 +476,35 @@ namespace Nuake
return false;
}
Vector3 DynamicWorld::GetCharacterGroundVelocity(const Entity& entity)
{
const uint32_t entityHandle = entity.GetHandle();
if (_registeredCharacters.find(entityHandle) != _registeredCharacters.end())
{
auto& characterController = _registeredCharacters[entityHandle].Character;
characterController->UpdateGroundVelocity();
const auto groundVelocity = characterController->GetGroundVelocity();
return Vector3(groundVelocity.GetX(), groundVelocity.GetY(), groundVelocity.GetZ());
}
return { 0, 0, 0 };
}
Vector3 DynamicWorld::GetCharacterGroundNormal(const Entity& entity)
{
const uint32_t entityHandle = entity.GetHandle();
if (_registeredCharacters.find(entityHandle) != _registeredCharacters.end())
{
auto& characterController = _registeredCharacters[entityHandle].Character;
const auto groundNormal = characterController->GetGroundNormal();
return Vector3(groundNormal.GetX(), groundNormal.GetY(), groundNormal.GetZ());
}
return { 0, 0, 0 };
}
void DynamicWorld::SetBodyPosition(const Entity& entity, const Vector3& position, const Quat& rotation)
{
const auto& bodyInterface = _JoltPhysicsSystem->GetBodyInterface();
@@ -501,7 +524,21 @@ namespace Nuake
if (newPosition != currentPosition || currentRotation != newRotation)
{
std::string name = entity.GetComponent<NameComponent>().Name;
_JoltBodyInterface->SetPositionAndRotation(bodyId, newPosition, newRotation, JPH::EActivation::DontActivate);
JPH::EMotionType bodyType = _JoltBodyInterface->GetMotionType(bodyId);
switch (bodyType)
{
case JPH::EMotionType::Kinematic:
{
_JoltBodyInterface->MoveKinematic(bodyId, newPosition, newRotation, Engine::GetFixedTimeStep());
break;
}
case JPH::EMotionType::Static:
{
_JoltBodyInterface->SetPositionAndRotation(bodyId, newPosition, newRotation, JPH::EActivation::DontActivate);
break;
}
}
}
}
}
@@ -517,7 +554,7 @@ namespace Nuake
}
}
std::vector<RaycastResult> DynamicWorld::Raycast(const Vector3& from, const Vector3& to)
std::vector<ShapeCastResult> DynamicWorld::Raycast(const Vector3& from, const Vector3& to)
{
// Create jolt ray
const auto& fromJolt = JPH::Vec3(from.x, from.y, from.z);
@@ -529,22 +566,24 @@ namespace Nuake
_JoltPhysicsSystem->GetNarrowPhaseQuery().CastRay(ray, JPH::RayCastSettings(), collector);
// Fetch results
std::vector<RaycastResult> raycastResults;
std::vector<ShapeCastResult> raycastResults;
if (collector.HadHit())
{
int num_hits = (int)collector.mHits.size();
JPH::BroadPhaseCastResult* results = collector.mHits.data();
// Format result
for (int i = 0; i < num_hits; ++i)
{
const float hitFraction = results[i].mFraction;
const JPH::Vec3& hitPosition = ray.GetPointOnRay(results[i].mFraction);
RaycastResult result
auto bodyId = static_cast<JPH::BodyID>(results[i].mBodyID);
auto layer = _JoltBodyInterface->GetObjectLayer(bodyId);
ShapeCastResult result
{
Vector3(hitPosition.GetX(), hitPosition.GetY(), hitPosition.GetZ()),
hitFraction
hitFraction,
Vector3(0, 0, 0),
layer
};
raycastResults.push_back(std::move(result));
@@ -621,7 +660,7 @@ namespace Nuake
continue;
}
JPH::Vec3 position = bodyInterface.GetCenterOfMassPosition(bodyId);
JPH::Vec3 position = bodyInterface.GetPosition(bodyId);
JPH::Vec3 velocity = bodyInterface.GetLinearVelocity(bodyId);
JPH::Mat44 joltTransform = bodyInterface.GetWorldTransform(bodyId);
const auto bodyRotation = bodyInterface.GetRotation(bodyId);
@@ -761,6 +800,8 @@ namespace Nuake
const auto& LayerFilter = _JoltPhysicsSystem->GetDefaultLayerFilter(Layers::CHARACTER);
const auto& joltGravity = _JoltPhysicsSystem->GetGravity();
auto& tempAllocatorPtr = *(joltTempAllocator);
c.second.Character->UpdateGroundVelocity();
if (characterController->AutoStepping)
{
// Create update settings from character controller
@@ -769,7 +810,7 @@ namespace Nuake
joltUpdateSettings.mWalkStairsStepUp = CreateJoltVec3(characterController->StepUp);
joltUpdateSettings.mWalkStairsStepForwardTest = characterController->StepDistance;
joltUpdateSettings.mWalkStairsMinStepForward = characterController->StepMinDistance;
c.second.Character->ExtendedUpdate(ts, joltGravity, joltUpdateSettings, broadPhaseLayerFilter, LayerFilter, { }, { }, tempAllocatorPtr);
}
else
@@ -868,7 +909,7 @@ namespace Nuake
_CollisionCallbacks.push_back(std::move(data));
}
const std::vector<CollisionData>& DynamicWorld::GetCollisionsData()
const std::vector<CollisionData> DynamicWorld::GetCollisionsData()
{
std::scoped_lock<std::mutex> lock(_CollisionCallbackMutex);
return _CollisionCallbacks;

View File

@@ -7,7 +7,6 @@
#include <map>
#include "RaycastResult.h"
#include <src/Physics/GhostObject.h>
#include "CharacterController.h"
#include "CollisionData.h"
@@ -72,9 +71,11 @@ namespace Nuake
void SetGravity(const Vector3& g);
void AddRigidbody(Ref<RigidBody> rb);
void AddGhostbody(Ref<GhostObject> gb);
void AddCharacterController(Ref<CharacterController> cc);
bool IsCharacterGrounded(const Entity& entity);
Vector3 GetCharacterGroundVelocity(const Entity& entity);
Vector3 GetCharacterGroundNormal(const Entity& entity);
void SetCharacterControllerPosition(const Entity& entity, const Vector3& position);
void SetBodyPosition(const Entity& entity, const Vector3& position, const Quat& rotation);
@@ -83,7 +84,7 @@ namespace Nuake
void MoveAndSlideCharacterController(const Entity& entity, const Vector3& velocity);
void AddForceToRigidBody(Entity& entity, const Vector3& force);
std::vector<RaycastResult> Raycast(const Vector3& from, const Vector3& to);
std::vector<ShapeCastResult> Raycast(const Vector3& from, const Vector3& to);
std::vector<ShapeCastResult> CastShape(const Vector3& from, const Vector3& to, const Ref<PhysicShape>& shape);
void StepSimulation(Timestep ts);
void Clear();
@@ -91,7 +92,7 @@ namespace Nuake
void ClearCollisionData();
void RegisterCollisionCallback(const CollisionData& data);
const std::vector<CollisionData>& GetCollisionsData();
const std::vector<CollisionData> GetCollisionsData();
private:
JPH::Ref<JPH::Shape> GetJoltShape(const Ref<PhysicShape> shape);
void SyncEntitiesTranforms();

View File

@@ -1,46 +0,0 @@
#include "GhostObject.h"
#include "src/Physics/PhysicsManager.h"
namespace Nuake
{
GhostObject::GhostObject(Vector3 position, Ref<Physics::PhysicShape> shape)
{
m_OverlappingEntities = std::vector<Entity>();
}
int GhostObject::OverlappingCount()
{
return 0;
}
void GhostObject::ClearOverlappingList()
{
m_OverlappingEntities.clear();
}
void GhostObject::SetEntityID(Entity ent)
{
}
void GhostObject::ScanOverlap()
{
ClearOverlappingList();
for (int i = 0; i < OverlappingCount(); i++)
{
int index =0;
if (index == -1)
continue;
Entity handle = Engine::GetCurrentScene()->GetEntity(index);
m_OverlappingEntities.push_back(handle);
}
}
std::vector<Entity> GhostObject::GetOverlappingEntities()
{
return m_OverlappingEntities;
}
}

View File

@@ -1,29 +0,0 @@
#pragma once
#include "src/Core/Core.h"
#include "src/Core/Maths.h"
#include "PhysicsShapes.h"
#include <vector>
#include <Engine.h>
namespace Nuake
{
class GhostObject {
private:
std::vector<Entity> m_OverlappingEntities;
public:
GhostObject(Vector3 position, Ref<Physics::PhysicShape> shape);
int OverlappingCount();
void ClearOverlappingList();
void ScanOverlap();
void SetEntityID(Entity ent);
std::vector<Entity> GetOverlappingEntities();
};
}

View File

@@ -17,11 +17,6 @@ namespace Nuake
m_World->AddRigidbody(rb);
}
void PhysicsManager::RegisterGhostBody(Ref<GhostObject> rb)
{
m_World->AddGhostbody(rb);
}
void PhysicsManager::RegisterCharacterController(Ref<Physics::CharacterController> cc)
{
m_World->AddCharacterController(cc);
@@ -47,7 +42,7 @@ namespace Nuake
m_World->Clear();
}
std::vector<RaycastResult> PhysicsManager::Raycast(const Vector3& from, const Vector3& to)
std::vector<ShapeCastResult> PhysicsManager::Raycast(const Vector3& from, const Vector3& to)
{
return m_World->Raycast(from, to);
}
@@ -57,7 +52,7 @@ namespace Nuake
return m_World->CastShape(from, to, shape);
}
const std::vector<Physics::CollisionData>& PhysicsManager::GetCollisions()
const std::vector<Physics::CollisionData> PhysicsManager::GetCollisions()
{
return m_World->GetCollisionsData();
}

View File

@@ -50,13 +50,12 @@ namespace Nuake
void Reset();
std::vector<RaycastResult> Raycast(const Vector3& from, const Vector3& to);
std::vector<ShapeCastResult> Raycast(const Vector3& from, const Vector3& to);
std::vector<ShapeCastResult> Shapecast(const Vector3& from, const Vector3& to, const Ref<Physics::PhysicShape>& shape);
const std::vector<Physics::CollisionData>& GetCollisions();
const std::vector<Physics::CollisionData> GetCollisions();
void RegisterBody(Ref<Physics::RigidBody> rb);
void RegisterGhostBody(Ref<GhostObject> rb);
void RegisterCharacterController(Ref<Physics::CharacterController> c);
void SetBodyTransform(const Entity& entity, const Vector3& position, const Quat& rotation);

View File

@@ -10,6 +10,8 @@ namespace Nuake
{
Vector3 WorldPosition;
float Fraction;
Vector3 ImpactNormal;
float Layer;
};
struct ShapeCastResult

View File

@@ -20,6 +20,7 @@ namespace Nuake
Quat _rotation;
Entity _entity;
bool _ForceKinematic = false;
bool _isTrigger = false;
bool m_LockXAxis = false;
bool m_LockYAxis = false;
@@ -29,7 +30,7 @@ namespace Nuake
RigidBody();
RigidBody(Vector3 position, Entity handle);
RigidBody(float mass, Vector3 position, Quat rotation, Matrix4 transform, Ref<PhysicShape> shape, Entity entity, Vector3 initialVel = Vector3(0, 0, 0));
RigidBody(float mass, Vector3 position, Quat rotation, Matrix4 transform, Ref<PhysicShape> shape, Entity entity, Vector3 initialVel = Vector3(0, 0, 0), bool forceKinematic = false);
void UpdateTransform();
@@ -43,6 +44,7 @@ namespace Nuake
void SetLockXAxis(bool lock) { m_LockXAxis = lock; }
void SetLockYAxis(bool lock) { m_LockYAxis = lock; }
void SetLockZAxis(bool lock) { m_LockZAxis = lock; }
bool GetForceKinematic() const { return _ForceKinematic; }
void SetEntityID(Entity ent);
Vector3 GetPosition() const { return _position; }

View File

@@ -20,12 +20,13 @@ namespace Nuake
}
RigidBody::RigidBody(float mass, Vector3 position, Quat rotation, Matrix4 transform, Ref<PhysicShape> shape, Entity entity, Vector3 initialVel) :
RigidBody::RigidBody(float mass, Vector3 position, Quat rotation, Matrix4 transform, Ref<PhysicShape> shape, Entity entity, Vector3 initialVel, bool forceKinematic) :
_position(position),
_collisionShape(shape),
_mass(mass),
_entity(entity),
_rotation(rotation)
_rotation(rotation),
_ForceKinematic(forceKinematic)
{
}

View File

@@ -1,5 +1,6 @@
#include "Framebuffer.h"
#include <glad/glad.h>
#include <Tracy.hpp>
namespace Nuake
{
@@ -84,6 +85,8 @@ namespace Nuake
void FrameBuffer::QueueResize(Vector2 size)
{
ZoneScoped;
if (size == m_Size)
return;

View File

@@ -179,7 +179,7 @@ namespace Nuake
try {
DESERIALIZE_VEC2(v["UV"], vertex.uv)
}
catch (std::exception& e) {
catch (std::exception& /*e*/) {
vertex.uv = { 0.0, 0.0 };
}
DESERIALIZE_VEC3(v["Position"], vertex.position)

View File

@@ -9,6 +9,7 @@
#include <random>
#include <src/Vendors/imgui/imgui.h>
#include <Tracy.hpp>
namespace Nuake
{
@@ -32,6 +33,8 @@ namespace Nuake
void SSAO::Resize(const Vector2& size)
{
ZoneScoped;
if (_size == size)
return;
@@ -42,6 +45,8 @@ namespace Nuake
void SSAO::Clear()
{
ZoneScoped;
_ssaoBlurFramebuffer->Bind();
{
RenderCommand::SetClearColor({ 1, 1, 1, 1});
@@ -96,6 +101,8 @@ namespace Nuake
void SSAO::Draw(FrameBuffer* gBuffer, const Matrix4& projection, const Matrix4& view)
{
ZoneScoped;
_ssaoFramebuffer->Bind();
{
_ssaoFramebuffer->Clear();

View File

@@ -3,6 +3,7 @@
#include "src/Rendering/Renderer.h"
#include <glad/glad.h>
#include <src/Vendors/imgui/imgui.h>
#include <Tracy.hpp>
namespace Nuake {
Volumetric::Volumetric()
{
@@ -37,6 +38,8 @@ namespace Nuake {
void Volumetric::Draw(Matrix4 projection, Matrix4 view, const Vector3& camPos, std::vector<LightComponent>& lights)
{
ZoneScoped;
mVolumetricFramebuffer->Bind();
{
mVolumetricFramebuffer->Clear();

View File

@@ -17,6 +17,7 @@
#include "src/Rendering/Textures/MaterialManager.h"
#include "src/Rendering/Vertex.h"
#include <imgui/imgui.h>
#include <Tracy.hpp>
namespace Nuake
{
@@ -254,6 +255,8 @@ namespace Nuake
int spotShadowMapCount = 0;
void Renderer::EndDraw()
{
ZoneScoped;
Shader* deferredShader = ShaderManager::GetShader("Resources/Shaders/deferred.shader");
deferredShader->Bind();
deferredShader->SetUniform1i("LightCount", 0);
@@ -418,6 +421,8 @@ namespace Nuake
void Renderer::DrawQuad(Matrix4 transform)
{
ZoneScoped;
QuadMesh->Bind();
RenderCommand::DrawArrays(0, 6);
}

View File

@@ -1,27 +1,34 @@
#pragma once
#include "src/Core/Maths.h"
#include "Shaders/Shader.h"
#include "src/Scene/Components/Components.h"
#include "src/Core/Core.h"
#include "Buffers/VertexArray.h"
#include "RenderList.h"
#include "src/Core/Core.h"
#include "src/Core/Maths.h"
#include "src/Rendering/Camera.h"
#include "src/Scene/Components/LightComponent.h"
#include "src/Scene/Components/TransformComponent.h"
#include "Shaders/Shader.h"
#include "Buffers/UniformBuffer.h"
#include "Buffers/VertexArray.h"
namespace Nuake
{
struct Light
struct TransformComponent;
struct LightComponent;
struct Light
{
TransformComponent transform;
LightComponent light;
};
const int MAX_LIGHT = 64;
struct LightData
{
int ShadowMapsIDs[CSM_AMOUNT];
float CascadeDepth[CSM_AMOUNT];
Matrix4 LightTransforms[CSM_AMOUNT];
int ShadowMapsIDs[4];
float CascadeDepth[4];
Matrix4 LightTransforms[4];
int Type;
Vector3 Position;
Vector3 Direction;

View File

@@ -1,13 +1,17 @@
#include "SceneRenderer.h"
#include "src/Rendering/Shaders/ShaderManager.h"
#include "src/Rendering/Shaders/ShaderManager.h"
#include "src/Resource/Project.h"
#include "src/Scene/Components/BSPBrushComponent.h"
#include "src/Scene/Components/SpriteComponent.h"
#include "src/Scene/Components/ModelComponent.h"
#include "src/Scene/Components/ParentComponent.h"
#include "src/Scene/Components/ParticleEmitterComponent.h"
#include "src/Scene/Components/SpriteComponent.h"
#include <src/Scene/Components/SkinnedModelComponent.h>
#include <glad/glad.h>
#include <src/Scene/Components/SkinnedModelComponent.h>
#include <src/Vendors/imgui/imgui.h>
#include <Tracy.hpp>
namespace Nuake
@@ -75,6 +79,9 @@ namespace Nuake
mCapsuleGizmo = CreateRef<CapsuleGizmo>();
mCapsuleGizmo->CreateMesh();
mDebugLines = std::vector<DebugLine>();
mDebugShapes = std::vector<DebugShape>();
}
void SceneRenderer::Cleanup()
@@ -83,31 +90,31 @@ namespace Nuake
void SceneRenderer::Update(const Timestep time, bool isEditorUpdate)
{
if (isEditorUpdate)
{
return;
}
// Delete debug shapes that are dead
std::erase_if(mDebugLines, [](const DebugLine& line)
if (mDebugLines.size() > 0)
{
return line.Life < 0.0f;
});
std::erase_if(mDebugLines, [](const DebugLine& line)
{
return line.Life < 0.0f;
});
std::erase_if(mDebugShapes, [](const DebugShape& shape)
{
return shape.Life < 0.0f;
});
for (auto& line : mDebugLines)
{
line.Life -= time;
for (auto& line : mDebugLines)
{
line.Life -= time;
}
}
for (auto& shape : mDebugShapes)
if (mDebugShapes.size() > 0)
{
shape.Life -= time;
std::erase_if(mDebugShapes, [](const DebugShape& shape)
{
return shape.Life < 0.0f;
});
for (auto& shape : mDebugShapes)
{
shape.Life -= time;
}
}
}
@@ -125,6 +132,8 @@ namespace Nuake
/// <param name="framebuffer">Framebuffer to render the scene to. Should be in the right size</param>
void SceneRenderer::RenderScene(Scene& scene, FrameBuffer& framebuffer)
{
ZoneScoped;
// Renders all shadow maps
ShadowPass(scene);
@@ -160,6 +169,18 @@ namespace Nuake
DebugRendererPass(scene);
#ifdef AMD
framebuffer.Bind();
{
RenderCommand::Clear();
Shader* shader = ShaderManager::GetShader("Resources/Shaders/copy.shader");
shader->Bind();
shader->SetUniformTex("u_Source", mShadingBuffer->GetTexture().get(), 0);
Renderer::DrawQuad();
}
framebuffer.Unbind();
#else
Ref<Texture> finalOutput = mShadingBuffer->GetTexture();
if (scene.GetEnvironment()->BloomEnabled)
{
@@ -178,7 +199,7 @@ namespace Nuake
if (lc.Type == Directional && lc.IsVolumetric && lc.CastShadows)
lightList.push_back(lc);
}
glDepthMask(false);
if (sceneEnv->VolumetricEnabled)
{
@@ -189,7 +210,7 @@ namespace Nuake
//finalOutput = mVolumetric->GetFinalOutput().get();
// combine
framebuffer.Bind();
{
RenderCommand::Clear();
@@ -322,7 +343,7 @@ namespace Nuake
shader->SetUniform1f("ndofstart", sceneEnv->DOFStart);
shader->SetUniform1f("ndofdist", sceneEnv->DOFDist);
shader->SetUniform1f("fdofstart", sceneEnv->DOFStart);
shader->SetUniform1f("fdofdist", sceneEnv->DOFDist);
shader->SetUniform1f("fdofdist", sceneEnv->DOFDist);
shader->SetUniform1f("CoC", sceneEnv->DOFCoc);
shader->SetUniform1f("maxblur", sceneEnv->DOFMaxBlue);
shader->SetUniform1f("threshold", sceneEnv->DOFThreshold);
@@ -341,44 +362,41 @@ namespace Nuake
}
mDOFBuffer->Unbind();
if (sceneEnv->BarrelDistortionEnabled)
mBarrelDistortionBuffer->QueueResize(framebufferResolution);
mBarrelDistortionBuffer->Bind();
{
mBarrelDistortionBuffer->QueueResize(framebufferResolution);
mBarrelDistortionBuffer->Bind();
RenderCommand::Clear();
Shader* shader = ShaderManager::GetShader("Resources/Shaders/barrel_distortion.shader");
shader->Bind();
shader->SetUniform1f("u_Distortion", sceneEnv->BarrelDistortion);
shader->SetUniform1f("u_DistortionEdge", sceneEnv->BarrelEdgeDistortion);
shader->SetUniform1f("u_Scale", sceneEnv->BarrelScale);
if (sceneEnv->DOFEnabled)
{
RenderCommand::Clear();
Shader* shader = ShaderManager::GetShader("Resources/Shaders/barrel_distortion.shader");
shader->Bind();
shader->SetUniform1f("u_Distortion", sceneEnv->BarrelDistortion);
shader->SetUniform1f("u_DistortionEdge", sceneEnv->BarrelEdgeDistortion);
shader->SetUniform1f("u_Scale", sceneEnv->BarrelScale);
if (sceneEnv->DOFEnabled)
{
shader->SetUniformTex("u_Source", mDOFBuffer->GetTexture().get(), 0);
}
else
{
shader->SetUniformTex("u_Source", finalOutput.get(), 0);
}
Renderer::DrawQuad();
shader->SetUniformTex("u_Source", mDOFBuffer->GetTexture().get(), 0);
}
mBarrelDistortionBuffer->Unbind();
framebuffer.Bind();
else
{
RenderCommand::Clear();
Shader* shader = ShaderManager::GetShader("Resources/Shaders/copy.shader");
shader->Bind();
shader->SetUniformTex("u_Source", mBarrelDistortionBuffer->GetTexture().get(), 0);
Renderer::DrawQuad();
shader->SetUniformTex("u_Source", finalOutput.get(), 0);
}
framebuffer.Unbind();
Renderer::DrawQuad();
}
mBarrelDistortionBuffer->Unbind();
framebuffer.Bind();
{
RenderCommand::Clear();
Shader* shader = ShaderManager::GetShader("Resources/Shaders/copy.shader");
shader->Bind();
shader->SetUniformTex("u_Source", mBarrelDistortionBuffer->GetTexture().get(), 0);
Renderer::DrawQuad();
}
framebuffer.Unbind();
mVignetteBuffer->QueueResize(framebufferResolution);
mVignetteBuffer->Bind();
@@ -389,27 +407,22 @@ namespace Nuake
shader->SetUniform1f("u_Intensity", sceneEnv->VignetteIntensity);
shader->SetUniform1f("u_Extend", sceneEnv->VignetteEnabled ? sceneEnv->VignetteExtend : 0.0f);
shader->SetUniformTex("u_Source", finalOutput.get(), 0);
shader->SetUniformTex("u_Source", framebuffer.GetTexture().get(), 0);
Renderer::DrawQuad();
}
mVignetteBuffer->Unbind();
ImGui::Begin("normals");
ImGui::Image((void*)mToneMapBuffer->GetTexture(GL_COLOR_ATTACHMENT0)->GetID(), ImGui::GetContentRegionAvail(), ImVec2(0, 1), ImVec2(1, 0));
ImGui::End();
framebuffer.Bind();
{
RenderCommand::Clear();
Shader* shader = ShaderManager::GetShader("Resources/Shaders/add.shader");
shader->Bind();
shader->SetUniformTex("u_Source", finalOutput.get(), 0);
shader->SetUniformTex("u_Source2", mOutlineBuffer->GetTexture().get(), 1);
Renderer::DrawQuad();
}
framebuffer.Unbind();
//framebuffer.Bind();
//{
// RenderCommand::Clear();
// Shader* shader = ShaderManager::GetShader("Resources/Shaders/add.shader");
// shader->Bind();
//
// shader->SetUniformTex("u_Source", mVignetteBuffer->GetTexture().get(), 0);
// shader->SetUniformTex("u_Source2", mOutlineBuffer->GetTexture().get(), 1);
// Renderer::DrawQuad();
//}
//framebuffer.Unbind();
framebuffer.Bind();
{
@@ -421,6 +434,11 @@ namespace Nuake
Renderer::DrawQuad();
}
framebuffer.Unbind();
#endif
glDepthMask(true);
@@ -485,6 +503,8 @@ namespace Nuake
void SceneRenderer::ShadowPass(Scene& scene)
{
ZoneScoped;
RenderCommand::Enable(RendererEnum::DEPTH_TEST);
Shader* shader = ShaderManager::GetShader("Resources/Shaders/shadowMap.shader");
@@ -533,10 +553,7 @@ namespace Nuake
if (model.IsTransparent || !visibility.Visible)
continue;
for (Ref<Mesh>& m : model.Meshes)
{
Renderer::SubmitMesh(m, transform.GetGlobalTransform());
}
}
Renderer::Flush(shader, true);
@@ -594,6 +611,8 @@ namespace Nuake
light.m_Framebuffers[0]->Clear();
{
Matrix4 spotLightTransform = Matrix4(1.0f);
Vector3 pos = lightTransform.GetGlobalPosition();
pos.y *= -1.0f;
pos.x *= -1.0f;
@@ -626,10 +645,7 @@ namespace Nuake
if (model.IsTransparent || !visibility.Visible)
continue;
for (Ref<Mesh>& m : model.Meshes)
{
Renderer::SubmitMesh(m, transform.GetGlobalTransform());
}
}
Renderer::Flush(shader, true);
@@ -719,33 +735,26 @@ namespace Nuake
}
}
if (lightDebug.m_Framebuffers[0])
{
mDisplayDepthBuffer->QueueResize(lightDebug.m_Framebuffers[0]->GetTexture(GL_DEPTH_ATTACHMENT)->GetSize());
mDisplayDepthBuffer->QueueResize(GetGBuffer().GetTexture(GL_DEPTH_ATTACHMENT)->GetSize());
mDisplayDepthBuffer->Bind();
mDisplayDepthBuffer->Clear();
Shader* displayDepthShader = ShaderManager::GetShader("Resources/Shaders/display_depth.shader");
displayDepthShader->Bind();
mDisplayDepthBuffer->Bind();
mDisplayDepthBuffer->Clear();
Shader* displayDepthShader = ShaderManager::GetShader("Resources/Shaders/display_depth.shader");
displayDepthShader->Bind();
lightDebug.m_Framebuffers[0]->GetTexture(GL_DEPTH_ATTACHMENT)->Bind(5);
displayDepthShader->SetUniform1i("u_Source", 5);
GetGBuffer().GetTexture(GL_DEPTH_ATTACHMENT)->Bind(5);
displayDepthShader->SetUniform1i("u_Source", 5);
RenderCommand::Disable(RendererEnum::DEPTH_TEST);
Renderer::DrawQuad(Matrix4(1.0f));
RenderCommand::Enable(RendererEnum::DEPTH_TEST);
mDisplayDepthBuffer->Unbind();
ImGui::SetNextWindowSize({ 800, 800 });
ImGui::Begin("Debug ShadowMap");
ImGui::Image((void*)mDisplayDepthBuffer->GetTexture()->GetID(), ImGui::GetContentRegionAvail(), { 0, 1 }, { 1, 0 });
ImGui::End();
}
RenderCommand::Disable(RendererEnum::DEPTH_TEST);
Renderer::DrawQuad(Matrix4(1.0f));
RenderCommand::Enable(RendererEnum::DEPTH_TEST);
mDisplayDepthBuffer->Unbind();
}
void SceneRenderer::GBufferPass(Scene& scene)
{
ZoneScoped;
mGBuffer->Bind();
mGBuffer->Clear();
{
@@ -801,10 +810,7 @@ namespace Nuake
if (model.IsTransparent || !visibility.Visible)
continue;
for (auto& b : model.Meshes)
{
Renderer::SubmitMesh(b, transform.GetGlobalTransform(), (uint32_t)e);
}
}
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
@@ -953,6 +959,8 @@ namespace Nuake
void SceneRenderer::ShadingPass(Scene& scene)
{
ZoneScoped;
mShadingBuffer->Bind();
mShadingBuffer->Clear();
{
@@ -1055,6 +1063,8 @@ namespace Nuake
void SceneRenderer::DebugRendererPass(Scene& scene)
{
ZoneScoped;
mShadingBuffer->Bind();
{
// Lines
@@ -1082,8 +1092,6 @@ namespace Nuake
RenderCommand::DrawLines(0, 2);
}
shader->Unbind();
shader = Nuake::ShaderManager::GetShader("Resources/Shaders/line.shader");
@@ -1118,7 +1126,6 @@ namespace Nuake
view = glm::scale(view, reinterpret_cast<Physics::Box*>(shape.Shape.get())->GetSize());
shader->SetUniformMat4f("u_View", view);
mBoxGizmo->Bind();
RenderCommand::DrawLines(0, 26);

View File

@@ -7,10 +7,14 @@
#include "src/Rendering/PostFX/Bloom.h"
#include "src/Rendering/PostFX/Volumetric.h"
#include "src/Rendering/PostFX/SSR.h"
#include "src/Physics/PhysicsShapes.h"
#include "Shapes/BoxGizmo.h"
#include "Shapes/SphereGizmo.h"
#include "Shapes/CapsuleGizmo.h"
#include "Shapes/CylinderGizmo.h"
#include <src/Resource/Model.h>
#include <glad/glad.h>
namespace Nuake
{
@@ -57,6 +61,11 @@ namespace Nuake
return *mGBuffer;
}
Ref<Texture> GetScaledDepthTexture()
{
return mDisplayDepthBuffer->GetTexture(GL_COLOR_ATTACHMENT0);
}
bool IsTempModelLoaded(const std::string& name) const
{
return mTempModels.find(name) != mTempModels.end();

View File

@@ -1,6 +1,6 @@
#include "src/Core/Core.h"
#include "Shader.h"
#include "src/Core/FileSystem.h"
#include "src/FileSystem/FileSystem.h"
#include "src/Core/Logger.h"
#include <sstream>

View File

@@ -2,6 +2,7 @@
#include "src/Core/Logger.h"
#include "src/Resource/StaticResources.h"
#include <Tracy.hpp>
#define LoadEmbeddedShader(file) \
m_Shaders[file##_path] = CreateScope<Shader>(file##_path, std::string(reinterpret_cast<const char*>(file), reinterpret_cast<const char*>(file) + file##_len));
@@ -48,6 +49,8 @@ namespace Nuake
Shader* ShaderManager::GetShader(const std::string& path)
{
ZoneScoped;
if (m_Shaders.find(path) == m_Shaders.end())
{
m_Shaders[path] = CreateScope<Shader>(path);

View File

@@ -7,7 +7,7 @@
#include "Texture.h"
#include <src/Resource/Serializable.h>
#include "src/Resource/Resource.h"
#include "src/Core/FileSystem.h"
#include "src/FileSystem/FileSystem.h"
namespace Nuake
{

View File

@@ -7,7 +7,7 @@
#include "json/json.hpp"
#include "../Rendering/Textures/Material.h"
#include "src/Core/FileSystem.h"
#include "src/FileSystem/FileSystem.h"
#include "src/Core/Logger.h"
namespace Nuake

View File

@@ -2,7 +2,7 @@
#include "src/Core/Logger.h"
#include <glad/glad.h>
#include <iostream>
#include <src/Core/FileSystem.h>
#include "src/FileSystem/FileSystem.h"
namespace Nuake
{

View File

@@ -76,6 +76,7 @@ namespace Nuake {
std::string Name;
std::string Description;
std::string Prefab;
std::string Script;
std::vector<ClassProperty> Properties;
FGDBaseEntity BaseClass;

View File

@@ -1,7 +1,8 @@
#include "FGDFile.h"
#include <src/Resource/FGD/FDGSerializer.h>
#include <src/Core/FileSystem.h>
#include "src/FileSystem/FileSystem.h"
#include "Engine.h"
#include "src/Resource/Project.h"
namespace Nuake {
FGDFile::FGDFile(const std::string path)

View File

@@ -1,5 +1,5 @@
#include "FDGSerializer.h"
#include <src/Core/FileSystem.h>
#include "src/FileSystem/FileSystem.h"
namespace Nuake {
bool FGDSerializer::BeginFGDFile(const std::string path)
@@ -33,6 +33,13 @@ namespace Nuake {
line += "\n [ \n";
for (auto& p : fgdClass.Properties)
{
if (p.type != ClassPropertyType::Integer ||
p.type != ClassPropertyType::String ||
p.type != ClassPropertyType::Float)
{
continue;
}
// E.g: myProp(integer) : "description"
line += " "; // Tabulation
line += p.name;
@@ -66,22 +73,42 @@ namespace Nuake {
}
// Properties here.
line += "\n [ \n";
line += "\n[ \n";
for (auto& p : fgdPoint.Properties)
{
if (p.type != ClassPropertyType::Integer &&
p.type != ClassPropertyType::String &&
p.type != ClassPropertyType::Float)
{
continue;
}
// E.g: myProp(integer) : "description"
line += " "; // Tabulation
line += p.name;
line += "(";
if (p.type == ClassPropertyType::Integer)
line += "integer";
if (p.type == ClassPropertyType::String)
line += "string";
if (p.type == ClassPropertyType::Float)
line += "float";
line += ") : ";
line += "\"" + p.description + "\"";
line += " : ";
if (p.type == ClassPropertyType::String)
{
line += " \"" + p.value + "\" ";
}
else if (p.type == ClassPropertyType::Integer || p.type == ClassPropertyType::Float)
{
line += p.value;
}
line += "\n";
}
line += "]";
line += "] \n";
FileSystem::WriteLine(line);
@@ -106,6 +133,13 @@ namespace Nuake {
line += "\n [ \n";
for (auto& p : fgdClass.Properties)
{
if (p.type != ClassPropertyType::Integer ||
p.type != ClassPropertyType::String ||
p.type != ClassPropertyType::Float)
{
continue;
}
// E.g: myProp(integer) : "description"
line += " "; // Tabulation
line += p.name;
@@ -114,6 +148,8 @@ namespace Nuake {
line += "integer";
if (p.type == ClassPropertyType::String)
line += "string";
if (p.type == ClassPropertyType::Float)
line += "float";
line += ") : ";
line += "\"" + p.description + "\"";
line += " : ";
@@ -121,7 +157,7 @@ namespace Nuake {
{
line += " \"" + p.value + "\" ";
}
else if (p.type == ClassPropertyType::Integer)
else if (p.type == ClassPropertyType::Integer || p.type == ClassPropertyType::Float)
{
line += p.value;
}

View File

@@ -1,5 +1,5 @@
#include "src/Resource/Model.h"
#include "src/Core/FileSystem.h"
#include "src/FileSystem/FileSystem.h"
#include "src/Core/Logger.h"
#include "src/Rendering/Mesh/Mesh.h"
#include "src/Resource/ModelLoader.h"

View File

@@ -1,6 +1,6 @@
#include "src/Resource/ModelLoader.h"
#include "src/Core/FileSystem.h"
#include "src/FileSystem/FileSystem.h"
#include "src/Core/Logger.h"
#include "src/Core/String.h"

View File

@@ -1,11 +1,16 @@
#include "Project.h"
#include "../Core/FileSystem.h"
#include "src/FileSystem/FileSystem.h"
#include "Engine.h"
#include "src/Core/Logger.h"
#include "src/Audio/AudioManager.h"
#include "src/Scripting/ScriptingEngineNet.h"
#include <json/json.hpp>
#include <filesystem>
#include <fstream>
#include <streambuf>
#include "../Core/Logger.h"
#include "Engine.h"
#include <src/Audio/AudioManager.h>
namespace Nuake
{
@@ -104,6 +109,116 @@ namespace Nuake
return project;
}
void Project::ExportEntitiesToTrenchbroom()
{
Ref<FGDFile> file = EntityDefinitionsFile;
file->BrushEntities.clear();
for (auto& [name, type] : ScriptingEngineNet::Get().GetBrushEntities())
{
FGDBrushEntity brushEntity = FGDBrushEntity(name);
brushEntity.Script = name;
brushEntity.Description = type.Description;
brushEntity.IsTrigger = type.isTrigger;
for (auto& t : type.exposedVars)
{
ClassProperty classProp;
classProp.name = t.Name;
classProp.type = ClassPropertyType::String;
if (t.Type == ExposedVarTypes::String && t.Value.has_value())
{
classProp.value = std::any_cast<std::string>(t.Value);
}
else if (t.Type == ExposedVarTypes::Float && t.Value.has_value())
{
classProp.value = std::any_cast<float>(t.Value);
classProp.type = ClassPropertyType::Float;
}
else if (t.Type == ExposedVarTypes::Int)
{
classProp.value = std::to_string(std::any_cast<int>(t.Value));
}
else
{
classProp.value = "";
}
brushEntity.Properties.push_back(classProp);
}
file->BrushEntities.push_back(brushEntity);
}
file->PointEntities.clear();
std::vector<std::string> bases;
for (auto& [name, type] : ScriptingEngineNet::Get().GetPointEntities())
{
FGDPointEntity pointEntity = FGDPointEntity(name);
pointEntity.Script = name;
pointEntity.Description = type.Description;
for (auto& t : type.exposedVars)
{
ClassProperty classProp;
classProp.name = t.Name;
classProp.type = ClassPropertyType::String;
if (t.Type == ExposedVarTypes::String)
{
if (t.Value.has_value())
{
classProp.value = std::any_cast<std::string>(t.Value);
}
classProp.type = ClassPropertyType::String;
}
else if (t.Type == ExposedVarTypes::Int)
{
if (t.Value.has_value())
{
classProp.value = std::to_string(std::any_cast<int>(t.Value));
}
classProp.type = ClassPropertyType::Integer;
}
else if (t.Type == ExposedVarTypes::Float)
{
if (t.Value.has_value())
{
classProp.value = std::to_string(std::any_cast<float>(t.Value));
}
classProp.type = ClassPropertyType::Float;
}
else if (t.Type == ExposedVarTypes::Bool)
{
if (t.Value.has_value())
{
classProp.value = std::to_string(std::any_cast<bool>(t.Value));
}
classProp.type = ClassPropertyType::Float;
}
else
{
classProp.value = "";
}
pointEntity.Properties.push_back(classProp);
}
file->PointEntities.push_back(pointEntity);
}
for (auto& b : bases)
{
FGDBaseEntity baseEntity;
baseEntity.Name = b;
file->BaseEntities.push_back(baseEntity);
}
file->Export();
}
json Project::Serialize()
{
BEGIN_SERIALIZE();

View File

@@ -19,7 +19,7 @@ namespace Nuake
bool SmoothCamera = false;
float SmoothCameraSpeed = 0.2f;
Color PrimaryColor = Color(97.0f / 255.0f, 0, 1.0f, 1.0f);
int PhysicsStep = 90.0f;
int PhysicsStep = 90;
int MaxPhysicsSubStep = 32;
int MaxPhysicsBodies = 4096;
int MaxPhysicsContactConstraints = 2048;
@@ -59,6 +59,8 @@ namespace Nuake
static Ref<Project> New();
static Ref<Project> Load(std::string& path);
void ExportEntitiesToTrenchbroom();
json Serialize() override;
bool Deserialize(const json& j) override;
};

View File

@@ -0,0 +1,105 @@
#include "ResourceLoader.h"
#include "src/Core/Logger.h"
#include "src/Core/String.h"
#include "src/Resource/Resource.h"
#include "src/Resource/ResourceManager.h"
#include "src/Rendering/Textures/Material.h"
#include "src/Resource/Model.h"
using namespace Nuake;
Ref<Material> ResourceLoader::LoadMaterial(const std::string& path)
{
const std::string FILE_NOT_FOUND = "[Resource Loader] File doesn't exists. \n ";
const std::string WRONG_EXTENSION = "[Resource Loader] Resource type mismatch file extension. \n expected: ";
const std::string MATERIAL_EXT = ".material";
if (path.empty())
{
Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING);
return nullptr;
}
if (!FileSystem::FileExists(path))
{
Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING);
return nullptr;
}
if (!String::EndsWith(path, MATERIAL_EXT))
{
std::string message = WRONG_EXTENSION + MATERIAL_EXT + " actual: " + path;
Logger::Log(message, "resource", LOG_TYPE::WARNING);
}
std::string content = FileSystem::ReadFile(path);
json j = json::parse(content);
UUID uuid = ReadUUID(j);
// Check if resource is already loaded.
if (ResourceManager::IsResourceLoaded(uuid))
{
return ResourceManager::GetResource<Material>(uuid);
}
Ref<Material> material = CreateRef<Material>();
material->ID = uuid;
material->Path = path;
material->Deserialize(j);
ResourceManager::RegisterResource(material);
return material;
}
Ref<Model> ResourceLoader::LoadModel(const std::string& path)
{
const std::string FILE_NOT_FOUND = "[Resource Loader] File doesn't exists. \n ";
const std::string WRONG_EXTENSION = "[Resource Loader] Resource type mismatch file extension. \n expected: ";
const std::string MESH_EXT = ".mesh";
if (path.empty())
{
Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING);
return nullptr;
}
if (!FileSystem::FileExists(path))
{
Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING);
return nullptr;
}
if (!String::EndsWith(path, MESH_EXT))
{
std::string message = WRONG_EXTENSION + MESH_EXT + " actual: " + path;
Logger::Log(message, "resource", LOG_TYPE::WARNING);
}
std::string content = FileSystem::ReadFile(path);
json j = json::parse(content);
UUID uuid = ReadUUID(j);
// Check if resource is already loaded.
if (ResourceManager::IsResourceLoaded(uuid))
{
return ResourceManager::GetResource<Model>(uuid);
}
Ref<Model> model = CreateRef<Model>();
model->ID = uuid;
model->Path = path;
model->Deserialize(j);
ResourceManager::RegisterResource(model);
return model;
}
UUID ResourceLoader::ReadUUID(json j)
{
if (j.contains("UUID"))
{
return UUID(j["UUID"]);
}
return UUID();
}

View File

@@ -1,13 +1,13 @@
#pragma once
#include "src/Core/Core.h"
#include "src/Core/Logger.h"
#include "src/Resource/Resource.h"
#include "src/Resource/ResourceManager.h"
#include "src/Rendering/Textures/Material.h"
#include "src/Resource/Model.h"
#include "src/Resource/UUID.h"
#include "src/Resource/Serializable.h"
namespace Nuake
{
class Material;
class Model;
class ResourceLoader
{
private:
@@ -19,101 +19,10 @@ namespace Nuake
ResourceLoader() = default;
~ResourceLoader() = default;
static Ref<Material> LoadMaterial(const std::string& path)
{
const std::string FILE_NOT_FOUND = "[Resource Loader] File doesn't exists. \n ";
const std::string WRONG_EXTENSION = "[Resource Loader] Resource type mismatch file extension. \n expected: ";
const std::string MATERIAL_EXT = ".material";
if (path.empty())
{
Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING);
return nullptr;
}
if (!FileSystem::FileExists(path))
{
Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING);
return nullptr;
}
if (!String::EndsWith(path, MATERIAL_EXT))
{
std::string message = WRONG_EXTENSION + MATERIAL_EXT + " actual: " + path;
Logger::Log(message, "resource", LOG_TYPE::WARNING);
}
std::string content = FileSystem::ReadFile(path);
json j = json::parse(content);
UUID uuid = ReadUUID(j);
// Check if resource is already loaded.
if (ResourceManager::IsResourceLoaded(uuid))
{
return ResourceManager::GetResource<Material>(uuid);
}
Ref<Material> material = CreateRef<Material>();
material->ID = uuid;
material->Path = path;
material->Deserialize(j);
ResourceManager::RegisterResource(material);
return material;
}
static Ref<Model> LoadModel(const std::string& path)
{
const std::string FILE_NOT_FOUND = "[Resource Loader] File doesn't exists. \n ";
const std::string WRONG_EXTENSION = "[Resource Loader] Resource type mismatch file extension. \n expected: ";
const std::string MESH_EXT = ".mesh";
if (path.empty())
{
Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING);
return nullptr;
}
if (!FileSystem::FileExists(path))
{
Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING);
return nullptr;
}
if (!String::EndsWith(path, MESH_EXT))
{
std::string message = WRONG_EXTENSION + MESH_EXT + " actual: " + path;
Logger::Log(message, "resource", LOG_TYPE::WARNING);
}
std::string content = FileSystem::ReadFile(path);
json j = json::parse(content);
UUID uuid = ReadUUID(j);
// Check if resource is already loaded.
if (ResourceManager::IsResourceLoaded(uuid))
{
return ResourceManager::GetResource<Model>(uuid);
}
Ref<Model> model = CreateRef<Model>();
model->ID = uuid;
model->Path = path;
model->Deserialize(j);
ResourceManager::RegisterResource(model);
return model;
}
static Ref<Material> LoadMaterial(const std::string& path);
static Ref<Model> LoadModel(const std::string& path);
private:
static UUID ReadUUID(json j)
{
if (j.contains("UUID"))
{
return UUID(j["UUID"]);
}
return UUID();
}
static UUID ReadUUID(json j);
};
}

View File

@@ -15,9 +15,6 @@ namespace Nuake
public:
static Ref<Resource> GetResource(const UUID& uuid);
template<typename R>
static Ref<R> LoadResource(const std::string& path);
static void RegisterResource(Ref<Resource> resource)
{
m_Resources[resource->ID] = resource;

View File

@@ -1,7 +1,7 @@
#include "src/Resource/ModelLoader.h"
#include "src/Resource/SkinnedModel.h"
#include "src/Core/FileSystem.h"
#include "src/FileSystem/FileSystem.h"
#include "src/Core/Logger.h"

File diff suppressed because it is too large Load Diff

View File

@@ -1,242 +1,245 @@
#ifndef FILES_DATA_H
#define FILES_DATA_H
#include <string>
namespace Nuake {
namespace StaticResources {
extern const std::string Resources_default_layout_ini_path;
extern unsigned int Resources_default_layout_ini_len;
extern unsigned char Resources_default_layout_ini[];
extern const std::string Resources_Fonts_fa_regular_400_ttf_path;
extern unsigned int Resources_Fonts_fa_regular_400_ttf_len;
extern unsigned char Resources_Fonts_fa_regular_400_ttf[];
extern const std::string Resources_Fonts_fa_regular_400_big_ttf_path;
extern unsigned int Resources_Fonts_fa_regular_400_big_ttf_len;
extern unsigned char Resources_Fonts_fa_regular_400_big_ttf[];
extern const std::string Resources_Fonts_fa_solid_900_ttf_path;
extern unsigned int Resources_Fonts_fa_solid_900_ttf_len;
extern unsigned char Resources_Fonts_fa_solid_900_ttf[];
extern const std::string Resources_Fonts_FiraMono_Bold_ttf_path;
extern unsigned int Resources_Fonts_FiraMono_Bold_ttf_len;
extern unsigned char Resources_Fonts_FiraMono_Bold_ttf[];
extern const std::string Resources_Fonts_FiraMono_Regular_ttf_path;
extern unsigned int Resources_Fonts_FiraMono_Regular_ttf_len;
extern unsigned char Resources_Fonts_FiraMono_Regular_ttf[];
extern const std::string Resources_Fonts_OpenSans_Bold_ttf_path;
extern unsigned int Resources_Fonts_OpenSans_Bold_ttf_len;
extern unsigned char Resources_Fonts_OpenSans_Bold_ttf[];
extern const std::string Resources_Fonts_OpenSans_Regular_ttf_path;
extern unsigned int Resources_Fonts_OpenSans_Regular_ttf_len;
extern unsigned char Resources_Fonts_OpenSans_Regular_ttf[];
extern const std::string Resources_Fonts_Poppins_Regular_ttf_path;
extern unsigned int Resources_Fonts_Poppins_Regular_ttf_len;
extern unsigned char Resources_Fonts_Poppins_Regular_ttf[];
extern const std::string Resources_Fonts_RobotoMono_Regular_ttf_path;
extern unsigned int Resources_Fonts_RobotoMono_Regular_ttf_len;
extern unsigned char Resources_Fonts_RobotoMono_Regular_ttf[];
extern const std::string Resources_Gizmos_bone_png_path;
extern unsigned int Resources_Gizmos_bone_png_len;
extern unsigned char Resources_Gizmos_bone_png[];
extern const std::string Resources_Gizmos_camera_png_path;
extern unsigned int Resources_Gizmos_camera_png_len;
extern unsigned char Resources_Gizmos_camera_png[];
extern const std::string Resources_Gizmos_light_png_path;
extern unsigned int Resources_Gizmos_light_png_len;
extern unsigned char Resources_Gizmos_light_png[];
extern const std::string Resources_Gizmos_light_directional_png_path;
extern unsigned int Resources_Gizmos_light_directional_png_len;
extern unsigned char Resources_Gizmos_light_directional_png[];
extern const std::string Resources_Gizmos_light_spot_png_path;
extern unsigned int Resources_Gizmos_light_spot_png_len;
extern unsigned char Resources_Gizmos_light_spot_png[];
extern const std::string Resources_Gizmos_particles_png_path;
extern unsigned int Resources_Gizmos_particles_png_len;
extern unsigned char Resources_Gizmos_particles_png[];
extern const std::string Resources_Gizmos_player_png_path;
extern unsigned int Resources_Gizmos_player_png_len;
extern unsigned char Resources_Gizmos_player_png[];
extern const std::string Resources_Gizmos_rigidbody_png_path;
extern unsigned int Resources_Gizmos_rigidbody_png_len;
extern unsigned char Resources_Gizmos_rigidbody_png[];
extern const std::string Resources_Gizmos_sound_emitter_png_path;
extern unsigned int Resources_Gizmos_sound_emitter_png_len;
extern unsigned char Resources_Gizmos_sound_emitter_png[];
extern const std::string Resources_Images_audio_file_icon_png_path;
extern unsigned int Resources_Images_audio_file_icon_png_len;
extern unsigned char Resources_Images_audio_file_icon_png[];
extern const std::string Resources_Images_box_png_path;
extern unsigned int Resources_Images_box_png_len;
extern unsigned char Resources_Images_box_png[];
extern const std::string Resources_Images_code_png_path;
extern unsigned int Resources_Images_code_png_len;
extern unsigned char Resources_Images_code_png[];
extern const std::string Resources_Images_csharp_icon_png_path;
extern unsigned int Resources_Images_csharp_icon_png_len;
extern unsigned char Resources_Images_csharp_icon_png[];
extern const std::string Resources_Images_cube_png_path;
extern unsigned int Resources_Images_cube_png_len;
extern unsigned char Resources_Images_cube_png[];
extern const std::string Resources_Images_file_icon_png_path;
extern unsigned int Resources_Images_file_icon_png_len;
extern unsigned char Resources_Images_file_icon_png[];
extern const std::string Resources_Images_folder_icon_png_path;
extern unsigned int Resources_Images_folder_icon_png_len;
extern unsigned char Resources_Images_folder_icon_png[];
extern const std::string Resources_Images_light_png_path;
extern unsigned int Resources_Images_light_png_len;
extern unsigned char Resources_Images_light_png[];
extern const std::string Resources_Images_logo_png_path;
extern unsigned int Resources_Images_logo_png_len;
extern unsigned char Resources_Images_logo_png[];
extern const std::string Resources_Images_logo_white_png_path;
extern unsigned int Resources_Images_logo_white_png_len;
extern unsigned char Resources_Images_logo_white_png[];
extern const std::string Resources_Images_nuake_logo_png_path;
extern unsigned int Resources_Images_nuake_logo_png_len;
extern unsigned char Resources_Images_nuake_logo_png[];
extern const std::string Resources_Images_physics_png_path;
extern unsigned int Resources_Images_physics_png_len;
extern unsigned char Resources_Images_physics_png[];
extern const std::string Resources_Images_project_icon_png_path;
extern unsigned int Resources_Images_project_icon_png_len;
extern unsigned char Resources_Images_project_icon_png[];
extern const std::string Resources_Images_scene_icon_png_path;
extern unsigned int Resources_Images_scene_icon_png_len;
extern unsigned char Resources_Images_scene_icon_png[];
extern const std::string Resources_Images_screenshot_png_path;
extern unsigned int Resources_Images_screenshot_png_len;
extern unsigned char Resources_Images_screenshot_png[];
extern const std::string Resources_Images_script_file_icon_png_path;
extern unsigned int Resources_Images_script_file_icon_png_len;
extern unsigned char Resources_Images_script_file_icon_png[];
extern const std::string Resources_Images_shape_png_path;
extern unsigned int Resources_Images_shape_png_len;
extern unsigned char Resources_Images_shape_png[];
extern const std::string Resources_Images_speaker_png_path;
extern unsigned int Resources_Images_speaker_png_len;
extern unsigned char Resources_Images_speaker_png[];
extern const std::string Resources_Images_wrench_png_path;
extern unsigned int Resources_Images_wrench_png_len;
extern unsigned char Resources_Images_wrench_png[];
extern const std::string Resources_resources_aps_path;
extern unsigned int Resources_resources_aps_len;
extern unsigned char Resources_resources_aps[];
extern const std::string Resources_resources_rc_path;
extern unsigned int Resources_resources_rc_len;
extern unsigned char Resources_resources_rc[];
extern const std::string Resources_Scripts_Audio_wren_path;
extern unsigned int Resources_Scripts_Audio_wren_len;
extern unsigned char Resources_Scripts_Audio_wren[];
extern const std::string Resources_Scripts_Engine_wren_path;
extern unsigned int Resources_Scripts_Engine_wren_len;
extern unsigned char Resources_Scripts_Engine_wren[];
extern const std::string Resources_Scripts_Input_wren_path;
extern unsigned int Resources_Scripts_Input_wren_len;
extern unsigned char Resources_Scripts_Input_wren[];
extern const std::string Resources_Scripts_Math_wren_path;
extern unsigned int Resources_Scripts_Math_wren_len;
extern unsigned char Resources_Scripts_Math_wren[];
extern const std::string Resources_Scripts_Physics_wren_path;
extern unsigned int Resources_Scripts_Physics_wren_len;
extern unsigned char Resources_Scripts_Physics_wren[];
extern const std::string Resources_Scripts_Scene_wren_path;
extern unsigned int Resources_Scripts_Scene_wren_len;
extern unsigned char Resources_Scripts_Scene_wren[];
extern const std::string Resources_Scripts_ScriptableEntity_wren_path;
extern unsigned int Resources_Scripts_ScriptableEntity_wren_len;
extern unsigned char Resources_Scripts_ScriptableEntity_wren[];
extern const std::string Resources_Shaders_add_shader_path;
extern unsigned int Resources_Shaders_add_shader_len;
extern unsigned char Resources_Shaders_add_shader[];
extern const std::string Resources_Shaders_atmospheric_sky_shader_path;
extern unsigned int Resources_Shaders_atmospheric_sky_shader_len;
extern unsigned char Resources_Shaders_atmospheric_sky_shader[];
extern const std::string Resources_Shaders_barrel_distortion_shader_path;
extern unsigned int Resources_Shaders_barrel_distortion_shader_len;
extern unsigned char Resources_Shaders_barrel_distortion_shader[];
extern const std::string Resources_Shaders_bloom_shader_path;
extern unsigned int Resources_Shaders_bloom_shader_len;
extern unsigned char Resources_Shaders_bloom_shader[];
extern const std::string Resources_Shaders_blur_shader_path;
extern unsigned int Resources_Shaders_blur_shader_len;
extern unsigned char Resources_Shaders_blur_shader[];
extern const std::string Resources_Shaders_BRD_shader_path;
extern unsigned int Resources_Shaders_BRD_shader_len;
extern unsigned char Resources_Shaders_BRD_shader[];
extern const std::string Resources_Shaders_combine_shader_path;
extern unsigned int Resources_Shaders_combine_shader_len;
extern unsigned char Resources_Shaders_combine_shader[];
extern const std::string Resources_Shaders_copy_shader_path;
extern unsigned int Resources_Shaders_copy_shader_len;
extern unsigned char Resources_Shaders_copy_shader[];
extern const std::string Resources_Shaders_debugLine_shader_path;
extern unsigned int Resources_Shaders_debugLine_shader_len;
extern unsigned char Resources_Shaders_debugLine_shader[];
extern const std::string Resources_Shaders_deferred_shader_path;
extern unsigned int Resources_Shaders_deferred_shader_len;
extern unsigned char Resources_Shaders_deferred_shader[];
extern const std::string Resources_Shaders_depth_aware_blur_shader_path;
extern unsigned int Resources_Shaders_depth_aware_blur_shader_len;
extern unsigned char Resources_Shaders_depth_aware_blur_shader[];
extern const std::string Resources_Shaders_display_depth_shader_path;
extern unsigned int Resources_Shaders_display_depth_shader_len;
extern unsigned char Resources_Shaders_display_depth_shader[];
extern const std::string Resources_Shaders_dither_shader_path;
extern unsigned int Resources_Shaders_dither_shader_len;
extern unsigned char Resources_Shaders_dither_shader[];
extern const std::string Resources_Shaders_dof_shader_path;
extern unsigned int Resources_Shaders_dof_shader_len;
extern unsigned char Resources_Shaders_dof_shader[];
extern const std::string Resources_Shaders_flat_shader_path;
extern unsigned int Resources_Shaders_flat_shader_len;
extern unsigned char Resources_Shaders_flat_shader[];
extern const std::string Resources_Shaders_gbuffer_shader_path;
extern unsigned int Resources_Shaders_gbuffer_shader_len;
extern unsigned char Resources_Shaders_gbuffer_shader[];
extern const std::string Resources_Shaders_gbuffer_skinned_shader_path;
extern unsigned int Resources_Shaders_gbuffer_skinned_shader_len;
extern unsigned char Resources_Shaders_gbuffer_skinned_shader[];
extern const std::string Resources_Shaders_gizmo_shader_path;
extern unsigned int Resources_Shaders_gizmo_shader_len;
extern unsigned char Resources_Shaders_gizmo_shader[];
extern const std::string Resources_Shaders_line_shader_path;
extern unsigned int Resources_Shaders_line_shader_len;
extern unsigned char Resources_Shaders_line_shader[];
extern const std::string Resources_Shaders_outline_shader_path;
extern unsigned int Resources_Shaders_outline_shader_len;
extern unsigned char Resources_Shaders_outline_shader[];
extern const std::string Resources_Shaders_pbr_shader_path;
extern unsigned int Resources_Shaders_pbr_shader_len;
extern unsigned char Resources_Shaders_pbr_shader[];
extern const std::string Resources_Shaders_sdf_text_shader_path;
extern unsigned int Resources_Shaders_sdf_text_shader_len;
extern unsigned char Resources_Shaders_sdf_text_shader[];
extern const std::string Resources_Shaders_shadowMap_shader_path;
extern unsigned int Resources_Shaders_shadowMap_shader_len;
extern unsigned char Resources_Shaders_shadowMap_shader[];
extern const std::string Resources_Shaders_shadowMap_skinned_shader_path;
extern unsigned int Resources_Shaders_shadowMap_skinned_shader_len;
extern unsigned char Resources_Shaders_shadowMap_skinned_shader[];
extern const std::string Resources_Shaders_skybox_shader_path;
extern unsigned int Resources_Shaders_skybox_shader_len;
extern unsigned char Resources_Shaders_skybox_shader[];
extern const std::string Resources_Shaders_ssao_shader_path;
extern unsigned int Resources_Shaders_ssao_shader_len;
extern unsigned char Resources_Shaders_ssao_shader[];
extern const std::string Resources_Shaders_ssr_shader_path;
extern unsigned int Resources_Shaders_ssr_shader_len;
extern unsigned char Resources_Shaders_ssr_shader[];
extern const std::string Resources_Shaders_tonemap_shader_path;
extern unsigned int Resources_Shaders_tonemap_shader_len;
extern unsigned char Resources_Shaders_tonemap_shader[];
extern const std::string Resources_Shaders_ui_shader_path;
extern unsigned int Resources_Shaders_ui_shader_len;
extern unsigned char Resources_Shaders_ui_shader[];
extern const std::string Resources_Shaders_vignette_shader_path;
extern unsigned int Resources_Shaders_vignette_shader_len;
extern unsigned char Resources_Shaders_vignette_shader[];
extern const std::string Resources_Shaders_volumetric_shader_path;
extern unsigned int Resources_Shaders_volumetric_shader_len;
extern unsigned char Resources_Shaders_volumetric_shader[];
}
#include <string>
namespace Nuake {
namespace StaticResources {
extern const std::string Resources_default_layout_ini_path;
extern unsigned int Resources_default_layout_ini_len;
extern unsigned char Resources_default_layout_ini[];
extern const std::string Resources_resources_aps_path;
extern unsigned int Resources_resources_aps_len;
extern unsigned char Resources_resources_aps[];
extern const std::string Resources_resources_rc_path;
extern unsigned int Resources_resources_rc_len;
extern unsigned char Resources_resources_rc[];
extern const std::string Resources_Fonts_fa_regular_400_ttf_path;
extern unsigned int Resources_Fonts_fa_regular_400_ttf_len;
extern unsigned char Resources_Fonts_fa_regular_400_ttf[];
extern const std::string Resources_Fonts_fa_regular_400_big_ttf_path;
extern unsigned int Resources_Fonts_fa_regular_400_big_ttf_len;
extern unsigned char Resources_Fonts_fa_regular_400_big_ttf[];
extern const std::string Resources_Fonts_fa_solid_900_ttf_path;
extern unsigned int Resources_Fonts_fa_solid_900_ttf_len;
extern unsigned char Resources_Fonts_fa_solid_900_ttf[];
extern const std::string Resources_Fonts_FiraMono_Bold_ttf_path;
extern unsigned int Resources_Fonts_FiraMono_Bold_ttf_len;
extern unsigned char Resources_Fonts_FiraMono_Bold_ttf[];
extern const std::string Resources_Fonts_FiraMono_Regular_ttf_path;
extern unsigned int Resources_Fonts_FiraMono_Regular_ttf_len;
extern unsigned char Resources_Fonts_FiraMono_Regular_ttf[];
extern const std::string Resources_Fonts_OpenSans_Bold_ttf_path;
extern unsigned int Resources_Fonts_OpenSans_Bold_ttf_len;
extern unsigned char Resources_Fonts_OpenSans_Bold_ttf[];
extern const std::string Resources_Fonts_OpenSans_Regular_ttf_path;
extern unsigned int Resources_Fonts_OpenSans_Regular_ttf_len;
extern unsigned char Resources_Fonts_OpenSans_Regular_ttf[];
extern const std::string Resources_Fonts_Poppins_Regular_ttf_path;
extern unsigned int Resources_Fonts_Poppins_Regular_ttf_len;
extern unsigned char Resources_Fonts_Poppins_Regular_ttf[];
extern const std::string Resources_Fonts_RobotoMono_Regular_ttf_path;
extern unsigned int Resources_Fonts_RobotoMono_Regular_ttf_len;
extern unsigned char Resources_Fonts_RobotoMono_Regular_ttf[];
extern const std::string Resources_Gizmos_bone_png_path;
extern unsigned int Resources_Gizmos_bone_png_len;
extern unsigned char Resources_Gizmos_bone_png[];
extern const std::string Resources_Gizmos_camera_png_path;
extern unsigned int Resources_Gizmos_camera_png_len;
extern unsigned char Resources_Gizmos_camera_png[];
extern const std::string Resources_Gizmos_light_png_path;
extern unsigned int Resources_Gizmos_light_png_len;
extern unsigned char Resources_Gizmos_light_png[];
extern const std::string Resources_Gizmos_light_directional_png_path;
extern unsigned int Resources_Gizmos_light_directional_png_len;
extern unsigned char Resources_Gizmos_light_directional_png[];
extern const std::string Resources_Gizmos_light_spot_png_path;
extern unsigned int Resources_Gizmos_light_spot_png_len;
extern unsigned char Resources_Gizmos_light_spot_png[];
extern const std::string Resources_Gizmos_particles_png_path;
extern unsigned int Resources_Gizmos_particles_png_len;
extern unsigned char Resources_Gizmos_particles_png[];
extern const std::string Resources_Gizmos_player_png_path;
extern unsigned int Resources_Gizmos_player_png_len;
extern unsigned char Resources_Gizmos_player_png[];
extern const std::string Resources_Gizmos_rigidbody_png_path;
extern unsigned int Resources_Gizmos_rigidbody_png_len;
extern unsigned char Resources_Gizmos_rigidbody_png[];
extern const std::string Resources_Gizmos_sound_emitter_png_path;
extern unsigned int Resources_Gizmos_sound_emitter_png_len;
extern unsigned char Resources_Gizmos_sound_emitter_png[];
extern const std::string Resources_Images_audio_file_icon_png_path;
extern unsigned int Resources_Images_audio_file_icon_png_len;
extern unsigned char Resources_Images_audio_file_icon_png[];
extern const std::string Resources_Images_box_png_path;
extern unsigned int Resources_Images_box_png_len;
extern unsigned char Resources_Images_box_png[];
extern const std::string Resources_Images_code_png_path;
extern unsigned int Resources_Images_code_png_len;
extern unsigned char Resources_Images_code_png[];
extern const std::string Resources_Images_csharp_icon_png_path;
extern unsigned int Resources_Images_csharp_icon_png_len;
extern unsigned char Resources_Images_csharp_icon_png[];
extern const std::string Resources_Images_cube_png_path;
extern unsigned int Resources_Images_cube_png_len;
extern unsigned char Resources_Images_cube_png[];
extern const std::string Resources_Images_file_icon_png_path;
extern unsigned int Resources_Images_file_icon_png_len;
extern unsigned char Resources_Images_file_icon_png[];
extern const std::string Resources_Images_folder_icon_png_path;
extern unsigned int Resources_Images_folder_icon_png_len;
extern unsigned char Resources_Images_folder_icon_png[];
extern const std::string Resources_Images_light_png_path;
extern unsigned int Resources_Images_light_png_len;
extern unsigned char Resources_Images_light_png[];
extern const std::string Resources_Images_logo_png_path;
extern unsigned int Resources_Images_logo_png_len;
extern unsigned char Resources_Images_logo_png[];
extern const std::string Resources_Images_logo_white_png_path;
extern unsigned int Resources_Images_logo_white_png_len;
extern unsigned char Resources_Images_logo_white_png[];
extern const std::string Resources_Images_nuake_logo_png_path;
extern unsigned int Resources_Images_nuake_logo_png_len;
extern unsigned char Resources_Images_nuake_logo_png[];
extern const std::string Resources_Images_physics_png_path;
extern unsigned int Resources_Images_physics_png_len;
extern unsigned char Resources_Images_physics_png[];
extern const std::string Resources_Images_project_icon_png_path;
extern unsigned int Resources_Images_project_icon_png_len;
extern unsigned char Resources_Images_project_icon_png[];
extern const std::string Resources_Images_scene_icon_png_path;
extern unsigned int Resources_Images_scene_icon_png_len;
extern unsigned char Resources_Images_scene_icon_png[];
extern const std::string Resources_Images_screenshot_png_path;
extern unsigned int Resources_Images_screenshot_png_len;
extern unsigned char Resources_Images_screenshot_png[];
extern const std::string Resources_Images_script_file_icon_png_path;
extern unsigned int Resources_Images_script_file_icon_png_len;
extern unsigned char Resources_Images_script_file_icon_png[];
extern const std::string Resources_Images_shape_png_path;
extern unsigned int Resources_Images_shape_png_len;
extern unsigned char Resources_Images_shape_png[];
extern const std::string Resources_Images_speaker_png_path;
extern unsigned int Resources_Images_speaker_png_len;
extern unsigned char Resources_Images_speaker_png[];
extern const std::string Resources_Images_wrench_png_path;
extern unsigned int Resources_Images_wrench_png_len;
extern unsigned char Resources_Images_wrench_png[];
extern const std::string Resources_Scripts_Audio_wren_path;
extern unsigned int Resources_Scripts_Audio_wren_len;
extern unsigned char Resources_Scripts_Audio_wren[];
extern const std::string Resources_Scripts_Engine_wren_path;
extern unsigned int Resources_Scripts_Engine_wren_len;
extern unsigned char Resources_Scripts_Engine_wren[];
extern const std::string Resources_Scripts_Input_wren_path;
extern unsigned int Resources_Scripts_Input_wren_len;
extern unsigned char Resources_Scripts_Input_wren[];
extern const std::string Resources_Scripts_Math_wren_path;
extern unsigned int Resources_Scripts_Math_wren_len;
extern unsigned char Resources_Scripts_Math_wren[];
extern const std::string Resources_Scripts_Physics_wren_path;
extern unsigned int Resources_Scripts_Physics_wren_len;
extern unsigned char Resources_Scripts_Physics_wren[];
extern const std::string Resources_Scripts_Scene_wren_path;
extern unsigned int Resources_Scripts_Scene_wren_len;
extern unsigned char Resources_Scripts_Scene_wren[];
extern const std::string Resources_Scripts_ScriptableEntity_wren_path;
extern unsigned int Resources_Scripts_ScriptableEntity_wren_len;
extern unsigned char Resources_Scripts_ScriptableEntity_wren[];
extern const std::string Resources_Shaders_add_shader_path;
extern unsigned int Resources_Shaders_add_shader_len;
extern unsigned char Resources_Shaders_add_shader[];
extern const std::string Resources_Shaders_atmospheric_sky_shader_path;
extern unsigned int Resources_Shaders_atmospheric_sky_shader_len;
extern unsigned char Resources_Shaders_atmospheric_sky_shader[];
extern const std::string Resources_Shaders_barrel_distortion_shader_path;
extern unsigned int Resources_Shaders_barrel_distortion_shader_len;
extern unsigned char Resources_Shaders_barrel_distortion_shader[];
extern const std::string Resources_Shaders_bloom_shader_path;
extern unsigned int Resources_Shaders_bloom_shader_len;
extern unsigned char Resources_Shaders_bloom_shader[];
extern const std::string Resources_Shaders_blur_shader_path;
extern unsigned int Resources_Shaders_blur_shader_len;
extern unsigned char Resources_Shaders_blur_shader[];
extern const std::string Resources_Shaders_BRD_shader_path;
extern unsigned int Resources_Shaders_BRD_shader_len;
extern unsigned char Resources_Shaders_BRD_shader[];
extern const std::string Resources_Shaders_combine_shader_path;
extern unsigned int Resources_Shaders_combine_shader_len;
extern unsigned char Resources_Shaders_combine_shader[];
extern const std::string Resources_Shaders_copy_shader_path;
extern unsigned int Resources_Shaders_copy_shader_len;
extern unsigned char Resources_Shaders_copy_shader[];
extern const std::string Resources_Shaders_debugLine_shader_path;
extern unsigned int Resources_Shaders_debugLine_shader_len;
extern unsigned char Resources_Shaders_debugLine_shader[];
extern const std::string Resources_Shaders_deferred_shader_path;
extern unsigned int Resources_Shaders_deferred_shader_len;
extern unsigned char Resources_Shaders_deferred_shader[];
extern const std::string Resources_Shaders_depth_aware_blur_shader_path;
extern unsigned int Resources_Shaders_depth_aware_blur_shader_len;
extern unsigned char Resources_Shaders_depth_aware_blur_shader[];
extern const std::string Resources_Shaders_display_depth_shader_path;
extern unsigned int Resources_Shaders_display_depth_shader_len;
extern unsigned char Resources_Shaders_display_depth_shader[];
extern const std::string Resources_Shaders_dither_shader_path;
extern unsigned int Resources_Shaders_dither_shader_len;
extern unsigned char Resources_Shaders_dither_shader[];
extern const std::string Resources_Shaders_dof_shader_path;
extern unsigned int Resources_Shaders_dof_shader_len;
extern unsigned char Resources_Shaders_dof_shader[];
extern const std::string Resources_Shaders_flat_shader_path;
extern unsigned int Resources_Shaders_flat_shader_len;
extern unsigned char Resources_Shaders_flat_shader[];
extern const std::string Resources_Shaders_gbuffer_shader_path;
extern unsigned int Resources_Shaders_gbuffer_shader_len;
extern unsigned char Resources_Shaders_gbuffer_shader[];
extern const std::string Resources_Shaders_gbuffer_skinned_shader_path;
extern unsigned int Resources_Shaders_gbuffer_skinned_shader_len;
extern unsigned char Resources_Shaders_gbuffer_skinned_shader[];
extern const std::string Resources_Shaders_gizmo_shader_path;
extern unsigned int Resources_Shaders_gizmo_shader_len;
extern unsigned char Resources_Shaders_gizmo_shader[];
extern const std::string Resources_Shaders_line_shader_path;
extern unsigned int Resources_Shaders_line_shader_len;
extern unsigned char Resources_Shaders_line_shader[];
extern const std::string Resources_Shaders_outline_shader_path;
extern unsigned int Resources_Shaders_outline_shader_len;
extern unsigned char Resources_Shaders_outline_shader[];
extern const std::string Resources_Shaders_pbr_shader_path;
extern unsigned int Resources_Shaders_pbr_shader_len;
extern unsigned char Resources_Shaders_pbr_shader[];
extern const std::string Resources_Shaders_sdf_text_shader_path;
extern unsigned int Resources_Shaders_sdf_text_shader_len;
extern unsigned char Resources_Shaders_sdf_text_shader[];
extern const std::string Resources_Shaders_shadowMap_shader_path;
extern unsigned int Resources_Shaders_shadowMap_shader_len;
extern unsigned char Resources_Shaders_shadowMap_shader[];
extern const std::string Resources_Shaders_shadowMap_skinned_shader_path;
extern unsigned int Resources_Shaders_shadowMap_skinned_shader_len;
extern unsigned char Resources_Shaders_shadowMap_skinned_shader[];
extern const std::string Resources_Shaders_skybox_shader_path;
extern unsigned int Resources_Shaders_skybox_shader_len;
extern unsigned char Resources_Shaders_skybox_shader[];
extern const std::string Resources_Shaders_ssao_shader_path;
extern unsigned int Resources_Shaders_ssao_shader_len;
extern unsigned char Resources_Shaders_ssao_shader[];
extern const std::string Resources_Shaders_ssr_shader_path;
extern unsigned int Resources_Shaders_ssr_shader_len;
extern unsigned char Resources_Shaders_ssr_shader[];
extern const std::string Resources_Shaders_tonemap_shader_path;
extern unsigned int Resources_Shaders_tonemap_shader_len;
extern unsigned char Resources_Shaders_tonemap_shader[];
extern const std::string Resources_Shaders_ui_shader_path;
extern unsigned int Resources_Shaders_ui_shader_len;
extern unsigned char Resources_Shaders_ui_shader[];
extern const std::string Resources_Shaders_vignette_shader_path;
extern unsigned int Resources_Shaders_vignette_shader_len;
extern unsigned char Resources_Shaders_vignette_shader[];
extern const std::string Resources_Shaders_volumetric_shader_path;
extern unsigned int Resources_Shaders_volumetric_shader_len;
extern unsigned char Resources_Shaders_volumetric_shader[];
}
}
#endif // FILES_DATA_H

Some files were not shown because too many files have changed in this diff Show More