mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
VideoCommon: add functionality to prepare for a mesh asset that is loaded from a GLTF file
This commit is contained in:
60
Source/Core/VideoCommon/Assets/MeshAsset.h
Normal file
60
Source/Core/VideoCommon/Assets/MeshAsset.h
Normal file
@ -0,0 +1,60 @@
|
||||
// Copyright 2023 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <picojson.h>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Matrix.h"
|
||||
|
||||
#include "VideoCommon/Assets/CustomAsset.h"
|
||||
#include "VideoCommon/NativeVertexFormat.h"
|
||||
#include "VideoCommon/RenderState.h"
|
||||
|
||||
namespace File
|
||||
{
|
||||
class IOFile;
|
||||
}
|
||||
|
||||
namespace VideoCommon
|
||||
{
|
||||
struct MeshDataChunk
|
||||
{
|
||||
std::unique_ptr<u8[]> vertex_data;
|
||||
u32 vertex_stride;
|
||||
u32 num_vertices;
|
||||
std::unique_ptr<u16[]> indices;
|
||||
u32 num_indices;
|
||||
PortableVertexDeclaration vertex_declaration;
|
||||
PrimitiveType primitive_type;
|
||||
u32 components_available;
|
||||
Common::Vec3 minimum_position;
|
||||
Common::Vec3 maximum_position;
|
||||
Common::Matrix44 transform;
|
||||
std::string material_name;
|
||||
};
|
||||
|
||||
struct MeshData
|
||||
{
|
||||
static bool FromJson(const CustomAssetLibrary::AssetID& asset_id, const picojson::object& json,
|
||||
MeshData* data);
|
||||
static void ToJson(picojson::object& obj, const MeshData& data);
|
||||
|
||||
static bool FromDolphinMesh(std::span<const u8> raw_data, MeshData* data);
|
||||
|
||||
static bool ToDolphinMesh(File::IOFile* file_data, const MeshData& data);
|
||||
|
||||
static bool FromGLTF(std::string_view gltf_file, MeshData* data);
|
||||
|
||||
std::vector<MeshDataChunk> m_mesh_chunks;
|
||||
std::map<std::string, CustomAssetLibrary::AssetID, std::less<>>
|
||||
m_mesh_material_to_material_asset_id;
|
||||
};
|
||||
} // namespace VideoCommon
|
Reference in New Issue
Block a user