tried making naming more uniform and implemented most of the opengl managers
This commit is contained in:
58
include/assets/file_parsers/generic/generic_3dtk_loader.hpp
Normal file
58
include/assets/file_parsers/generic/generic_3dtk_loader.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <charconv>
|
||||
#include <string_view>
|
||||
|
||||
#include "glm/mat4x4.hpp"
|
||||
#include "util/result.hpp"
|
||||
#include "util/string_list.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
|
||||
#include "../../read_buffers"
|
||||
#include "../../data_stores"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
|
||||
|
||||
|
||||
template<bool Normal, bool Color, bool Reflectance>
|
||||
struct generic_3dtk_loader
|
||||
{
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const ztu::string_list& filenames,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
dynamic_point_cloud_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
dynamic_point_cloud_store& store,
|
||||
prefetch_lookup& id_lookup,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
protected:
|
||||
|
||||
[[nodiscard]] static ztu::result<pose_prefetch_lookup::index_type> parse_index(
|
||||
std::string_view filename
|
||||
);
|
||||
|
||||
ztu::result<std::pair<ztu::u32, std::chars_format>> analyze_component_format(
|
||||
std::string_view line
|
||||
);
|
||||
|
||||
void transform_point_cloud(
|
||||
std::span<point_cloud_vertex_components::position::value_type> points,
|
||||
const glm::mat4& pose
|
||||
);
|
||||
|
||||
private:
|
||||
std::error_code read_point_file(
|
||||
const std::filesystem::path& filename,
|
||||
dynamic_point_cloud_buffer& point_cloud
|
||||
);
|
||||
};
|
||||
|
||||
#define INCLUDE_GENERIC_3DTK_LOADER_IMPLEMENTATION
|
||||
#include "../../data_parsers"
|
||||
#undef INCLUDE_GENERIC_3DTK_LOADER_IMPLEMENTATION
|
||||
35
include/assets/file_parsers/glsl_loader.hpp
Normal file
35
include/assets/file_parsers/glsl_loader.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/prefetch_lookups/mesh_prefetch_lookup.hpp"
|
||||
#include "assets/data/shader_source_data.hpp"
|
||||
#include "util/string_list.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
struct glsl_loader
|
||||
{
|
||||
static constexpr auto name = std::string_view("glsl");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
shader_source_data& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
shader_source_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
};
|
||||
|
||||
}
|
||||
19
include/assets/file_parsers/interface.txt
Normal file
19
include/assets/file_parsers/interface.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
|
||||
struct X {
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
// space stuff that has to persist
|
||||
dynamic_X_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
dynamic_X_store& store,
|
||||
prefetch_lookup& id_lookup,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
}
|
||||
59
include/assets/file_parsers/kitti_loader.hpp
Normal file
59
include/assets/file_parsers/kitti_loader.hpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
#include <span>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
#include "assets/data/point_cloud_data.hpp"
|
||||
#include "assets/data_stores/point_cloud_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "glm/mat4x4.hpp"
|
||||
#include "util/result.hpp"
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
struct kitti_loader
|
||||
{
|
||||
static constexpr auto name = std::string_view("kitti");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
point_cloud_data& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
shader_source_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
inline static constexpr auto frame_folder = "frames";
|
||||
|
||||
[[nodiscard]] static ztu::result<std::size_t> frame_id_from_filename(
|
||||
std::string_view filename
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load_point_file(
|
||||
const std::filesystem::path& filename,
|
||||
dynamic_point_cloud_buffer& point_cloud
|
||||
);
|
||||
|
||||
static void transform_point_cloud(
|
||||
std::span<point_cloud_vertex_components::position> points,
|
||||
const glm::mat4& pose
|
||||
);
|
||||
|
||||
[[nodiscard]] static ztu::result<std::string_view> parent_directory(std::string_view path);
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
37
include/assets/file_parsers/kitti_pose_loader.hpp
Normal file
37
include/assets/file_parsers/kitti_pose_loader.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "util/string_list.hpp"
|
||||
#include "../data_stores"
|
||||
#include "assets/data"
|
||||
#include "assets/prefetch_lookups/pose_prefetch_lookup.hpp"
|
||||
|
||||
struct kitti_pose_loader
|
||||
{
|
||||
static constexpr auto name = std::string_view("kitti_pose");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
dynamic_pose_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
shader_source_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
static constexpr auto pose_filename = std::string_view{ "pose.txt" };
|
||||
|
||||
static std::error_code parse_pose(
|
||||
std::ifstream& in,
|
||||
dynamic_pose_buffer& pose
|
||||
);
|
||||
};
|
||||
56
include/assets/file_parsers/mtl_loader.hpp
Normal file
56
include/assets/file_parsers/mtl_loader.hpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/data"
|
||||
#include "../data_stores"
|
||||
#include "../data_stores"
|
||||
#include "util/string_lookup.hpp"
|
||||
#include "util/result.hpp"
|
||||
|
||||
namespace mtl_loader_error
|
||||
{
|
||||
enum class codes {
|
||||
ok = 0,
|
||||
cannot_open_file,
|
||||
cannot_open_texture,
|
||||
malformed_ambient_color,
|
||||
malformed_diffuse_color,
|
||||
malformed_specular_color,
|
||||
malformed_specular_exponent,
|
||||
malformed_dissolve,
|
||||
unknown_line_begin
|
||||
};
|
||||
} // namespace mtl_loader_error
|
||||
|
||||
struct mtl_loader
|
||||
{
|
||||
static constexpr auto name = std::string_view("mtl");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
// THis is not very elegant, but right now I do not see a better solution...
|
||||
[[nodiscard]] static std::error_code load(
|
||||
dynamic_material_library_buffer& material_library_buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
shader_source_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
protected:
|
||||
static void find_textures(
|
||||
std::span<char> buffer,
|
||||
std::filesystem::path& path_buffer,
|
||||
const std::filesystem::path& base_directory,
|
||||
std::ifstream& in,
|
||||
ztu::string_list& texture_filenames
|
||||
);
|
||||
};
|
||||
82
include/assets/file_parsers/obj_loader.hpp
Executable file
82
include/assets/file_parsers/obj_loader.hpp
Executable file
@@ -0,0 +1,82 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
#include <string_view>
|
||||
#include "../data_loaders"
|
||||
#include "../data_stores"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include <set>
|
||||
|
||||
namespace obj_loader_error {
|
||||
|
||||
enum class codes {
|
||||
ok = 0,
|
||||
cannot_open_file,
|
||||
malformed_vertex,
|
||||
malformed_texture_coordinate,
|
||||
malformed_normal,
|
||||
malformed_face,
|
||||
face_index_out_of_range,
|
||||
unknown_line_begin,
|
||||
use_material_without_material_library,
|
||||
unknown_material_name
|
||||
};
|
||||
|
||||
} // namespace obj_loader_error
|
||||
|
||||
struct obj_loader {
|
||||
|
||||
static constexpr auto name = std::string_view("obj");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
dynamic_mesh_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_shader_source_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
protected:
|
||||
using index_type = dynamic_mesh_buffer::index_type;
|
||||
using vertex_type = std::array<index_type, 3>;
|
||||
|
||||
struct indexed_vertex_type
|
||||
{
|
||||
vertex_type vertex;
|
||||
index_type buffer_index;
|
||||
|
||||
friend auto operator<=>(const indexed_vertex_type& a, const indexed_vertex_type& b) {
|
||||
return a.vertex <=> b.vertex;
|
||||
}
|
||||
|
||||
bool operator==(const indexed_vertex_type& other) const noexcept {
|
||||
return other.vertex == vertex;
|
||||
}
|
||||
};
|
||||
|
||||
static void find_materials(
|
||||
std::span<char> buffer,
|
||||
std::filesystem::path& path_buffer,
|
||||
const std::filesystem::path& base_directory,
|
||||
std::ifstream& in,
|
||||
ztu::string_list& material_filenames
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code obj_loader::parse_file(
|
||||
dynamic_mesh_buffer& read_buffer,
|
||||
dynamic_mesh_buffer& mesh_buffer,
|
||||
std::filesystem::path& path_buffer,
|
||||
const std::filesystem::path& base_directory,
|
||||
std::set<indexed_vertex_type>& vertex_ids,
|
||||
std::ifstream& in,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_shader_source_store& store,
|
||||
bool pedantic
|
||||
);
|
||||
};
|
||||
30
include/assets/file_parsers/stl_loader.hpp
Normal file
30
include/assets/file_parsers/stl_loader.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
#include <string_view>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/data"
|
||||
#include "../data_stores"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
|
||||
struct stl_loader {
|
||||
|
||||
static constexpr auto name = std::string_view("stl");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
// space stuff that has to persist
|
||||
dynamic_mesh_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
shader_source_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
};
|
||||
40
include/assets/file_parsers/threedtk_pose_loader.hpp
Normal file
40
include/assets/file_parsers/threedtk_pose_loader.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/data"
|
||||
#include "util/string_list.hpp"
|
||||
#include "util/result.hpp"
|
||||
#include "assets/prefetch_lookups/pose_prefetch_lookup.hpp"
|
||||
|
||||
struct threedtk_pose_loader
|
||||
{
|
||||
static constexpr auto name = std::string_view("3dtk_pose");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
dynamic_pose_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
shader_source_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
protected:
|
||||
static std::error_code parse_transform_info(
|
||||
std::ifstream& in,
|
||||
std::string& line,
|
||||
std::array<glm::vec3, 2>& transform_info
|
||||
);
|
||||
|
||||
static ztu::result<pose_prefetch_lookup::index_type> parse_index(
|
||||
std::string_view filename
|
||||
);
|
||||
};
|
||||
9
include/assets/file_parsers/uos_loader.hpp
Normal file
9
include/assets/file_parsers/uos_loader.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_3dtk_loader.hpp"
|
||||
|
||||
struct uos_loader : generic_3dtk_loader<false, false, false>
|
||||
{
|
||||
static constexpr auto name = std::string_view("uos");
|
||||
};
|
||||
|
||||
8
include/assets/file_parsers/uos_normal_loader.hpp
Normal file
8
include/assets/file_parsers/uos_normal_loader.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_3dtk_loader.hpp"
|
||||
|
||||
struct uos_normal_loader : generic_3dtk_loader<true, false, false>
|
||||
{
|
||||
static constexpr auto name = std::string_view("uos_normal");
|
||||
};
|
||||
8
include/assets/file_parsers/uos_rgb_loader.hpp
Normal file
8
include/assets/file_parsers/uos_rgb_loader.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_3dtk_loader.hpp"
|
||||
|
||||
struct uos_rgb_loader : generic_3dtk_loader<false, true, false>
|
||||
{
|
||||
static constexpr auto name = std::string_view("uos_rgb");
|
||||
};
|
||||
8
include/assets/file_parsers/uosr_loader.hpp
Normal file
8
include/assets/file_parsers/uosr_loader.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_3dtk_loader.hpp"
|
||||
|
||||
struct uosr_loader : generic_3dtk_loader<false, false, true>
|
||||
{
|
||||
static constexpr auto name = std::string_view("uosr");
|
||||
};
|
||||
Reference in New Issue
Block a user