| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <map> |
| 7 |
#include <memory> |
| 8 |
#include <span> |
| 9 |
#include <string> |
| 10 |
#include <string_view> |
| 11 |
|
| 12 |
#include <picojson.h> |
| 13 |
|
| 14 |
#include "Common/CommonTypes.h" |
| 15 |
#include "Common/Matrix.h" |
| 16 |
|
| 17 |
#include "VideoCommon/Assets/CustomAsset.h" |
| 18 |
#include "VideoCommon/NativeVertexFormat.h" |
| 19 |
#include "VideoCommon/RenderState.h" |
| 20 |
|
| 21 |
namespace File |
| 22 |
{ |
| 23 |
class IOFile; |
| 24 |
} |
| 25 |
|
| 26 |
namespace VideoCommon |
| 27 |
{ |
| 28 |
struct MeshDataChunk |
| 29 |
{ |
| 30 |
std::unique_ptr<u8[]> vertex_data; |
| 31 |
u32 vertex_stride; |
| 32 |
u32 num_vertices; |
| 33 |
std::unique_ptr<u16[]> indices; |
| 34 |
u32 num_indices; |
| 35 |
PortableVertexDeclaration vertex_declaration; |
| 36 |
PrimitiveType primitive_type; |
| 37 |
u32 components_available; |
| 38 |
Common::Vec3 minimum_position; |
| 39 |
Common::Vec3 maximum_position; |
| 40 |
Common::Matrix44 transform; |
| 41 |
std::string material_name; |
| 42 |
}; |
| 43 |
|
| 44 |
struct MeshData |
| 45 |
{ |
| 46 |
static bool FromJson(const CustomAssetLibrary::AssetID& asset_id, const picojson::object& json, |
| 47 |
MeshData* data); |
| 48 |
static void ToJson(picojson::object& obj, const MeshData& data); |
| 49 |
|
| 50 |
static bool FromDolphinMesh(std::span<const u8> raw_data, MeshData* data); |
| 51 |
|
| 52 |
static bool ToDolphinMesh(File::IOFile* file_data, const MeshData& data); |
| 53 |
|
| 54 |
static bool FromGLTF(std::string_view gltf_file, MeshData* data); |
| 55 |
|
| 56 |
std::vector<MeshDataChunk> m_mesh_chunks; |
| 57 |
std::map<std::string, CustomAssetLibrary::AssetID, std::less<>> |
| 58 |
m_mesh_material_to_material_asset_id; |
| 59 |
}; |
| 60 |
|
| 61 |
class MeshAsset final : public CustomLoadableAsset<MeshData> |
| 62 |
{ |
| 63 |
public: |
| 64 |
using CustomLoadableAsset::CustomLoadableAsset; |
| 65 |
|
| 66 |
private: |
| 67 |
CustomAssetLibrary::LoadInfo LoadImpl(const CustomAssetLibrary::AssetID& asset_id) override; |
| 68 |
}; |
| 69 |
} |