vengine  0.0.1
3D graphics engine
Loading...
Searching...
No Matches
Model.cpp
Go to the documentation of this file.
2
3std::unordered_map<std::string, std::shared_ptr<ven::Model>> ven::ModelFactory::loadAll(Device& device, const std::string& folderPath)
4{
5 std::unordered_map<std::string, std::shared_ptr<Model>> modelCache;
6
7 for (const auto &entry : std::filesystem::directory_iterator(folderPath)) {
8 if (entry.is_regular_file()) {
9 Logger::logExecutionTime("Creating model " + entry.path().string(), [&]() {
10 const std::string &filepath = entry.path().string();
11 modelCache[filepath] = create(device, filepath);
12 });
13 } else {
14 Logger::logWarning("Skipping non-regular file " + entry.path().string());
15 }
16 }
17 return modelCache;
18}
19
20std::unique_ptr<ven::Model> ven::ModelFactory::create(Device& device, const std::string& filepath)
21{
22 Model::Builder builder{};
23 builder.loadModel(filepath);
24 return std::make_unique<Model>(device, builder);
25}
This file contains the Model Factory class.
Class for device.
Definition Device.hpp:35
static void logWarning(const std::string &message)
Definition Logger.hpp:45
static void logExecutionTime(const std::string &message, Func &&func)
Definition Logger.hpp:35
static std::unordered_map< std::string, std::shared_ptr< Model > > loadAll(Device &device, const std::string &folderPath)
Definition Model.cpp:3
static std::unique_ptr< Model > create(Device &device, const std::string &filepath)
Definition Model.cpp:20
void loadModel(const std::string &filename)
Definition model.cpp:105