2026-01-08 19:23:19 +08:00
|
|
|
|
#pragma once
|
2026-01-09 16:40:30 +08:00
|
|
|
|
#include "math.hpp"
|
|
|
|
|
|
#include <vector>
|
2026-01-08 19:23:19 +08:00
|
|
|
|
|
|
|
|
|
|
namespace basalt::shared::object_loader {
|
|
|
|
|
|
|
2026-01-09 16:40:30 +08:00
|
|
|
|
class Object {
|
|
|
|
|
|
public:
|
|
|
|
|
|
Object(std::vector<math::Vector3>&& vertices, std::vector<math::Triangle>&& triangles);
|
|
|
|
|
|
~Object();
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
size_t get_vertices_count() const;
|
|
|
|
|
|
const math::Vector3* get_vertices() const;
|
|
|
|
|
|
size_t get_triangle_count() const;
|
|
|
|
|
|
const math::Triangle* get_triangles() const;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
std::vector<math::Vector3> vertices;
|
|
|
|
|
|
std::vector<math::Triangle> triangles;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum class ObjectLoaderStatus {
|
|
|
|
|
|
Ready,
|
|
|
|
|
|
Loaded,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief
|
|
|
|
|
|
* @details
|
|
|
|
|
|
* \li 加载的模型的坐标系与Blender一致。
|
|
|
|
|
|
* \li 加载的模型的顶点顺序为CCW,即右手定则确认法线方向。
|
|
|
|
|
|
*/
|
2026-01-08 19:23:19 +08:00
|
|
|
|
class IObjectLoader {
|
|
|
|
|
|
public:
|
|
|
|
|
|
IObjectLoader();
|
|
|
|
|
|
virtual ~IObjectLoader();
|
|
|
|
|
|
|
2026-01-09 16:40:30 +08:00
|
|
|
|
public:
|
|
|
|
|
|
virtual void load();
|
|
|
|
|
|
const Object& get_object(size_t index) const;
|
|
|
|
|
|
size_t get_object_count() const;
|
|
|
|
|
|
|
2026-01-08 19:23:19 +08:00
|
|
|
|
protected:
|
2026-01-09 16:40:30 +08:00
|
|
|
|
ObjectLoaderStatus status;
|
|
|
|
|
|
std::vector<Object> objects;
|
2026-01-08 19:23:19 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace basalt::shared::object_loader
|