diff --git a/.gitattributes b/.gitattributes index 44b7e7df6e16968f484ac85f7825c490e95212e7..89e6e0465dcb4de965d7340518d0fc757f43e1ca 100644 --- a/.gitattributes +++ b/.gitattributes @@ -21,4 +21,5 @@ README.md text *.PNG filter=lfs diff=lfs merge=lfs *.OBJ filter=lfs diff=lfs merge=lfs -text *.JPG filter=lfs diff=lfs merge=lfs -*.MTL filter=lfs diff=lfs merge=lfs -text \ No newline at end of file +*.MTL filter=lfs diff=lfs merge=lfs -text +*.stl filter=lfs diff=lfs merge=lfs -text diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bd70efcfca3aea4ab861f211810a9a55079822ee..0cff5604add6f8058e9a2d2398ea0540b0142e0d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,6 +20,7 @@ #------------------------------------------------------------------------------- stages: + - clear - conan - cmake - build @@ -29,8 +30,12 @@ stages: # Windows #------------------------------------------------------------------------------- +# casual builds + conan:windows:msvc++14.1: stage: conan + except: + - schedules tags: - msvc++14.1 - opengl @@ -46,6 +51,8 @@ conan:windows:msvc++14.1: cmake:windows:msvc++14.1: stage: cmake + except: + - schedules tags: - msvc++14.1 - opengl @@ -62,6 +69,8 @@ cmake:windows:msvc++14.1: build:windows:msvc++14.1: stage: build + except: + - schedules tags: - msvc++14.1 - opengl @@ -80,6 +89,8 @@ build:windows:msvc++14.1: test:windows:msvc++14.1: stage: test + except: + - schedules tags: - msvc++14.1 - opengl @@ -89,12 +100,100 @@ test:windows:msvc++14.1: - cd build - cmake --build . --config Release --target Unit-Test-Suite +# nightly builds + +clear:windows_nightly:msvc++14.1: + stage: clear + only: + - schedules + tags: + - msvc++14.1 + - nightly + script: + - echo %CONAN_USER_HOME% + - cd C:\dev && rmdir /s /q conan_nightly + - mkdir conan_nightly + +conan:windows_nightly:msvc++14.1: + stage: conan + only: + - schedules + tags: + - msvc++14.1 + - nightly + script: + - conan remote add rwth-vr--bintray https://api.bintray.com/conan/rwth-vr/conan + - conan remote add bincrafters_public https://api.bintray.com/conan/bincrafters/public-conan + - rmdir /s /q build + - mkdir build + - cd build + - conan install --build=missing -s compiler="Visual Studio" -s compiler.version=15 -s build_type=Release -s compiler.runtime=MD .. + artifacts: + paths: + - build + expire_in: 1 week + +cmake:windows_nightly:msvc++14.1: + stage: cmake + only: + - schedules + tags: + - msvc++14.1 + - nightly + dependencies: + - conan:windows_nightly:msvc++14.1 + script: + - cd build + - cmake -G "Visual Studio 15 2017 Win64" -DIS_BUILD_SERVER:BOOL=TRUE .. + artifacts: + untracked: true + paths: + - build + expire_in: 1 week + +build:windows_nightly:msvc++14.1: + stage: build + only: + - schedules + tags: + - msvc++14.1 + - nightly + dependencies: + - cmake:windows_nightly:msvc++14.1 + script: + - cd build + - cmake --build . --config Release --target Cpplint-Test-Suite + - cmake --build . --config Release --target Cppcheck-Test-Suite + - cmake --build . --config Release -- /m /verbosity:minimal + artifacts: + paths: + - build + expire_in: 1 week + allow_failure: true + +test:windows_nightly:msvc++14.1: + stage: test + only: + - schedules + tags: + - msvc++14.1 + - nightly + dependencies: + - build:windows_nightly:msvc++14.1 + script: + - cd build + - cmake --build . --config Release --target Unit-Test-Suite + #------------------------------------------------------------------------------- # Linux #------------------------------------------------------------------------------- +# casual builds + conan:linux:gcc5.3.1: stage: conan + except: + - schedules tags: - gcc5.3.1 - opengl @@ -111,6 +210,8 @@ conan:linux:gcc5.3.1: conan:linux:gcc6.3.1: stage: conan + except: + - schedules tags: - gcc6.3.1 - opengl @@ -127,6 +228,8 @@ conan:linux:gcc6.3.1: cmake:linux:gcc5.3.1: stage: cmake + except: + - schedules tags: - gcc5.3.1 - opengl @@ -143,6 +246,8 @@ cmake:linux:gcc5.3.1: cmake:linux:gcc6.3.1: stage: cmake + except: + - schedules tags: - gcc6.3.1 - opengl @@ -159,6 +264,8 @@ cmake:linux:gcc6.3.1: build:linux:gcc5.3.1: stage: build + except: + - schedules tags: - gcc5.3.1 - opengl @@ -177,6 +284,8 @@ build:linux:gcc5.3.1: build:linux:gcc6.3.1: stage: build + except: + - schedules tags: - gcc6.3.1 - opengl @@ -195,6 +304,8 @@ build:linux:gcc6.3.1: test:linux:gcc5.3.1: stage: test + except: + - schedules tags: - gcc5.3.1 - opengl @@ -206,6 +317,8 @@ test:linux:gcc5.3.1: test:linux:gcc6.3.1: stage: test + except: + - schedules tags: - gcc6.3.1 - opengl @@ -214,3 +327,173 @@ test:linux:gcc6.3.1: script: - cd build - make Unit-Test-Suite + +# nightly builds + +clear:linux_nightly:gcc5.3.1: + stage: clear + only: + - schedules + tags: + - gcc5.3.1 + - nightly + script: + - echo $CONAN_USER_HOME + - cd /home/gitlab-runner/dev + - rm -rf ./conan_nightly_5_3_1 + - mkdir conan_nightly_5_3_1 + +clear:linux_nightly:gcc6.3.1: + stage: clear + only: + - schedules + tags: + - gcc6.3.1 + - nightly + script: + - echo $CONAN_USER_HOME + - cd /home/gitlab-runner/dev + - rm -rf ./conan_nightly_6_3_1 + - mkdir conan_nightly_6_3_1 + +conan:linux_nightly:gcc5.3.1: + stage: conan + only: + - schedules + tags: + - gcc5.3.1 + - nightly + script: + - conan remote add rwth-vr--bintray https://api.bintray.com/conan/rwth-vr/conan + - conan remote add bincrafters_public https://api.bintray.com/conan/bincrafters/public-conan + - mkdir build + - cd build + - export CC=gcc + - export CXX=g++ + - conan install .. --build=missing -s compiler="gcc" -s compiler.version="5.3" -s compiler.libcxx="libstdc++11" -s build_type=Release + artifacts: + paths: + - build + expire_in: 1 week + +conan:linux_nightly:gcc6.3.1: + stage: conan + only: + - schedules + tags: + - gcc6.3.1 + - nightly + script: + - conan remote add rwth-vr--bintray https://api.bintray.com/conan/rwth-vr/conan + - conan remote add bincrafters_public https://api.bintray.com/conan/bincrafters/public-conan + - mkdir build + - cd build + - export CC=gcc + - export CXX=g++ + - conan install .. --build=missing -s compiler="gcc" -s compiler.version="6.3" -s compiler.libcxx="libstdc++11" -s build_type=Release + artifacts: + paths: + - build + expire_in: 1 week + +cmake:linux_nightly:gcc5.3.1: + stage: cmake + only: + - schedules + tags: + - gcc5.3.1 + - nightly + dependencies: + - conan:linux_nightly:gcc5.3.1 + script: + - cd build + - cmake .. -DIS_BUILD_SERVER:BOOL=TRUE -DCMAKE_BUILD_TYPE=Release + artifacts: + untracked: true + paths: + - build + expire_in: 1 week + +cmake:linux_nightly:gcc6.3.1: + stage: cmake + only: + - schedules + tags: + - gcc6.3.1 + - nightly + dependencies: + - conan:linux_nightly:gcc6.3.1 + script: + - cd build + - cmake .. -DIS_BUILD_SERVER:BOOL=TRUE -DCMAKE_BUILD_TYPE=Release + artifacts: + untracked: true + paths: + - build + expire_in: 1 week + +build:linux_nightly:gcc5.3.1: + stage: build + only: + - schedules + tags: + - gcc5.3.1 + - nightly + dependencies: + - cmake:linux_nightly:gcc5.3.1 + script: + - cd build + - make Cpplint-Test-Suite + - make Cppcheck-Test-Suite + - make -j8 + artifacts: + paths: + - build + expire_in: 1 week + allow_failure: true + +build:linux_nightly:gcc6.3.1: + stage: build + only: + - schedules + tags: + - gcc6.3.1 + - nightly + dependencies: + - cmake:linux_nightly:gcc6.3.1 + script: + - cd build + - make Cpplint-Test-Suite + - make Cppcheck-Test-Suite + - make -j8 + artifacts: + paths: + - build + expire_in: 1 week + allow_failure: true + +test:linux_nightly:gcc5.3.1: + stage: test + only: + - schedules + tags: + - gcc5.3.1 + - nightly + dependencies: + - build:linux_nightly:gcc5.3.1 + script: + - cd build + - make Unit-Test-Suite + +test:linux_nightly:gcc6.3.1: + stage: test + only: + - schedules + tags: + - gcc6.3.1 + - nightly + dependencies: + - build:linux_nightly:gcc6.3.1 + script: + - cd build + - make Unit-Test-Suite \ No newline at end of file diff --git a/cmake/WarningLevels.cmake b/cmake/WarningLevels.cmake index 8b20c58477352b4a7a88ff43a9d073d39bfd4c2d..56a8e549bb1067c10917f306c3ef5e7b68d45396 100644 --- a/cmake/WarningLevels.cmake +++ b/cmake/WarningLevels.cmake @@ -41,6 +41,7 @@ set(WARNING_LEVELS_RWTH_GCC -Wall -Wextra -Wmissing-braces + -Wmissing-declarations -pedantic -pedantic-errors -Wno-c++98-compat diff --git a/cmake/assign_source_group.cmake b/cmake/assign_source_group.cmake new file mode 100644 index 0000000000000000000000000000000000000000..648f93ebd32efe33f2d366e4a08c4ec2d0598f26 --- /dev/null +++ b/cmake/assign_source_group.cmake @@ -0,0 +1,17 @@ +# Assigns the given files to source groups identical to their location. +function(assign_source_group) + foreach(_SOURCE IN ITEMS ${ARGN}) + if (IS_ABSOLUTE "${_SOURCE}") + file(RELATIVE_PATH _SOURCE_REL "${CMAKE_CURRENT_SOURCE_DIR}" "${_SOURCE}") + else() + set(_SOURCE_REL "${_SOURCE}") + endif() + get_filename_component(_SOURCE_PATH "${_SOURCE_REL}" PATH) + if(WIN32) + string(REPLACE "/" "\\" _SOURCE_PATH_MSVC "${_SOURCE_PATH}") + source_group("${_SOURCE_PATH_MSVC}" FILES "${_SOURCE}") + else() + source_group("${_SOURCE_PATH}" FILES "${_SOURCE}") + endif() + endforeach() +endfunction(assign_source_group) \ No newline at end of file diff --git a/cmake/suppress_warnings.hpp.in b/cmake/suppress_warnings.hpp.in index 89e84c7db1004f1bdebdd3f3099b0182e6dd8a58..5a9ae8a7c8ad2d395ce944f1a859c6d09c11b93c 100644 --- a/cmake/suppress_warnings.hpp.in +++ b/cmake/suppress_warnings.hpp.in @@ -40,15 +40,19 @@ _Pragma("clang diagnostic ignored \"-Wsign-conversion\"") \ _Pragma("clang diagnostic ignored \"-Wnewline-eof\"") \ _Pragma("clang diagnostic ignored \"-Wnon-virtual-dtor\"") \ - _Pragma("clang diagnostic ignored \"-Wextra-semi\"") + _Pragma("clang diagnostic ignored \"-Wextra-semi\"") #define SUPPRESS_WARNINGS_BEGIN_PADDED \ _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Wpadded\"") +#define SUPPRESS_WARNINGS_BEGIN_MISSING_DECLARATIONS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wmissing-prototypes\"") #define SUPPRESS_WARNINGS_END _Pragma("clang diagnostic pop") #elif defined _MSC_VER #define SUPPRESS_WARNINGS_BEGIN __pragma(warning(push, 0)); #define SUPPRESS_WARNINGS_BEGIN_PADDED __pragma(warning(push)); +#define SUPPRESS_WARNINGS_BEGIN_MISSING_DECLARATIONS __pragma(warning(push)); #define SUPPRESS_WARNINGS_END __pragma(warning(pop)); #elif defined __GNUC__ @@ -63,10 +67,14 @@ SUPPRESS_WARNINGS_GCC7_AND_ABOVE \ _Pragma("GCC diagnostic ignored \"-Wall\"") \ _Pragma("GCC diagnostic ignored \"-Wextra\"") \ + _Pragma("GCC diagnostic ignored \"-Wmissing-declarations\"") \ _Pragma("GCC diagnostic ignored \"-Wpadded\"") #define SUPPRESS_WARNINGS_BEGIN_PADDED \ _Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic ignored \"-Wpadded\"") +#define SUPPRESS_WARNINGS_BEGIN_MISSING_DECLARATIONS \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wmissing-declarations\"") #define SUPPRESS_WARNINGS_END _Pragma("GCC diagnostic pop") #endif diff --git a/conanfile.py b/conanfile.py index 41cacdd49a281bd7bdcfdcb1c544221f16fb7ea6..f76578b8f71b5b0ee45153a53fd986c97e7dc5d7 100644 --- a/conanfile.py +++ b/conanfile.py @@ -24,7 +24,7 @@ from conans import ConanFile, CMake class ProjectPhoenix(ConanFile): name = "phx" - version = "18.03.0" + version = "18.05.0" license = "3-Clause BSD License" description = """Project Phoenix""" settings = "os", "compiler", "build_type", "arch" @@ -64,6 +64,8 @@ class ProjectPhoenix(ConanFile): self.copy("*.dll", dst="tests/Release", src="bin") self.copy("*.dll", dst="demos/viewer/Debug", src="bin") self.copy("*.dll", dst="demos/viewer/Release", src="bin") + self.copy("*.dll", dst="demos/combustion_demo/Debug", src="bin") + self.copy("*.dll", dst="demos/combustion_demo/Release", src="bin") self.copy("*.so", dst="lib", src="lib") self.copy("*.so*", dst="lib", src="lib") self.copy("*.dylib", dst="lib", src="lib") diff --git a/demos/CMakeLists.txt b/demos/CMakeLists.txt index ea9e625480443f4a735aee5a0754c18485e22390..5418319efff8cbaf7308ecb1ab73d1de0a5e63f3 100644 --- a/demos/CMakeLists.txt +++ b/demos/CMakeLists.txt @@ -21,3 +21,4 @@ #------------------------------------------------------------------------------ add_subdirectory(viewer) +add_subdirectory(combustion_demo) \ No newline at end of file diff --git a/demos/combustion_demo/CMakeLists.txt b/demos/combustion_demo/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..6746db4d55f561712c96aefc61bc47eca30df255 --- /dev/null +++ b/demos/combustion_demo/CMakeLists.txt @@ -0,0 +1,47 @@ +#------------------------------------------------------------------------------ +# Project Phoenix +# +# Copyright (c) 2017-2018 RWTH Aachen University, Germany, +# Virtual Reality & Immersive Visualization Group. +#------------------------------------------------------------------------------ +# License +# +# Licensed under the 3-Clause BSD License (the "License"); +# you may not use this file except in compliance with the License. +# See the file LICENSE for the full text. +# You may obtain a copy of the License at +# +# https://opensource.org/licenses/BSD-3-Clause +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#------------------------------------------------------------------------------ + +file(GLOB COMBUSTION_DEMO_SOURCES src/*.cpp) +file(GLOB COMBUSTION_DEMO_HEADERS src/*.hpp) + +add_executable(combustion_demo + ${COMBUSTION_DEMO_SOURCES} + ${COMBUSTION_DEMO_HEADERS} + resource_file.rc +) + +target_include_directories(combustion_demo + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src + phoenix +) +target_link_libraries(combustion_demo + phoenix +) +set_warning_levels_RWTH(combustion_demo) +add_test_cpplint(NAME "combustion_demo--cpplint" + ${COMBUSTION_DEMO_SOURCES} + ${COMBUSTION_DEMO_HEADERS} +) + +add_test_cppcheck(NAME "combustion_demo--cppcheck" + ${COMBUSTION_DEMO_SOURCES} +) diff --git a/demos/combustion_demo/debug.ico b/demos/combustion_demo/debug.ico new file mode 100644 index 0000000000000000000000000000000000000000..d50bba3f00e11284dacdb4fc5204d44719d06f17 Binary files /dev/null and b/demos/combustion_demo/debug.ico differ diff --git a/demos/combustion_demo/phoenix.ico b/demos/combustion_demo/phoenix.ico new file mode 100644 index 0000000000000000000000000000000000000000..eb61a4bbc71865920433a7e6a017048146f26ba9 Binary files /dev/null and b/demos/combustion_demo/phoenix.ico differ diff --git a/demos/combustion_demo/resource_file.rc b/demos/combustion_demo/resource_file.rc new file mode 100644 index 0000000000000000000000000000000000000000..9d43170e1f42673464a80b382527e7e1de273191 --- /dev/null +++ b/demos/combustion_demo/resource_file.rc @@ -0,0 +1,7 @@ +// Icon Resource Definition +#define MAIN_ICON 102 +#if defined(_DEBUG) +MAIN_ICON ICON "debug.ico" +#else +MAIN_ICON ICON "phoenix.ico" +#endif \ No newline at end of file diff --git a/demos/combustion_demo/src/combustion_demo.cpp b/demos/combustion_demo/src/combustion_demo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ab98cf21304a2b4c89fb7af0d7c128616598acde --- /dev/null +++ b/demos/combustion_demo/src/combustion_demo.cpp @@ -0,0 +1,204 @@ +//------------------------------------------------------------------------------ +// Project Phoenix +// +// Copyright (c) 2017-2018 RWTH Aachen University, Germany, +// Virtual Reality & Immersive Visualization Group. +//------------------------------------------------------------------------------ +// License +// +// Licensed under the 3-Clause BSD License (the "License"); +// you may not use this file except in compliance with the License. +// See the file LICENSE for the full text. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/BSD-3-Clause +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//------------------------------------------------------------------------------ + +#include <chrono> +#include <future> +#include <iostream> +#include <memory> +#include <string> +#include <utility> +#include <vector> + +#include "desk_behavior.hpp" +#include "desktop_navigation_behavior.hpp" +#include "phx/core/runtime_component.hpp" +#include "phx/display/display_system_openvr.hpp" +#include "phx/display/display_system_window.hpp" +#include "phx/input/input_system.hpp" +#include "phx/rendering/auxiliary/splash_screen.hpp" +#include "phx/rendering/components/mesh_handle.hpp" +#include "phx/resources/loaders/assimp_model_loader.hpp" +#include "phx/resources/loaders/scene_loader.hpp" +#include "phx/setup.hpp" +#include "vr_controller_navigation_behavior.hpp" + +#if defined __clang__ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#endif + +int main(int, char**) { + std::unique_ptr<phx::Engine> engine = phx::Setup::CreateDefaultEngine(false); + auto scene = engine->GetScene(); + auto rendering_system = engine->GetSystem<phx::RenderingSystem>(); + rendering_system->SetEnabled(false); + auto openvr_system = engine->GetSystem<phx::DisplaySystemOpenVR>(); + + phx::SplashScreen* splash = engine->CreateSystem<phx::SplashScreen>( + engine->GetSystem<phx::DisplaySystemWindow>()->GetWindow()); + engine->MoveSystemBefore(splash, + engine->GetSystem<phx::DisplaySystemWindow>()); + + auto assimp_loader = static_cast<phx::AssimpModelLoader*>( + phx::ResourceManager::instance().GetLoaderForType(".stl")); + + assimp_loader->SetProgressUpdateCallback( + [splash](float progress) { splash->SetLoadProgress(progress); }); + + phx::InputSystem* input_system = engine->GetSystem<phx::InputSystem>(); + + input_system->AddKeyPressCallback([&engine](char key) { + if (key == 'q') engine->Stop(); + }); + + auto virtual_platform = scene->GetEntitiesWithComponents< + phx::RuntimeComponent<phx::USER_PLATFORM>>()[0]; + // virtual_platform->AddComponent<DesktopNavigationBehavior>( + // engine->GetSystem<phx::InputSystem>()); + auto controller_navigation_behavior = + virtual_platform->AddComponent<VRControllerNavigationBehavior>( + openvr_system); + + auto handle = std::async([&controller_navigation_behavior, &scene, + rendering_system, splash, input_system, + openvr_system]() { + auto model_surface_entity = phx::SceneLoader::InsertModelIntoScene( + "models/combustion/mixture_surface_0.2_lower.stl", scene.get()); + auto surface_transform = + model_surface_entity->GetFirstComponent<phx::Transform>(); + auto surface_material_handle = + surface_transform->GetChild(0) + ->GetEntity() + ->GetFirstComponent<phx::MaterialHandle>(); + auto surface_material = surface_material_handle->GetMaterial(); + surface_material->SetAmbientColor(glm::vec3(0.1f)); + surface_material->SetDiffuseColor(glm::vec3(1.0f)); + surface_material->SetSpecularColor(glm::vec3(0.4f)); + surface_material->SetShininess(100.0); + + auto model_boundingbox = phx::SceneLoader::InsertModelIntoScene( + "models/combustion/data_box.stl", scene.get()); + auto boundingbox_transform = + model_boundingbox->GetFirstComponent<phx::Transform>(); + auto boundingbox_mesh_handle = boundingbox_transform->GetChild(0) + ->GetEntity() + ->GetFirstComponent<phx::MeshHandle>(); + boundingbox_mesh_handle->SetWireframeMode(true); + + std::array<glm::vec3, 2> bbox = + boundingbox_mesh_handle->GetMesh()->GetBoundingBox(); + glm::vec3 bbox_diff = bbox[1] - bbox[0]; + glm::vec3 center_vec = bbox_diff * 0.5f * 0.001f; + surface_transform->SetLocalTranslation(-center_vec); + boundingbox_transform->SetLocalTranslation( + glm::vec3(-center_vec[0], center_vec[1], -center_vec[2])); + + auto vis_root = scene->CreateEntity(); + auto vis_root_transform = vis_root->AddComponent<phx::Transform>(); + surface_transform->SetParent(vis_root_transform, false); + boundingbox_transform->SetParent(vis_root_transform, false); + vis_root_transform->SetLocalScale(glm::vec3(0.001f, 0.001f, 0.001f)); + vis_root_transform->SetLocalTranslation(glm::vec3(-0.4f, 0.02f, -0.25f)); + + auto floor_entity = phx::SceneLoader::InsertModelIntoScene( + "models/cube/cube.obj", scene.get()); + auto floor_transform = floor_entity->GetFirstComponent<phx::Transform>(); + floor_transform->SetLocalScale(glm::vec3(1000.0f, 0.05f, 1000.0f)); + auto floor_material = floor_transform->GetChild(0) + ->GetEntity() + ->GetFirstComponent<phx::MaterialHandle>(); + floor_material->GetMaterial()->SetDiffuseColor(glm::vec3(0.5f, 0.5f, 0.5f)); + floor_material->GetMaterial()->SetSpecularColor( + glm::vec3(1.0f, 1.0f, 1.0f)); + floor_material->GetMaterial()->SetAmbientColor(glm::vec3(0.1f, 0.1f, 0.1f)); + + controller_navigation_behavior->SetTarget(vis_root_transform); + + auto desk_entity = phx::SceneLoader::InsertModelIntoScene( + "models/cube/cube2.obj", scene.get()); + auto desk_transform = desk_entity->GetFirstComponent<phx::Transform>(); + desk_transform->SetLocalScale(glm::vec3(2.0f, 0.03f, 1.0f)); + auto desk_material = desk_transform->GetChild(0) + ->GetEntity() + ->GetFirstComponent<phx::MaterialHandle>(); + desk_material->GetMaterial()->SetDiffuseColor(glm::vec3(0.5f, 1.0f, 0.5f)); + desk_material->GetMaterial()->SetSpecularColor(glm::vec3(1.0f, 1.0f, 1.0f)); + desk_material->GetMaterial()->SetAmbientColor(glm::vec3(0.1f, 0.2f, 0.1f)); + + auto desk_root = scene->CreateEntity(); + auto desk_root_transform = desk_root->AddComponent<phx::Transform>(); + desk_root_transform->SetLocalTranslation(glm::vec3(0.0f, 0.8f, 0.0f)); + desk_transform->SetParent(desk_root_transform, false); + vis_root_transform->SetParent(desk_root_transform, false); + desk_root->AddComponent<DeskBehavior>(openvr_system); + + rendering_system->SetEnabled(true); + splash->SetEnabled(false); + }); + + std::vector<glm::quat> light_dirs{ + glm::quat(glm::angleAxis(-0.25f * glm::pi<float>(), glm::vec3(1, 0, 0))), + glm::quat(glm::angleAxis(0.25f * glm::pi<float>(), glm::vec3(0, 1, 0))), + glm::quat(glm::angleAxis(-0.25f * glm::pi<float>(), glm::vec3(0, 1, 0))), + glm::quat(glm::angleAxis(0.75f * glm::pi<float>(), glm::vec3(1, 0, 0)))}; + std::vector<glm::vec3> light_colors{ + glm::vec3(1.0, 1.0, 1.0), glm::vec3(1.0, 1.0, 1.0), + glm::vec3(1.0, 1.0, 1.0), glm::vec3(1.0, 1.0, 1.0)}; + std::vector<float> light_intensities{1.0f, 0.9f, 0.8f, 0.7f}; + + for (std::size_t i = 0; i < light_dirs.size(); i++) { + phx::Entity* light_entity = scene->CreateEntity(); + phx::Transform* light_transform = + light_entity->AddComponent<phx::Transform>(); + light_transform->SetLocalRotation(light_dirs[i]); + phx::Light* light = light_entity->AddComponent<phx::Light>(); + light->SetType(phx::Light::Type::kDirectional); + light->SetColor(light_colors[i]); + light->SetIntensity(light_intensities[i]); + } + + auto virtual_platform_transform = + scene + ->GetEntitiesWithComponents< + phx::RuntimeComponent<phx::USER_PLATFORM>>()[0] + ->GetFirstComponent<phx::Transform>(); + + virtual_platform_transform->SetLocalTranslation(glm::vec3(.0f, .0f, .0f)); + + phx::Entity* camera = + scene->GetEntitiesWithComponents<phx::RenderTarget>()[0]; + if (camera->GetFirstComponent<phx::RuntimeComponent<phx::LEFT_EYE>>() == + nullptr && + camera->GetFirstComponent<phx::RuntimeComponent<phx::RIGHT_EYE>>() == + nullptr) { + auto camera_projection = camera->GetFirstComponent<phx::Projection>(); + camera_projection->SetPerspective(glm::radians(68.0f), 4.0f / 3.0f, 0.01f, + 1000.0f); + } + + if (!openvr_system) { + camera->AddComponent<DesktopNavigationBehavior>(input_system); + } + + engine->Run(); + + return EXIT_SUCCESS; +} diff --git a/demos/combustion_demo/src/desk_behavior.cpp b/demos/combustion_demo/src/desk_behavior.cpp new file mode 100644 index 0000000000000000000000000000000000000000..380884774f1140111f27f87a6f7ee735392fe611 --- /dev/null +++ b/demos/combustion_demo/src/desk_behavior.cpp @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// Project Phoenix +// +// Copyright (c) 2017-2018 RWTH Aachen University, Germany, +// Virtual Reality & Immersive Visualization Group. +//------------------------------------------------------------------------------ +// License +// +// Licensed under the 3-Clause BSD License (the "License"); +// you may not use this file except in compliance with the License. +// See the file LICENSE for the full text. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/BSD-3-Clause +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//------------------------------------------------------------------------------ + +#include "desk_behavior.hpp" + +#include <vector> + +#include "phx/suppress_warnings.hpp" + +SUPPRESS_WARNINGS_BEGIN +#include "glm/detail/type_vec3.hpp" +#include "glm/glm.hpp" +SUPPRESS_WARNINGS_END + +#include "phx/core/entity.hpp" +#include "phx/core/runtime_component.hpp" +#include "phx/core/scene.hpp" +#include "phx/display/display_system_openvr.hpp" +#include "phx/rendering/components/transform.hpp" + +DeskBehavior::DeskBehavior(phx::DisplaySystemOpenVR* openvr_system) + : openvr_system_(openvr_system), position_set_(false) {} + +void DeskBehavior::OnUpdate() { + if (!openvr_system_ || position_set_) return; + + const auto scene = GetEntity()->GetScene(); + + const auto left_controller = scene->GetEntitiesWithComponents< + phx::RuntimeComponent<phx::LEFT_CONTROLLER>>()[0]; + const auto right_controller = scene->GetEntitiesWithComponents< + phx::RuntimeComponent<phx::RIGHT_CONTROLLER>>()[0]; + + const auto left_controller_translation = + left_controller->GetFirstComponent<phx::Transform>() + ->GetGlobalTranslation(); + const auto right_controller_translation = + right_controller->GetFirstComponent<phx::Transform>() + ->GetGlobalTranslation(); + const auto difference = + left_controller_translation - right_controller_translation; + const auto center = right_controller_translation + difference / 2.0f; + + const auto right = glm::normalize(difference); + const auto up = glm::vec3(0, 1, 0); + const auto forward = glm::cross(right, up); + + auto transform = GetEntity()->GetFirstComponent<phx::Transform>(); + transform->LookAt(transform->GetLocalTranslation() + forward); + transform->SetLocalTranslation(center + 0.3f * forward - 0.075f * up); + + position_set_ = true; +} diff --git a/demos/combustion_demo/src/desk_behavior.hpp b/demos/combustion_demo/src/desk_behavior.hpp new file mode 100644 index 0000000000000000000000000000000000000000..970d1b4add5cf342bdc3618316b2bca37869bcc4 --- /dev/null +++ b/demos/combustion_demo/src/desk_behavior.hpp @@ -0,0 +1,53 @@ +//------------------------------------------------------------------------------ +// Project Phoenix +// +// Copyright (c) 2017-2018 RWTH Aachen University, Germany, +// Virtual Reality & Immersive Visualization Group. +//------------------------------------------------------------------------------ +// License +// +// Licensed under the 3-Clause BSD License (the "License"); +// you may not use this file except in compliance with the License. +// See the file LICENSE for the full text. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/BSD-3-Clause +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//------------------------------------------------------------------------------ + +#ifndef DEMOS_COMBUSTION_DEMO_SRC_DESK_BEHAVIOR_HPP_ +#define DEMOS_COMBUSTION_DEMO_SRC_DESK_BEHAVIOR_HPP_ + +#include "phx/suppress_warnings.hpp" + +SUPPRESS_WARNINGS_BEGIN +#include "glm/glm.hpp" +SUPPRESS_WARNINGS_END + +#include "phx/display/display_system_openvr.hpp" +#include "phx/scripting/behavior.hpp" + +class DeskBehavior : public phx::Behavior { + public: + explicit DeskBehavior(phx::DisplaySystemOpenVR* openvr_system_); + DeskBehavior(const DeskBehavior& that) = default; + DeskBehavior(DeskBehavior&& temp) = default; + virtual ~DeskBehavior() = default; + DeskBehavior& operator=(const DeskBehavior& that) = default; + DeskBehavior& operator=(DeskBehavior&& temp) = default; + + void OnUpdate() override; + + protected: + phx::DisplaySystemOpenVR* openvr_system_; + + private: + bool position_set_; +}; + +#endif // DEMOS_COMBUSTION_DEMO_SRC_DESK_BEHAVIOR_HPP_ diff --git a/demos/combustion_demo/src/desktop_navigation_behavior.cpp b/demos/combustion_demo/src/desktop_navigation_behavior.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0491b8c21da54044d239d8ebce43394ab9c54027 --- /dev/null +++ b/demos/combustion_demo/src/desktop_navigation_behavior.cpp @@ -0,0 +1,101 @@ +//------------------------------------------------------------------------------ +// Project Phoenix +// +// Copyright (c) 2017-2018 RWTH Aachen University, Germany, +// Virtual Reality & Immersive Visualization Group. +//------------------------------------------------------------------------------ +// License +// +// Licensed under the 3-Clause BSD License (the "License"); +// you may not use this file except in compliance with the License. +// See the file LICENSE for the full text. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/BSD-3-Clause +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//------------------------------------------------------------------------------ + +#include "desktop_navigation_behavior.hpp" + +#include "phx/suppress_warnings.hpp" + +SUPPRESS_WARNINGS_BEGIN +#include "glm/detail/type_vec3.hpp" +#include "glm/glm.hpp" +SUPPRESS_WARNINGS_END + +#include "phx/core/entity.hpp" +#include "phx/rendering/components/transform.hpp" + +DesktopNavigationBehavior::DesktopNavigationBehavior( + phx::InputSystem* input_system) + : input_system_(input_system) { + input_system_->AddMouseMoveCallback( + [this](int x, int y) { OnMouseMove(x, y); }); + input_system_->AddMousePressCallback( + [this](unsigned btn) { OnMousePress(btn); }); + input_system_->AddMouseReleaseCallback( + [this](unsigned btn) { OnMouseRelease(btn); }); +} + +void DesktopNavigationBehavior::OnUpdate() { + const auto transform = GetEntity()->GetFirstComponent<phx::Transform>(); + + if (rotation_mode_) { + euler_angles_[0] += glm::radians(accumulated_mouse_pos_[1] * 0.0885416666f); + euler_angles_[1] += glm::radians(accumulated_mouse_pos_[0] * 0.0885416666f); + + transform->SetGlobalRotation(euler_angles_); + } + if (strafe_mode_) { + transform->Translate(transform->Up() * + static_cast<float>(accumulated_mouse_pos_[1]) * + 0.005f); + transform->Translate(transform->Right() * + static_cast<float>(accumulated_mouse_pos_[0]) * + -0.005f); + } + if (translation_mode_) { + transform->Translate(transform->Forward() * + static_cast<float>(accumulated_mouse_pos_[1]) * + 0.005f); + transform->Translate(transform->Right() * + static_cast<float>(accumulated_mouse_pos_[0]) * + -0.005f); + } + + accumulated_mouse_pos_ = glm::ivec2{0, 0}; +} + +void DesktopNavigationBehavior::OnMouseMove(int x, int y) { + accumulated_mouse_pos_ += glm::ivec2{x, y}; +} + +void DesktopNavigationBehavior::OnMousePress(unsigned btn) { + if (btn == 1) { + rotation_mode_ = true; + } + if (btn == 2) { + strafe_mode_ = true; + } + if (btn == 3) { + translation_mode_ = true; + } +} + +void DesktopNavigationBehavior::OnMouseRelease(unsigned btn) { + if (btn == 1) { + rotation_mode_ = false; + } + if (btn == 2) { + strafe_mode_ = false; + } + if (btn == 3) { + translation_mode_ = false; + } +} diff --git a/demos/combustion_demo/src/desktop_navigation_behavior.hpp b/demos/combustion_demo/src/desktop_navigation_behavior.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c394669cc307d679652fc69e9c4442bb20843625 --- /dev/null +++ b/demos/combustion_demo/src/desktop_navigation_behavior.hpp @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// Project Phoenix +// +// Copyright (c) 2017-2018 RWTH Aachen University, Germany, +// Virtual Reality & Immersive Visualization Group. +//------------------------------------------------------------------------------ +// License +// +// Licensed under the 3-Clause BSD License (the "License"); +// you may not use this file except in compliance with the License. +// See the file LICENSE for the full text. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/BSD-3-Clause +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//------------------------------------------------------------------------------ + +#ifndef DEMOS_COMBUSTION_DEMO_SRC_DESKTOP_NAVIGATION_BEHAVIOR_HPP_ +#define DEMOS_COMBUSTION_DEMO_SRC_DESKTOP_NAVIGATION_BEHAVIOR_HPP_ + +#include "phx/suppress_warnings.hpp" + +SUPPRESS_WARNINGS_BEGIN +#include "glm/glm.hpp" +SUPPRESS_WARNINGS_END + +#include "phx/input/input_system.hpp" +#include "phx/scripting/behavior.hpp" + +class DesktopNavigationBehavior : public phx::Behavior { + public: + explicit DesktopNavigationBehavior(phx::InputSystem* input_system); + DesktopNavigationBehavior(const DesktopNavigationBehavior& that) = default; + DesktopNavigationBehavior(DesktopNavigationBehavior&& temp) = default; + virtual ~DesktopNavigationBehavior() = default; + DesktopNavigationBehavior& operator=(const DesktopNavigationBehavior& that) = + default; + DesktopNavigationBehavior& operator=(DesktopNavigationBehavior&& temp) = + default; + + void OnUpdate() override; + void OnMouseMove(int x, int y); + void OnMousePress(unsigned btn); + void OnMouseRelease(unsigned btn); + + protected: + phx::InputSystem* input_system_; + + private: + glm::ivec2 accumulated_mouse_pos_ = glm::ivec2(0); + glm::vec3 euler_angles_ = glm::vec3(0.0f); + bool rotation_mode_ = false; + bool strafe_mode_ = false; + bool translation_mode_ = false; +}; + +#endif // DEMOS_COMBUSTION_DEMO_SRC_DESKTOP_NAVIGATION_BEHAVIOR_HPP_ diff --git a/demos/combustion_demo/src/vr_controller_navigation_behavior.cpp b/demos/combustion_demo/src/vr_controller_navigation_behavior.cpp new file mode 100644 index 0000000000000000000000000000000000000000..79d59837cba7a58dc44d2e46f68ee043c61af330 --- /dev/null +++ b/demos/combustion_demo/src/vr_controller_navigation_behavior.cpp @@ -0,0 +1,97 @@ +//------------------------------------------------------------------------------ +// Project Phoenix +// +// Copyright (c) 2017-2018 RWTH Aachen University, Germany, +// Virtual Reality & Immersive Visualization Group. +//------------------------------------------------------------------------------ +// License +// +// Licensed under the 3-Clause BSD License (the "License"); +// you may not use this file except in compliance with the License. +// See the file LICENSE for the full text. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/BSD-3-Clause +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//------------------------------------------------------------------------------ + +#include "vr_controller_navigation_behavior.hpp" + +#include <vector> + +#include "phx/suppress_warnings.hpp" + +SUPPRESS_WARNINGS_BEGIN +#include "glm/detail/type_vec3.hpp" +#include "glm/glm.hpp" +#include "glm/gtc/matrix_access.hpp" +SUPPRESS_WARNINGS_END + +#include "phx/core/engine.hpp" +#include "phx/core/entity.hpp" +#include "phx/core/runtime_component.hpp" +#include "phx/core/scene.hpp" +#include "phx/display/display_system_openvr.hpp" +#include "phx/display/hmd.hpp" +#include "phx/rendering/components/transform.hpp" + +VRControllerNavigationBehavior::VRControllerNavigationBehavior( + phx::DisplaySystemOpenVR* display_system_openvr) + : display_system_openvr_(display_system_openvr) {} + +void VRControllerNavigationBehavior::OnUpdate() { + // If there exists an HMD and a transform. + phx::HMD* hmd = nullptr; + if (display_system_openvr_ != nullptr) { + hmd = display_system_openvr_->GetHMD(); + } + const auto transform = GetEntity()->GetFirstComponent<phx::Transform>(); + if (hmd == nullptr || transform == nullptr) return; + + auto indices = hmd->GetControllerIndices(); + + for (auto i = 0u; i < indices.size(); ++i) { + vr::VRControllerState_t controller_state; + vr::VRSystem()->GetControllerState(indices[i], &controller_state, + sizeof controller_state); + + // Set the transform based on whether the trigger is pressed. + if (controller_state.ulButtonTouched & + vr::ButtonMaskFromId(vr::EVRButtonId::k_EButton_SteamVR_Trigger)) + transform->Translate( + -0.05F * glm::column(hmd->GetRightControllerTransformation(), 2)); + + if (target_) { + if (!is_grip_down_ && + controller_state.ulButtonPressed & + vr::ButtonMaskFromId(vr::EVRButtonId::k_EButton_Grip)) { + target_->SetParent( + GetEntity() + ->GetScene() + ->GetEntitiesWithComponents< + phx::RuntimeComponent<phx::RIGHT_CONTROLLER>>()[0] + ->GetFirstComponent<phx::Transform>()); + is_grip_down_ = true; + } else if (is_grip_down_ && + controller_state.ulButtonPressed & + vr::ButtonMaskFromId( + vr::EVRButtonId::k_EButton_SteamVR_Touchpad)) { + target_->SetParent(nullptr); + is_grip_down_ = false; + } + } + } +} + +void VRControllerNavigationBehavior::SetTarget(phx::Transform* target) { + target_ = target; +} + +phx::Transform* VRControllerNavigationBehavior::GetTarget() const { + return target_; +} diff --git a/demos/combustion_demo/src/vr_controller_navigation_behavior.hpp b/demos/combustion_demo/src/vr_controller_navigation_behavior.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f0110d07f44bd3c2acd2d6287feced6af904c3db --- /dev/null +++ b/demos/combustion_demo/src/vr_controller_navigation_behavior.hpp @@ -0,0 +1,57 @@ +//------------------------------------------------------------------------------ +// Project Phoenix +// +// Copyright (c) 2017-2018 RWTH Aachen University, Germany, +// Virtual Reality & Immersive Visualization Group. +//------------------------------------------------------------------------------ +// License +// +// Licensed under the 3-Clause BSD License (the "License"); +// you may not use this file except in compliance with the License. +// See the file LICENSE for the full text. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/BSD-3-Clause +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//------------------------------------------------------------------------------ + +#ifndef DEMOS_COMBUSTION_DEMO_SRC_VR_CONTROLLER_NAVIGATION_BEHAVIOR_HPP_ +#define DEMOS_COMBUSTION_DEMO_SRC_VR_CONTROLLER_NAVIGATION_BEHAVIOR_HPP_ + +#include "phx/display/display_system_openvr.hpp" +#include "phx/rendering/components/transform.hpp" +#include "phx/scripting/behavior.hpp" + +class VRControllerNavigationBehavior : public phx::Behavior { + public: + explicit VRControllerNavigationBehavior( + phx::DisplaySystemOpenVR* display_system_openvr); + VRControllerNavigationBehavior(const VRControllerNavigationBehavior& that) = + default; + VRControllerNavigationBehavior(VRControllerNavigationBehavior&& temp) = + default; + virtual ~VRControllerNavigationBehavior() = default; + VRControllerNavigationBehavior& operator=( + const VRControllerNavigationBehavior& that) = default; + VRControllerNavigationBehavior& operator=( + VRControllerNavigationBehavior&& temp) = default; + + void OnUpdate() override; + + void SetTarget(phx::Transform* target); + phx::Transform* GetTarget() const; + + protected: + phx::DisplaySystemOpenVR* display_system_openvr_; + + private: + phx::Transform* target_ = nullptr; + bool is_grip_down_ = false; +}; + +#endif // DEMOS_COMBUSTION_DEMO_SRC_VR_CONTROLLER_NAVIGATION_BEHAVIOR_HPP_ diff --git a/demos/viewer/src/navigation_behavior.cpp b/demos/viewer/src/navigation_behavior.cpp index b93fedc62fcf6ed9e92709af458817ac90a7ce43..e9c914fd4d8658c03d65d1362203764739d3e2ed 100644 --- a/demos/viewer/src/navigation_behavior.cpp +++ b/demos/viewer/src/navigation_behavior.cpp @@ -32,12 +32,12 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/gtc/matrix_access.hpp" SUPPRESS_WARNINGS_END -#include "phx/display_system_openvr.hpp" -#include "phx/engine.hpp" -#include "phx/entity.hpp" -#include "phx/hmd.hpp" -#include "phx/scene.hpp" -#include "phx/transform.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/entity.hpp" +#include "phx/core/scene.hpp" +#include "phx/display/display_system_openvr.hpp" +#include "phx/display/hmd.hpp" +#include "phx/rendering/components/transform.hpp" NavigationBehavior::NavigationBehavior( phx::DisplaySystemOpenVR* display_system_openvr) diff --git a/demos/viewer/src/navigation_behavior.hpp b/demos/viewer/src/navigation_behavior.hpp index 0dcd7085ae57ac203d3485d85e71bd52a2f63e51..ac2e06c9ef98424e746f42a41d3880e5079781da 100644 --- a/demos/viewer/src/navigation_behavior.hpp +++ b/demos/viewer/src/navigation_behavior.hpp @@ -23,8 +23,8 @@ #ifndef DEMOS_VIEWER_SRC_NAVIGATION_BEHAVIOR_HPP_ #define DEMOS_VIEWER_SRC_NAVIGATION_BEHAVIOR_HPP_ -#include "phx/behavior.hpp" -#include "phx/display_system_openvr.hpp" +#include "phx/display/display_system_openvr.hpp" +#include "phx/scripting/behavior.hpp" class NavigationBehavior : public phx::Behavior { public: diff --git a/demos/viewer/src/rotation_behavior.cpp b/demos/viewer/src/rotation_behavior.cpp index 94d0799921c4dcd236ebb1d1526179e89072b850..8f3cdd738d51b119f46950f5087541076f2de583 100644 --- a/demos/viewer/src/rotation_behavior.cpp +++ b/demos/viewer/src/rotation_behavior.cpp @@ -29,10 +29,10 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/glm.hpp" SUPPRESS_WARNINGS_END -#include "phx/engine.hpp" -#include "phx/entity.hpp" -#include "phx/scene.hpp" -#include "phx/transform.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/entity.hpp" +#include "phx/core/scene.hpp" +#include "phx/rendering/components/transform.hpp" void RotationBehavior::OnUpdate() { auto transform = GetEntity()->GetFirstComponent<phx::Transform>(); diff --git a/demos/viewer/src/rotation_behavior.hpp b/demos/viewer/src/rotation_behavior.hpp index aa9b81e74b4568ff00d81ba27eb31318678dbd44..8002373678ee32079d9668b750fe63fdbb4873ae 100644 --- a/demos/viewer/src/rotation_behavior.hpp +++ b/demos/viewer/src/rotation_behavior.hpp @@ -23,7 +23,7 @@ #ifndef DEMOS_VIEWER_SRC_ROTATION_BEHAVIOR_HPP_ #define DEMOS_VIEWER_SRC_ROTATION_BEHAVIOR_HPP_ -#include "phx/behavior.hpp" +#include "phx/scripting/behavior.hpp" class RotationBehavior : public phx::Behavior { public: diff --git a/demos/viewer/src/viewer.cpp b/demos/viewer/src/viewer.cpp index 358ba7fa1a55321e6520258f4e8db36726fa35ee..d8d6fe5a575496de37b140e615c349bb0ee62fa0 100644 --- a/demos/viewer/src/viewer.cpp +++ b/demos/viewer/src/viewer.cpp @@ -21,38 +21,39 @@ //------------------------------------------------------------------------------ #include <chrono> +#include <future> #include <iostream> #include <memory> #include <string> #include <utility> #include <vector> -#include "phx/assimp_model_loader.hpp" -#include "phx/display_system_window.hpp" -#include "phx/engine.hpp" -#include "phx/entity.hpp" -#include "phx/input_system.hpp" -#include "phx/light.hpp" -#include "phx/logger.hpp" -#include "phx/material_handle.hpp" -#include "phx/mesh.hpp" -#include "phx/mesh_handle.hpp" -#include "phx/openvr_resource_loader.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/entity.hpp" +#include "phx/core/logger.hpp" +#include "phx/core/runtime_component.hpp" +#include "phx/core/scene.hpp" +#include "phx/display/display_system_openvr.hpp" +#include "phx/display/display_system_window.hpp" +#include "phx/display/window.hpp" +#include "phx/input/input_system.hpp" +#include "phx/rendering/auxiliary/splash_screen.hpp" +#include "phx/rendering/components/light.hpp" +#include "phx/rendering/components/material_handle.hpp" +#include "phx/rendering/components/mesh_handle.hpp" +#include "phx/rendering/components/transform.hpp" +#include "phx/rendering/rendering_system.hpp" +#include "phx/resources/loaders/assimp_model_loader.hpp" +#include "phx/resources/loaders/openvr_resource_loader.hpp" +#include "phx/resources/loaders/scene_loader.hpp" +#include "phx/resources/types/mesh.hpp" +#include "phx/resources/resource_declaration.hpp" +#include "phx/resources/resource_manager.hpp" +#include "phx/resources/resource_pointer.hpp" #include "phx/phoenix.hpp" -#include "phx/rendering_system.hpp" -#include "phx/resource_declaration.hpp" -#include "phx/resource_manager.hpp" -#include "phx/resource_pointer.hpp" -#include "phx/runtime_component.hpp" -#include "phx/scene.hpp" -#include "phx/scene_loader.hpp" #include "phx/setup.hpp" -#include "phx/splash_screen.hpp" -#include "phx/transform.hpp" -#include "phx/window.hpp" #include "navigation_behavior.hpp" -#include "phx/display_system_openvr.hpp" #include "rotation_behavior.hpp" #include "viewer_system.hpp" @@ -61,18 +62,21 @@ #endif int main(int, char**) { - std::unique_ptr<phx::Engine> engine = phx::Setup::CreateDefaultEngine(); + std::unique_ptr<phx::Engine> engine = phx::Setup::CreateDefaultEngine(false); auto scene = engine->GetScene(); + auto rendering_system = engine->GetSystem<phx::RenderingSystem>(); + rendering_system->SetEnabled(false); + + phx::SplashScreen* splash = engine->CreateSystem<phx::SplashScreen>( + engine->GetSystem<phx::DisplaySystemWindow>()->GetWindow()); + engine->MoveSystemBefore(splash, + engine->GetSystem<phx::DisplaySystemWindow>()); - phx::SplashScreen splash( - engine->GetSystem<phx::DisplaySystemWindow>()->GetWindow()); - splash.Draw(); auto assimp_loader = static_cast<phx::AssimpModelLoader*>( - phx::ResourceManager::instance().GetLoaderForType(".obj")); - assimp_loader->SetProgressUpdateCallback([&splash](float progress) { - splash.SetLoadProgress(progress); - splash.Draw(); - }); + phx::ResourceManager::instance().GetLoaderForType(".obj")); + + assimp_loader->SetProgressUpdateCallback( + [splash](float progress) { splash->SetLoadProgress(progress); }); phx::InputSystem* input_system = engine->GetSystem<phx::InputSystem>(); ViewerSystem* viewer_system = engine->CreateSystem<ViewerSystem>(); @@ -83,9 +87,14 @@ int main(int, char**) { viewer_system->SetShowFramerate(!viewer_system->GetShowFramerate()); }); - phx::SceneLoader::InsertModelIntoScene( + auto handle = std::async([&scene, rendering_system, splash]() { + phx::SceneLoader::InsertModelIntoScene( "models/UniversityScene/Univers20171013.obj", scene.get()); + rendering_system->SetEnabled(true); + splash->SetEnabled(false); + }); + std::vector<glm::quat> light_dirs{ glm::quat(glm::angleAxis(-0.25f * glm::pi<float>(), glm::vec3(1, 0, 0))), glm::quat(glm::angleAxis(0.25f * glm::pi<float>(), glm::vec3(0, 1, 0))), @@ -107,27 +116,14 @@ int main(int, char**) { light->SetIntensity(light_intensities[i]); } - auto virtual_platform_transform = - scene - ->GetEntitiesWithComponents< - phx::RuntimeComponent<phx::USER_PLATFORM>>()[0] - ->GetFirstComponent<phx::Transform>(); - - virtual_platform_transform->SetLocalTranslation(glm::vec3(0.f, -1.f, -2.f)); - - phx::Entity* camera = - scene->GetEntitiesWithComponents<phx::RenderTarget>()[0]; - if (camera->GetFirstComponent<phx::RuntimeComponent<phx::LEFT_EYE>>() == - nullptr && - camera->GetFirstComponent<phx::RuntimeComponent<phx::RIGHT_EYE>>() == - nullptr) { - auto camera_projection = camera->GetFirstComponent<phx::Projection>(); - camera_projection->SetPerspective(glm::radians(68.0f), 4.0f / 3.0f, 0.01f, - 1000.0f); - } - auto virtual_platform = scene->GetEntitiesWithComponents< phx::RuntimeComponent<phx::USER_PLATFORM>>()[0]; + auto virtual_platform_transform = + virtual_platform->GetFirstComponent<phx::Transform>(); + glm::vec3 start_position{0.f, -1.f, -2.f}; + virtual_platform_transform->SetLocalTranslation(start_position); + phx::info("The virtual platform's start position is: {}", start_position); + virtual_platform->AddComponent<NavigationBehavior>( engine->GetSystem<phx::DisplaySystemOpenVR>()); diff --git a/demos/viewer/src/viewer_system.cpp b/demos/viewer/src/viewer_system.cpp index 5354fab236b4a6c122722af754aca2697255c6df..5fd77fc5cbf7111287e73bb24c5dd12eb61f6724 100644 --- a/demos/viewer/src/viewer_system.cpp +++ b/demos/viewer/src/viewer_system.cpp @@ -25,8 +25,8 @@ #include <iostream> #include <string> -#include "phx/engine.hpp" -#include "phx/logger.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/logger.hpp" ViewerSystem::ViewerSystem(phx::Engine* engine) : phx::System(engine) {} diff --git a/demos/viewer/src/viewer_system.hpp b/demos/viewer/src/viewer_system.hpp index f4298c3ce7ececcced9772eb3eaee9eb6e3251f8..82dc5c9536685b356d43e3442c08b7aaff71e4dd 100644 --- a/demos/viewer/src/viewer_system.hpp +++ b/demos/viewer/src/viewer_system.hpp @@ -27,9 +27,9 @@ #include "phx/suppress_warnings.hpp" -#include "phx/engine.hpp" -#include "phx/frame_timer.hpp" -#include "phx/system.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/frame_timer.hpp" +#include "phx/core/system.hpp" SUPPRESS_WARNINGS_BEGIN_PADDED diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 74d8d59a664bd41be9bd4e7d40e26a27edcd6c79..84ff95b01b9781f453aa91b55031b5a267f9b6bb 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -20,8 +20,8 @@ # limitations under the License. #------------------------------------------------------------------------------ -file(GLOB PHOENIX_SOURCES phx/*.cpp) -file(GLOB PHOENIX_HEADERS phx/*.hpp) +file(GLOB_RECURSE PHOENIX_SOURCES phx/*.cpp phx/*.c) +file(GLOB_RECURSE PHOENIX_HEADERS phx/*.hpp phx/*.h) # configure resources directory include string set(_RESOURCES_ROOT_PATH "${CMAKE_SOURCE_DIR}/resources/") @@ -29,6 +29,10 @@ set(SOURCE_RESOURCES_INCLUDE_FILE "${CMAKE_SOURCE_DIR}/cmake/resources_path.hpp. set(TARGET_RESOURCES_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/phx/resources_path.hpp") configure_file(${SOURCE_RESOURCES_INCLUDE_FILE} ${TARGET_RESOURCES_INCLUDE_FILE} @ONLY) +include(assign_source_group) +assign_source_group(${PHOENIX_SOURCES}) +assign_source_group(${PHOENIX_HEADERS}) + add_library(phoenix ${PHOENIX_SOURCES} ${PHOENIX_HEADERS} diff --git a/library/phx/component.cpp b/library/phx/core/component.cpp similarity index 97% rename from library/phx/component.cpp rename to library/phx/core/component.cpp index 7f34e170ca14df0bad295115a194950213a9e18f..54263176d1664aa53db66f92b32c09168b6bbb53 100644 --- a/library/phx/component.cpp +++ b/library/phx/core/component.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "component.hpp" +#include "phx/core/component.hpp" namespace phx { diff --git a/library/phx/component.hpp b/library/phx/core/component.hpp similarity index 91% rename from library/phx/component.hpp rename to library/phx/core/component.hpp index ccd93f7d9c0e91371bd88a8a26a4df46e33e9f02..1faa0952bfa7cc2cfdd9ad077f0a654758cc77a4 100644 --- a/library/phx/component.hpp +++ b/library/phx/core/component.hpp @@ -20,14 +20,14 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_COMPONENT_HPP_ -#define LIBRARY_PHX_COMPONENT_HPP_ +#ifndef LIBRARY_PHX_CORE_COMPONENT_HPP_ +#define LIBRARY_PHX_CORE_COMPONENT_HPP_ #include <ostream> #include <string> +#include "phx/utility/aspects/loggable.hpp" #include "phx/export.hpp" -#include "phx/loggable.hpp" namespace phx { @@ -57,4 +57,4 @@ class PHOENIX_EXPORT Component : public Loggable { } // namespace phx -#endif // LIBRARY_PHX_COMPONENT_HPP_ +#endif // LIBRARY_PHX_CORE_COMPONENT_HPP_ diff --git a/library/phx/component_check.hpp b/library/phx/core/component_check.hpp similarity index 93% rename from library/phx/component_check.hpp rename to library/phx/core/component_check.hpp index d0cbcc88d3367b2b401a00258194282a661776c8..d7fbb114166df882159418d733fe316d2c6b6640 100644 --- a/library/phx/component_check.hpp +++ b/library/phx/core/component_check.hpp @@ -20,14 +20,14 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_COMPONENT_CHECK_HPP_ -#define LIBRARY_PHX_COMPONENT_CHECK_HPP_ +#ifndef LIBRARY_PHX_CORE_COMPONENT_CHECK_HPP_ +#define LIBRARY_PHX_CORE_COMPONENT_CHECK_HPP_ #include <tuple> #include "boost/optional.hpp" -#include "phx/entity.hpp" +#include "phx/core/entity.hpp" #include "phx/export.hpp" namespace phx { @@ -80,4 +80,4 @@ struct PHOENIX_EXPORT ComponentGather { } // namespace phx -#endif // LIBRARY_PHX_COMPONENT_CHECK_HPP_ +#endif // LIBRARY_PHX_CORE_COMPONENT_CHECK_HPP_ diff --git a/library/phx/engine.cpp b/library/phx/core/engine.cpp similarity index 94% rename from library/phx/engine.cpp rename to library/phx/core/engine.cpp index 2ca67313b4ae9dc73c008738edb8357478c0fe89..ee1dc39af9649f1dba9870c73b8012aec0b04293 100644 --- a/library/phx/engine.cpp +++ b/library/phx/core/engine.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "engine.hpp" +#include "phx/core/engine.hpp" #include <iostream> #include <memory> @@ -28,8 +28,8 @@ #include <utility> #include <vector> -#include "phx/logger.hpp" -#include "phx/scene.hpp" +#include "phx/core/logger.hpp" +#include "phx/core/scene.hpp" namespace phx { @@ -69,7 +69,8 @@ bool Engine::IsRunning() const { return is_running_; } void Engine::UpdateSystems() { // before updating all systems, update the frame timer frame_timer_.Tick(); - for (auto& system : systems_) system->Update(frame_timer_.GetTimeInfo()); + for (auto& system : systems_) + if (system->GetEnabled()) system->Update(frame_timer_.GetTimeInfo()); } std::string Engine::ToString() const { diff --git a/library/phx/engine.hpp b/library/phx/core/engine.hpp similarity index 94% rename from library/phx/engine.hpp rename to library/phx/core/engine.hpp index b7c51154b09a19a35febbd8edbe7bbb1a74bc868..8f2f9f38ce3c43499539959cf0065bc0f5cf5e5c 100644 --- a/library/phx/engine.hpp +++ b/library/phx/core/engine.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_ENGINE_HPP_ -#define LIBRARY_PHX_ENGINE_HPP_ +#ifndef LIBRARY_PHX_CORE_ENGINE_HPP_ +#define LIBRARY_PHX_CORE_ENGINE_HPP_ #include <algorithm> #include <chrono> @@ -40,13 +40,13 @@ SUPPRESS_WARNINGS_BEGIN #include "boost/signals2/signal.hpp" SUPPRESS_WARNINGS_END -#include "phx/behavior.hpp" +#include "phx/core/frame_timer.hpp" +#include "phx/core/scene.hpp" +#include "phx/core/system.hpp" +#include "phx/scripting/behavior.hpp" +#include "phx/utility/aspects/loggable.hpp" +#include "phx/utility/orderable_list.hpp" #include "phx/export.hpp" -#include "phx/frame_timer.hpp" -#include "phx/loggable.hpp" -#include "phx/orderable_list.hpp" -#include "phx/scene.hpp" -#include "phx/system.hpp" namespace phx { @@ -169,4 +169,4 @@ SUPPRESS_WARNINGS_END } // namespace phx -#endif // LIBRARY_PHX_ENGINE_HPP_ +#endif // LIBRARY_PHX_CORE_ENGINE_HPP_ diff --git a/library/phx/entity.cpp b/library/phx/core/entity.cpp similarity index 97% rename from library/phx/entity.cpp rename to library/phx/core/entity.cpp index 38a70397762a9b64b0faef3e266db4da1a7fa833..36d74d15a9c097e294875e7427280282dc41109a 100644 --- a/library/phx/entity.cpp +++ b/library/phx/core/entity.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "entity.hpp" +#include "phx/core/entity.hpp" #include <string> diff --git a/library/phx/entity.hpp b/library/phx/core/entity.hpp similarity index 93% rename from library/phx/entity.hpp rename to library/phx/core/entity.hpp index 7d9b7939bac276a32122c4fa11ca2ac6fb2141fb..51bffc058a592a266ab21e9ba1740688ce54cf53 100644 --- a/library/phx/entity.hpp +++ b/library/phx/core/entity.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_ENTITY_HPP_ -#define LIBRARY_PHX_ENTITY_HPP_ +#ifndef LIBRARY_PHX_CORE_ENTITY_HPP_ +#define LIBRARY_PHX_CORE_ENTITY_HPP_ #include <algorithm> #include <memory> @@ -30,10 +30,10 @@ #include <type_traits> #include <vector> -#include "phx/component.hpp" +#include "phx/core/component.hpp" +#include "phx/utility/aspects/loggable.hpp" +#include "phx/utility/aspects/nameable.hpp" #include "phx/export.hpp" -#include "phx/loggable.hpp" -#include "phx/nameable.hpp" namespace phx { @@ -103,4 +103,4 @@ class PHOENIX_EXPORT Entity : public Nameable, public Loggable { } // namespace phx -#endif // LIBRARY_PHX_ENTITY_HPP_ +#endif // LIBRARY_PHX_CORE_ENTITY_HPP_ diff --git a/library/phx/frame_timer.hpp b/library/phx/core/frame_timer.hpp similarity index 93% rename from library/phx/frame_timer.hpp rename to library/phx/core/frame_timer.hpp index 82b967c3bad4cb5640299c9d2b04c61430531009..ec8207f848e9a28c4acfa8d463487f487d7a9295 100644 --- a/library/phx/frame_timer.hpp +++ b/library/phx/core/frame_timer.hpp @@ -20,13 +20,13 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_FRAME_TIMER_HPP_ -#define LIBRARY_PHX_FRAME_TIMER_HPP_ +#ifndef LIBRARY_PHX_CORE_FRAME_TIMER_HPP_ +#define LIBRARY_PHX_CORE_FRAME_TIMER_HPP_ #include <chrono> #include "phx/export.hpp" -#include "phx/time_info.hpp" +#include "phx/core/time_info.hpp" namespace phx { @@ -67,4 +67,4 @@ class PHOENIX_EXPORT FrameTimer final { } // namespace phx -#endif // LIBRARY_PHX_FRAME_TIMER_HPP_ +#endif // LIBRARY_PHX_CORE_FRAME_TIMER_HPP_ diff --git a/library/phx/logger.cpp b/library/phx/core/logger.cpp similarity index 98% rename from library/phx/logger.cpp rename to library/phx/core/logger.cpp index 578b7255a88895ea4c98595c0e61d22b7249fcc9..c47e5434b5d4bee38ff33d71a3c14cda4034c117 100644 --- a/library/phx/logger.cpp +++ b/library/phx/core/logger.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "logger.hpp" +#include "phx/core/logger.hpp" #include <memory> #include <vector> diff --git a/library/phx/logger.hpp b/library/phx/core/logger.hpp similarity index 94% rename from library/phx/logger.hpp rename to library/phx/core/logger.hpp index 83a962d845b6bd057d491088dff5bfacebaaf199..7ef947af5bd962eedebb673f5f0b304fe62d7543 100644 --- a/library/phx/logger.hpp +++ b/library/phx/core/logger.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_LOGGER_HPP_ -#define LIBRARY_PHX_LOGGER_HPP_ +#ifndef LIBRARY_PHX_CORE_LOGGER_HPP_ +#define LIBRARY_PHX_CORE_LOGGER_HPP_ #include <memory> #include <sstream> @@ -31,6 +31,7 @@ #include "spdlog/logger.h" #include "phx/export.hpp" +#include "phx/utility/stream_helpers.hpp" namespace phx { @@ -66,4 +67,4 @@ PHX_CONVENIENCE_LOGGER_FUNCTIONS(critical) } // namespace phx -#endif // LIBRARY_PHX_LOGGER_HPP_ +#endif // LIBRARY_PHX_CORE_LOGGER_HPP_ diff --git a/library/phx/runtime_component.hpp b/library/phx/core/runtime_component.hpp similarity index 90% rename from library/phx/runtime_component.hpp rename to library/phx/core/runtime_component.hpp index 226edd3859ea0ee4e3650e1e5a305417722c1410..48ae0917bf0b081c1e8715a8540e7857c69606d2 100644 --- a/library/phx/runtime_component.hpp +++ b/library/phx/core/runtime_component.hpp @@ -20,13 +20,12 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_RUNTIME_COMPONENT_HPP_ -#define LIBRARY_PHX_RUNTIME_COMPONENT_HPP_ +#ifndef LIBRARY_PHX_CORE_RUNTIME_COMPONENT_HPP_ +#define LIBRARY_PHX_CORE_RUNTIME_COMPONENT_HPP_ +#include "phx/core/component.hpp" #include "phx/export.hpp" -#include "phx/component.hpp" - namespace phx { enum RuntimeComponentType { @@ -51,4 +50,4 @@ class PHOENIX_EXPORT RuntimeComponent : public Component { } // namespace phx -#endif // LIBRARY_PHX_RUNTIME_COMPONENT_HPP_ +#endif // LIBRARY_PHX_CORE_RUNTIME_COMPONENT_HPP_ diff --git a/library/phx/scene.cpp b/library/phx/core/scene.cpp similarity index 95% rename from library/phx/scene.cpp rename to library/phx/core/scene.cpp index 00933e4940f25304858b3da1a9d57b70149b5ca3..e45799d9f174d3544594034b27e7c372008833e1 100644 --- a/library/phx/scene.cpp +++ b/library/phx/core/scene.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "scene.hpp" +#include "phx/core/scene.hpp" #include <cstddef> @@ -30,8 +30,8 @@ #include <utility> #include <vector> -#include "phx/transform.hpp" -#include "phx/runtime_component.hpp" +#include "phx/core/runtime_component.hpp" +#include "phx/rendering/components/transform.hpp" namespace phx { diff --git a/library/phx/scene.hpp b/library/phx/core/scene.hpp similarity index 93% rename from library/phx/scene.hpp rename to library/phx/core/scene.hpp index 71fd7260aa62b72183d5d2cd7fb1cf182069c68e..6d4ba7d6b353587bbbc4f963ec86c058b66388e9 100644 --- a/library/phx/scene.hpp +++ b/library/phx/core/scene.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_SCENE_HPP_ -#define LIBRARY_PHX_SCENE_HPP_ +#ifndef LIBRARY_PHX_CORE_SCENE_HPP_ +#define LIBRARY_PHX_CORE_SCENE_HPP_ #include <cstddef> @@ -32,11 +32,11 @@ #include <utility> #include <vector> -#include "phx/component_check.hpp" -#include "phx/entity.hpp" +#include "phx/core/component_check.hpp" +#include "phx/core/entity.hpp" +#include "phx/utility/aspects/loggable.hpp" +#include "phx/utility/aspects/nameable.hpp" #include "phx/export.hpp" -#include "phx/loggable.hpp" -#include "phx/nameable.hpp" namespace phx { @@ -125,4 +125,4 @@ std::vector<std::tuple<Components*...>> Scene::GetFirstComponentsMany() const { } // namespace phx -#endif // LIBRARY_PHX_SCENE_HPP_ +#endif // LIBRARY_PHX_CORE_SCENE_HPP_ diff --git a/library/phx/system.cpp b/library/phx/core/system.cpp similarity index 86% rename from library/phx/system.cpp rename to library/phx/core/system.cpp index b4ae86cd80cb4032346641978f13acff50f9eb75..b4aab2b1d4ed24765c88aa2a621958799ce8a3ba 100644 --- a/library/phx/system.cpp +++ b/library/phx/core/system.cpp @@ -20,12 +20,16 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "system.hpp" -#include "engine.hpp" +#include "phx/core/system.hpp" +#include "phx/core/engine.hpp" namespace phx { System::System(Engine* engine) : engine_(engine) {} phx::Engine* System::GetEngine() const { return engine_; } +void System::SetEnabled(bool enabled) { enabled_ = enabled; } + +bool System::GetEnabled() const { return enabled_; } + } // namespace phx diff --git a/library/phx/system.hpp b/library/phx/core/system.hpp similarity index 84% rename from library/phx/system.hpp rename to library/phx/core/system.hpp index ffdf3b01cba3197b9f29417977be323980aa587b..90b468e32f4249bdae32e9e82aec01f3f5421b64 100644 --- a/library/phx/system.hpp +++ b/library/phx/core/system.hpp @@ -20,14 +20,14 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_SYSTEM_HPP_ -#define LIBRARY_PHX_SYSTEM_HPP_ +#ifndef LIBRARY_PHX_CORE_SYSTEM_HPP_ +#define LIBRARY_PHX_CORE_SYSTEM_HPP_ #include <string> +#include "phx/core/frame_timer.hpp" +#include "phx/utility/aspects/loggable.hpp" #include "phx/export.hpp" -#include "phx/frame_timer.hpp" -#include "phx/loggable.hpp" namespace phx { class Engine; @@ -41,6 +41,9 @@ class PHOENIX_EXPORT System : public Loggable { Engine* GetEngine() const; + void SetEnabled(bool enabled); + bool GetEnabled() const; + protected: explicit System(Engine* engine); System(const System&) = delete; @@ -50,8 +53,10 @@ class PHOENIX_EXPORT System : public Loggable { System& operator=(System&&) = default; Engine* engine_ = nullptr; + + bool enabled_ = true; }; } // namespace phx -#endif // LIBRARY_PHX_SYSTEM_HPP_ +#endif // LIBRARY_PHX_CORE_SYSTEM_HPP_ diff --git a/library/phx/time_info.hpp b/library/phx/core/time_info.hpp similarity index 91% rename from library/phx/time_info.hpp rename to library/phx/core/time_info.hpp index 735ae8c9d963c654d878a2698e1a277605f66821..d26403c84b6f65a2e25ff92ac54b9b0235f5ef6e 100644 --- a/library/phx/time_info.hpp +++ b/library/phx/core/time_info.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_TIME_INFO_HPP_ -#define LIBRARY_PHX_TIME_INFO_HPP_ +#ifndef LIBRARY_PHX_CORE_TIME_INFO_HPP_ +#define LIBRARY_PHX_CORE_TIME_INFO_HPP_ #include <cstddef> @@ -38,4 +38,4 @@ struct PHOENIX_EXPORT TimeInfo { }; } // namespace phx -#endif // LIBRARY_PHX_TIME_INFO_HPP_ +#endif // LIBRARY_PHX_CORE_TIME_INFO_HPP_ diff --git a/library/phx/display_system.cpp b/library/phx/display/display_system.cpp similarity index 96% rename from library/phx/display_system.cpp rename to library/phx/display/display_system.cpp index 675f964211c9f8d7d852aa198436487b267a04ae..d6730963c2c30ae2d7da8438211fc912ccf1520b 100644 --- a/library/phx/display_system.cpp +++ b/library/phx/display/display_system.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "display_system.hpp" +#include "phx/display/display_system.hpp" namespace phx { DisplaySystem::DisplaySystem(Engine* engine) : System(engine) {} diff --git a/library/phx/display_system.hpp b/library/phx/display/display_system.hpp similarity index 85% rename from library/phx/display_system.hpp rename to library/phx/display/display_system.hpp index 08e2d36364fc6747c9cb8d2605b45e990ebeaa9d..fd06a71bcaa5b4dc3f3f3298da08113f5ce1105c 100644 --- a/library/phx/display_system.hpp +++ b/library/phx/display/display_system.hpp @@ -20,16 +20,16 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_DISPLAY_SYSTEM_HPP_ -#define LIBRARY_PHX_DISPLAY_SYSTEM_HPP_ +#ifndef LIBRARY_PHX_DISPLAY_DISPLAY_SYSTEM_HPP_ +#define LIBRARY_PHX_DISPLAY_DISPLAY_SYSTEM_HPP_ #include <memory> #include <vector> -#include "phx/engine.hpp" +#include "phx/rendering/backend/render_target.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/system.hpp" #include "phx/export.hpp" -#include "phx/render_target.hpp" -#include "phx/system.hpp" namespace phx { @@ -51,4 +51,4 @@ class PHOENIX_EXPORT DisplaySystem : public System { } // namespace phx -#endif // LIBRARY_PHX_DISPLAY_SYSTEM_HPP_ +#endif // LIBRARY_PHX_DISPLAY_DISPLAY_SYSTEM_HPP_ diff --git a/library/phx/display_system_openvr.cpp b/library/phx/display/display_system_openvr.cpp similarity index 94% rename from library/phx/display_system_openvr.cpp rename to library/phx/display/display_system_openvr.cpp index 7938a3fce7112a3c5791d209b315c3d5fc4b616e..a455ed5a07f6b738c4fd939f5402f22b04e55a8c 100644 --- a/library/phx/display_system_openvr.cpp +++ b/library/phx/display/display_system_openvr.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "display_system_openvr.hpp" +#include "phx/display/display_system_openvr.hpp" #include <algorithm> #include <memory> @@ -29,11 +29,11 @@ #include <utility> #include <vector> -#include "engine.hpp" -#include "logger.hpp" -#include "rendering_system.hpp" -#include "runtime_component.hpp" -#include "scene.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/logger.hpp" +#include "phx/core/runtime_component.hpp" +#include "phx/core/scene.hpp" +#include "phx/rendering/rendering_system.hpp" #undef CreateWindow diff --git a/library/phx/display_system_openvr.hpp b/library/phx/display/display_system_openvr.hpp similarity index 84% rename from library/phx/display_system_openvr.hpp rename to library/phx/display/display_system_openvr.hpp index 389c6e41dff4208bacd729bc1d63941f0180faaa..0fcdec3ddac0296a707c9e39afb980c87babd653 100644 --- a/library/phx/display_system_openvr.hpp +++ b/library/phx/display/display_system_openvr.hpp @@ -20,18 +20,18 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_DISPLAY_SYSTEM_OPENVR_HPP_ -#define LIBRARY_PHX_DISPLAY_SYSTEM_OPENVR_HPP_ +#ifndef LIBRARY_PHX_DISPLAY_DISPLAY_SYSTEM_OPENVR_HPP_ +#define LIBRARY_PHX_DISPLAY_DISPLAY_SYSTEM_OPENVR_HPP_ #include <memory> #include <vector> -#include "phx/display_system.hpp" +#include "phx/core/scene.hpp" +#include "phx/display/display_system.hpp" +#include "phx/display/hmd.hpp" +#include "phx/display/window.hpp" +#include "phx/rendering/backend/render_target.hpp" #include "phx/export.hpp" -#include "phx/hmd.hpp" -#include "phx/render_target.hpp" -#include "phx/scene.hpp" -#include "phx/window.hpp" namespace phx { @@ -68,4 +68,4 @@ class PHOENIX_EXPORT DisplaySystemOpenVR : public DisplaySystem { } // namespace phx -#endif // LIBRARY_PHX_DISPLAY_SYSTEM_OPENVR_HPP_ +#endif // LIBRARY_PHX_DISPLAY_DISPLAY_SYSTEM_OPENVR_HPP_ diff --git a/library/phx/display_system_window.cpp b/library/phx/display/display_system_window.cpp similarity index 61% rename from library/phx/display_system_window.cpp rename to library/phx/display/display_system_window.cpp index 095f56d72197328a03dbd26bfd21ba74abf3350a..190c2fe08b595e1b073a287a949629ba4b7c6b30 100644 --- a/library/phx/display_system_window.cpp +++ b/library/phx/display/display_system_window.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "display_system_window.hpp" +#include "phx/display/display_system_window.hpp" #include <algorithm> #include <memory> @@ -31,8 +31,10 @@ #include "SDL2/SDL_video.h" -#include "logger.hpp" -#include "rendering_system.hpp" +#include "phx/core/scene.hpp" +#include "phx/core/logger.hpp" +#include "phx/core/runtime_component.hpp" +#include "phx/rendering/rendering_system.hpp" #undef CreateWindow @@ -46,13 +48,9 @@ DisplaySystemWindow::DisplaySystemWindow(Engine* engine) } DisplaySystemWindow::~DisplaySystemWindow() { SDL_VideoQuit(); } -void DisplaySystemWindow::DestroyWindow() { - window_.reset(); -} +void DisplaySystemWindow::DestroyWindow() { window_.reset(); } -Window* DisplaySystemWindow::GetWindow() { - return window_.get(); -} +Window* DisplaySystemWindow::GetWindow() { return window_.get(); } void DisplaySystemWindow::Update(const FrameTimer::TimeInfo&) { if (window_ != nullptr) { @@ -60,4 +58,20 @@ void DisplaySystemWindow::Update(const FrameTimer::TimeInfo&) { } } +void DisplaySystemWindow::CreateRenderTarget(Scene* scene, float field_of_view, + float near_plane, + float far_plane) { + Entity* platform = + scene->GetEntitiesWithComponents<RuntimeComponent<USER_PLATFORM>>()[0]; + Entity* camera = scene->CreateEntity(); + camera->AddComponent<Transform>()->SetParent( + platform->GetFirstComponent<Transform>()); + auto window_size = window_->GetSize(); + camera->AddComponent<Projection>()->SetPerspective( + glm::radians(field_of_view), + static_cast<float>(window_size[0]) / static_cast<float>(window_size[1]), + near_plane, far_plane); + camera->AddComponent<RenderTarget>(window_size); +} + } // namespace phx diff --git a/library/phx/display_system_window.hpp b/library/phx/display/display_system_window.hpp similarity index 78% rename from library/phx/display_system_window.hpp rename to library/phx/display/display_system_window.hpp index 024c34de643bb5ef6fccc1e82688b435541585f9..1b41d76bb2835b793bed04e3dc284ed03013a6c9 100644 --- a/library/phx/display_system_window.hpp +++ b/library/phx/display/display_system_window.hpp @@ -20,16 +20,17 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_DISPLAY_SYSTEM_WINDOW_HPP_ -#define LIBRARY_PHX_DISPLAY_SYSTEM_WINDOW_HPP_ +#ifndef LIBRARY_PHX_DISPLAY_DISPLAY_SYSTEM_WINDOW_HPP_ +#define LIBRARY_PHX_DISPLAY_DISPLAY_SYSTEM_WINDOW_HPP_ #include <memory> #include <vector> -#include "phx/display_system.hpp" +#include "phx/core/scene.hpp" +#include "phx/display/display_system.hpp" +#include "phx/display/window.hpp" +#include "phx/rendering/backend/render_target.hpp" #include "phx/export.hpp" -#include "phx/render_target.hpp" -#include "phx/window.hpp" #undef CreateWindow @@ -52,6 +53,11 @@ class PHOENIX_EXPORT DisplaySystemWindow : public DisplaySystem { void Update(const FrameTimer::TimeInfo&) override; + // field_of_view anglie in degree in the y direction, + // near_plane, far_plane distance in meters + void CreateRenderTarget(Scene* scene, float field_of_view, float near_plane, + float far_plane); + protected: std::unique_ptr<Window> window_; }; @@ -64,4 +70,4 @@ Window* DisplaySystemWindow::CreateWindow(Arguments&&... arguments) { } } // namespace phx -#endif // LIBRARY_PHX_DISPLAY_SYSTEM_WINDOW_HPP_ +#endif // LIBRARY_PHX_DISPLAY_DISPLAY_SYSTEM_WINDOW_HPP_ diff --git a/library/phx/hmd.cpp b/library/phx/display/hmd.cpp similarity index 98% rename from library/phx/hmd.cpp rename to library/phx/display/hmd.cpp index 16194898bce619c8f79972531de415e69b5d0a53..c43329e2076bf3ad6dca6f6bb04affa19112f743 100644 --- a/library/phx/hmd.cpp +++ b/library/phx/display/hmd.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "hmd.hpp" +#include "phx/display/hmd.hpp" #include <algorithm> #include <array> @@ -39,9 +39,10 @@ SUPPRESS_WARNINGS_END #include "openvr.h" //NOLINT #include "gl/texture.hpp" -#include "phx/logger.hpp" -#include "phx/resource_manager.hpp" -#include "phx/resource_pointer.hpp" + +#include "phx/core/logger.hpp" +#include "phx/resources/resource_manager.hpp" +#include "phx/resources/resource_pointer.hpp" namespace phx { HMD::HMD() { diff --git a/library/phx/hmd.hpp b/library/phx/display/hmd.hpp similarity index 94% rename from library/phx/hmd.hpp rename to library/phx/display/hmd.hpp index 5ccffcfa0c9bfb0bfd86c28d8054905f1a4a700e..4bf398e9009ead18a97c8aec08fbdce9345be680 100644 --- a/library/phx/hmd.hpp +++ b/library/phx/display/hmd.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_HMD_HPP_ -#define LIBRARY_PHX_HMD_HPP_ +#ifndef LIBRARY_PHX_DISPLAY_HMD_HPP_ +#define LIBRARY_PHX_DISPLAY_HMD_HPP_ #include <memory> #include <vector> @@ -35,9 +35,9 @@ SUPPRESS_WARNINGS_BEGIN #include "openvr.h" //NOLINT SUPPRESS_WARNINGS_END +#include "phx/resources/types/material.hpp" +#include "phx/resources/types/mesh.hpp" #include "phx/export.hpp" -#include "phx/material.hpp" -#include "phx/mesh.hpp" #include "gl/texture.hpp" @@ -114,4 +114,4 @@ class PHOENIX_EXPORT HMD { } // namespace phx -#endif // LIBRARY_PHX_HMD_HPP_ +#endif // LIBRARY_PHX_DISPLAY_HMD_HPP_ diff --git a/library/phx/window.cpp b/library/phx/display/window.cpp similarity index 98% rename from library/phx/window.cpp rename to library/phx/display/window.cpp index edc41151a95ac2d2785ed975b657dbcdc8cdfedb..014c6ddefa32bffb66827ebf71f6e5ef88adf1b8 100644 --- a/library/phx/window.cpp +++ b/library/phx/display/window.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "window.hpp" +#include "phx/display/window.hpp" #include <stdexcept> #include <string> diff --git a/library/phx/window.hpp b/library/phx/display/window.hpp similarity index 93% rename from library/phx/window.hpp rename to library/phx/display/window.hpp index 23edcc2ed4affbb1b95fedf52aba016b8d89d948..b68d1d2d67f3a4a4f63bf6fb2d7ca7cd74d196da 100644 --- a/library/phx/window.hpp +++ b/library/phx/display/window.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_WINDOW_HPP_ -#define LIBRARY_PHX_WINDOW_HPP_ +#ifndef LIBRARY_PHX_DISPLAY_WINDOW_HPP_ +#define LIBRARY_PHX_DISPLAY_WINDOW_HPP_ #include <string> @@ -69,4 +69,4 @@ class PHOENIX_EXPORT Window { } // namespace phx -#endif // LIBRARY_PHX_WINDOW_HPP_ +#endif // LIBRARY_PHX_DISPLAY_WINDOW_HPP_ diff --git a/library/phx/input_system.cpp b/library/phx/input/input_system.cpp similarity index 91% rename from library/phx/input_system.cpp rename to library/phx/input/input_system.cpp index df27af3ce77b7b1595dc6be0044d375a9635845f..5b68fd671b36d533dc6a57822b7b4afba9b7590d 100644 --- a/library/phx/input_system.cpp +++ b/library/phx/input/input_system.cpp @@ -20,12 +20,12 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "input_system.hpp" +#include "phx/input/input_system.hpp" #include <string> -#include "logger.hpp" -#include "rendering_system.hpp" +#include "phx/core/logger.hpp" +#include "phx/rendering/rendering_system.hpp" #include "phx/suppress_warnings.hpp" SUPPRESS_WARNINGS_BEGIN @@ -59,7 +59,7 @@ boost::signals2::connection InputSystem::AddKeyReleaseCallback( } boost::signals2::connection InputSystem::AddMouseMoveCallback( - const std::function<void(unsigned, unsigned)>& callback) { + const std::function<void(int, int)>& callback) { return mouse_move_signal_.connect(callback); } @@ -89,8 +89,8 @@ void InputSystem::UpdateSDLEvents() { key_release_signal_(static_cast<char>(event.key.keysym.sym)); break; case SDL_MOUSEMOTION: - mouse_move_signal_(static_cast<unsigned int>(event.motion.xrel), - static_cast<unsigned int>(event.motion.yrel)); + mouse_move_signal_(static_cast<int>(event.motion.xrel), + static_cast<int>(event.motion.yrel)); break; case SDL_MOUSEBUTTONDOWN: mouse_press_signal_(event.button.button); diff --git a/library/phx/input_system.hpp b/library/phx/input/input_system.hpp similarity index 90% rename from library/phx/input_system.hpp rename to library/phx/input/input_system.hpp index a85319a40eb754266c947f03f332d9b0c3cee693..bd9d6076aa905c46fec92866711bdd4321cc7490 100644 --- a/library/phx/input_system.hpp +++ b/library/phx/input/input_system.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_INPUT_SYSTEM_HPP_ -#define LIBRARY_PHX_INPUT_SYSTEM_HPP_ +#ifndef LIBRARY_PHX_INPUT_INPUT_SYSTEM_HPP_ +#define LIBRARY_PHX_INPUT_INPUT_SYSTEM_HPP_ #include <functional> #include <string> @@ -34,9 +34,9 @@ SUPPRESS_WARNINGS_BEGIN #include "boost/signals2/signal.hpp" SUPPRESS_WARNINGS_END -#include "phx/engine.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/system.hpp" #include "phx/export.hpp" -#include "phx/system.hpp" namespace phx { @@ -59,7 +59,7 @@ class PHOENIX_EXPORT InputSystem : public System { boost::signals2::connection AddKeyReleaseCallback( const std::function<void(char)>& callback); boost::signals2::connection AddMouseMoveCallback( - const std::function<void(unsigned int, unsigned int)>& callback); + const std::function<void(int, int)>& callback); boost::signals2::connection AddMousePressCallback( const std::function<void(unsigned int)>& callback); boost::signals2::connection AddMouseReleaseCallback( @@ -82,7 +82,7 @@ class PHOENIX_EXPORT InputSystem : public System { boost::signals2::signal<void()> quit_signal_; boost::signals2::signal<void(char)> key_press_signal_; boost::signals2::signal<void(char)> key_release_signal_; - boost::signals2::signal<void(unsigned int, unsigned int)> mouse_move_signal_; + boost::signals2::signal<void(int, int)> mouse_move_signal_; boost::signals2::signal<void(unsigned int)> mouse_press_signal_; boost::signals2::signal<void(unsigned int)> mouse_release_signal_; @@ -91,4 +91,4 @@ class PHOENIX_EXPORT InputSystem : public System { } // namespace phx -#endif // LIBRARY_PHX_INPUT_SYSTEM_HPP_ +#endif // LIBRARY_PHX_INPUT_INPUT_SYSTEM_HPP_ diff --git a/library/phx/openvr_controller_behavior.cpp b/library/phx/input/openvr_controller_behavior.cpp similarity index 91% rename from library/phx/openvr_controller_behavior.cpp rename to library/phx/input/openvr_controller_behavior.cpp index 51620fe1f74a172e3890a0207fa47f23c91a4383..cd229828f4a407039f843dc5219e07d7d5c6aaca 100644 --- a/library/phx/openvr_controller_behavior.cpp +++ b/library/phx/input/openvr_controller_behavior.cpp @@ -20,12 +20,12 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "openvr_controller_behavior.hpp" +#include "phx/input/openvr_controller_behavior.hpp" -#include "phx/entity.hpp" -#include "phx/runtime_component.hpp" -#include "phx/scene.hpp" -#include "phx/transform.hpp" +#include "phx/core/entity.hpp" +#include "phx/core/runtime_component.hpp" +#include "phx/core/scene.hpp" +#include "phx/rendering/components/transform.hpp" namespace phx { void OpenVRControllerBehavior::OnUpdate() { diff --git a/library/phx/openvr_controller_behavior.hpp b/library/phx/input/openvr_controller_behavior.hpp similarity index 86% rename from library/phx/openvr_controller_behavior.hpp rename to library/phx/input/openvr_controller_behavior.hpp index a1b0340fb01912a614f75e2fa3e283821f76f2ff..c31643b67d511b4a813eb82e0d75db5f0039648d 100644 --- a/library/phx/openvr_controller_behavior.hpp +++ b/library/phx/input/openvr_controller_behavior.hpp @@ -20,12 +20,12 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_OPENVR_CONTROLLER_BEHAVIOR_HPP_ -#define LIBRARY_PHX_OPENVR_CONTROLLER_BEHAVIOR_HPP_ +#ifndef LIBRARY_PHX_INPUT_OPENVR_CONTROLLER_BEHAVIOR_HPP_ +#define LIBRARY_PHX_INPUT_OPENVR_CONTROLLER_BEHAVIOR_HPP_ #include "phx/suppress_warnings.hpp" -#include "phx/behavior.hpp" +#include "phx/scripting/behavior.hpp" #include "phx/export.hpp" namespace phx { @@ -45,4 +45,4 @@ class PHOENIX_EXPORT OpenVRControllerBehavior : public Behavior { SUPPRESS_WARNINGS_END } // namespace phx -#endif // LIBRARY_PHX_OPENVR_CONTROLLER_BEHAVIOR_HPP_ +#endif // LIBRARY_PHX_INPUT_OPENVR_CONTROLLER_BEHAVIOR_HPP_ diff --git a/library/phx/openvr_controller_system.cpp b/library/phx/input/openvr_controller_system.cpp similarity index 91% rename from library/phx/openvr_controller_system.cpp rename to library/phx/input/openvr_controller_system.cpp index 01a18ad27879ff4a817143af9081477a807b8040..eecf2be7c87c8437f68888ac9670a81bb7123009 100644 --- a/library/phx/openvr_controller_system.cpp +++ b/library/phx/input/openvr_controller_system.cpp @@ -20,21 +20,21 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "openvr_controller_system.hpp" +#include "phx/input/openvr_controller_system.hpp" #include <memory> #include <string> #include <utility> -#include "phx/display_system_openvr.hpp" -#include "phx/logger.hpp" -#include "phx/material_handle.hpp" -#include "phx/mesh_handle.hpp" -#include "phx/openvr_controller_behavior.hpp" -#include "phx/openvr_resource_loader.hpp" -#include "phx/resource_manager.hpp" -#include "phx/resource_pointer.hpp" -#include "phx/transform.hpp" +#include "phx/core/logger.hpp" +#include "phx/display/display_system_openvr.hpp" +#include "phx/input/openvr_controller_behavior.hpp" +#include "phx/rendering/components/material_handle.hpp" +#include "phx/rendering/components/mesh_handle.hpp" +#include "phx/rendering/components/transform.hpp" +#include "phx/resources/loaders/openvr_resource_loader.hpp" +#include "phx/resources/resource_manager.hpp" +#include "phx/resources/resource_pointer.hpp" namespace phx { diff --git a/library/phx/openvr_controller_system.hpp b/library/phx/input/openvr_controller_system.hpp similarity index 86% rename from library/phx/openvr_controller_system.hpp rename to library/phx/input/openvr_controller_system.hpp index 17f7cfd53707f4876766e7c8871e0ec3186a0553..c382d2585a76e56a4c2cdcaa7215bb7c9fa09011 100644 --- a/library/phx/openvr_controller_system.hpp +++ b/library/phx/input/openvr_controller_system.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_OPENVR_CONTROLLER_SYSTEM_HPP_ -#define LIBRARY_PHX_OPENVR_CONTROLLER_SYSTEM_HPP_ +#ifndef LIBRARY_PHX_INPUT_OPENVR_CONTROLLER_SYSTEM_HPP_ +#define LIBRARY_PHX_INPUT_OPENVR_CONTROLLER_SYSTEM_HPP_ #include <memory> #include <vector> @@ -32,12 +32,12 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/glm.hpp" SUPPRESS_WARNINGS_END -#include "phx/display_system.hpp" -#include "phx/engine.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/system.hpp" +#include "phx/display/display_system.hpp" +#include "phx/display/hmd.hpp" +#include "phx/input/openvr_controller_behavior.hpp" #include "phx/export.hpp" -#include "phx/hmd.hpp" -#include "phx/openvr_controller_behavior.hpp" -#include "phx/system.hpp" namespace phx { class PHOENIX_EXPORT OpenVRControllerSystem : public System { @@ -70,4 +70,4 @@ class PHOENIX_EXPORT OpenVRControllerSystem : public System { } // namespace phx -#endif // LIBRARY_PHX_OPENVR_CONTROLLER_SYSTEM_HPP_ +#endif // LIBRARY_PHX_INPUT_OPENVR_CONTROLLER_SYSTEM_HPP_ diff --git a/library/phx/splash_screen.cpp b/library/phx/rendering/auxiliary/splash_screen.cpp similarity index 87% rename from library/phx/splash_screen.cpp rename to library/phx/rendering/auxiliary/splash_screen.cpp index 3064a85876105d783d1c8282cabd900418d83d71..6dc547a6cb0699368c4b098f3a2f495504c902ac 100644 --- a/library/phx/splash_screen.cpp +++ b/library/phx/rendering/auxiliary/splash_screen.cpp @@ -20,22 +20,21 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "splash_screen.hpp" - -#include <gl/all.hpp> +#include "phx/rendering/auxiliary/splash_screen.hpp" #include <cmath> #include <memory> #include <string> -#include "phx/image.hpp" -#include "phx/resource_manager.hpp" -#include "phx/resource_utils.hpp" +#include "phx/resources/types/image.hpp" +#include "phx/resources/resource_manager.hpp" +#include "phx/resources/resource_utils.hpp" #include "phx/resources_path.hpp" namespace phx { -phx::SplashScreen::SplashScreen(Window* window) : window_(window) { +phx::SplashScreen::SplashScreen(Engine* engine, Window* window) + : System(engine), window_(window) { splash_image_ = ResourceUtils::LoadResourceFromFile<Image>( "textures/splash_progress.png"); @@ -46,6 +45,8 @@ phx::SplashScreen::SplashScreen(Window* window) : window_(window) { default_framebuffer_ = std::make_unique<gl::framebuffer>(0); } +void SplashScreen::Update(const FrameTimer::TimeInfo&) { Draw(); } + void SplashScreen::Draw() { auto splash_dimensions = splash_image_->GetDimensions(); auto progress_dimensions = progressbar_image_->GetDimensions(); @@ -99,9 +100,12 @@ void SplashScreen::Draw() { gl::print_error("OpenGl Error blitting Splash Screen: "); constexpr float progressbar_max_pixel_width = 198.f; - const unsigned int progressbar_current_pixel_width = - static_cast<unsigned int>( - std::round(load_progress_ * progressbar_max_pixel_width)); + unsigned int progressbar_current_pixel_width; + { + std::lock_guard<std::mutex> lock_guard(load_progress_mutex_); + progressbar_current_pixel_width = static_cast<unsigned int>( + std::round(load_progress_ * progressbar_max_pixel_width)); + } const int progressbar_pixel_height = 9; auto progressbar_x_offset = x_offset + 98; @@ -115,11 +119,10 @@ void SplashScreen::Draw() { progressbar_x_offset), static_cast<GLsizei>(progressbar_pixel_height + progressbar_y_offset), GL_COLOR_BUFFER_BIT, GL_LINEAR); - - window_->Swap(); } void SplashScreen::SetLoadProgress(float progress) { + std::lock_guard<std::mutex> lock_guard(load_progress_mutex_); load_progress_ = progress; } diff --git a/library/phx/splash_screen.hpp b/library/phx/rendering/auxiliary/splash_screen.hpp similarity index 68% rename from library/phx/splash_screen.hpp rename to library/phx/rendering/auxiliary/splash_screen.hpp index 8755048cd61e850108a5505898ea3b99c70a7ad4..2a9007e7b2a870d788a5492fef07de605364332a 100644 --- a/library/phx/splash_screen.hpp +++ b/library/phx/rendering/auxiliary/splash_screen.hpp @@ -20,46 +20,53 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_SPLASH_SCREEN_HPP_ -#define LIBRARY_PHX_SPLASH_SCREEN_HPP_ +#ifndef LIBRARY_PHX_RENDERING_AUXILIARY_SPLASH_SCREEN_HPP_ +#define LIBRARY_PHX_RENDERING_AUXILIARY_SPLASH_SCREEN_HPP_ #include <memory> +#include <mutex> #include "phx/suppress_warnings.hpp" +#include "phx/core/system.hpp" +#include "phx/display/window.hpp" #include "phx/export.hpp" -#include "phx/image.hpp" -#include "phx/resource_pointer.hpp" -#include "phx/window.hpp" +#include "phx/resources/resource_pointer.hpp" +#include "phx/resources/types/image.hpp" #include "gl/framebuffer.hpp" namespace phx { SUPPRESS_WARNINGS_BEGIN_PADDED -class PHOENIX_EXPORT SplashScreen { +class PHOENIX_EXPORT SplashScreen : public System { public: - explicit SplashScreen(Window* window); - SplashScreen(const SplashScreen&) = default; - SplashScreen(SplashScreen&&) = default; - ~SplashScreen() = default; - - SplashScreen& operator=(const SplashScreen&) = default; - SplashScreen& operator=(SplashScreen&&) = default; + SplashScreen() = delete; + SplashScreen(Engine* engine, Window* window); + virtual ~SplashScreen() = default; + void Update(const FrameTimer::TimeInfo&) override; void Draw(); void SetLoadProgress(float progress); + protected: + SplashScreen(const SplashScreen&) = delete; + SplashScreen(SplashScreen&&) = default; + + SplashScreen& operator=(const SplashScreen&) = delete; + SplashScreen& operator=(SplashScreen&&) = default; + private: std::unique_ptr<gl::framebuffer> default_framebuffer_; ResourcePointer<Image> splash_image_; std::unique_ptr<Image> progressbar_image_; Window* window_; + std::mutex load_progress_mutex_; float load_progress_ = 0.f; }; SUPPRESS_WARNINGS_END } // namespace phx -#endif // LIBRARY_PHX_SPLASH_SCREEN_HPP_ +#endif // LIBRARY_PHX_RENDERING_AUXILIARY_SPLASH_SCREEN_HPP_ diff --git a/library/phx/opengl_image_buffer_data.cpp b/library/phx/rendering/backend/opengl_image_buffer_data.cpp similarity index 98% rename from library/phx/opengl_image_buffer_data.cpp rename to library/phx/rendering/backend/opengl_image_buffer_data.cpp index 5a87d2f8a4308c9466b77c468df451d19357dbd1..2198b578e4351ccc02dfa2a506ce18193064124d 100644 --- a/library/phx/opengl_image_buffer_data.cpp +++ b/library/phx/rendering/backend/opengl_image_buffer_data.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "opengl_image_buffer_data.hpp" +#include "phx/rendering/backend/opengl_image_buffer_data.hpp" #include <algorithm> #include <memory> diff --git a/library/phx/opengl_image_buffer_data.hpp b/library/phx/rendering/backend/opengl_image_buffer_data.hpp similarity index 97% rename from library/phx/opengl_image_buffer_data.hpp rename to library/phx/rendering/backend/opengl_image_buffer_data.hpp index 13ec7a85db6dcbf96d8c04c4f1987247ec5bc166..128d6b20063ed269fcaa7bfa0abed3f9dc82f61f 100644 --- a/library/phx/opengl_image_buffer_data.hpp +++ b/library/phx/rendering/backend/opengl_image_buffer_data.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_OPENGL_IMAGE_BUFFER_DATA_HPP_ -#define LIBRARY_PHX_OPENGL_IMAGE_BUFFER_DATA_HPP_ +#ifndef LIBRARY_PHX_RENDERING_BACKEND_OPENGL_IMAGE_BUFFER_DATA_HPP_ +#define LIBRARY_PHX_RENDERING_BACKEND_OPENGL_IMAGE_BUFFER_DATA_HPP_ #include <algorithm> #include <cmath> @@ -34,10 +34,10 @@ #include "GL/glew.h" #include "gl/texture.hpp" +#include "phx/resources/types/image.hpp" +#include "phx/resources/resource_manager.hpp" +#include "phx/resources/resource_utils.hpp" #include "phx/export.hpp" -#include "phx/image.hpp" -#include "phx/resource_manager.hpp" -#include "phx/resource_utils.hpp" namespace phx { @@ -393,4 +393,4 @@ phx::OpenGLImageBufferData<T> phx::OpenGLImageBufferData<T>::ReadFromFilePNG( } // namespace phx -#endif // LIBRARY_PHX_OPENGL_IMAGE_BUFFER_DATA_HPP_ +#endif // LIBRARY_PHX_RENDERING_BACKEND_OPENGL_IMAGE_BUFFER_DATA_HPP_ diff --git a/library/phx/render_target.cpp b/library/phx/rendering/backend/render_target.cpp similarity index 94% rename from library/phx/render_target.cpp rename to library/phx/rendering/backend/render_target.cpp index 02008a7d97e3072cb6c1a7a42ebb34edc9393210..b8b1c611a6b5a0c5eaaa351dbeec3cd492b9f08e 100644 --- a/library/phx/render_target.cpp +++ b/library/phx/rendering/backend/render_target.cpp @@ -20,17 +20,17 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "render_target.hpp" +#include "phx/rendering/backend/render_target.hpp" #include <memory> #include "gl/command_execution.hpp" #include "gl/viewport.hpp" -#include "phx/entity.hpp" -#include "phx/logger.hpp" -#include "phx/projection.hpp" -#include "phx/transform.hpp" +#include "phx/core/entity.hpp" +#include "phx/core/logger.hpp" +#include "phx/rendering/components/projection.hpp" +#include "phx/rendering/components/transform.hpp" namespace phx { phx::RenderTarget::RenderTarget(const glm::uvec2 dimensions) diff --git a/library/phx/render_target.hpp b/library/phx/rendering/backend/render_target.hpp similarity index 91% rename from library/phx/render_target.hpp rename to library/phx/rendering/backend/render_target.hpp index f441a947c7a32e831d353f1078bfd6b986bf2d28..be07213d041ca9e41aec02c17b72d5e00f56090f 100644 --- a/library/phx/render_target.hpp +++ b/library/phx/rendering/backend/render_target.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_RENDER_TARGET_HPP_ -#define LIBRARY_PHX_RENDER_TARGET_HPP_ +#ifndef LIBRARY_PHX_RENDERING_BACKEND_RENDER_TARGET_HPP_ +#define LIBRARY_PHX_RENDERING_BACKEND_RENDER_TARGET_HPP_ #include <memory> @@ -38,7 +38,7 @@ SUPPRESS_WARNINGS_END #include "gl/renderbuffer.hpp" #include "gl/texture.hpp" -#include "phx/component.hpp" +#include "phx/core/component.hpp" #include "phx/export.hpp" namespace phx { @@ -73,4 +73,4 @@ SUPPRESS_WARNINGS_END } // namespace phx -#endif // LIBRARY_PHX_RENDER_TARGET_HPP_ +#endif // LIBRARY_PHX_RENDERING_BACKEND_RENDER_TARGET_HPP_ diff --git a/library/phx/shader_program.cpp b/library/phx/rendering/backend/shader_program.cpp similarity index 93% rename from library/phx/shader_program.cpp rename to library/phx/rendering/backend/shader_program.cpp index 85f76897a39a9db2028f7681ebfc46788b795cc8..4d53dc6c6245d2b0fdd1fe631f42cd1b7c3f2f28 100644 --- a/library/phx/shader_program.cpp +++ b/library/phx/rendering/backend/shader_program.cpp @@ -20,16 +20,16 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "phx/shader_program.hpp" +#include "phx/rendering/backend/shader_program.hpp" #include <fstream> #include <iostream> #include <memory> #include <string> -#include "phx/logger.hpp" -#include "phx/resource.hpp" -#include "phx/shader_source.hpp" +#include "phx/core/logger.hpp" +#include "phx/resources/types/shader_source.hpp" +#include "phx/resources/resource.hpp" namespace phx { diff --git a/library/phx/shader_program.hpp b/library/phx/rendering/backend/shader_program.hpp similarity index 86% rename from library/phx/shader_program.hpp rename to library/phx/rendering/backend/shader_program.hpp index 63bc305fb810aeb66a55d9c6ecdc016849a0e466..93c6d7a56319bc436740a4e938fba132490a00ec 100644 --- a/library/phx/shader_program.hpp +++ b/library/phx/rendering/backend/shader_program.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_SHADER_PROGRAM_HPP_ -#define LIBRARY_PHX_SHADER_PROGRAM_HPP_ +#ifndef LIBRARY_PHX_RENDERING_BACKEND_SHADER_PROGRAM_HPP_ +#define LIBRARY_PHX_RENDERING_BACKEND_SHADER_PROGRAM_HPP_ #include <cstddef> #include <memory> @@ -37,12 +37,12 @@ SUPPRESS_WARNINGS_END #include "gl/program.hpp" #include "gl/shader.hpp" +#include "phx/rendering/components/transform.hpp" +#include "phx/rendering/render_passes/render_pass.hpp" +#include "phx/resources/types/mesh.hpp" +#include "phx/resources/types/shader_source.hpp" +#include "phx/resources/resource_pointer.hpp" #include "phx/export.hpp" -#include "phx/mesh.hpp" -#include "phx/render_pass.hpp" -#include "phx/resource_pointer.hpp" -#include "phx/shader_source.hpp" -#include "phx/transform.hpp" namespace phx { @@ -95,4 +95,4 @@ SUPPRESS_WARNINGS_END } // namespace phx -#endif // LIBRARY_PHX_SHADER_PROGRAM_HPP_ +#endif // LIBRARY_PHX_RENDERING_BACKEND_SHADER_PROGRAM_HPP_ diff --git a/library/phx/light.cpp b/library/phx/rendering/components/light.cpp similarity index 97% rename from library/phx/light.cpp rename to library/phx/rendering/components/light.cpp index 3f571a0381c07386d280f4f362f09f5b3d17d380..547edfe9b790799f584b6996d1059759bdf9efea 100644 --- a/library/phx/light.cpp +++ b/library/phx/rendering/components/light.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "light.hpp" +#include "phx/rendering/components/light.hpp" #include <string> diff --git a/library/phx/light.hpp b/library/phx/rendering/components/light.hpp similarity index 91% rename from library/phx/light.hpp rename to library/phx/rendering/components/light.hpp index de0a6522916b8b8326916751fc49d38d8e2a86e4..e8abc925810b1d63db905fad6a885e2843d2cb90 100644 --- a/library/phx/light.hpp +++ b/library/phx/rendering/components/light.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_LIGHT_HPP_ -#define LIBRARY_PHX_LIGHT_HPP_ +#ifndef LIBRARY_PHX_RENDERING_COMPONENTS_LIGHT_HPP_ +#define LIBRARY_PHX_RENDERING_COMPONENTS_LIGHT_HPP_ #include <string> @@ -31,7 +31,7 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/glm.hpp" SUPPRESS_WARNINGS_END -#include "phx/component.hpp" +#include "phx/core/component.hpp" #include "phx/export.hpp" namespace phx { @@ -84,4 +84,4 @@ SUPPRESS_WARNINGS_END } // namespace phx -#endif // LIBRARY_PHX_LIGHT_HPP_ +#endif // LIBRARY_PHX_RENDERING_COMPONENTS_LIGHT_HPP_ diff --git a/library/phx/material_handle.cpp b/library/phx/rendering/components/material_handle.cpp similarity index 94% rename from library/phx/material_handle.cpp rename to library/phx/rendering/components/material_handle.cpp index ecafabb6b67ee45ee2c2fd99868b29712b00b2fd..0e058bba73ae1c5d0bab1fac7f947951bb5a77fa 100644 --- a/library/phx/material_handle.cpp +++ b/library/phx/rendering/components/material_handle.cpp @@ -20,12 +20,12 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "material_handle.hpp" +#include "phx/rendering/components/material_handle.hpp" #include <iostream> #include <string> -#include "logger.hpp" +#include "phx/core/logger.hpp" namespace phx { diff --git a/library/phx/material_handle.hpp b/library/phx/rendering/components/material_handle.hpp similarity index 83% rename from library/phx/material_handle.hpp rename to library/phx/rendering/components/material_handle.hpp index e51fb04fc2790a0b2fcb2603a93fbb60ab31f6fe..a2a5a14442cccc3b29a88c10fa6f811199754af1 100644 --- a/library/phx/material_handle.hpp +++ b/library/phx/rendering/components/material_handle.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_MATERIAL_HANDLE_HPP_ -#define LIBRARY_PHX_MATERIAL_HANDLE_HPP_ +#ifndef LIBRARY_PHX_RENDERING_COMPONENTS_MATERIAL_HANDLE_HPP_ +#define LIBRARY_PHX_RENDERING_COMPONENTS_MATERIAL_HANDLE_HPP_ #include <string> #include <vector> @@ -32,11 +32,11 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/vec3.hpp" SUPPRESS_WARNINGS_END -#include "phx/component.hpp" +#include "phx/core/component.hpp" +#include "phx/resources/types/material.hpp" +#include "phx/resources/resource_pointer.hpp" +#include "phx/utility/aspects/nameable.hpp" #include "phx/export.hpp" -#include "phx/material.hpp" -#include "phx/nameable.hpp" -#include "phx/resource_pointer.hpp" namespace phx { @@ -62,4 +62,4 @@ class PHOENIX_EXPORT MaterialHandle final : public Component, public Nameable { } // namespace phx -#endif // LIBRARY_PHX_MATERIAL_HANDLE_HPP_ +#endif // LIBRARY_PHX_RENDERING_COMPONENTS_MATERIAL_HANDLE_HPP_ diff --git a/library/phx/mesh_handle.cpp b/library/phx/rendering/components/mesh_handle.cpp similarity index 88% rename from library/phx/mesh_handle.cpp rename to library/phx/rendering/components/mesh_handle.cpp index e8b2f5f2a875f6aff6f0f669c1f4397c1683609b..14041b3414920d201f59526cee2f4cd310acb139 100644 --- a/library/phx/mesh_handle.cpp +++ b/library/phx/rendering/components/mesh_handle.cpp @@ -19,11 +19,12 @@ // See the License for the specific language governing permissions and // limitations under the License. //------------------------------------------------------------------------------ -#include "mesh_handle.hpp" + +#include "phx/rendering/components/mesh_handle.hpp" #include <string> -#include "phx/mesh.hpp" +#include "phx/resources/types/mesh.hpp" namespace phx { @@ -31,6 +32,10 @@ void MeshHandle::SetMesh(ResourcePointer<Mesh> mesh) { mesh_ = mesh; } ResourcePointer<Mesh> MeshHandle::GetMesh() const { return mesh_; } +void MeshHandle::SetWireframeMode(bool enabled) { wireframe_mode_ = enabled; } + +bool MeshHandle::GetWireframeMode() const { return wireframe_mode_; } + std::string MeshHandle::ToString() const { if (mesh_ == nullptr) return GetName() + " (MeshHandle <empty>)"; diff --git a/library/phx/mesh_handle.hpp b/library/phx/rendering/components/mesh_handle.hpp similarity index 79% rename from library/phx/mesh_handle.hpp rename to library/phx/rendering/components/mesh_handle.hpp index 729d62289c8e6a0e9b47e4f92722242f281dd56d..5bbf59c677ff2ea2d6d9fa9160b361d38e603e7d 100644 --- a/library/phx/mesh_handle.hpp +++ b/library/phx/rendering/components/mesh_handle.hpp @@ -19,16 +19,16 @@ // See the License for the specific language governing permissions and // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_MESH_HANDLE_HPP_ -#define LIBRARY_PHX_MESH_HANDLE_HPP_ +#ifndef LIBRARY_PHX_RENDERING_COMPONENTS_MESH_HANDLE_HPP_ +#define LIBRARY_PHX_RENDERING_COMPONENTS_MESH_HANDLE_HPP_ #include <string> -#include "phx/component.hpp" +#include "phx/core/component.hpp" +#include "phx/resources/types/mesh.hpp" +#include "phx/resources/resource_pointer.hpp" +#include "phx/utility/aspects/nameable.hpp" #include "phx/export.hpp" -#include "phx/mesh.hpp" -#include "phx/nameable.hpp" -#include "phx/resource_pointer.hpp" namespace phx { /** @@ -41,6 +41,9 @@ class PHOENIX_EXPORT MeshHandle final : public Component, public Nameable { void SetMesh(ResourcePointer<Mesh> mesh); ResourcePointer<Mesh> GetMesh() const; + void SetWireframeMode(bool enabled); + bool GetWireframeMode() const; + std::string ToString() const override; protected: @@ -52,10 +55,10 @@ class PHOENIX_EXPORT MeshHandle final : public Component, public Nameable { MeshHandle& operator=(const MeshHandle&) = delete; MeshHandle& operator=(MeshHandle&&) = default; - protected: private: ResourcePointer<Mesh> mesh_{nullptr}; + bool wireframe_mode_ = false; }; } // namespace phx -#endif // LIBRARY_PHX_MESH_HANDLE_HPP_ +#endif // LIBRARY_PHX_RENDERING_COMPONENTS_MESH_HANDLE_HPP_ diff --git a/library/phx/projection.cpp b/library/phx/rendering/components/projection.cpp similarity index 97% rename from library/phx/projection.cpp rename to library/phx/rendering/components/projection.cpp index 81713abd912bc564b7a0615a738cfcc05e7a052c..63b56491e4f5f2328ae7fbfab08b13b384a16101 100644 --- a/library/phx/projection.cpp +++ b/library/phx/rendering/components/projection.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "projection.hpp" +#include "phx/rendering/components/projection.hpp" #include <string> diff --git a/library/phx/projection.hpp b/library/phx/rendering/components/projection.hpp similarity index 89% rename from library/phx/projection.hpp rename to library/phx/rendering/components/projection.hpp index 17671b52416f0bdda621d5f711670fd7f955a2b9..b347dae5a61e47dd5e9066eb687d964a5bb07b27 100644 --- a/library/phx/projection.hpp +++ b/library/phx/rendering/components/projection.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_PROJECTION_HPP_ -#define LIBRARY_PHX_PROJECTION_HPP_ +#ifndef LIBRARY_PHX_RENDERING_COMPONENTS_PROJECTION_HPP_ +#define LIBRARY_PHX_RENDERING_COMPONENTS_PROJECTION_HPP_ #include <string> @@ -31,7 +31,7 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/mat4x4.hpp" SUPPRESS_WARNINGS_END -#include "phx/component.hpp" +#include "phx/core/component.hpp" #include "phx/export.hpp" namespace phx { @@ -63,4 +63,4 @@ class PHOENIX_EXPORT Projection final : public Component { } // namespace phx -#endif // LIBRARY_PHX_PROJECTION_HPP_ +#endif // LIBRARY_PHX_RENDERING_COMPONENTS_PROJECTION_HPP_ diff --git a/library/phx/transform.cpp b/library/phx/rendering/components/transform.cpp similarity index 94% rename from library/phx/transform.cpp rename to library/phx/rendering/components/transform.cpp index 32f699262afff5d85e53f5074623bea8a9ce66cf..0200fcb6d5895920acdd34e2a52bbd6f9252577f 100644 --- a/library/phx/transform.cpp +++ b/library/phx/rendering/components/transform.cpp @@ -32,11 +32,10 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/gtx/transform.hpp" SUPPRESS_WARNINGS_END -#include "transform.hpp" - -#include "phx/entity.hpp" -#include "phx/logger.hpp" -#include "phx/stream_helpers.hpp" +#include "phx/core/entity.hpp" +#include "phx/core/logger.hpp" +#include "phx/rendering/components/transform.hpp" +#include "phx/utility/stream_helpers.hpp" namespace phx { Transform::Transform(const glm::vec3& translation, const glm::quat& rotation, @@ -108,7 +107,7 @@ const glm::quat& Transform::GetGlobalRotation() const { } Transform& Transform::SetGlobalRotation(const glm::quat& rotation) { local_rotation_ = - parent_ ? rotation * glm::inverse(parent_->global_rotation_) : rotation; + parent_ ? glm::inverse(parent_->global_rotation_) * rotation : rotation; UpdateLocalMatrix(); return *this; } @@ -134,7 +133,7 @@ Transform& Transform::SetGlobalScale(const glm::vec3& scale) { const glm::mat4& Transform::GetGlobalMatrix() const { return global_matrix_; } Transform& Transform::SetGlobalMatrix(const glm::mat4& matrix) { local_matrix_ = - parent_ ? matrix * glm::inverse(parent_->global_matrix_) : matrix; + parent_ ? glm::inverse(parent_->global_matrix_) * matrix : matrix; glm::vec3 skew; glm::vec4 perspective; glm::decompose(local_matrix_, local_scale_, local_rotation_, @@ -148,10 +147,10 @@ Transform& Transform::Translate(const glm::vec3& amount) { return SetLocalTranslation(amount + local_translation_); } Transform& Transform::Rotate(const glm::quat& amount) { - return SetLocalRotation(amount * local_rotation_); + return SetLocalRotation(local_rotation_ * amount); } Transform& Transform::RotateEuler(const glm::vec3& amount) { - return SetLocalRotation(glm::quat(glm::radians(amount)) * local_rotation_); + return SetLocalRotation(local_rotation_ * glm::quat(glm::radians(amount))); } Transform& Transform::Scale(const glm::vec3& amount) { return SetLocalScale(amount + local_scale_); diff --git a/library/phx/transform.hpp b/library/phx/rendering/components/transform.hpp similarity index 94% rename from library/phx/transform.hpp rename to library/phx/rendering/components/transform.hpp index 99092fe7e690363f8c2651b794d08a24fb6a9325..b67c14855ba21e89aeb98eb9f80fda9f625a0fc9 100644 --- a/library/phx/transform.hpp +++ b/library/phx/rendering/components/transform.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_TRANSFORM_HPP_ -#define LIBRARY_PHX_TRANSFORM_HPP_ +#ifndef LIBRARY_PHX_RENDERING_COMPONENTS_TRANSFORM_HPP_ +#define LIBRARY_PHX_RENDERING_COMPONENTS_TRANSFORM_HPP_ #include <ostream> #include <string> @@ -34,9 +34,9 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/vec4.hpp" SUPPRESS_WARNINGS_END -#include "phx/component.hpp" +#include "phx/core/component.hpp" +#include "phx/utility/aspects/hierarchical.hpp" #include "phx/export.hpp" -#include "phx/hierarchical.hpp" namespace phx { @@ -126,4 +126,4 @@ class PHOENIX_EXPORT Transform : public Component, } // namespace phx -#endif // LIBRARY_PHX_TRANSFORM_HPP_ +#endif // LIBRARY_PHX_RENDERING_COMPONENTS_TRANSFORM_HPP_ diff --git a/library/phx/frame_graph.cpp b/library/phx/rendering/frame_graph.cpp similarity index 91% rename from library/phx/frame_graph.cpp rename to library/phx/rendering/frame_graph.cpp index c672239f7ec7a5e17ecc6163b3731273ce057b89..8c25c72b218964a02f0696cb3bf76a5fe4971b9f 100644 --- a/library/phx/frame_graph.cpp +++ b/library/phx/rendering/frame_graph.cpp @@ -20,13 +20,13 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "phx/frame_graph.hpp" +#include "phx/rendering/frame_graph.hpp" #include <memory> #include <utility> -#include "phx/clear_pass.hpp" -#include "phx/geometry_pass.hpp" +#include "phx/rendering/render_passes/clear_pass.hpp" +#include "phx/rendering/render_passes/geometry_pass.hpp" namespace phx { diff --git a/library/phx/frame_graph.hpp b/library/phx/rendering/frame_graph.hpp similarity index 91% rename from library/phx/frame_graph.hpp rename to library/phx/rendering/frame_graph.hpp index 09079b5ead43296d5791c92d895756d114840e10..a6b4cbaf87f73cd6fce95aa39a110392f13e250c 100644 --- a/library/phx/frame_graph.hpp +++ b/library/phx/rendering/frame_graph.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_FRAME_GRAPH_HPP_ -#define LIBRARY_PHX_FRAME_GRAPH_HPP_ +#ifndef LIBRARY_PHX_RENDERING_FRAME_GRAPH_HPP_ +#define LIBRARY_PHX_RENDERING_FRAME_GRAPH_HPP_ #include <list> #include <memory> @@ -29,7 +29,7 @@ #include <vector> #include "phx/export.hpp" -#include "phx/render_pass.hpp" +#include "phx/rendering/render_passes/render_pass.hpp" namespace phx { class PHOENIX_EXPORT FrameGraph { @@ -71,4 +71,4 @@ std::vector<RenderPassType*> phx::FrameGraph::GetRenderPasses() const { } // namespace phx -#endif // LIBRARY_PHX_FRAME_GRAPH_HPP_ +#endif // LIBRARY_PHX_RENDERING_FRAME_GRAPH_HPP_ diff --git a/library/phx/blit_pass.cpp b/library/phx/rendering/render_passes/blit_pass.cpp similarity index 97% rename from library/phx/blit_pass.cpp rename to library/phx/rendering/render_passes/blit_pass.cpp index 92f9deb7fe361960d913f95c23b4c056044e8d8a..e8029f84039fe2be178867a289d500d1ff9724d5 100644 --- a/library/phx/blit_pass.cpp +++ b/library/phx/rendering/render_passes/blit_pass.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "blit_pass.hpp" +#include "phx/rendering/render_passes/blit_pass.hpp" #include <memory> diff --git a/library/phx/blit_pass.hpp b/library/phx/rendering/render_passes/blit_pass.hpp similarity index 84% rename from library/phx/blit_pass.hpp rename to library/phx/rendering/render_passes/blit_pass.hpp index 8b62607003da4462e6bacbfcd93af9e24616e619..2d1a41a3b1e7901b9e2b8d35f9d0e7349fe8e942 100644 --- a/library/phx/blit_pass.hpp +++ b/library/phx/rendering/render_passes/blit_pass.hpp @@ -20,16 +20,16 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_BLIT_PASS_HPP_ -#define LIBRARY_PHX_BLIT_PASS_HPP_ +#ifndef LIBRARY_PHX_RENDERING_RENDER_PASSES_BLIT_PASS_HPP_ +#define LIBRARY_PHX_RENDERING_RENDER_PASSES_BLIT_PASS_HPP_ #include <memory> #include "gl/framebuffer.hpp" #include "phx/export.hpp" -#include "phx/render_pass.hpp" -#include "phx/render_target.hpp" +#include "phx/rendering/backend/render_target.hpp" +#include "phx/rendering/render_passes/render_pass.hpp" namespace phx { @@ -52,4 +52,4 @@ class PHOENIX_EXPORT BlitPass : public RenderPass { } // namespace phx -#endif // LIBRARY_PHX_BLIT_PASS_HPP_ +#endif // LIBRARY_PHX_RENDERING_RENDER_PASSES_BLIT_PASS_HPP_ diff --git a/library/phx/clear_pass.cpp b/library/phx/rendering/render_passes/clear_pass.cpp similarity index 96% rename from library/phx/clear_pass.cpp rename to library/phx/rendering/render_passes/clear_pass.cpp index 6d42887213e4d5bb272feefbb0ff3a17a3455894..f971ac29c642bcf3dc9e9ea49c064bbc9151e342 100644 --- a/library/phx/clear_pass.cpp +++ b/library/phx/rendering/render_passes/clear_pass.cpp @@ -28,7 +28,7 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/gtc/type_ptr.hpp" SUPPRESS_WARNINGS_END -#include "clear_pass.hpp" +#include "phx/rendering/render_passes/clear_pass.hpp" namespace phx { diff --git a/library/phx/clear_pass.hpp b/library/phx/rendering/render_passes/clear_pass.hpp similarity index 85% rename from library/phx/clear_pass.hpp rename to library/phx/rendering/render_passes/clear_pass.hpp index 4df4c70bb388be168607f25bda00fe65376c43d3..82de13564646794ef732d918da2f631eaee7e5a4 100644 --- a/library/phx/clear_pass.hpp +++ b/library/phx/rendering/render_passes/clear_pass.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_CLEAR_PASS_HPP_ -#define LIBRARY_PHX_CLEAR_PASS_HPP_ +#ifndef LIBRARY_PHX_RENDERING_RENDER_PASSES_CLEAR_PASS_HPP_ +#define LIBRARY_PHX_RENDERING_RENDER_PASSES_CLEAR_PASS_HPP_ #include "phx/suppress_warnings.hpp" @@ -30,9 +30,9 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/vec4.hpp" SUPPRESS_WARNINGS_END +#include "phx/rendering/backend/render_target.hpp" +#include "phx/rendering/render_passes/render_pass.hpp" #include "phx/export.hpp" -#include "phx/render_pass.hpp" -#include "phx/render_target.hpp" namespace phx { @@ -56,4 +56,4 @@ class PHOENIX_EXPORT ClearPass : public RenderPass { } // namespace phx -#endif // LIBRARY_PHX_CLEAR_PASS_HPP_ +#endif // LIBRARY_PHX_RENDERING_RENDER_PASSES_CLEAR_PASS_HPP_ diff --git a/library/phx/geometry_pass.cpp b/library/phx/rendering/render_passes/geometry_pass.cpp similarity index 96% rename from library/phx/geometry_pass.cpp rename to library/phx/rendering/render_passes/geometry_pass.cpp index 81987ac6acb99103684547bb8443762ecab65aa6..ca4eef6be568b55fbbaa72b8cffc8070f04d4460 100644 --- a/library/phx/geometry_pass.cpp +++ b/library/phx/rendering/render_passes/geometry_pass.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "geometry_pass.hpp" +#include "phx/rendering/render_passes/geometry_pass.hpp" #include <algorithm> #include <iostream> @@ -33,11 +33,11 @@ #include "glm/gtc/type_ptr.hpp" #include "glm/gtx/matrix_operation.hpp" -#include "phx/logger.hpp" -#include "phx/mesh.hpp" -#include "phx/resource_utils.hpp" -#include "phx/shader_source.hpp" -#include "phx/transform.hpp" +#include "phx/core/logger.hpp" +#include "phx/rendering/components/transform.hpp" +#include "phx/resources/types/mesh.hpp" +#include "phx/resources/types/shader_source.hpp" +#include "phx/resources/resource_utils.hpp" namespace phx { @@ -224,6 +224,8 @@ void GeometryPass::Draw(const RenderingInstance& rendering_instance) { SetMaterialShaderUniforms(rendering_instance.material); glEnable(GL_DEPTH_TEST); + glPolygonMode(GL_FRONT_AND_BACK, + rendering_instance.wireframe_mode ? GL_LINE : GL_FILL); glDrawElements( GL_TRIANGLES, static_cast<GLsizei>(rendering_instance.mesh->GetIndices().size()), @@ -260,7 +262,7 @@ void GeometryPass::SetLightShaderUniforms() { for (auto it_light = light_transform_pairs_.begin(); it_light != light_transform_pairs_.end(); ++it_light) { glm::vec3 light_color(1, 1, 1); - glm::vec3 light_dir(0, 0, 1); + glm::vec3 light_dir(0, 0, -1); float light_intensity = 1.0f; if (it_light->first != nullptr && it_light->second != nullptr) { Light* light = it_light->first; diff --git a/library/phx/geometry_pass.hpp b/library/phx/rendering/render_passes/geometry_pass.hpp similarity index 85% rename from library/phx/geometry_pass.hpp rename to library/phx/rendering/render_passes/geometry_pass.hpp index 847648d73b38a52192df694081953719a5643e1b..bd2edb0c40e650bf294feac2a7834babe3c53570 100644 --- a/library/phx/geometry_pass.hpp +++ b/library/phx/rendering/render_passes/geometry_pass.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_GEOMETRY_PASS_HPP_ -#define LIBRARY_PHX_GEOMETRY_PASS_HPP_ +#ifndef LIBRARY_PHX_RENDERING_RENDER_PASSES_GEOMETRY_PASS_HPP_ +#define LIBRARY_PHX_RENDERING_RENDER_PASSES_GEOMETRY_PASS_HPP_ #include <cstddef> #include <map> @@ -36,16 +36,16 @@ SUPPRESS_WARNINGS_BEGIN #include "gl/vertex_array.hpp" SUPPRESS_WARNINGS_END +#include "phx/rendering/backend/render_target.hpp" +#include "phx/rendering/backend/shader_program.hpp" +#include "phx/rendering/components/light.hpp" +#include "phx/rendering/components/material_handle.hpp" +#include "phx/rendering/components/projection.hpp" +#include "phx/rendering/components/transform.hpp" +#include "phx/rendering/render_passes/render_pass.hpp" +#include "phx/resources/types/mesh.hpp" +#include "phx/resources/resource_manager.hpp" #include "phx/export.hpp" -#include "phx/light.hpp" -#include "phx/material_handle.hpp" -#include "phx/mesh.hpp" -#include "phx/projection.hpp" -#include "phx/render_pass.hpp" -#include "phx/render_target.hpp" -#include "phx/resource_manager.hpp" -#include "phx/shader_program.hpp" -#include "phx/transform.hpp" namespace phx { @@ -64,6 +64,7 @@ class PHOENIX_EXPORT GeometryPass : public RenderPass { Mesh* mesh = nullptr; Material* material = nullptr; Transform* transform = nullptr; + bool wireframe_mode = false; }; struct RenderOffset { std::size_t vertex_offset; @@ -139,4 +140,4 @@ SUPPRESS_WARNINGS_END } // namespace phx -#endif // LIBRARY_PHX_GEOMETRY_PASS_HPP_ +#endif // LIBRARY_PHX_RENDERING_RENDER_PASSES_GEOMETRY_PASS_HPP_ diff --git a/library/phx/render_pass.hpp b/library/phx/rendering/render_passes/render_pass.hpp similarity index 88% rename from library/phx/render_pass.hpp rename to library/phx/rendering/render_passes/render_pass.hpp index 1009afed720765d7aa1419e00f57fb2be02997ac..ed01445f7e52b95d030be7a8785a9cdf7a7126ce 100644 --- a/library/phx/render_pass.hpp +++ b/library/phx/rendering/render_passes/render_pass.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_RENDER_PASS_HPP_ -#define LIBRARY_PHX_RENDER_PASS_HPP_ +#ifndef LIBRARY_PHX_RENDERING_RENDER_PASSES_RENDER_PASS_HPP_ +#define LIBRARY_PHX_RENDERING_RENDER_PASSES_RENDER_PASS_HPP_ #include "phx/export.hpp" @@ -44,4 +44,4 @@ class PHOENIX_EXPORT RenderPass { } // namespace phx -#endif // LIBRARY_PHX_RENDER_PASS_HPP_ +#endif // LIBRARY_PHX_RENDERING_RENDER_PASSES_RENDER_PASS_HPP_ diff --git a/library/phx/rendering_system.cpp b/library/phx/rendering/rendering_system.cpp similarity index 82% rename from library/phx/rendering_system.cpp rename to library/phx/rendering/rendering_system.cpp index b403cbecc009abe26a32c6b1efd303ffcf73489c..bf4ea619bdfdc7660b2ddd95736d9c309a4061d8 100644 --- a/library/phx/rendering_system.cpp +++ b/library/phx/rendering/rendering_system.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "rendering_system.hpp" +#include "phx/rendering/rendering_system.hpp" #include <iostream> #include <memory> @@ -29,17 +29,17 @@ #include <utility> #include <vector> -#include "engine.hpp" -#include "light.hpp" -#include "logger.hpp" -#include "material_handle.hpp" -#include "mesh.hpp" -#include "mesh_handle.hpp" -#include "projection.hpp" -#include "runtime_component.hpp" -#include "scene.hpp" -#include "system.hpp" -#include "transform.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/logger.hpp" +#include "phx/core/runtime_component.hpp" +#include "phx/core/scene.hpp" +#include "phx/core/system.hpp" +#include "phx/rendering/components/light.hpp" +#include "phx/rendering/components/material_handle.hpp" +#include "phx/rendering/components/mesh_handle.hpp" +#include "phx/rendering/components/projection.hpp" +#include "phx/rendering/components/transform.hpp" +#include "phx/resources/types/mesh.hpp" #include "gl/opengl.hpp" @@ -84,8 +84,9 @@ void RenderingSystem::Update(const FrameTimer::TimeInfo&) { Material* material = nullptr; if (material_handle != nullptr) material = material_handle->GetMaterial().Get(); - rendering_instances.push_back( - {mesh_handle->GetMesh().Get(), material, transform}); + rendering_instances.push_back({mesh_handle->GetMesh().Get(), material, + transform, + mesh_handle->GetWireframeMode()}); } else if (light != nullptr) { light_transform_pairs.push_back( std::pair<Light*, Transform*>(light, transform)); diff --git a/library/phx/rendering_system.hpp b/library/phx/rendering/rendering_system.hpp similarity index 82% rename from library/phx/rendering_system.hpp rename to library/phx/rendering/rendering_system.hpp index 40da48362089f540ebadc82d309a3f3e9874041c..6d56ee71d065e304d9482dc023b099d30a87a77a 100644 --- a/library/phx/rendering_system.hpp +++ b/library/phx/rendering/rendering_system.hpp @@ -20,22 +20,22 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_RENDERING_SYSTEM_HPP_ -#define LIBRARY_PHX_RENDERING_SYSTEM_HPP_ +#ifndef LIBRARY_PHX_RENDERING_RENDERING_SYSTEM_HPP_ +#define LIBRARY_PHX_RENDERING_RENDERING_SYSTEM_HPP_ #include <memory> #include <ostream> #include <string> #include <vector> -#include "phx/display_system.hpp" -#include "phx/engine.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/scene.hpp" +#include "phx/core/system.hpp" +#include "phx/display/display_system.hpp" +#include "phx/rendering/backend/render_target.hpp" +#include "phx/rendering/render_passes/geometry_pass.hpp" +#include "phx/rendering/frame_graph.hpp" #include "phx/export.hpp" -#include "phx/frame_graph.hpp" -#include "phx/geometry_pass.hpp" -#include "phx/render_target.hpp" -#include "phx/scene.hpp" -#include "phx/system.hpp" namespace phx { @@ -70,4 +70,4 @@ class PHOENIX_EXPORT RenderingSystem : public System { } // namespace phx -#endif // LIBRARY_PHX_RENDERING_SYSTEM_HPP_ +#endif // LIBRARY_PHX_RENDERING_RENDERING_SYSTEM_HPP_ diff --git a/library/phx/assimp_model_loader.cpp b/library/phx/resources/loaders/assimp_model_loader.cpp similarity index 92% rename from library/phx/assimp_model_loader.cpp rename to library/phx/resources/loaders/assimp_model_loader.cpp index 0c079c9a011db2ca4fc2195961945f5b0c4ba7dd..97f706fc3b371c0cc233f6218c59e48c197bb0c2 100644 --- a/library/phx/assimp_model_loader.cpp +++ b/library/phx/resources/loaders/assimp_model_loader.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "assimp_model_loader.hpp" +#include "phx/resources/loaders/assimp_model_loader.hpp" #include <iostream> #include <memory> @@ -30,13 +30,13 @@ #include "assimp/Importer.hpp" // C++ importer interface #include "assimp/postprocess.h" // Post processing flags -#include "phx/image_loader.hpp" -#include "phx/logger.hpp" -#include "phx/model.hpp" -#include "phx/resource_declaration.hpp" -#include "phx/resource_manager.hpp" -#include "phx/resource_utils.hpp" +#include "phx/resources/loaders/image_loader.hpp" +#include "phx/resources/types/model.hpp" +#include "phx/resources/resource_declaration.hpp" +#include "phx/resources/resource_manager.hpp" +#include "phx/resources/resource_utils.hpp" #include "phx/resources_path.hpp" +#include "phx/core/logger.hpp" namespace phx { @@ -181,6 +181,7 @@ std::unique_ptr<phx::Mesh> AssimpModelLoader::LoadSingleMesh( resource->SetTangents(LoadTangents(mesh)); resource->SetBitangents(LoadBitangents(mesh)); resource->SetTextureCoords(LoadTextureCoords(mesh)); + resource->SetBoundingBox(ComputeBoundingBox(resource->GetVertices())); auto mesh_name = std::string(mesh->mName.C_Str()); // If an object is unnamed, assimp names it "defaultobject" @@ -314,5 +315,20 @@ bool AssimpModelLoader::AssimpProgressHandler::Update(float percentage) { return true; } +std::array<glm::vec3, 2> AssimpModelLoader::ComputeBoundingBox( + const std::vector<glm::vec3> &vertices) { + std::array<glm::vec3, 2> boundingbox = { + {glm::vec3(INFINITY), glm::vec3(-INFINITY)}}; + for (auto &vertex : vertices) { + for (int i = 0; i < 3; i++) { + if (vertex[i] < boundingbox[0][i]) { + boundingbox[0][i] = vertex[i]; + } else if (vertex[i] > boundingbox[1][i]) { + boundingbox[1][i] = vertex[i]; + } + } + } + return boundingbox; +} } // namespace phx diff --git a/library/phx/assimp_model_loader.hpp b/library/phx/resources/loaders/assimp_model_loader.hpp similarity index 88% rename from library/phx/assimp_model_loader.hpp rename to library/phx/resources/loaders/assimp_model_loader.hpp index 88426077760a81fcd6087b2ddf7a12be62f44deb..9f5abd2073008c220b8b1aea02d50a0cc2b3b5b6 100644 --- a/library/phx/assimp_model_loader.hpp +++ b/library/phx/resources/loaders/assimp_model_loader.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_ASSIMP_MODEL_LOADER_HPP_ -#define LIBRARY_PHX_ASSIMP_MODEL_LOADER_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_LOADERS_ASSIMP_MODEL_LOADER_HPP_ +#define LIBRARY_PHX_RESOURCES_LOADERS_ASSIMP_MODEL_LOADER_HPP_ #include <functional> #include <memory> @@ -39,12 +39,12 @@ SUPPRESS_WARNINGS_BEGIN SUPPRESS_WARNINGS_END #include "phx/export.hpp" -#include "phx/material.hpp" -#include "phx/mesh.hpp" -#include "phx/model.hpp" -#include "phx/resource_declaration.hpp" -#include "phx/resource_load_strategy.hpp" -#include "phx/resource_pointer.hpp" +#include "phx/resources/types/material.hpp" +#include "phx/resources/types/mesh.hpp" +#include "phx/resources/types/model.hpp" +#include "phx/resources/resource_declaration.hpp" +#include "phx/resources/resource_load_strategy.hpp" +#include "phx/resources/resource_pointer.hpp" namespace phx { @@ -103,6 +103,9 @@ class PHOENIX_EXPORT AssimpModelLoader final : public ResourceLoadStrategy { bool LoadFile(const std::string& filename); + std::array<glm::vec3, 2> ComputeBoundingBox( + const std::vector<glm::vec3>& vertices); + static const int kInvalidMaterialIndex = -1; Assimp::Importer importer_; @@ -127,4 +130,4 @@ std::vector<glm::vec3> phx::AssimpModelLoader::LoadVectorData( } // namespace phx -#endif // LIBRARY_PHX_ASSIMP_MODEL_LOADER_HPP_ +#endif // LIBRARY_PHX_RESOURCES_LOADERS_ASSIMP_MODEL_LOADER_HPP_ diff --git a/library/phx/image_loader.cpp b/library/phx/resources/loaders/image_loader.cpp similarity index 95% rename from library/phx/image_loader.cpp rename to library/phx/resources/loaders/image_loader.cpp index a28713dd9312f2e826bc760b64083ad2990b62f9..ca100f042bbdb9f8f6266745e56234d7f62f1682 100644 --- a/library/phx/image_loader.cpp +++ b/library/phx/resources/loaders/image_loader.cpp @@ -20,14 +20,14 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "phx/image_loader.hpp" +#include "phx/resources/loaders/image_loader.hpp" #include <memory> #include <string> #include <utility> -#include "phx/image.hpp" -#include "phx/logger.hpp" +#include "phx/core/logger.hpp" +#include "phx/resources/types/image.hpp" #include "phx/resources_path.hpp" namespace phx { diff --git a/library/phx/image_loader.hpp b/library/phx/resources/loaders/image_loader.hpp similarity index 87% rename from library/phx/image_loader.hpp rename to library/phx/resources/loaders/image_loader.hpp index 131a58643e471b11c4d9f5e7e9149e79af2a82a8..aaebda26146ff3e81c26ee33369a6dfe93e99961 100644 --- a/library/phx/image_loader.hpp +++ b/library/phx/resources/loaders/image_loader.hpp @@ -20,14 +20,14 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_IMAGE_LOADER_HPP_ -#define LIBRARY_PHX_IMAGE_LOADER_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_LOADERS_IMAGE_LOADER_HPP_ +#define LIBRARY_PHX_RESOURCES_LOADERS_IMAGE_LOADER_HPP_ #include <memory> #include <string> #include <vector> -#include "phx/resource_load_strategy.hpp" +#include "phx/resources/resource_load_strategy.hpp" namespace phx { class ImageLoader final : public ResourceLoadStrategy { @@ -45,4 +45,4 @@ class ImageLoader final : public ResourceLoadStrategy { }; } // namespace phx -#endif // LIBRARY_PHX_IMAGE_LOADER_HPP_ +#endif // LIBRARY_PHX_RESOURCES_LOADERS_IMAGE_LOADER_HPP_ diff --git a/library/phx/openvr_resource_loader.cpp b/library/phx/resources/loaders/openvr_resource_loader.cpp similarity index 95% rename from library/phx/openvr_resource_loader.cpp rename to library/phx/resources/loaders/openvr_resource_loader.cpp index d4aa3b4822893a9cfb6a39a764847dacfb491742..3c24d99ef7846cdd8f5e5e6e9005e0bbf055c9e5 100644 --- a/library/phx/openvr_resource_loader.cpp +++ b/library/phx/resources/loaders/openvr_resource_loader.cpp @@ -20,13 +20,13 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "openvr_resource_loader.hpp" +#include "phx/resources/loaders/openvr_resource_loader.hpp" #include <memory> #include <string> -#include "logger.hpp" -#include "material.hpp" +#include "phx/core/logger.hpp" +#include "phx/resources/types/material.hpp" namespace phx { diff --git a/library/phx/openvr_resource_loader.hpp b/library/phx/resources/loaders/openvr_resource_loader.hpp similarity index 82% rename from library/phx/openvr_resource_loader.hpp rename to library/phx/resources/loaders/openvr_resource_loader.hpp index d51e796557e2160129c94d761834f23af71edd73..357ff8ad9489e2ac269f962b8a48979d884c26d9 100644 --- a/library/phx/openvr_resource_loader.hpp +++ b/library/phx/resources/loaders/openvr_resource_loader.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_OPENVR_RESOURCE_LOADER_HPP_ -#define LIBRARY_PHX_OPENVR_RESOURCE_LOADER_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_LOADERS_OPENVR_RESOURCE_LOADER_HPP_ +#define LIBRARY_PHX_RESOURCES_LOADERS_OPENVR_RESOURCE_LOADER_HPP_ #include <memory> #include <vector> @@ -33,10 +33,10 @@ SUPPRESS_WARNINGS_BEGIN SUPPRESS_WARNINGS_END #include "phx/export.hpp" -#include "phx/hmd.hpp" -#include "phx/mesh.hpp" -#include "phx/resource_declaration.hpp" -#include "phx/resource_load_strategy.hpp" +#include "phx/display/hmd.hpp" +#include "phx/resources/types/mesh.hpp" +#include "phx/resources/resource_declaration.hpp" +#include "phx/resources/resource_load_strategy.hpp" namespace phx { class Mesh; @@ -59,4 +59,4 @@ class PHOENIX_EXPORT OpenVRResourceLoader final : public ResourceLoadStrategy { } // namespace phx -#endif // LIBRARY_PHX_OPENVR_RESOURCE_LOADER_HPP_ +#endif // LIBRARY_PHX_RESOURCES_LOADERS_OPENVR_RESOURCE_LOADER_HPP_ diff --git a/library/phx/scene_loader.cpp b/library/phx/resources/loaders/scene_loader.cpp similarity index 81% rename from library/phx/scene_loader.cpp rename to library/phx/resources/loaders/scene_loader.cpp index ef6fa6fa88ac6d8a832806836d7a310805662e05..e77a9a515972dd20efe24488d0cf22fff3f54500 100644 --- a/library/phx/scene_loader.cpp +++ b/library/phx/resources/loaders/scene_loader.cpp @@ -20,24 +20,24 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "scene_loader.hpp" +#include "phx/resources/loaders/scene_loader.hpp" #include <string> -#include "material_handle.hpp" -#include "mesh_handle.hpp" -#include "model.hpp" -#include "resource_manager.hpp" -#include "resource_utils.hpp" -#include "transform.hpp" +#include "phx/rendering/components/material_handle.hpp" +#include "phx/rendering/components/mesh_handle.hpp" +#include "phx/rendering/components/transform.hpp" +#include "phx/resources/types/model.hpp" +#include "phx/resources/resource_manager.hpp" +#include "phx/resources/resource_utils.hpp" namespace phx { -bool SceneLoader::InsertModelIntoScene(const std::string& file_name, - Scene* scene) { +phx::Entity* SceneLoader::InsertModelIntoScene(const std::string& file_name, + Scene* scene) { auto model = ResourceUtils::LoadResourceFromFile<Model>(file_name); if (model == nullptr) { - return false; + return nullptr; } auto rootEntity = scene->CreateEntity(); @@ -54,7 +54,7 @@ bool SceneLoader::InsertModelIntoScene(const std::string& file_name, } } - return true; + return rootEntity; } std::string SceneLoader::ConstructRootName(const std::string& file_name) { diff --git a/library/phx/scene_loader.hpp b/library/phx/resources/loaders/scene_loader.hpp similarity index 77% rename from library/phx/scene_loader.hpp rename to library/phx/resources/loaders/scene_loader.hpp index 204af32dde777a4e863e912f5977bd290b385b28..b96bd59fa3405755a963a6ecec9190f19f805704 100644 --- a/library/phx/scene_loader.hpp +++ b/library/phx/resources/loaders/scene_loader.hpp @@ -20,19 +20,21 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_SCENE_LOADER_HPP_ -#define LIBRARY_PHX_SCENE_LOADER_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_LOADERS_SCENE_LOADER_HPP_ +#define LIBRARY_PHX_RESOURCES_LOADERS_SCENE_LOADER_HPP_ #include <string> +#include "phx/core/scene.hpp" #include "phx/export.hpp" -#include "phx/scene.hpp" namespace phx { class PHOENIX_EXPORT SceneLoader { public: - static bool InsertModelIntoScene(const std::string& file_name, Scene* scene); + // Returns the root entity of the model + static Entity* InsertModelIntoScene(const std::string& file_name, + Scene* scene); private: static std::string ConstructRootName(const std::string& file_name); @@ -40,4 +42,4 @@ class PHOENIX_EXPORT SceneLoader { } // namespace phx -#endif // LIBRARY_PHX_SCENE_LOADER_HPP_ +#endif // LIBRARY_PHX_RESOURCES_LOADERS_SCENE_LOADER_HPP_ diff --git a/library/phx/shader_loader.cpp b/library/phx/resources/loaders/shader_loader.cpp similarity index 93% rename from library/phx/shader_loader.cpp rename to library/phx/resources/loaders/shader_loader.cpp index 01b5697cfd98149dbea819ec9c25a37c41df5c27..8e51d914968dbd351aa792a7e18442f18a8273ff 100644 --- a/library/phx/shader_loader.cpp +++ b/library/phx/resources/loaders/shader_loader.cpp @@ -20,16 +20,16 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "phx/shader_loader.hpp" +#include "phx/resources/loaders/shader_loader.hpp" #include <fstream> #include <memory> #include <string> #include <utility> -#include "phx/logger.hpp" +#include "phx/core/logger.hpp" +#include "phx/resources/types/shader_source.hpp" #include "phx/resources_path.hpp" -#include "phx/shader_source.hpp" namespace phx { diff --git a/library/phx/shader_loader.hpp b/library/phx/resources/loaders/shader_loader.hpp similarity index 85% rename from library/phx/shader_loader.hpp rename to library/phx/resources/loaders/shader_loader.hpp index 324daa8eef9dc5a65b5241ff2db6baa23a6acdcd..a23444fa3d7df4e823a3a31cd8fe9341c8ef8c96 100644 --- a/library/phx/shader_loader.hpp +++ b/library/phx/resources/loaders/shader_loader.hpp @@ -20,14 +20,14 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_SHADER_LOADER_HPP_ -#define LIBRARY_PHX_SHADER_LOADER_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_LOADERS_SHADER_LOADER_HPP_ +#define LIBRARY_PHX_RESOURCES_LOADERS_SHADER_LOADER_HPP_ #include <memory> #include <string> -#include "phx/resource_declaration.hpp" -#include "phx/resource_load_strategy.hpp" +#include "phx/resources/resource_declaration.hpp" +#include "phx/resources/resource_load_strategy.hpp" namespace phx { class ShaderLoader final : public ResourceLoadStrategy { @@ -51,4 +51,4 @@ class ShaderLoader final : public ResourceLoadStrategy { } // namespace phx -#endif // LIBRARY_PHX_SHADER_LOADER_HPP_ +#endif // LIBRARY_PHX_RESOURCES_LOADERS_SHADER_LOADER_HPP_ diff --git a/library/phx/resource.hpp b/library/phx/resources/resource.hpp similarity index 91% rename from library/phx/resource.hpp rename to library/phx/resources/resource.hpp index b3a1d9698e5e322c303d8182b3e4631838e2c069..b83eeb8e88a74570fc40f3adf447b2c0aa692685 100644 --- a/library/phx/resource.hpp +++ b/library/phx/resources/resource.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_RESOURCE_HPP_ -#define LIBRARY_PHX_RESOURCE_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_RESOURCE_HPP_ +#define LIBRARY_PHX_RESOURCES_RESOURCE_HPP_ namespace phx { /** @@ -42,4 +42,4 @@ class Resource { }; } // namespace phx -#endif // LIBRARY_PHX_RESOURCE_HPP_ +#endif // LIBRARY_PHX_RESOURCES_RESOURCE_HPP_ diff --git a/library/phx/resource_declaration.hpp b/library/phx/resources/resource_declaration.hpp similarity index 86% rename from library/phx/resource_declaration.hpp rename to library/phx/resources/resource_declaration.hpp index 570068d5727cfe64d7ad78196fa2b3acbaf44528..0a0c325617cf1640400b0509c7c71fbd17cd521d 100644 --- a/library/phx/resource_declaration.hpp +++ b/library/phx/resources/resource_declaration.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_RESOURCE_DECLARATION_HPP_ -#define LIBRARY_PHX_RESOURCE_DECLARATION_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_RESOURCE_DECLARATION_HPP_ +#define LIBRARY_PHX_RESOURCES_RESOURCE_DECLARATION_HPP_ #include "json.hpp" @@ -29,4 +29,4 @@ namespace phx { using ResourceDeclaration = nlohmann::json; } // namespace phx -#endif // LIBRARY_PHX_RESOURCE_DECLARATION_HPP_ +#endif // LIBRARY_PHX_RESOURCES_RESOURCE_DECLARATION_HPP_ diff --git a/library/phx/resource_load_strategy.hpp b/library/phx/resources/resource_load_strategy.hpp similarity index 86% rename from library/phx/resource_load_strategy.hpp rename to library/phx/resources/resource_load_strategy.hpp index 35c4f954eb8cf3f30bbb52cdeb7ffb0d40eeb067..98925b4325691b69af4de2576a81a4da86464edf 100644 --- a/library/phx/resource_load_strategy.hpp +++ b/library/phx/resources/resource_load_strategy.hpp @@ -20,13 +20,13 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_RESOURCE_LOAD_STRATEGY_HPP_ -#define LIBRARY_PHX_RESOURCE_LOAD_STRATEGY_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_RESOURCE_LOAD_STRATEGY_HPP_ +#define LIBRARY_PHX_RESOURCES_RESOURCE_LOAD_STRATEGY_HPP_ #include <memory> -#include "resource.hpp" -#include "resource_declaration.hpp" +#include "phx/resources/resource_declaration.hpp" +#include "phx/resources/resource.hpp" namespace phx { /** @@ -52,4 +52,4 @@ class ResourceLoadStrategy { }; } // namespace phx -#endif // LIBRARY_PHX_RESOURCE_LOAD_STRATEGY_HPP_ +#endif // LIBRARY_PHX_RESOURCES_RESOURCE_LOAD_STRATEGY_HPP_ diff --git a/library/phx/resource_manager.cpp b/library/phx/resources/resource_manager.cpp similarity index 90% rename from library/phx/resource_manager.cpp rename to library/phx/resources/resource_manager.cpp index 309d82f4cf22f5692029e02b5f75c1648a9772fc..938b6dd7f128ea37b08cc1566d7ea94697f9bc35 100644 --- a/library/phx/resource_manager.cpp +++ b/library/phx/resources/resource_manager.cpp @@ -19,16 +19,16 @@ // See the License for the specific language governing permissions and // limitations under the License. //------------------------------------------------------------------------------ -#include "resource_manager.hpp" +#include "phx/resources/resource_manager.hpp" #include <algorithm> #include <memory> #include <string> #include <utility> -#include "phx/assimp_model_loader.hpp" -#include "phx/image_loader.hpp" -#include "phx/shader_loader.hpp" +#include "phx/resources/loaders/assimp_model_loader.hpp" +#include "phx/resources/loaders/image_loader.hpp" +#include "phx/resources/loaders/shader_loader.hpp" namespace phx { @@ -73,6 +73,7 @@ phx::ResourceLoadStrategy *ResourceManager::GetLoaderForType( void ResourceManager::RegisterMeshResourceExtensions() { this->RegisterResourceType(".obj", std::make_unique<AssimpModelLoader>()); + this->RegisterResourceType(".stl", std::make_unique<AssimpModelLoader>()); } void ResourceManager::RegisterShaderResourceExtensions() { @@ -86,6 +87,7 @@ void ResourceManager::RegisterShaderResourceExtensions() { void ResourceManager::RegisterImageResourceExtensions() { this->RegisterResourceType(".jpg", std::make_unique<ImageLoader>()); + this->RegisterResourceType(".jpeg", std::make_unique<ImageLoader>()); this->RegisterResourceType(".png", std::make_unique<ImageLoader>()); } diff --git a/library/phx/resource_manager.hpp b/library/phx/resources/resource_manager.hpp similarity index 88% rename from library/phx/resource_manager.hpp rename to library/phx/resources/resource_manager.hpp index 1949b293fa82998e7dd7c09f73a00f1aa95d5ab7..54cf258ca1a0b8cc9eb1c0c6ded2134152216a6f 100644 --- a/library/phx/resource_manager.hpp +++ b/library/phx/resources/resource_manager.hpp @@ -20,20 +20,20 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_RESOURCE_MANAGER_HPP_ -#define LIBRARY_PHX_RESOURCE_MANAGER_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_RESOURCE_MANAGER_HPP_ +#define LIBRARY_PHX_RESOURCES_RESOURCE_MANAGER_HPP_ #include <map> #include <memory> #include <string> +#include "phx/core/logger.hpp" +#include "phx/resources/resource_declaration.hpp" +#include "phx/resources/resource_load_strategy.hpp" +#include "phx/resources/resource_pointer.hpp" +#include "phx/resources/resource_proxy.hpp" +#include "phx/utility/aspects/singleton.hpp" #include "phx/export.hpp" -#include "phx/logger.hpp" -#include "phx/resource_declaration.hpp" -#include "phx/resource_load_strategy.hpp" -#include "phx/resource_pointer.hpp" -#include "phx/resource_proxy.hpp" -#include "phx/singleton.hpp" namespace phx { /** @@ -94,4 +94,4 @@ ResourcePointer<ResourceType> phx::ResourceManager::DeclareResource( } // namespace phx -#endif // LIBRARY_PHX_RESOURCE_MANAGER_HPP_ +#endif // LIBRARY_PHX_RESOURCES_RESOURCE_MANAGER_HPP_ diff --git a/library/phx/resource_pointer.hpp b/library/phx/resources/resource_pointer.hpp similarity index 92% rename from library/phx/resource_pointer.hpp rename to library/phx/resources/resource_pointer.hpp index 4e2f0f8d9ea889d4f09ec5d60c2e18ecef8bd494..3ee0ca1f5298cf4018f7d65269f913734e194856 100644 --- a/library/phx/resource_pointer.hpp +++ b/library/phx/resources/resource_pointer.hpp @@ -20,13 +20,13 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_RESOURCE_POINTER_HPP_ -#define LIBRARY_PHX_RESOURCE_POINTER_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_RESOURCE_POINTER_HPP_ +#define LIBRARY_PHX_RESOURCES_RESOURCE_POINTER_HPP_ #include <cstddef> +#include "phx/resources/resource_proxy.hpp" #include "phx/export.hpp" -#include "resource_proxy.hpp" namespace phx { @@ -71,4 +71,4 @@ class PHOENIX_EXPORT ResourcePointer { } // namespace phx -#endif // LIBRARY_PHX_RESOURCE_POINTER_HPP_ +#endif // LIBRARY_PHX_RESOURCES_RESOURCE_POINTER_HPP_ diff --git a/library/phx/resource_proxy.cpp b/library/phx/resources/resource_proxy.cpp similarity index 94% rename from library/phx/resource_proxy.cpp rename to library/phx/resources/resource_proxy.cpp index b2908d0b56521f2c6f7026a7845e5906f3a8cac8..a2453e7906e3e08918bd4779d8ec041e2ddb3924 100644 --- a/library/phx/resource_proxy.cpp +++ b/library/phx/resources/resource_proxy.cpp @@ -20,8 +20,9 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "resource_proxy.hpp" -#include "resource_manager.hpp" +#include "phx/resources/resource_proxy.hpp" + +#include "phx/resources/resource_manager.hpp" namespace phx { diff --git a/library/phx/resource_proxy.hpp b/library/phx/resources/resource_proxy.hpp similarity index 91% rename from library/phx/resource_proxy.hpp rename to library/phx/resources/resource_proxy.hpp index abcb5b7a8bbacc7fdd1705a49042b40f51febbc3..967dfa32f4939cd393460bc07f92a1df37ece541 100644 --- a/library/phx/resource_proxy.hpp +++ b/library/phx/resources/resource_proxy.hpp @@ -20,13 +20,13 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_RESOURCE_PROXY_HPP_ -#define LIBRARY_PHX_RESOURCE_PROXY_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_RESOURCE_PROXY_HPP_ +#define LIBRARY_PHX_RESOURCES_RESOURCE_PROXY_HPP_ #include <memory> -#include "resource.hpp" -#include "resource_declaration.hpp" +#include "phx/resources/resource.hpp" +#include "phx/resources/resource_declaration.hpp" namespace phx { class ResourceManager; @@ -70,4 +70,4 @@ ResourceTargetType *phx::ResourceProxy::GetAs() const { } // namespace phx -#endif // LIBRARY_PHX_RESOURCE_PROXY_HPP_ +#endif // LIBRARY_PHX_RESOURCES_RESOURCE_PROXY_HPP_ diff --git a/library/phx/resource_utils.cpp b/library/phx/resources/resource_utils.cpp similarity index 95% rename from library/phx/resource_utils.cpp rename to library/phx/resources/resource_utils.cpp index 1e2c1995d089c4ad671e42f5f65db3fd4eb47ec8..e8e82fcb5356defa3988ae2696281f75a7054cc9 100644 --- a/library/phx/resource_utils.cpp +++ b/library/phx/resources/resource_utils.cpp @@ -19,13 +19,13 @@ // See the License for the specific language governing permissions and // limitations under the License. //------------------------------------------------------------------------------ -#include "resource_utils.hpp" +#include "phx/resources/resource_utils.hpp" #include <algorithm> #include <locale> #include <string> -#include "phx/resource_manager.hpp" +#include "phx/resources/resource_manager.hpp" #include "phx/resources_path.hpp" namespace phx { diff --git a/library/phx/resource_utils.hpp b/library/phx/resources/resource_utils.hpp similarity index 82% rename from library/phx/resource_utils.hpp rename to library/phx/resources/resource_utils.hpp index c27d46ee044641f0e3d45083f2ac8f371c5ce772..8f18bc1fa3c17ae0db1dc93a83ed4aebab8d8236 100644 --- a/library/phx/resource_utils.hpp +++ b/library/phx/resources/resource_utils.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_RESOURCE_UTILS_HPP_ -#define LIBRARY_PHX_RESOURCE_UTILS_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_RESOURCE_UTILS_HPP_ +#define LIBRARY_PHX_RESOURCES_RESOURCE_UTILS_HPP_ #include <map> #include <memory> @@ -29,13 +29,13 @@ #include "json.hpp" +#include "phx/core/logger.hpp" +#include "phx/resources/resource_declaration.hpp" +#include "phx/resources/resource_load_strategy.hpp" +#include "phx/resources/resource_manager.hpp" +#include "phx/resources/resource_pointer.hpp" +#include "phx/utility/aspects/singleton.hpp" #include "phx/export.hpp" -#include "phx/logger.hpp" -#include "phx/resource_declaration.hpp" -#include "phx/resource_load_strategy.hpp" -#include "phx/resource_manager.hpp" -#include "phx/resource_pointer.hpp" -#include "phx/singleton.hpp" namespace phx { /** @@ -63,4 +63,4 @@ class PHOENIX_EXPORT ResourceUtils final { } // namespace phx -#endif // LIBRARY_PHX_RESOURCE_UTILS_HPP_ +#endif // LIBRARY_PHX_RESOURCES_RESOURCE_UTILS_HPP_ diff --git a/library/phx/image.cpp b/library/phx/resources/types/image.cpp similarity index 99% rename from library/phx/image.cpp rename to library/phx/resources/types/image.cpp index c2af360d9c091595cc00fa883d69f94edffe8096..f4da0845b2f216c908b3172ebc1bf92c935027c9 100644 --- a/library/phx/image.cpp +++ b/library/phx/resources/types/image.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "image.hpp" +#include "phx/resources/types/image.hpp" #include <string> #include <utility> diff --git a/library/phx/image.hpp b/library/phx/resources/types/image.hpp similarity index 94% rename from library/phx/image.hpp rename to library/phx/resources/types/image.hpp index fa4593e4aea52dcd1a253a33dc133fe8027eb5c5..a5497948d3270f868eee852939ae1a27acdfe367 100644 --- a/library/phx/image.hpp +++ b/library/phx/resources/types/image.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_IMAGE_HPP_ -#define LIBRARY_PHX_IMAGE_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_TYPES_IMAGE_HPP_ +#define LIBRARY_PHX_RESOURCES_TYPES_IMAGE_HPP_ #ifdef _WIN32 #define NOMINMAX @@ -38,9 +38,9 @@ #include "FreeImage.h" +#include "phx/resources/resource.hpp" +#include "phx/utility/aspects/loggable.hpp" #include "phx/export.hpp" -#include "phx/loggable.hpp" -#include "phx/resource.hpp" namespace phx { class PHOENIX_EXPORT Image : public Resource, public Loggable { @@ -124,4 +124,4 @@ class PHOENIX_EXPORT Image : public Resource, public Loggable { }; // namespace phx } // namespace phx -#endif // LIBRARY_PHX_IMAGE_HPP_ +#endif // LIBRARY_PHX_RESOURCES_TYPES_IMAGE_HPP_ diff --git a/library/phx/material.cpp b/library/phx/resources/types/material.cpp similarity index 98% rename from library/phx/material.cpp rename to library/phx/resources/types/material.cpp index 7809e25d95ec336118961986c3837941178c4c89..f79e5d332942b63f933ddc00235cb201fe4e8d06 100644 --- a/library/phx/material.cpp +++ b/library/phx/resources/types/material.cpp @@ -20,14 +20,14 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "material.hpp" +#include "phx/resources/types/material.hpp" #include <math.h> #include <algorithm> #include <memory> #include <string> -#include "logger.hpp" +#include "phx/core/logger.hpp" namespace phx { diff --git a/library/phx/material.hpp b/library/phx/resources/types/material.hpp similarity index 90% rename from library/phx/material.hpp rename to library/phx/resources/types/material.hpp index 520bbd5adc423fb721d0ca48d6804a1a3661eaa6..557dbfc01397270ac47f926fec0be7a2d4f663ed 100644 --- a/library/phx/material.hpp +++ b/library/phx/resources/types/material.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_MATERIAL_HPP_ -#define LIBRARY_PHX_MATERIAL_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_TYPES_MATERIAL_HPP_ +#define LIBRARY_PHX_RESOURCES_TYPES_MATERIAL_HPP_ #include <memory> #include <string> @@ -35,11 +35,11 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/vec3.hpp" SUPPRESS_WARNINGS_END -#include "nameable.hpp" +#include "phx/resources/resource.hpp" +#include "phx/resources/resource_pointer.hpp" +#include "phx/resources/types/image.hpp" +#include "phx/utility/aspects/nameable.hpp" #include "phx/export.hpp" -#include "phx/image.hpp" -#include "phx/resource.hpp" -#include "phx/resource_pointer.hpp" namespace phx { @@ -102,4 +102,4 @@ class PHOENIX_EXPORT Material : public Resource, public Nameable { } // namespace phx -#endif // LIBRARY_PHX_MATERIAL_HPP_ +#endif // LIBRARY_PHX_RESOURCES_TYPES_MATERIAL_HPP_ diff --git a/library/phx/mesh.cpp b/library/phx/resources/types/mesh.cpp similarity index 69% rename from library/phx/mesh.cpp rename to library/phx/resources/types/mesh.cpp index fe06eb2fd87fdea52aad92c644abe4f1e1bf79e6..9c1e178cbf3fc86bf8ce0403a09bd173b0677384 100644 --- a/library/phx/mesh.cpp +++ b/library/phx/resources/types/mesh.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "mesh.hpp" +#include "phx/resources/types/mesh.hpp" #include <string> #include <utility> @@ -74,4 +74,30 @@ void Mesh::SetIndices(std::vector<unsigned int>&& indices) { const std::vector<unsigned int>& Mesh::GetIndices() const { return indices_; } +void Mesh::SetBoundingBox(const std::array<glm::vec3, 2>& boundingbox) { + boundingbox_ = std::move(boundingbox); +} + +const std::array<glm::vec3, 2>& Mesh::GetBoundingBox() const { + return boundingbox_; +} + +Mesh Mesh::GenerateBoundingBoxMesh() { + Mesh boundingbox; + + boundingbox.SetVertices( + {glm::vec3{boundingbox_[0][0], boundingbox_[0][1], boundingbox_[0][2]}, + glm::vec3{boundingbox_[0][0], boundingbox_[1][1], boundingbox_[0][2]}, + glm::vec3{boundingbox_[0][0], boundingbox_[0][1], boundingbox_[1][2]}, + glm::vec3{boundingbox_[0][0], boundingbox_[1][1], boundingbox_[1][2]}, + glm::vec3{boundingbox_[1][0], boundingbox_[1][1], boundingbox_[1][2]}, + glm::vec3{boundingbox_[1][0], boundingbox_[0][1], boundingbox_[0][2]}, + glm::vec3{boundingbox_[1][0], boundingbox_[1][1], boundingbox_[0][2]}, + glm::vec3{boundingbox_[1][0], boundingbox_[0][1], boundingbox_[1][2]}}); + boundingbox.SetIndices({ + 0, + }); + return boundingbox; +} + } // namespace phx diff --git a/library/phx/mesh.hpp b/library/phx/resources/types/mesh.hpp similarity index 84% rename from library/phx/mesh.hpp rename to library/phx/resources/types/mesh.hpp index 6e1e5685e7a28a16bfb4e0be22d5c1b2f432ca11..b9618fd13b5474d2d0f07034d745ade239429356 100644 --- a/library/phx/mesh.hpp +++ b/library/phx/resources/types/mesh.hpp @@ -20,9 +20,10 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_MESH_HPP_ -#define LIBRARY_PHX_MESH_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_TYPES_MESH_HPP_ +#define LIBRARY_PHX_RESOURCES_TYPES_MESH_HPP_ +#include <array> #include <string> #include <vector> @@ -32,9 +33,9 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/glm.hpp" SUPPRESS_WARNINGS_END +#include "phx/resources/resource.hpp" +#include "phx/utility/aspects/nameable.hpp" #include "phx/export.hpp" -#include "phx/nameable.hpp" -#include "phx/resource.hpp" namespace phx { @@ -70,6 +71,11 @@ class PHOENIX_EXPORT Mesh : public Resource, public Nameable { void SetIndices(std::vector<unsigned int> &&indices); const std::vector<unsigned int> &GetIndices() const; + void SetBoundingBox(const std::array<glm::vec3, 2> &boundingbox); + const std::array<glm::vec3, 2> &GetBoundingBox() const; + + Mesh GenerateBoundingBoxMesh(); + private: std::vector<glm::vec3> vertices_; std::vector<glm::vec3> normals_; @@ -77,8 +83,9 @@ class PHOENIX_EXPORT Mesh : public Resource, public Nameable { std::vector<glm::vec3> bitangents_; std::vector<glm::vec2> texture_coords_; std::vector<unsigned int> indices_; + std::array<glm::vec3, 2> boundingbox_; }; } // namespace phx -#endif // LIBRARY_PHX_MESH_HPP_ +#endif // LIBRARY_PHX_RESOURCES_TYPES_MESH_HPP_ diff --git a/library/phx/model.cpp b/library/phx/resources/types/model.cpp similarity index 95% rename from library/phx/model.cpp rename to library/phx/resources/types/model.cpp index 62e78a3a57d3d05252b139432c206bda5f884e26..e10c2c2ea5c8b2293afafd53a871c527c332debe 100644 --- a/library/phx/model.cpp +++ b/library/phx/resources/types/model.cpp @@ -20,13 +20,13 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "model.hpp" +#include "phx/resources/types/model.hpp" #include <string> #include <vector> -#include "phx/logger.hpp" -#include "phx/material.hpp" +#include "phx/core/logger.hpp" +#include "phx/resources/types/material.hpp" namespace phx { diff --git a/library/phx/model.hpp b/library/phx/resources/types/model.hpp similarity index 87% rename from library/phx/model.hpp rename to library/phx/resources/types/model.hpp index f6ce4133b1a0e0bb01a8ce057d2bb6d3119e167b..f45df4b9742fe29bfea1dcfa0bb0fa170d0faa62 100644 --- a/library/phx/model.hpp +++ b/library/phx/resources/types/model.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_MODEL_HPP_ -#define LIBRARY_PHX_MODEL_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_TYPES_MODEL_HPP_ +#define LIBRARY_PHX_RESOURCES_TYPES_MODEL_HPP_ #include <map> #include <string> @@ -33,11 +33,11 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/glm.hpp" SUPPRESS_WARNINGS_END +#include "phx/resources/types/material.hpp" +#include "phx/resources/types/mesh.hpp" +#include "phx/resources/resource.hpp" +#include "phx/resources/resource_pointer.hpp" #include "phx/export.hpp" -#include "phx/material.hpp" -#include "phx/mesh.hpp" -#include "phx/resource.hpp" -#include "phx/resource_pointer.hpp" namespace phx { @@ -73,4 +73,4 @@ class PHOENIX_EXPORT Model : public Resource { } // namespace phx -#endif // LIBRARY_PHX_MODEL_HPP_ +#endif // LIBRARY_PHX_RESOURCES_TYPES_MODEL_HPP_ diff --git a/library/phx/shader_source.cpp b/library/phx/resources/types/shader_source.cpp similarity index 96% rename from library/phx/shader_source.cpp rename to library/phx/resources/types/shader_source.cpp index ef36646791d67f6674a9ecf282fd9c44b42f78a5..c6fe488054ac8be7745a2640383caa3114cf6bb4 100644 --- a/library/phx/shader_source.cpp +++ b/library/phx/resources/types/shader_source.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "phx/shader_source.hpp" +#include "phx/resources/types/shader_source.hpp" #include <cstddef> #include <string> diff --git a/library/phx/shader_source.hpp b/library/phx/resources/types/shader_source.hpp similarity index 88% rename from library/phx/shader_source.hpp rename to library/phx/resources/types/shader_source.hpp index 0b9c0d8c8342c1a1aa598289607255482488d874..432aa87a945fa6bec17c47c8a8b39ce5e56b08c1 100644 --- a/library/phx/shader_source.hpp +++ b/library/phx/resources/types/shader_source.hpp @@ -20,14 +20,14 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_SHADER_SOURCE_HPP_ -#define LIBRARY_PHX_SHADER_SOURCE_HPP_ +#ifndef LIBRARY_PHX_RESOURCES_TYPES_SHADER_SOURCE_HPP_ +#define LIBRARY_PHX_RESOURCES_TYPES_SHADER_SOURCE_HPP_ #include <cstddef> #include <string> +#include "phx/resources/resource.hpp" #include "phx/export.hpp" -#include "phx/resource.hpp" namespace phx { class PHOENIX_EXPORT ShaderSource final : public Resource { @@ -51,4 +51,4 @@ class PHOENIX_EXPORT ShaderSource final : public Resource { }; } // namespace phx -#endif // LIBRARY_PHX_SHADER_SOURCE_HPP_ +#endif // LIBRARY_PHX_RESOURCES_TYPES_SHADER_SOURCE_HPP_ diff --git a/library/phx/behavior.cpp b/library/phx/scripting/behavior.cpp similarity index 96% rename from library/phx/behavior.cpp rename to library/phx/scripting/behavior.cpp index c5a6e2d4c079e5aaa67e5484f89daf878163ee1c..5f046b8b7c44b6c16f967ffb8c091a0eefd9fb3a 100644 --- a/library/phx/behavior.cpp +++ b/library/phx/scripting/behavior.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "behavior.hpp" +#include "phx/scripting/behavior.hpp" #include <string> diff --git a/library/phx/behavior.hpp b/library/phx/scripting/behavior.hpp similarity index 87% rename from library/phx/behavior.hpp rename to library/phx/scripting/behavior.hpp index 4ec2fa75798671f089d942c469464825e45b9f2d..5733f0579d73e6c22da478b4e9e234dbd1b95be5 100644 --- a/library/phx/behavior.hpp +++ b/library/phx/scripting/behavior.hpp @@ -20,14 +20,14 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_BEHAVIOR_HPP_ -#define LIBRARY_PHX_BEHAVIOR_HPP_ +#ifndef LIBRARY_PHX_SCRIPTING_BEHAVIOR_HPP_ +#define LIBRARY_PHX_SCRIPTING_BEHAVIOR_HPP_ #include <string> -#include "phx/component.hpp" +#include "phx/core/component.hpp" +#include "phx/core/frame_timer.hpp" #include "phx/export.hpp" -#include "phx/frame_timer.hpp" namespace phx { @@ -52,4 +52,4 @@ class PHOENIX_EXPORT Behavior : public Component { } // namespace phx -#endif // LIBRARY_PHX_BEHAVIOR_HPP_ +#endif // LIBRARY_PHX_SCRIPTING_BEHAVIOR_HPP_ diff --git a/library/phx/behavior_system.cpp b/library/phx/scripting/behavior_system.cpp similarity index 90% rename from library/phx/behavior_system.cpp rename to library/phx/scripting/behavior_system.cpp index de26fa1794bfeeead8d2dce7e86ebe2bed663759..234e0d47405b988ac3b60950bb86e3ab8f0eaaab 100644 --- a/library/phx/behavior_system.cpp +++ b/library/phx/scripting/behavior_system.cpp @@ -20,12 +20,11 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "behavior_system.hpp" +#include "phx/scripting/behavior_system.hpp" -#include "phx/engine.hpp" -#include "phx/scene.hpp" - -#include "behavior.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/scene.hpp" +#include "phx/scripting/behavior.hpp" namespace phx { BehaviorSystem::BehaviorSystem(Engine* engine) : System(engine) {} diff --git a/library/phx/behavior_system.hpp b/library/phx/scripting/behavior_system.hpp similarity index 88% rename from library/phx/behavior_system.hpp rename to library/phx/scripting/behavior_system.hpp index 54819db82d4d95d4dced1ca240d87812936424db..5513e828fc5cf1e59db20b0beabc5d914b4a4fc3 100644 --- a/library/phx/behavior_system.hpp +++ b/library/phx/scripting/behavior_system.hpp @@ -20,14 +20,14 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_BEHAVIOR_SYSTEM_HPP_ -#define LIBRARY_PHX_BEHAVIOR_SYSTEM_HPP_ +#ifndef LIBRARY_PHX_SCRIPTING_BEHAVIOR_SYSTEM_HPP_ +#define LIBRARY_PHX_SCRIPTING_BEHAVIOR_SYSTEM_HPP_ #include "phx/suppress_warnings.hpp" -#include "phx/engine.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/system.hpp" #include "phx/export.hpp" -#include "phx/system.hpp" namespace phx { @@ -54,4 +54,4 @@ SUPPRESS_WARNINGS_END } // namespace phx -#endif // LIBRARY_PHX_BEHAVIOR_SYSTEM_HPP_ +#endif // LIBRARY_PHX_SCRIPTING_BEHAVIOR_SYSTEM_HPP_ diff --git a/library/phx/setup.cpp b/library/phx/setup.cpp index 0d5ff27d4693e93541dc5380ecff61f6da41fe47..0c0a862450954383f9621a8cc40f27a5473e5449 100644 --- a/library/phx/setup.cpp +++ b/library/phx/setup.cpp @@ -27,27 +27,27 @@ #include <string> #include <utility> -#include "behavior_system.hpp" -#include "blit_pass.hpp" -#include "clear_pass.hpp" -#include "component.hpp" -#include "display_system_openvr.hpp" -#include "display_system_window.hpp" -#include "engine.hpp" -#include "hmd.hpp" -#include "input_system.hpp" -#include "logger.hpp" -#include "openvr_controller_system.hpp" -#include "render_target.hpp" -#include "rendering_system.hpp" -#include "runtime_component.hpp" -#include "scene.hpp" -#include "tracking_system_openvr.hpp" +#include "phx/core/component.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/logger.hpp" +#include "phx/core/runtime_component.hpp" +#include "phx/core/scene.hpp" +#include "phx/display/display_system_openvr.hpp" +#include "phx/display/display_system_window.hpp" +#include "phx/display/hmd.hpp" +#include "phx/input/input_system.hpp" +#include "phx/input/openvr_controller_system.hpp" +#include "phx/rendering/backend/render_target.hpp" +#include "phx/rendering/render_passes/blit_pass.hpp" +#include "phx/rendering/render_passes/clear_pass.hpp" +#include "phx/rendering/rendering_system.hpp" +#include "phx/scripting/behavior_system.hpp" +#include "phx/tracking/tracking_system_openvr.hpp" #undef CreateWindow namespace phx { -std::unique_ptr<Engine> Setup::CreateDefaultEngine() { +std::unique_ptr<Engine> Setup::CreateDefaultEngine(bool use_hmd_if_available) { auto engine = std::make_unique<Engine>(); auto engine_ptr = engine.get(); engine->SetScene(std::make_shared<Scene>()); @@ -60,7 +60,7 @@ std::unique_ptr<Engine> Setup::CreateDefaultEngine() { DisplaySystemOpenVR* displaysys_hmd = nullptr; bool using_hmd = false; - if (HMD::IsHMDPresent()) { + if (HMD::IsHMDPresent() && use_hmd_if_available) { info("An HMD is present so we use it"); using_hmd = true; @@ -95,15 +95,8 @@ std::unique_ptr<Engine> Setup::CreateDefaultEngine() { engine->MoveSystemAfter(behavior_system, tracking_system); engine->MoveSystemAfter(controller_system, tracking_system); } else { - // TODO(@ALL): This should not be done here. - Entity* platform = - engine->GetScene() - ->GetEntitiesWithComponents<RuntimeComponent<USER_PLATFORM>>()[0]; - Entity* camera = engine->GetScene()->CreateEntity(); - camera->AddComponent<Transform>()->SetParent( - platform->GetFirstComponent<Transform>()); - camera->AddComponent<Projection>(); - camera->AddComponent<RenderTarget>(window_size); + displaysys_window->CreateRenderTarget(engine->GetScene().get(), 68.0f, + 0.01f, 1000.0f); SetupDefaultFrameGraphWindow(rendering_system, engine.get()); } diff --git a/library/phx/setup.hpp b/library/phx/setup.hpp index ee37cf4cf9b4712479652c1d5aa2716bf5b29343..6d197c26a60051776db2617c1b8dd1446f32914a 100644 --- a/library/phx/setup.hpp +++ b/library/phx/setup.hpp @@ -25,12 +25,12 @@ #include <memory> -#include "phx/engine.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/scene.hpp" +#include "phx/display/window.hpp" +#include "phx/rendering/frame_graph.hpp" +#include "phx/rendering/rendering_system.hpp" #include "phx/export.hpp" -#include "phx/frame_graph.hpp" -#include "phx/rendering_system.hpp" -#include "phx/scene.hpp" -#include "phx/window.hpp" namespace phx { @@ -41,7 +41,8 @@ class PHOENIX_EXPORT Setup { // sets up the engine with the most default setup // i.e.: RenderingSystem and an InputSystem // also creates an empty scene for the engine - static std::unique_ptr<Engine> CreateDefaultEngine(); + static std::unique_ptr<Engine> CreateDefaultEngine( + bool use_hmd_if_available = true); static void SetupDefaultFrameGraphWindow(RenderingSystem* rendering_system, Engine* engine); diff --git a/library/phx/tracking_system_openvr.cpp b/library/phx/tracking/tracking_system_openvr.cpp similarity index 94% rename from library/phx/tracking_system_openvr.cpp rename to library/phx/tracking/tracking_system_openvr.cpp index e78c6ebade0c9b4dec3453b79a37ac0bb8da64a1..e101095e0ff421af0d03b59666e79bc2684abb70 100644 --- a/library/phx/tracking_system_openvr.cpp +++ b/library/phx/tracking/tracking_system_openvr.cpp @@ -20,17 +20,17 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "tracking_system_openvr.hpp" +#include "phx/tracking/tracking_system_openvr.hpp" #include <memory> #include <string> -#include "display_system_openvr.hpp" -#include "hmd.hpp" -#include "logger.hpp" -#include "projection.hpp" -#include "runtime_component.hpp" -#include "transform.hpp" +#include "phx/core/logger.hpp" +#include "phx/core/runtime_component.hpp" +#include "phx/display/display_system_openvr.hpp" +#include "phx/display/hmd.hpp" +#include "phx/rendering/components/projection.hpp" +#include "phx/rendering/components/transform.hpp" namespace phx { diff --git a/library/phx/tracking_system_openvr.hpp b/library/phx/tracking/tracking_system_openvr.hpp similarity index 89% rename from library/phx/tracking_system_openvr.hpp rename to library/phx/tracking/tracking_system_openvr.hpp index 9c1498555367f468a097c6b42cc437aff2577b74..ad35174c67e3bc5199e575e4dcff6ba65c9be1fb 100644 --- a/library/phx/tracking_system_openvr.hpp +++ b/library/phx/tracking/tracking_system_openvr.hpp @@ -20,18 +20,18 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_TRACKING_SYSTEM_OPENVR_HPP_ -#define LIBRARY_PHX_TRACKING_SYSTEM_OPENVR_HPP_ +#ifndef LIBRARY_PHX_TRACKING_TRACKING_SYSTEM_OPENVR_HPP_ +#define LIBRARY_PHX_TRACKING_TRACKING_SYSTEM_OPENVR_HPP_ #include <memory> #include <string> #include "phx/suppress_warnings.hpp" -#include "phx/display_system_openvr.hpp" -#include "phx/engine.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/system.hpp" +#include "phx/display/display_system_openvr.hpp" #include "phx/export.hpp" -#include "phx/system.hpp" SUPPRESS_WARNINGS_BEGIN #define BOOST_BIND_NO_PLACEHOLDERS @@ -77,4 +77,4 @@ class PHOENIX_EXPORT TrackingSystemOpenVR : public System { } // namespace phx -#endif // LIBRARY_PHX_TRACKING_SYSTEM_OPENVR_HPP_ +#endif // LIBRARY_PHX_TRACKING_TRACKING_SYSTEM_OPENVR_HPP_ diff --git a/library/phx/hierarchical.hpp b/library/phx/utility/aspects/hierarchical.hpp similarity index 94% rename from library/phx/hierarchical.hpp rename to library/phx/utility/aspects/hierarchical.hpp index f12ecfc5a80770bbed87f5e02a12bca6926b0168..45dd77d166b3908678d4e8e22ceb3ba00050bcb0 100644 --- a/library/phx/hierarchical.hpp +++ b/library/phx/utility/aspects/hierarchical.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_HIERARCHICAL_HPP_ -#define LIBRARY_PHX_HIERARCHICAL_HPP_ +#ifndef LIBRARY_PHX_UTILITY_ASPECTS_HIERARCHICAL_HPP_ +#define LIBRARY_PHX_UTILITY_ASPECTS_HIERARCHICAL_HPP_ #include <algorithm> #include <cstddef> @@ -87,4 +87,4 @@ class PHOENIX_EXPORT Hierarchical { } // namespace phx -#endif // LIBRARY_PHX_HIERARCHICAL_HPP_ +#endif // LIBRARY_PHX_UTILITY_ASPECTS_HIERARCHICAL_HPP_ diff --git a/library/phx/loggable.hpp b/library/phx/utility/aspects/loggable.hpp similarity index 91% rename from library/phx/loggable.hpp rename to library/phx/utility/aspects/loggable.hpp index f6c21e4466c6158f92e0c48d078a60fb2366fb49..2bfd5060aa6365abed3f827ec18beab9193892f8 100644 --- a/library/phx/loggable.hpp +++ b/library/phx/utility/aspects/loggable.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_LOGGABLE_HPP_ -#define LIBRARY_PHX_LOGGABLE_HPP_ +#ifndef LIBRARY_PHX_UTILITY_ASPECTS_LOGGABLE_HPP_ +#define LIBRARY_PHX_UTILITY_ASPECTS_LOGGABLE_HPP_ #include <ostream> #include <string> @@ -56,4 +56,4 @@ T& PHOENIX_EXPORT operator<<(T& out, const Loggable& loggable) { } // namespace phx -#endif // LIBRARY_PHX_LOGGABLE_HPP_ +#endif // LIBRARY_PHX_UTILITY_ASPECTS_LOGGABLE_HPP_ diff --git a/library/phx/nameable.hpp b/library/phx/utility/aspects/nameable.hpp similarity index 91% rename from library/phx/nameable.hpp rename to library/phx/utility/aspects/nameable.hpp index dc27b6f6de800cdf4b2e4e14cad4af90603b4cf8..53b110ccded8d17aa88c8eee5092ea3690f38612 100644 --- a/library/phx/nameable.hpp +++ b/library/phx/utility/aspects/nameable.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_NAMEABLE_HPP_ -#define LIBRARY_PHX_NAMEABLE_HPP_ +#ifndef LIBRARY_PHX_UTILITY_ASPECTS_NAMEABLE_HPP_ +#define LIBRARY_PHX_UTILITY_ASPECTS_NAMEABLE_HPP_ #include <string> @@ -50,4 +50,4 @@ class PHOENIX_EXPORT Nameable { } // namespace phx -#endif // LIBRARY_PHX_NAMEABLE_HPP_ +#endif // LIBRARY_PHX_UTILITY_ASPECTS_NAMEABLE_HPP_ diff --git a/library/phx/singleton.hpp b/library/phx/utility/aspects/singleton.hpp similarity index 92% rename from library/phx/singleton.hpp rename to library/phx/utility/aspects/singleton.hpp index 73fddef37be3d30202a44b280b29abf25161b545..c2e70bfddd7ccea3cd276d118e924152d6e57659 100644 --- a/library/phx/singleton.hpp +++ b/library/phx/utility/aspects/singleton.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_SINGLETON_HPP_ -#define LIBRARY_PHX_SINGLETON_HPP_ +#ifndef LIBRARY_PHX_UTILITY_ASPECTS_SINGLETON_HPP_ +#define LIBRARY_PHX_UTILITY_ASPECTS_SINGLETON_HPP_ #include <memory> #include <mutex> @@ -63,4 +63,4 @@ template <class type> std::unique_ptr<type> singleton<type>::instance_ = nullptr; } // namespace phx -#endif // LIBRARY_PHX_SINGLETON_HPP_ +#endif // LIBRARY_PHX_UTILITY_ASPECTS_SINGLETON_HPP_ diff --git a/library/phx/orderable_list.hpp b/library/phx/utility/orderable_list.hpp similarity index 96% rename from library/phx/orderable_list.hpp rename to library/phx/utility/orderable_list.hpp index a9f50f36c48863528d1a72301b7146a730ccc3f4..20965c02a5859aee301e79ab224df355f399ba86 100644 --- a/library/phx/orderable_list.hpp +++ b/library/phx/utility/orderable_list.hpp @@ -20,15 +20,15 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_ORDERABLE_LIST_HPP_ -#define LIBRARY_PHX_ORDERABLE_LIST_HPP_ +#ifndef LIBRARY_PHX_UTILITY_ORDERABLE_LIST_HPP_ +#define LIBRARY_PHX_UTILITY_ORDERABLE_LIST_HPP_ #include <memory> #include <utility> #include <vector> +#include "phx/core/logger.hpp" #include "phx/export.hpp" -#include "phx/logger.hpp" namespace phx { @@ -132,4 +132,4 @@ void phx::OrderableList<ElementType>::MoveRelativeTo(ElementType* element, } // namespace phx -#endif // LIBRARY_PHX_ORDERABLE_LIST_HPP_ +#endif // LIBRARY_PHX_UTILITY_ORDERABLE_LIST_HPP_ diff --git a/library/phx/stream_helpers.cpp b/library/phx/utility/stream_helpers.cpp similarity index 98% rename from library/phx/stream_helpers.cpp rename to library/phx/utility/stream_helpers.cpp index 1ca8820eb960d4386816c8d1cdeda28da3f9dff1..e903b3fbd5ba71b07a1447caa24165dceda1e9c7 100644 --- a/library/phx/stream_helpers.cpp +++ b/library/phx/utility/stream_helpers.cpp @@ -20,7 +20,7 @@ // limitations under the License. //------------------------------------------------------------------------------ -#include "stream_helpers.hpp" +#include "phx/utility/stream_helpers.hpp" namespace glm { PhxStreamSettings::PhxStreamSettings(std::ostream& stream) : stream_(stream) { diff --git a/library/phx/stream_helpers.hpp b/library/phx/utility/stream_helpers.hpp similarity index 94% rename from library/phx/stream_helpers.hpp rename to library/phx/utility/stream_helpers.hpp index 0c924d2681858e4e67747a3ef69391200aefd71e..c464887c49b75208f9433a0181e50e5b2e4046db 100644 --- a/library/phx/stream_helpers.hpp +++ b/library/phx/utility/stream_helpers.hpp @@ -20,8 +20,8 @@ // limitations under the License. //------------------------------------------------------------------------------ -#ifndef LIBRARY_PHX_STREAM_HELPERS_HPP_ -#define LIBRARY_PHX_STREAM_HELPERS_HPP_ +#ifndef LIBRARY_PHX_UTILITY_STREAM_HELPERS_HPP_ +#define LIBRARY_PHX_UTILITY_STREAM_HELPERS_HPP_ #include <ostream> @@ -75,4 +75,4 @@ PHOENIX_EXPORT std::ostream& operator<<(std::ostream& out, const glm::mat4& mat); } // namespace glm -#endif // LIBRARY_PHX_STREAM_HELPERS_HPP_ +#endif // LIBRARY_PHX_UTILITY_STREAM_HELPERS_HPP_ diff --git a/resources/models/combustion/data_box.stl b/resources/models/combustion/data_box.stl new file mode 100644 index 0000000000000000000000000000000000000000..cecb4d3c9ac945568bb84b8bbc2e82b000e12915 --- /dev/null +++ b/resources/models/combustion/data_box.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a2663aab1d005c25da49372e639c39c44e9ba76adf4e60659554950e77cc7b82 +size 684 diff --git a/resources/models/combustion/floor.stl b/resources/models/combustion/floor.stl new file mode 100644 index 0000000000000000000000000000000000000000..adae63f30d474b33737634bec7fa90b8b3526455 --- /dev/null +++ b/resources/models/combustion/floor.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e91b4c4ce14156b1addc49f1ec4fab6a5d80ef81c7b8ff0a30845ff5d8ffb6d9 +size 184 diff --git a/resources/models/combustion/mixing_layer_0.2_lowres.stl b/resources/models/combustion/mixing_layer_0.2_lowres.stl new file mode 100644 index 0000000000000000000000000000000000000000..0400ed8b78fc9b3a0475f9a0e768a737077cf2ba --- /dev/null +++ b/resources/models/combustion/mixing_layer_0.2_lowres.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef36f673ae0c59610e49354ade67213d5d6f65e4cd2088b40f8c135deb48b665 +size 2341784 diff --git a/resources/models/combustion/mixture_surface_0.2_lower.stl b/resources/models/combustion/mixture_surface_0.2_lower.stl new file mode 100644 index 0000000000000000000000000000000000000000..cc44d3c0d984cc47ebf30ab6b74eedd2cfc9cfce --- /dev/null +++ b/resources/models/combustion/mixture_surface_0.2_lower.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:82c2429ef75c4b1404aad374fd8214cdb61271e50e5c03a0563919e41df87b97 +size 76440084 diff --git a/resources/models/combustion/mixture_surface_0.2_upper.stl b/resources/models/combustion/mixture_surface_0.2_upper.stl new file mode 100644 index 0000000000000000000000000000000000000000..86e6033a340cdc5c8a86bf0a26c1652ad75d7e73 --- /dev/null +++ b/resources/models/combustion/mixture_surface_0.2_upper.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2037d5c39fc649f7c20227443cfaa3121371da7ca73ebecd42b8b7aac589c1a9 +size 78831184 diff --git a/resources/models/cube/cube.obj b/resources/models/cube/cube.obj new file mode 100644 index 0000000000000000000000000000000000000000..f42e55fa1448bf2aae3d3b75f5e4b35f9d2b4bad --- /dev/null +++ b/resources/models/cube/cube.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bfcd76533c150be3296b9531272fbd08b94bfa4c8694958341f9ca960fc73bc3 +size 798 diff --git a/resources/models/cube/cube2.obj b/resources/models/cube/cube2.obj new file mode 100644 index 0000000000000000000000000000000000000000..22784b153af7bda1fecabe0aaae386ee30d612af --- /dev/null +++ b/resources/models/cube/cube2.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:923b22927d08fe145f02179d4451d760677891c803bfb2ede53625abcc993623 +size 800 diff --git a/resources/models/cube/default.mtl b/resources/models/cube/default.mtl new file mode 100644 index 0000000000000000000000000000000000000000..ae8d5ab15ccb6de82245eb8b4bc12efa2bd4f2c2 --- /dev/null +++ b/resources/models/cube/default.mtl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0e26b79fdba701da25a1d3d93fc32733422ece98f3b8c3a03ca82cfca4ee3e5c +size 277 diff --git a/resources/models/cube/default.png b/resources/models/cube/default.png new file mode 100644 index 0000000000000000000000000000000000000000..a4e844b7c3450b0dcfd66eea23d2a290c64eb6b7 --- /dev/null +++ b/resources/models/cube/default.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c18791857b0674ba8e19ce2446c29659bd263cd26947f5d37605ad69a41de4d1 +size 3073 diff --git a/resources/models/cube/default2.mtl b/resources/models/cube/default2.mtl new file mode 100644 index 0000000000000000000000000000000000000000..e3a059caef93eea36c95b2b6572dbe090700313f --- /dev/null +++ b/resources/models/cube/default2.mtl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ee2d873be68c67c1792ead16ed799dce477aa33fe68b0693a152e34182794c6 +size 279 diff --git a/resources/models/cube/default2.png b/resources/models/cube/default2.png new file mode 100644 index 0000000000000000000000000000000000000000..a4e844b7c3450b0dcfd66eea23d2a290c64eb6b7 --- /dev/null +++ b/resources/models/cube/default2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c18791857b0674ba8e19ce2446c29659bd263cd26947f5d37605ad69a41de4d1 +size 3073 diff --git a/tests/reference_images/model_loading_default_cam_light.png b/tests/reference_images/model_loading_default_cam_light.png index e77344cecd38c045febc795da3db46c43be98912..11880ed51413623f53d45f6395e6ffb1d1fcdf06 100644 --- a/tests/reference_images/model_loading_default_cam_light.png +++ b/tests/reference_images/model_loading_default_cam_light.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:185d5ab0ffb00ebb0d3c17857f7e39057484944fb52d6019aa5e3e8d3541fe3e -size 8970 +oid sha256:84c18304fc64916ad7bbab6ebcf7bf733d1a323f237f0873296fbf311cdd729f +size 58698 diff --git a/tests/src/integration_test_hmd.cpp b/tests/src/integration_test_hmd.cpp index 9a71c4ec06ce21fbb2c41cf1bbd034a4eda12b0b..7babf1ca229f2eb11ea665b3b9ce7ba0b4e2c82d 100644 --- a/tests/src/integration_test_hmd.cpp +++ b/tests/src/integration_test_hmd.cpp @@ -29,14 +29,14 @@ #include "phx/suppress_warnings.hpp" -#include "phx/engine.hpp" -#include "phx/light.hpp" -#include "phx/opengl_image_buffer_data.hpp" -#include "phx/resource_utils.hpp" -#include "phx/runtime_component.hpp" -#include "phx/scene_loader.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/runtime_component.hpp" +#include "phx/rendering/backend/opengl_image_buffer_data.hpp" +#include "phx/rendering/components/light.hpp" +#include "phx/rendering/components/transform.hpp" +#include "phx/resources/loaders/scene_loader.hpp" +#include "phx/resources/resource_utils.hpp" #include "phx/setup.hpp" -#include "phx/transform.hpp" SUPPRESS_WARNINGS_BEGIN #include "mocks/openvr_mock.hpp" diff --git a/tests/src/integration_test_model_rendering.cpp b/tests/src/integration_test_model_rendering.cpp index 4b9416dad1fbd4ac028b01a2c67ece54298a56c7..729b5fc573b4f15c65d316a35ddfa63b460fc17c 100644 --- a/tests/src/integration_test_model_rendering.cpp +++ b/tests/src/integration_test_model_rendering.cpp @@ -27,19 +27,19 @@ #include "phx/suppress_warnings.hpp" -#include "phx/assimp_model_loader.hpp" -#include "phx/display_system_window.hpp" -#include "phx/frame_timer.hpp" -#include "phx/mesh.hpp" -#include "phx/mesh_handle.hpp" -#include "phx/opengl_image_buffer_data.hpp" -#include "phx/rendering_system.hpp" -#include "phx/resource_declaration.hpp" -#include "phx/resource_manager.hpp" -#include "phx/resource_utils.hpp" -#include "phx/scene.hpp" +#include "phx/resources/loaders/assimp_model_loader.hpp" +#include "phx/display/display_system_window.hpp" +#include "phx/display/window.hpp" +#include "phx/core/frame_timer.hpp" +#include "phx/rendering/backend/opengl_image_buffer_data.hpp" +#include "phx/rendering/components/mesh_handle.hpp" +#include "phx/rendering/rendering_system.hpp" +#include "phx/resources/types/mesh.hpp" +#include "phx/resources/resource_declaration.hpp" +#include "phx/resources/resource_manager.hpp" +#include "phx/resources/resource_utils.hpp" +#include "phx/core/scene.hpp" #include "phx/setup.hpp" -#include "phx/window.hpp" #include "test_utilities/opengl_buffer_data_comparison.hpp" @@ -51,9 +51,7 @@ SUPPRESS_WARNINGS_END extern template struct trompeloeil::reporter<trompeloeil::specialized>; -#if defined __clang__ -#pragma clang diagnostic ignored "-Wmissing-prototypes" -#endif +SUPPRESS_WARNINGS_BEGIN_MISSING_DECLARATIONS phx::Entity* LoadBunny(glm::vec3 pos, float angleDeg, const std::string& material_name, phx::Scene* scene) { @@ -159,3 +157,5 @@ SCENARIO( } } } + +SUPPRESS_WARNINGS_END diff --git a/tests/src/integration_test_opengl_buffer_data_download.cpp b/tests/src/integration_test_opengl_buffer_data_download.cpp index 7b9e2c2707f673f8ad166cc2280783908edd9466..459f99ba1b3fc4785de28aaf5e70ce816e3a9bd6 100644 --- a/tests/src/integration_test_opengl_buffer_data_download.cpp +++ b/tests/src/integration_test_opengl_buffer_data_download.cpp @@ -29,18 +29,18 @@ #include "phx/suppress_warnings.hpp" -#include "phx/engine.hpp" -#include "phx/entity.hpp" -#include "phx/mesh.hpp" -#include "phx/mesh_handle.hpp" -#include "phx/opengl_image_buffer_data.hpp" -#include "phx/rendering_system.hpp" -#include "phx/resource_declaration.hpp" -#include "phx/resource_manager.hpp" -#include "phx/resource_pointer.hpp" -#include "phx/scene.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/entity.hpp" +#include "phx/core/scene.hpp" +#include "phx/display/window.hpp" +#include "phx/rendering/backend/opengl_image_buffer_data.hpp" +#include "phx/rendering/components/mesh_handle.hpp" +#include "phx/rendering/rendering_system.hpp" +#include "phx/resources/resource_declaration.hpp" +#include "phx/resources/resource_manager.hpp" +#include "phx/resources/resource_pointer.hpp" +#include "phx/resources/types/mesh.hpp" #include "phx/setup.hpp" -#include "phx/window.hpp" SUPPRESS_WARNINGS_BEGIN #include "mocks/openvr_mock.hpp" @@ -105,7 +105,7 @@ class SceneSetupSimple { material_handle->SetMaterial(material); std::vector<glm::vec3> vertices = { - {-1.0f, -1.0f, 0.5f}, {1.0f, -1.0f, 0.5f}, {1.0f, 1.0f, 0.5f}}; + {-4.0f, -3.0f, -0.05f}, {4.0f, -3.0f, -0.05f}, {4.0f, 3.0f, -0.05f}}; std::vector<glm::vec3> normals = { {0.f, 0.f, 1.f}, {0.f, 0.f, 1.f}, {0.f, 0.f, 1.f}}; std::vector<unsigned int> indices = {0u, 1u, 2u}; @@ -245,8 +245,9 @@ SCENARIO("OpenGLImageBufferData can download pixels from the frame buffer", phx::OpenGLImageBufferData<phx::OpenGLImageBufferDataType_Float32> buffer( 1024, 768); buffer.ReadDepthPixels(true); + THEN( - "The lower right half of the image is at depth 0.75, the other half " + "The lower right half of the image is at depth 0.8, the other half " "is at 1.0") { phx::OpenGLImageBufferData<phx::OpenGLImageBufferDataType_Float32> triangleBuffer(1024, 768); @@ -257,7 +258,7 @@ SCENARIO("OpenGLImageBufferData can download pixels from the frame buffer", static_cast<float>(x) / 1024.f > static_cast<float>(y) / 768.f; if (lower_right_half) { triangleBuffer.SetPixel( - x, y, phx::OpenGLImageBufferDataType_Float32(0.75f)); + x, y, phx::OpenGLImageBufferDataType_Float32(0.8f)); } else { triangleBuffer.SetPixel( x, y, phx::OpenGLImageBufferDataType_Float32(1.f)); diff --git a/tests/src/integration_test_rendering.cpp b/tests/src/integration_test_rendering.cpp index fae6373d2b335894e644afe32725def618896dbb..0d23dbd4216219d241ce3bc04aa5ebfd669e6d2d 100644 --- a/tests/src/integration_test_rendering.cpp +++ b/tests/src/integration_test_rendering.cpp @@ -28,16 +28,16 @@ #include "phx/suppress_warnings.hpp" -#include "phx/display_system_window.hpp" -#include "phx/frame_timer.hpp" -#include "phx/mesh.hpp" -#include "phx/mesh_handle.hpp" -#include "phx/opengl_image_buffer_data.hpp" -#include "phx/rendering_system.hpp" -#include "phx/resource_manager.hpp" -#include "phx/scene.hpp" +#include "phx/core/frame_timer.hpp" +#include "phx/core/scene.hpp" +#include "phx/display/display_system_window.hpp" +#include "phx/display/window.hpp" +#include "phx/rendering/backend/opengl_image_buffer_data.hpp" +#include "phx/rendering/components/mesh_handle.hpp" +#include "phx/rendering/rendering_system.hpp" +#include "phx/resources/types/mesh.hpp" +#include "phx/resources/resource_manager.hpp" #include "phx/setup.hpp" -#include "phx/window.hpp" SUPPRESS_WARNINGS_BEGIN #include "mocks/openvr_mock.hpp" @@ -51,9 +51,7 @@ SUPPRESS_WARNINGS_END extern template struct trompeloeil::reporter<trompeloeil::specialized>; -#if defined __clang__ -#pragma clang diagnostic ignored "-Wmissing-prototypes" -#endif +SUPPRESS_WARNINGS_BEGIN_MISSING_DECLARATIONS void SetupLightAndCamera(phx::Scene* scene) { phx::Entity* main_light = scene->CreateEntity(); @@ -95,6 +93,8 @@ void CreateTestTriangleComponent(phx::Entity* triangle) { mesh_handle->SetMesh(mesh); } +SUPPRESS_WARNINGS_END + SCENARIO("We can render a simple triangle", "[phx][phx::Rendering]") { ALLOW_CALL(openvr_mock.Get(), VR_IsHmdPresent()).RETURN(false); GIVEN("A complete triangle") { diff --git a/tests/src/mocks/generation/Create_openGL_mock.py b/tests/src/mocks/generation/Create_openGL_mock.py index e113d9005ca04a02224e258bb5c6c71d5497de26..d89dc8cec1962420138a7fea82bc3e46f9540cfc 100644 --- a/tests/src/mocks/generation/Create_openGL_mock.py +++ b/tests/src/mocks/generation/Create_openGL_mock.py @@ -62,7 +62,7 @@ functions_to_mock =['glClear', 'glEnable', 'glClearColor', 'glCreateProgram', 'g '__glewGetVertexArrayIndexediv', '__glewGetVertexArrayiv', '__glewVertexArrayAttribBinding', '__glewVertexArrayAttribIFormat', '__glewVertexArrayAttribLFormat', '__glewVertexArrayBindingDivisor', '__glewDeleteVertexArrays', 'glBindTexture', 'glDeleteTextures', '__glewCreateTextures', '__glewNamedFramebufferTexture', '__glewTextureStorage2D', '__glewBindFramebuffer', 'glIsTexture', '__glewGetTextureHandleARB', '__glewGenerateTextureMipmap', '__glewTextureParameteri', '__glewTextureSubImage2D', - '__glewBindBufferBase', '__glewBindBuffer', '__glewBindBufferRange', '__glewCreateShaderProgramv', 'glDepthRange', '__glewDepthRangef', '__glewDepthRangeIndexed', '__glewViewportIndexedf'] + '__glewBindBufferBase', '__glewBindBuffer', '__glewBindBufferRange', '__glewCreateShaderProgramv', 'glDepthRange', '__glewDepthRangef', '__glewDepthRangeIndexed', '__glewViewportIndexedf', 'glPolygonMode'] #allow calls you want to provide and not be auto generated allow_calls_provided = ['ALLOW_CALL(open_gl_mock, glewInit()).RETURN(GLEW_OK);', diff --git a/tests/src/mocks/generation/opengl_mock_template.cpp b/tests/src/mocks/generation/opengl_mock_template.cpp index 909308da6e3dd03667b13d5814987b8a9c7366df..a5c644778b913b0d24835e18445bd1dc8ce154fd 100644 --- a/tests/src/mocks/generation/opengl_mock_template.cpp +++ b/tests/src/mocks/generation/opengl_mock_template.cpp @@ -36,10 +36,7 @@ #pragma clang diagnostic pop #endif -#if defined __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wmissing-prototypes" -#endif +SUPPRESS_WARNINGS_BEGIN_MISSING_DECLARATIONS #ifdef __cplusplus extern "C" { @@ -55,6 +52,4 @@ GLenum glewInit() { return open_gl_mock.glewInit(); } } #endif -#if defined __clang__ -#pragma clang diagnostic pop -#endif +SUPPRESS_WARNINGS_END diff --git a/tests/src/test-transform.cpp b/tests/src/test-transform.cpp index a02f86e2635ce824d1efe520fe8154d30c34688f..4f844065e07dc3a97702f34d9cb4cef598eb9e11 100644 --- a/tests/src/test-transform.cpp +++ b/tests/src/test-transform.cpp @@ -32,11 +32,11 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/glm.hpp" SUPPRESS_WARNINGS_END -#include "phx/entity.hpp" -#include "phx/scene.hpp" -#include "phx/transform.hpp" +#include "phx/core/entity.hpp" +#include "phx/core/logger.hpp" +#include "phx/core/scene.hpp" +#include "phx/rendering/components/transform.hpp" -#include "phx/logger.hpp" #include "test_utilities/glm_mat4.hpp" #include "test_utilities/glm_quat.hpp" #include "test_utilities/glm_vec3.hpp" @@ -177,18 +177,18 @@ SCENARIO( WHEN("We rotate it in Euler angles by [5.0, 10.0, 15.0].") { transform->RotateEuler(glm::vec3(5.0f, 10.0f, 15.0f)); THEN( - "The local rotation vector should be equal to [45.76f, 44.63f, " - "85.70f].") { + "The local rotation vector should be equal to [51.351, 43.540, " + "85.105].") { auto rotation = transform->GetLocalRotationEuler(); REQUIRE(test_utilities::Approx<glm::vec3>(rotation) == - glm::vec3(45.7610f, 44.6317f, 85.7065f)); + glm::vec3(51.351f, 43.540f, 85.105f)); } THEN( "The local transform matrix should be equal to the corresponding " "rotation matrix.") { - const glm::mat4 rotation_matrix(0.05327f, 0.70964f, -0.70254f, 0.0f, - -0.65801f, 0.55414f, 0.50984f, 0.0f, - 0.75112f, 0.43512f, 0.49647f, 0.0f, + const glm::mat4 rotation_matrix(0.06185f, 0.72225f, -0.68886f, 0.0f, + -0.57637f, 0.58931f, 0.56613f, 0.0f, + 0.81484f, 0.36202f, 0.45274f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); REQUIRE(test_utilities::Approx<glm::mat4>( transform->GetLocalMatrix()) == rotation_matrix); diff --git a/tests/src/test_assimp_loader.cpp b/tests/src/test_assimp_loader.cpp index 613ee4564563aabd2ea0de4c3045d8f82841d29d..16626f0aa7b5c5dc8cf2f39d99cee75eea8f4fc9 100644 --- a/tests/src/test_assimp_loader.cpp +++ b/tests/src/test_assimp_loader.cpp @@ -26,11 +26,11 @@ #include "catch/catch.hpp" -#include "phx/assimp_model_loader.hpp" -#include "phx/logger.hpp" -#include "phx/mesh.hpp" -#include "phx/nameable.hpp" -#include "phx/resource_utils.hpp" +#include "phx/core/logger.hpp" +#include "phx/resources/types/mesh.hpp" +#include "phx/resources/loaders/assimp_model_loader.hpp" +#include "phx/resources/resource_utils.hpp" +#include "phx/utility/aspects/nameable.hpp" #include "test_utilities/log_capture.hpp" @@ -94,6 +94,18 @@ SCENARIO("The assimp loader loads models using the Assimp library.", } } } + WHEN("We load a unit cube.") { + auto resource = phx::ResourceUtils::LoadResourceFromFile<phx::Model>( + "models/cube/cube.obj"); + auto mesh = resource->GetMesh(); + auto bounding_box = mesh->GetBoundingBox(); + THEN("The lower bound should be at (-0.5,-0.5,-0.5)") { + REQUIRE(bounding_box[0] == glm::vec3(-0.5f)); + } + THEN("The upper bound should be at (0.5,0.5,0.5)") { + REQUIRE(bounding_box[1] == glm::vec3(0.5f)); + } + } WHEN("We load a specific material.") { const std::string material_name = "Material.001"; auto resource = phx::ResourceUtils::LoadResourceFromFile<phx::Material>( diff --git a/tests/src/test_behavior_system.cpp b/tests/src/test_behavior_system.cpp index 493787f420b89df4f281d8ada3add8156c1bd94e..d7ce2e41fd95c38264588fbf57f7614c612dd97a 100644 --- a/tests/src/test_behavior_system.cpp +++ b/tests/src/test_behavior_system.cpp @@ -26,10 +26,10 @@ #include "catch/catch.hpp" #include "trompeloeil.hpp" -#include "phx/behavior.hpp" -#include "phx/behavior_system.hpp" -#include "phx/engine.hpp" -#include "phx/scene.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/scene.hpp" +#include "phx/scripting/behavior.hpp" +#include "phx/scripting/behavior_system.hpp" extern template struct trompeloeil::reporter<trompeloeil::specialized>; diff --git a/tests/src/test_clear_pass.cpp b/tests/src/test_clear_pass.cpp index d5db32896437c18990051b25e0c07b91b2fb4e03..2a8322c1a6361b681b86398e5a18b4d0df0f2a40 100644 --- a/tests/src/test_clear_pass.cpp +++ b/tests/src/test_clear_pass.cpp @@ -33,8 +33,8 @@ SUPPRESS_WARNINGS_END #include "mocks/opengl_mock.hpp" -#include "phx/clear_pass.hpp" -#include "phx/render_target.hpp" +#include "phx/rendering/backend/render_target.hpp" +#include "phx/rendering/render_passes/clear_pass.hpp" extern template struct trompeloeil::reporter<trompeloeil::specialized>; diff --git a/tests/src/test_display_system.cpp b/tests/src/test_display_system.cpp index 97135366aa074c6ed2dcc0d869125bbe2e3eb3b4..5441032582559874deec4c0e6561cbe8d10cfa98 100644 --- a/tests/src/test_display_system.cpp +++ b/tests/src/test_display_system.cpp @@ -29,9 +29,9 @@ #include "mocks/sdl_mock.hpp" -#include "phx/display_system_window.hpp" -#include "phx/logger.hpp" -#include "phx/window.hpp" +#include "phx/core/logger.hpp" +#include "phx/display/display_system_window.hpp" +#include "phx/display/window.hpp" using trompeloeil::_; using trompeloeil::ne; diff --git a/tests/src/test_engine.cpp b/tests/src/test_engine.cpp index 02b9efd634ccea19931a1ccccab5481fd5c0ec02..e500e5b1f3680fc465e5d9584ffb449c0d82c65b 100644 --- a/tests/src/test_engine.cpp +++ b/tests/src/test_engine.cpp @@ -28,14 +28,14 @@ #include "catch/catch.hpp" -#include "phx/behavior.hpp" -#include "phx/display_system_window.hpp" -#include "phx/engine.hpp" -#include "phx/input_system.hpp" -#include "phx/logger.hpp" -#include "phx/rendering_system.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/logger.hpp" +#include "phx/core/system.hpp" +#include "phx/display/display_system_window.hpp" +#include "phx/input/input_system.hpp" +#include "phx/rendering/rendering_system.hpp" +#include "phx/scripting/behavior.hpp" #include "phx/setup.hpp" -#include "phx/system.hpp" #include "test_utilities/log_capture.hpp" diff --git a/tests/src/test_entity.cpp b/tests/src/test_entity.cpp index 12baf3feefaa045485aa2f7824abb3b32d680949..a4182668389c3fe4cda81d0fbc404076c1830995 100644 --- a/tests/src/test_entity.cpp +++ b/tests/src/test_entity.cpp @@ -22,9 +22,9 @@ #include "catch/catch.hpp" -#include "phx/component.hpp" -#include "phx/entity.hpp" -#include "phx/mesh_handle.hpp" +#include "phx/core/component.hpp" +#include "phx/core/entity.hpp" +#include "phx/rendering/components/mesh_handle.hpp" SCENARIO("An entity can keep track of components.", "[phx][phx::Entity]") { GIVEN("A new entity.") { diff --git a/tests/src/test_frame_graph.cpp b/tests/src/test_frame_graph.cpp index 2008be84053496297c680dac6f2bc875e2dd2fec..65308ab53e9a7b7672f6ae5b5b07dc5c614a2a10 100644 --- a/tests/src/test_frame_graph.cpp +++ b/tests/src/test_frame_graph.cpp @@ -27,8 +27,8 @@ #include "trompeloeil.hpp" -#include "phx/frame_graph.hpp" -#include "phx/render_pass.hpp" +#include "phx/rendering/render_passes/render_pass.hpp" +#include "phx/rendering/frame_graph.hpp" extern template struct trompeloeil::reporter<trompeloeil::specialized>; diff --git a/tests/src/test_geometry_pass.cpp b/tests/src/test_geometry_pass.cpp index d8cdc27c771136f87a763a8cb840352afbd17ceb..141e691c4dc634829b26108db667980e675c1bf9 100644 --- a/tests/src/test_geometry_pass.cpp +++ b/tests/src/test_geometry_pass.cpp @@ -37,11 +37,11 @@ SUPPRESS_WARNINGS_BEGIN #include "trompeloeil.hpp" SUPPRESS_WARNINGS_END -#include "phx/entity.hpp" -#include "phx/geometry_pass.hpp" -#include "phx/projection.hpp" -#include "phx/render_target.hpp" -#include "phx/transform.hpp" +#include "phx/core/entity.hpp" +#include "phx/rendering/backend/render_target.hpp" +#include "phx/rendering/components/projection.hpp" +#include "phx/rendering/components/transform.hpp" +#include "phx/rendering/render_passes/geometry_pass.hpp" #include "mocks/opengl_mock.hpp" diff --git a/tests/src/test_image.cpp b/tests/src/test_image.cpp index db69d982d9a5a7e3b6dc858599c2c55a454fa352..bc6f702a54d3096148e61d1c9c2a6aeb7d9a5a9a 100644 --- a/tests/src/test_image.cpp +++ b/tests/src/test_image.cpp @@ -25,8 +25,8 @@ #include <cstddef> #include <memory> #include "catch/catch.hpp" -#include "phx/image.hpp" -#include "phx/opengl_image_buffer_data.hpp" +#include "phx/rendering/backend/opengl_image_buffer_data.hpp" +#include "phx/resources/types/image.hpp" #include "test_utilities/opengl_buffer_data_comparison.hpp" SCENARIO("We can create an empty image.", "[phx][phx::Image]") { diff --git a/tests/src/test_input_system.cpp b/tests/src/test_input_system.cpp index dc2a11142349b5407fabd1d807c19498bd2bdfc4..7ac9cbc35cd66467dc29edadfd45c862b2613313 100644 --- a/tests/src/test_input_system.cpp +++ b/tests/src/test_input_system.cpp @@ -24,8 +24,8 @@ #include "catch/catch.hpp" -#include "phx/engine.hpp" -#include "phx/input_system.hpp" +#include "phx/core/engine.hpp" +#include "phx/input/input_system.hpp" #include "trompeloeil.hpp" diff --git a/tests/src/test_light.cpp b/tests/src/test_light.cpp index c8a4fadf4720565da8848fc67326acb5c2f4ac43..6506ab2cdfa096a474b6518518795482aaac7a8d 100644 --- a/tests/src/test_light.cpp +++ b/tests/src/test_light.cpp @@ -24,8 +24,8 @@ #include "catch/catch.hpp" -#include "phx/entity.hpp" -#include "phx/light.hpp" +#include "phx/core/entity.hpp" +#include "phx/rendering/components/light.hpp" #include "glm/glm.hpp" diff --git a/tests/src/test_material.cpp b/tests/src/test_material.cpp index 8b97af72d9295751bb61760364f1b597a98da095..34f0552562a062641b060f9d222b54c5058fecda 100644 --- a/tests/src/test_material.cpp +++ b/tests/src/test_material.cpp @@ -25,9 +25,9 @@ #include "catch/catch.hpp" -#include "phx/component.hpp" -#include "phx/logger.hpp" -#include "phx/material_handle.hpp" +#include "phx/core/component.hpp" +#include "phx/core/logger.hpp" +#include "phx/rendering/components/material_handle.hpp" #include "test_utilities/glm_vec3.hpp" diff --git a/tests/src/test_mesh.cpp b/tests/src/test_mesh.cpp index cf5ef60e92b77e9623d7ed006613a375c57df68a..4aea83e47a4b54b1c74a48b5011f2665dfc04f2b 100644 --- a/tests/src/test_mesh.cpp +++ b/tests/src/test_mesh.cpp @@ -26,7 +26,7 @@ #include "catch/catch.hpp" -#include "phx/mesh.hpp" +#include "phx/resources/types/mesh.hpp" #define TEST_ATTRIBUTE(ATTRIBUTE_NAME, ATTRIBUTE_TYPE) \ WHEN("We query the " #ATTRIBUTE_NAME) { \ diff --git a/tests/src/test_model.cpp b/tests/src/test_model.cpp index 2d6b927ea4056039e4f4414a15b1c55671abfc9a..7098d7ca52f01c7dec6872d7a815ff80aee976b3 100644 --- a/tests/src/test_model.cpp +++ b/tests/src/test_model.cpp @@ -24,10 +24,10 @@ #include "catch/catch.hpp" -#include "phx/assimp_model_loader.hpp" -#include "phx/model.hpp" -#include "phx/resource_manager.hpp" -#include "phx/resource_utils.hpp" +#include "phx/resources/loaders/assimp_model_loader.hpp" +#include "phx/resources/types/model.hpp" +#include "phx/resources/resource_manager.hpp" +#include "phx/resources/resource_utils.hpp" SCENARIO("A Model can be loaded that contains multiple meshes", "[phx][phx::Model]") { diff --git a/tests/src/test_opengl_buffer_data.cpp b/tests/src/test_opengl_buffer_data.cpp index da2958389ac079df5b9681364847f15d9dd1c7e4..f52f171b53db4afbe9e3513c54d48a46c585479a 100644 --- a/tests/src/test_opengl_buffer_data.cpp +++ b/tests/src/test_opengl_buffer_data.cpp @@ -25,7 +25,7 @@ #include "catch/catch.hpp" -#include "phx/opengl_image_buffer_data.hpp" +#include "phx/rendering/backend/opengl_image_buffer_data.hpp" #include "phx/resources_path.hpp" #include "test_utilities/opengl_buffer_data_comparison.hpp" diff --git a/tests/src/test_opengl_buffer_data_comparison.cpp b/tests/src/test_opengl_buffer_data_comparison.cpp index 4696e60ead7f64e50b95edd713cfac8013fbfcda..067c0153e08441e38d5c6027f5922cf900d6024d 100644 --- a/tests/src/test_opengl_buffer_data_comparison.cpp +++ b/tests/src/test_opengl_buffer_data_comparison.cpp @@ -23,7 +23,7 @@ #include <iostream> #include "catch/catch.hpp" -#include "phx/opengl_image_buffer_data.hpp" +#include "phx/rendering/backend/opengl_image_buffer_data.hpp" #include "test_utilities/opengl_buffer_data_comparison.hpp" SCENARIO("OpenGLImageBufferData can be compared", "[tests][test::utils]") { diff --git a/tests/src/test_openvr_controller_system.cpp b/tests/src/test_openvr_controller_system.cpp index 22d3acf01a91f4d15c9ceb424d311930288b2fe2..0b2987fe9e6899e0ed6e1434137415228c94a054 100644 --- a/tests/src/test_openvr_controller_system.cpp +++ b/tests/src/test_openvr_controller_system.cpp @@ -32,14 +32,14 @@ SUPPRESS_WARNINGS_END #include "trompeloeil.hpp" -#include "phx/display_system_openvr.hpp" -#include "phx/entity.hpp" -#include "phx/material_handle.hpp" -#include "phx/mesh_handle.hpp" -#include "phx/openvr_controller_behavior.hpp" -#include "phx/openvr_controller_system.hpp" -#include "phx/rendering_system.hpp" -#include "phx/scene.hpp" +#include "phx/core/entity.hpp" +#include "phx/core/scene.hpp" +#include "phx/display/display_system_openvr.hpp" +#include "phx/input/openvr_controller_behavior.hpp" +#include "phx/input/openvr_controller_system.hpp" +#include "phx/rendering/components/material_handle.hpp" +#include "phx/rendering/components/mesh_handle.hpp" +#include "phx/rendering/rendering_system.hpp" #include "mocks/opengl_mock.hpp" #include "mocks/openvr_mock.hpp" diff --git a/tests/src/test_orderable_list.cpp b/tests/src/test_orderable_list.cpp index 093264bad578bcdabf0cc7d1aabfd0cd30395173..ee67a84a3dc235e3c8d5efaefc917466faf4225a 100644 --- a/tests/src/test_orderable_list.cpp +++ b/tests/src/test_orderable_list.cpp @@ -26,7 +26,7 @@ #include "catch/catch.hpp" #include "trompeloeil.hpp" -#include "phx/orderable_list.hpp" +#include "phx/utility/orderable_list.hpp" using trompeloeil::_; using trompeloeil::ne; diff --git a/tests/src/test_projection.cpp b/tests/src/test_projection.cpp index d38f27056061dc6686fc944cb5ad3b236cda0d2b..a6927186a093e2c9ab5c128e37f4c9414a5b2825 100644 --- a/tests/src/test_projection.cpp +++ b/tests/src/test_projection.cpp @@ -28,8 +28,8 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/glm.hpp" SUPPRESS_WARNINGS_END -#include "phx/entity.hpp" -#include "phx/projection.hpp" +#include "phx/core/entity.hpp" +#include "phx/rendering/components/projection.hpp" #include "test_utilities/glm_mat4.hpp" diff --git a/tests/src/test_rendering_system.cpp b/tests/src/test_rendering_system.cpp index cd925e872804a65417c00adf684761e9f8741404..c3ce5f433bbd9b08337e27864765e7fea58f9f86 100644 --- a/tests/src/test_rendering_system.cpp +++ b/tests/src/test_rendering_system.cpp @@ -24,14 +24,14 @@ #include "catch/catch.hpp" -#include "phx/display_system_window.hpp" -#include "phx/engine.hpp" -#include "phx/entity.hpp" -#include "phx/geometry_pass.hpp" -#include "phx/mesh.hpp" -#include "phx/rendering_system.hpp" -#include "phx/scene.hpp" -#include "phx/transform.hpp" +#include "phx/display/display_system_window.hpp" +#include "phx/core/engine.hpp" +#include "phx/core/entity.hpp" +#include "phx/core/scene.hpp" +#include "phx/rendering/components/transform.hpp" +#include "phx/rendering/render_passes/geometry_pass.hpp" +#include "phx/rendering/rendering_system.hpp" +#include "phx/resources/types/mesh.hpp" #include "trompeloeil.hpp" diff --git a/tests/src/test_resource_manager.cpp b/tests/src/test_resource_manager.cpp index a217d071cdc5914ca202e1003c672f2ccf9fad15..b3fcdb79350f94107d0212a81315c0a6ecb24001 100644 --- a/tests/src/test_resource_manager.cpp +++ b/tests/src/test_resource_manager.cpp @@ -34,13 +34,13 @@ SUPPRESS_WARNINGS_END #include "assimp/postprocess.h" // Post processing flags -#include "phx/image.hpp" -#include "phx/image_loader.hpp" -#include "phx/model.hpp" -#include "phx/resource_declaration.hpp" -#include "phx/resource_manager.hpp" -#include "phx/resource_utils.hpp" -#include "phx/shader_source.hpp" +#include "phx/resources/loaders/image_loader.hpp" +#include "phx/resources/types/image.hpp" +#include "phx/resources/types/model.hpp" +#include "phx/resources/types/shader_source.hpp" +#include "phx/resources/resource_declaration.hpp" +#include "phx/resources/resource_manager.hpp" +#include "phx/resources/resource_utils.hpp" SCENARIO( "Check the declaration phase of a resource life cycle. A resource needs to " diff --git a/tests/src/test_resource_pointer.cpp b/tests/src/test_resource_pointer.cpp index 2a36059fe6f23f5219374eda299c312701ec5785..8a0c9e361ed76e402de7b9552845b73351e21f3c 100644 --- a/tests/src/test_resource_pointer.cpp +++ b/tests/src/test_resource_pointer.cpp @@ -22,10 +22,10 @@ #include "catch/catch.hpp" -#include "phx/image.hpp" -#include "phx/resource_manager.hpp" -#include "phx/resource_pointer.hpp" -#include "phx/resource_utils.hpp" +#include "phx/resources/types/image.hpp" +#include "phx/resources/resource_manager.hpp" +#include "phx/resources/resource_pointer.hpp" +#include "phx/resources/resource_utils.hpp" SCENARIO( "The resource pointer makes the underlying resource available through the " diff --git a/tests/src/test_resource_utils.cpp b/tests/src/test_resource_utils.cpp index 154d5a12cc885ff931db52c3ab788a464ba5b838..d2b0a9bb82b807735219581322600fec1e1c6e26 100644 --- a/tests/src/test_resource_utils.cpp +++ b/tests/src/test_resource_utils.cpp @@ -24,9 +24,9 @@ #include "catch/catch.hpp" -#include "phx/image.hpp" -#include "phx/resource_declaration.hpp" -#include "phx/resource_utils.hpp" +#include "phx/resources/types/image.hpp" +#include "phx/resources/resource_declaration.hpp" +#include "phx/resources/resource_utils.hpp" #include "phx/resources_path.hpp" SCENARIO("Resource utils can extract file extensions.", diff --git a/tests/src/test_scene.cpp b/tests/src/test_scene.cpp index e52dd2fe8a58e7393ec827280dd92517ff0d4f62..96aeef23214eb650fc77bbd25b1df9f321363f37 100644 --- a/tests/src/test_scene.cpp +++ b/tests/src/test_scene.cpp @@ -22,9 +22,9 @@ #include "catch/catch.hpp" -#include "phx/entity.hpp" -#include "phx/runtime_component.hpp" -#include "phx/scene.hpp" +#include "phx/core/entity.hpp" +#include "phx/core/runtime_component.hpp" +#include "phx/core/scene.hpp" SCENARIO("A scene keeps track of entities.", "[phx][phx::Scene]") { GIVEN("An empty scene") { diff --git a/tests/src/test_scene_loader.cpp b/tests/src/test_scene_loader.cpp index c62ab489b7bd3b926b0bbe978972a3bc37c3a0bf..1e69d84c692c57071f22d50d69d4df46bfe838d0 100644 --- a/tests/src/test_scene_loader.cpp +++ b/tests/src/test_scene_loader.cpp @@ -24,11 +24,11 @@ #include "catch/catch.hpp" -#include "phx/entity.hpp" -#include "phx/mesh_handle.hpp" -#include "phx/scene.hpp" -#include "phx/scene_loader.hpp" -#include "phx/transform.hpp" +#include "phx/core/entity.hpp" +#include "phx/core/scene.hpp" +#include "phx/rendering/components/mesh_handle.hpp" +#include "phx/rendering/components/transform.hpp" +#include "phx/resources/loaders/scene_loader.hpp" SCENARIO("The scene loader can load a model", "[phx][phx::SceneLoader]") { GIVEN("An empty scene") { diff --git a/tests/src/test_shader.cpp b/tests/src/test_shader.cpp index 1e7bdfffe16aaa32f55e419ad277d734c0ecd5ae..b5e510e51b93f8b670b21f2b5b2aca7d10410746 100644 --- a/tests/src/test_shader.cpp +++ b/tests/src/test_shader.cpp @@ -34,9 +34,9 @@ SUPPRESS_WARNINGS_END #include "catch/catch.hpp" -#include "phx/resource_manager.hpp" -#include "phx/resource_utils.hpp" -#include "phx/shader_program.hpp" +#include "phx/rendering/backend/shader_program.hpp" +#include "phx/resources/resource_manager.hpp" +#include "phx/resources/resource_utils.hpp" #include "mocks/opengl_mock.hpp" diff --git a/tests/src/test_tracking_system.cpp b/tests/src/test_tracking_system.cpp index 2b1ae42eabbcb6ac2a7d0e187008c9ab14253dcc..44124c76815edf17b45827619708cb257c698973 100644 --- a/tests/src/test_tracking_system.cpp +++ b/tests/src/test_tracking_system.cpp @@ -34,13 +34,13 @@ SUPPRESS_WARNINGS_BEGIN SUPPRESS_WARNINGS_END #include "mocks/sdl_mock.hpp" -#include "phx/display_system_openvr.hpp" -#include "phx/entity.hpp" -#include "phx/projection.hpp" -#include "phx/runtime_component.hpp" -#include "phx/scene.hpp" -#include "phx/tracking_system_openvr.hpp" -#include "phx/transform.hpp" +#include "phx/core/entity.hpp" +#include "phx/core/runtime_component.hpp" +#include "phx/core/scene.hpp" +#include "phx/display/display_system_openvr.hpp" +#include "phx/rendering/components/projection.hpp" +#include "phx/rendering/components/transform.hpp" +#include "phx/tracking/tracking_system_openvr.hpp" #include "test_utilities/glm_mat4.hpp" diff --git a/tests/test_utilities/dummy_material_generator.cpp b/tests/test_utilities/dummy_material_generator.cpp index 9c3140db47361bbd25dc3a989e89a18fb4ad2923..4dcf8e004a7d1bd854f0f734247ece4c1d28d155 100644 --- a/tests/test_utilities/dummy_material_generator.cpp +++ b/tests/test_utilities/dummy_material_generator.cpp @@ -26,7 +26,7 @@ #include <utility> #include <vector> -#include "phx/material.hpp" +#include "phx/resources/types/material.hpp" namespace phx { diff --git a/tests/test_utilities/dummy_material_generator.hpp b/tests/test_utilities/dummy_material_generator.hpp index 87df638b6954851b52d679a169686e73b26ba468..746df1f1d199b3887f8f26a600eeb20dfa6b71ab 100644 --- a/tests/test_utilities/dummy_material_generator.hpp +++ b/tests/test_utilities/dummy_material_generator.hpp @@ -33,7 +33,7 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/vec3.hpp" SUPPRESS_WARNINGS_END -#include "phx/resource_load_strategy.hpp" +#include "phx/resources/resource_load_strategy.hpp" namespace phx { class Material; diff --git a/tests/test_utilities/dummy_mesh_generator.cpp b/tests/test_utilities/dummy_mesh_generator.cpp index ba4e062170120ba0aae1f3a36de3d55a06c7e760..5c6a4f4e925777dcbefaf58f2e0ce2b6396074c8 100644 --- a/tests/test_utilities/dummy_mesh_generator.cpp +++ b/tests/test_utilities/dummy_mesh_generator.cpp @@ -26,7 +26,7 @@ #include <utility> #include <vector> -#include "phx/mesh.hpp" +#include "phx/resources/types/mesh.hpp" namespace phx { diff --git a/tests/test_utilities/dummy_mesh_generator.hpp b/tests/test_utilities/dummy_mesh_generator.hpp index d12a719e4e198051a7758675ac2770fac22f4426..49c73df2c9849330a259cd0883c07de04e87826c 100644 --- a/tests/test_utilities/dummy_mesh_generator.hpp +++ b/tests/test_utilities/dummy_mesh_generator.hpp @@ -33,7 +33,7 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/vec3.hpp" SUPPRESS_WARNINGS_END -#include "phx/resource_load_strategy.hpp" +#include "phx/resources/resource_load_strategy.hpp" namespace phx { class Mesh; diff --git a/tests/test_utilities/glm_mat4.hpp b/tests/test_utilities/glm_mat4.hpp index c34f9e9eeb2d7daa75e5f752120f0018932145a0..33fb19347cc3a09624d3e2c9d9695a8d600e4c32 100644 --- a/tests/test_utilities/glm_mat4.hpp +++ b/tests/test_utilities/glm_mat4.hpp @@ -36,7 +36,7 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/glm.hpp" SUPPRESS_WARNINGS_END -#include "phx/stream_helpers.hpp" +#include "phx/utility/stream_helpers.hpp" #include "approx.hpp" diff --git a/tests/test_utilities/glm_quat.hpp b/tests/test_utilities/glm_quat.hpp index a6dd611a663dcbe7283f067ef91430d313b15473..2d36d62045d2b75cfaeb154d0bd98b2256185802 100644 --- a/tests/test_utilities/glm_quat.hpp +++ b/tests/test_utilities/glm_quat.hpp @@ -36,7 +36,7 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/glm.hpp" SUPPRESS_WARNINGS_END -#include "phx/stream_helpers.hpp" +#include "phx/utility/stream_helpers.hpp" #include "approx.hpp" diff --git a/tests/test_utilities/glm_vec3.hpp b/tests/test_utilities/glm_vec3.hpp index d9a1de832d5e38f673b4111d7f2f2dbb3be0b57a..d33ee272edb8b709e0fdb86e2d6f3f443d5a7f8f 100644 --- a/tests/test_utilities/glm_vec3.hpp +++ b/tests/test_utilities/glm_vec3.hpp @@ -36,7 +36,7 @@ SUPPRESS_WARNINGS_BEGIN #include "glm/glm.hpp" SUPPRESS_WARNINGS_END -#include "phx/stream_helpers.hpp" +#include "phx/utility/stream_helpers.hpp" #include "approx.hpp" diff --git a/tests/test_utilities/opengl_buffer_data_comparison.cpp b/tests/test_utilities/opengl_buffer_data_comparison.cpp index 2f64ad4cd8e28b8473b2c297d38dc45fb9019ae6..c9e952a6114b1c7f1bfc49d6af50536cdd779ef8 100644 --- a/tests/test_utilities/opengl_buffer_data_comparison.cpp +++ b/tests/test_utilities/opengl_buffer_data_comparison.cpp @@ -24,7 +24,7 @@ #include <string> -#include "phx/image.hpp" +#include "phx/resources/types/image.hpp" namespace test_utilities { diff --git a/tests/test_utilities/opengl_buffer_data_comparison.hpp b/tests/test_utilities/opengl_buffer_data_comparison.hpp index 2ffdc3f3140f72ece5936003d80aec7bbc65f087..5f86bb1bb79253277cd60ca51606447cfd5997d4 100644 --- a/tests/test_utilities/opengl_buffer_data_comparison.hpp +++ b/tests/test_utilities/opengl_buffer_data_comparison.hpp @@ -37,9 +37,9 @@ #include "catch/catch.hpp" -#include "phx/image.hpp" -#include "phx/opengl_image_buffer_data.hpp" -#include "phx/resource_manager.hpp" +#include "phx/rendering/backend/opengl_image_buffer_data.hpp" +#include "phx/resources/types/image.hpp" +#include "phx/resources/resource_manager.hpp" #include "test_utilities/reference_image_path.hpp" diff --git a/tests/test_utilities/tests/src/test_log_capture.cpp b/tests/test_utilities/tests/src/test_log_capture.cpp index 4202c170e8e0d4346c08e55234c3f3b66abbd1c8..93e9ff79adf421b47b588eee67ecba890a51d908 100644 --- a/tests/test_utilities/tests/src/test_log_capture.cpp +++ b/tests/test_utilities/tests/src/test_log_capture.cpp @@ -25,7 +25,7 @@ #include "catch/catch.hpp" -#include "phx/logger.hpp" +#include "phx/core/logger.hpp" #include "test_utilities/log_capture.hpp" diff --git a/tests/test_utilities/tests/src/test_reference_images.cpp b/tests/test_utilities/tests/src/test_reference_images.cpp index f2005d2cc4c4a91fd7f15de4cdee2bd3cfd5510a..1db9888215186a58ffc86c98484c278c3d7af563 100644 --- a/tests/test_utilities/tests/src/test_reference_images.cpp +++ b/tests/test_utilities/tests/src/test_reference_images.cpp @@ -28,9 +28,9 @@ #include "catch/catch.hpp" -#include "phx/opengl_image_buffer_data.hpp" -#include "phx/resource_manager.hpp" -#include "phx/resource_utils.hpp" +#include "phx/rendering/backend/opengl_image_buffer_data.hpp" +#include "phx/resources/resource_manager.hpp" +#include "phx/resources/resource_utils.hpp" #include "test_utilities/opengl_buffer_data_comparison.hpp" #include "test_utilities/reference_image_path.hpp"