VideoCommon: add functionality to prepare for a mesh asset that is loaded from a GLTF file

This commit is contained in:
iwubcode
2024-02-11 13:28:00 -06:00
parent ecfcae8718
commit 60772ed9d2
4 changed files with 713 additions and 0 deletions
+2
View File
@@ -656,6 +656,7 @@
<ClInclude Include="VideoCommon\Assets\CustomTextureData.h" />
<ClInclude Include="VideoCommon\Assets\DirectFilesystemAssetLibrary.h" />
<ClInclude Include="VideoCommon\Assets\MaterialAsset.h" />
<ClInclude Include="VideoCommon\Assets\MeshAsset.h" />
<ClInclude Include="VideoCommon\Assets\ShaderAsset.h" />
<ClInclude Include="VideoCommon\Assets\TextureAsset.h" />
<ClInclude Include="VideoCommon\AsyncRequests.h" />
@@ -1293,6 +1294,7 @@
<ClCompile Include="VideoCommon\Assets\CustomTextureData.cpp" />
<ClCompile Include="VideoCommon\Assets\DirectFilesystemAssetLibrary.cpp" />
<ClCompile Include="VideoCommon\Assets\MaterialAsset.cpp" />
<ClCompile Include="VideoCommon\Assets\MeshAsset.cpp" />
<ClCompile Include="VideoCommon\Assets\ShaderAsset.cpp" />
<ClCompile Include="VideoCommon\Assets\TextureAsset.cpp" />
<ClCompile Include="VideoCommon\AsyncRequests.cpp" />
File diff suppressed because it is too large Load Diff
@@ -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
+3
View File
@@ -20,6 +20,8 @@ add_library(videocommon
Assets/DirectFilesystemAssetLibrary.h
Assets/MaterialAsset.cpp
Assets/MaterialAsset.h
Assets/MeshAsset.cpp
Assets/MeshAsset.h
Assets/ShaderAsset.cpp
Assets/ShaderAsset.h
Assets/TextureAsset.cpp
@@ -216,6 +218,7 @@ PRIVATE
imgui
implot
glslang
tinygltf
)
if(_M_X86_64)