-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58e5eea
commit a25e355
Showing
46 changed files
with
598 additions
and
326 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
include(${CMAKE_SOURCE_DIR}/cmake/common.cmake) | ||
|
||
era_begin(assets_compiler "APP") | ||
require_thirdparty_module(assets_compiler EnTT) | ||
require_thirdparty_module(assets_compiler yaml-cpp) | ||
require_thirdparty_module(assets_compiler rttr_core) | ||
require_thirdparty_module(assets_compiler DirectXTex) | ||
require_module(assets_compiler base) | ||
require_module(assets_compiler core) | ||
|
||
target_include_directories(assets_compiler PUBLIC modules/thirdparty-imgui/imgui) | ||
era_end(assets_compiler) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Copyright (c) 2023-present Eldar Muradov. All rights reserved. | ||
#include <fstream> | ||
#include <iostream> | ||
|
||
#include <clara/clapa.hpp> | ||
|
||
#include <asset/bin.h> | ||
#include <asset/model_asset.h> | ||
|
||
#include <core/log.h> | ||
#include <core/string.h> | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
using namespace era_engine; | ||
using namespace clara; | ||
|
||
try | ||
{ | ||
fs::path path; | ||
bool verbose = false; | ||
|
||
Parser cli; | ||
cli += Opt(verbose, "verbose")["-v"]["--verbose"]("Enable verbose logging"); | ||
cli += Opt(path, "path")["-p"]["--path"]("Path to asset"); | ||
|
||
auto result = cli.parse(Args(argc, argv)); | ||
if (!result) | ||
{ | ||
std::cerr << "Error in command line: " << result.errorMessage() << std::endl; | ||
} | ||
|
||
path = get_full_path(path); | ||
|
||
if (!fs::exists(path)) | ||
{ | ||
std::cerr << "Could not find file '" << path << "'.\n"; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
std::string extension = path.extension().string(); | ||
|
||
fs::path cached_filename = path; | ||
cached_filename.replace_extension("." + std::to_string(mesh_flag_default) + ".cache.bin"); | ||
fs::path cache_filepath = L"asset_cache" / cached_filename; | ||
|
||
if (fs::exists(cache_filepath)) | ||
{ | ||
auto last_cache_write_time = fs::last_write_time(cache_filepath); | ||
auto last_original_write_time = fs::last_write_time(path); | ||
|
||
if (last_cache_write_time > last_original_write_time) | ||
{ | ||
std::cout << "Asset is already compiled! \n"; | ||
return EXIT_SUCCESS; | ||
} | ||
} | ||
|
||
std::cout << "Preprocessing asset '" << path << "' for faster loading next time.\n"; | ||
|
||
ModelAsset result_mesh; | ||
|
||
std::transform(extension.begin(), extension.end(), extension.begin(), | ||
[](char c) { return std::tolower(c); }); | ||
if (extension == ".fbx") | ||
{ | ||
result_mesh = loadFBX(path, mesh_flag_default); | ||
} | ||
else if (extension == ".obj") | ||
{ | ||
result_mesh = loadOBJ(path, mesh_flag_default); | ||
} | ||
|
||
fs::create_directories(cache_filepath.parent_path()); | ||
writeBIN(result_mesh, cache_filepath); | ||
} | ||
catch (const std::exception& ex) | ||
{ | ||
std::cerr << ex.what() << "\n"; | ||
|
||
std::ofstream output("logs/compiler_error_log.txt"); | ||
output << "Runtime Error>" << ex.what() << std::endl; | ||
output.close(); | ||
|
||
std::this_thread::sleep_for(std::chrono::duration<float>(5000.0f)); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include "editor/editor_init_system.h" | ||
|
||
#include <core/ecs/input_reciever_component.h> | ||
#include <core/ecs/input_sender_component.h> | ||
#include <core/string.h> | ||
|
||
#include <rendering/mesh_shader.h> | ||
#include <rendering/ecs/renderer_holder_root_component.h> | ||
|
||
#include <ecs/update_groups.h> | ||
#include <ecs/base_components/transform_component.h> | ||
#include <ecs/rendering/world_renderer.h> | ||
#include <ecs/rendering/scene_rendering.h> | ||
#include <core/ecs/camera_holder_component.h> | ||
#include <ecs/rendering/mesh_component.h> | ||
|
||
#include <audio/audio.h> | ||
|
||
#include <terrain/terrain.h> | ||
|
||
#include <animation/skinning.h> | ||
|
||
#include <rttr/policy.h> | ||
#include <rttr/registration> | ||
|
||
namespace era_engine | ||
{ | ||
RTTR_REGISTRATION | ||
{ | ||
using namespace rttr; | ||
|
||
registration::class_<EditorInitSystem>("GameInitSystem") | ||
.constructor<World*>()(policy::ctor::as_raw_ptr) | ||
.method("update", &EditorInitSystem::update)(metadata("update_group", update_types::BEGIN)); | ||
} | ||
|
||
EditorInitSystem::EditorInitSystem(World* _world) | ||
: System(_world) | ||
{ | ||
} | ||
|
||
EditorInitSystem::~EditorInitSystem() | ||
{ | ||
} | ||
|
||
void EditorInitSystem::init() | ||
{ | ||
RendererHolderRootComponent* renderer_holder_rc = world->add_root_component<RendererHolderRootComponent>(); | ||
ASSERT(renderer_holder_rc != nullptr); | ||
|
||
Entity camera_entity = world->create_entity("CameraEntity"); | ||
camera_entity.add_component<CameraHolderComponent>() | ||
.add_component<InputRecieverComponent>() | ||
.add_component<InputSenderComponent>(); | ||
|
||
CameraHolderComponent& camera_holder_component = camera_entity.get_component<CameraHolderComponent>(); | ||
camera_holder_component.set_camera_type(CameraHolderComponent::FREE_CAMERA); | ||
camera_holder_component.set_render_camera(&renderer_holder_rc->camera); | ||
|
||
camera_entity.get_component<InputSenderComponent>().add_reciever(camera_entity.get_component_if_exists<InputRecieverComponent>()); | ||
} | ||
|
||
void EditorInitSystem::update(float dt) | ||
{ | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#include <ecs/system.h> | ||
|
||
namespace era_engine | ||
{ | ||
|
||
class EditorInitSystem final : public System | ||
{ | ||
public: | ||
EditorInitSystem(World* _world); | ||
~EditorInitSystem(); | ||
|
||
void init() override; | ||
void update(float dt) override; | ||
ERA_VIRTUAL_REFLECT(System) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#pragma once | ||
|
||
#include "ecs/system.h" | ||
#include <ecs/system.h> | ||
|
||
namespace era_engine | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#include "core_api.h" | ||
|
||
namespace era_engine | ||
{ | ||
struct ModelAsset; | ||
|
||
ERA_CORE_API void writeBIN(const ModelAsset& asset, const fs::path& path); | ||
|
||
ERA_CORE_API ModelAsset loadFBX(const fs::path& path, uint32 flags); | ||
ERA_CORE_API ModelAsset loadOBJ(const fs::path& path, uint32 flags); | ||
ERA_CORE_API ModelAsset loadBIN(const fs::path& path); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.