本文整理汇总了C++中AssetLoader::load方法的典型用法代码示例。如果您正苦于以下问题:C++ AssetLoader::load方法的具体用法?C++ AssetLoader::load怎么用?C++ AssetLoader::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssetLoader
的用法示例。
在下文中一共展示了AssetLoader::load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deserialized
Scene Scene::deserialized(io::ReaderRef reader, AssetLoader<StaticMesh>& mesh_loader, const AssetPtr<Material>& default_material) {
y_profile();
struct Header {
u32 magic;
AssetType type;
u32 version;
u32 statics;
u32 lights;
bool is_valid() const {
return magic == fs::magic_number &&
type == AssetType::Scene &&
version == 2;
}
};
auto header = reader->read_one<Header>();
if(!header.is_valid()) {
y_throw("Invalid header.");
}
Scene scene;
scene.static_meshes().set_min_capacity(header.statics);
scene.lights().set_min_capacity(header.lights);
{
for(u32 i = 0; i != header.statics; ++i) {
auto id = reader->read_one<AssetId>();
auto transform = reader->read_one<math::Transform<>>();
if(id == AssetId::invalid_id()) {
log_msg("Skipping asset with invalid id.", Log::Warning);
continue;
}
try {
auto mesh = mesh_loader.load(id);
auto inst = std::make_unique<StaticMeshInstance>(mesh, default_material);
inst->transform() = transform;
scene.static_meshes().emplace_back(std::move(inst));
} catch(std::exception& e) {
log_msg(fmt("Unable to load asset: %, Skipping.", e.what()), Log::Warning);
continue;
}
}
}
{
for(u32 i = 0; i != header.lights; ++i) {
// load as point, then read on top. Maybe change this ?
auto light = std::make_unique<Light>(Light::Point);
reader->read_one(*light);
scene.lights().emplace_back(std::move(light));
}
}
return scene;
}
示例2: loadMaterialTestModel
//////////////////////////////////////////
// Standard Material Test Models
//////////////////////////////////////////
std::shared_ptr<TriangleMesh> loadMaterialTestModel( AssetLoader & loader )
{
std::string modelBasePath = "models";
//auto mesh = loader.load( modelBasePath + "/dacunni/material_test1.obj" );
//auto mesh = loader.load( modelBasePath + "/dacunni/material_test1.stl" );
auto mesh = loader.load( modelBasePath + "/tf3dm.com/soccerball/untitled.ply" );
//auto mesh = loader.load( modelBasePath + "/uvsphere.ply" );
//auto mesh = loader.loadMultiPartMerged( modelBasePath + "/test_objects/mori/testObj.obj" );
#if 0
auto mesh = loader.loadMultiPartMerged( modelBasePath + "/test_objects/mitsuba/mitsuba.obj" );
#endif
#if 0
mesh->makeCanonical();
#endif
#if 1
mesh->accelerator = new TMOctreeAccelerator( *mesh );
mesh->accelerator->build();
#endif
return mesh;
}