mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-15 00:11:55 +07:00
mesh asset
This commit is contained in:
@@ -13,6 +13,7 @@ namespace e2d
|
||||
class asset;
|
||||
class library;
|
||||
class text_asset;
|
||||
class mesh_asset;
|
||||
class image_asset;
|
||||
class binary_asset;
|
||||
class shader_asset;
|
||||
|
||||
@@ -30,6 +30,12 @@ namespace e2d
|
||||
static std::shared_ptr<text_asset> load(library& library, str_view address);
|
||||
};
|
||||
|
||||
class mesh_asset final : public content_asset<mesh> {
|
||||
public:
|
||||
using content_asset<mesh>::content_asset;
|
||||
static std::shared_ptr<mesh_asset> load(library& library, str_view address);
|
||||
};
|
||||
|
||||
class image_asset final : public content_asset<image> {
|
||||
public:
|
||||
using content_asset<image>::content_asset;
|
||||
|
||||
@@ -1411,6 +1411,27 @@ namespace e2d
|
||||
return std::make_shared<text_asset>(std::move(content));
|
||||
}
|
||||
|
||||
//
|
||||
// mesh_asset
|
||||
//
|
||||
|
||||
std::shared_ptr<mesh_asset> mesh_asset::load(library& library, str_view address) {
|
||||
const auto mesh_data = library.load_asset<binary_asset>(address);
|
||||
if ( !mesh_data ) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mesh content;
|
||||
if ( !meshes::try_load_mesh(content, mesh_data->content()) ) {
|
||||
the<debug>().error("ASSETS: Failed to create mesh asset:\n"
|
||||
"--> Address: %0",
|
||||
address);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return std::make_shared<mesh_asset>(std::move(content));
|
||||
}
|
||||
|
||||
//
|
||||
// image_asset
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user