Add controller models

This commit is contained in:
Guillaume Meunier
2024-01-28 11:33:32 +01:00
parent 95d1020559
commit 20c5ad3d0e
28 changed files with 2096 additions and 10 deletions
+6
View File
@@ -73,6 +73,11 @@ else()
file(GLOB PLATFORM_SOURCE CONFIGURE_DEPENDS
"decoder/ffmpeg/*.cpp")
target_sources(wivrn PRIVATE ${PLATFORM_SOURCE})
install(DIRECTORY ${CMAKE_SOURCE_DIR}/assets DESTINATION ${CMAKE_INSTALL_DATADIR}/wivrn)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/share)
file(CREATE_LINK ${CMAKE_SOURCE_DIR}/assets ${CMAKE_BINARY_DIR}/share/assets SYMBOLIC)
endif()
if(ANDROID OR Vulkan_VERSION VERSION_LESS 1.3.268)
@@ -159,3 +164,4 @@ if(USE_ANDROID_VALIDATION_LAYER)
target_link_libraries(wivrn vvl1 vvl2) # Hack to get gradle to package the validation layer in the APK
endif()
+25 -7
View File
@@ -19,13 +19,14 @@
#include "asset.h"
#include "application.h"
#include <filesystem>
#include <fstream>
#include <spdlog/spdlog.h>
#ifdef __ANDROID__
#include <android/asset_manager.h>
asset::asset(std::filesystem::path path)
asset::asset(const std::filesystem::path& path)
{
spdlog::debug("Loading Android asset {}", path.string());
android_asset = AAssetManager_open(application::asset_manager(), path.c_str(), AASSET_MODE_BUFFER);
@@ -56,17 +57,34 @@ asset::~asset()
#else
asset::asset(std::filesystem::path path)
static std::filesystem::path get_asset_root()
{
const char * path = std::getenv("WIVRN_ASSET_ROOT");
if (path && strcmp(path, ""))
return path;
// Linux only: see https://stackoverflow.com/a/1024937
auto exe = std::filesystem::read_symlink("/proc/self/exe");
return exe.parent_path().parent_path() / "share" / "wivrn" / "assets";
}
std::filesystem::path asset::asset_root()
{
static std::filesystem::path root = get_asset_root();
return root;
}
asset::asset(const std::filesystem::path& path)
{
assert(path.is_relative());
// TODO mmap
// TODO: load only once if it is already loaded
// TODO load only once if it is already loaded
spdlog::debug("Loading file asset {}", path.string());
if (path.is_relative())
path = "assets" / path;
std::ifstream file(path, std::ios::binary | std::ios::ate);
std::ifstream file(asset_root() / path, std::ios::binary | std::ios::ate);
file.exceptions(std::ios_base::badbit | std::ios_base::failbit);
size_t size = file.tellg();
+2 -2
View File
@@ -31,17 +31,17 @@ struct AAsset;
class asset
{
#ifdef __ANDROID__
AAsset * android_asset = nullptr;
std::span<const std::byte> bytes;
#else
static std::filesystem::path asset_root();
std::vector<std::byte> bytes;
#endif
public:
asset() = default;
asset(std::filesystem::path path);
asset(const std::filesystem::path& path);
#ifdef __ANDROID__
asset(asset && other);
+1 -1
View File
@@ -86,7 +86,7 @@ scenes::lobby::lobby() :
teapot.import(loader("lobby.gltf"));
input = input_profile("webxr-profiles/" + choose_webxr_profile() + "/profile.json", loader, teapot);
input = input_profile("controllers/" + choose_webxr_profile() + "/profile.json", loader, teapot);
spdlog::info("Loaded input profile {}", input->id);
}