19 #ifndef SIMULANT_LOADER_H
20 #define SIMULANT_LOADER_H
23 #include <unordered_map>
30 #include "utils/kfs.h"
32 #include "streams/file_ifstream.h"
33 #include "generic/property.h"
34 #include "generic/any/any.h"
37 #include "assets/material.h"
44 std::istream& portable_getline(std::istream& stream, std::string& str);
46 class VirtualFileSystem;
64 typedef std::unordered_map<unicode, smlt::any> LoaderOptions;
68 typedef std::shared_ptr<Loader> ptr;
70 Loader(
const Path& filename, std::shared_ptr<std::istream> data):
75 void into(
Loadable* resource,
const LoaderOptions& options = LoaderOptions()) {
76 into(*resource, options);
79 void into(std::shared_ptr<Loadable> resource,
const LoaderOptions& options=LoaderOptions()) {
80 into(*resource, options);
83 void into(
Window& window,
const LoaderOptions& options=LoaderOptions()) {
93 std::shared_ptr<std::istream> data_;
97 T* thing =
dynamic_cast<T*
>(&loadable);
99 S_WARN(
"Attempted to cast resource to invalid type");
108 virtual void into(
Loadable& resource,
const LoaderOptions& options = LoaderOptions()) = 0;
113 typedef std::shared_ptr<LoaderType> ptr;
117 virtual const char* name() = 0;
118 virtual bool supports(
const Path& filename)
const = 0;
119 virtual Loader::ptr loader_for(
const Path& filename, std::shared_ptr<std::istream> data)
const = 0;
121 bool has_hint(LoaderHint hint) {
122 return (
bool) hints_.count(hint);
126 void add_hint(LoaderHint hint) {
130 std::set<LoaderHint> hints_;
137 TextureFormat format;
138 std::vector<uint8_t> data;
149 void into(
Loadable& resource,
const LoaderOptions& options = LoaderOptions())
override;
152 virtual bool format_stored_upside_down()
const {
return true; }
162 CullMode cull_mode = CULL_MODE_NONE;
167 bool obj_include_faces_with_missing_texture_vertices =
false;
172 bool blending_enabled =
true;
177 std::string override_texture_extension =
"";
180 #define MESH_LOAD_OPTIONS_KEY "mesh_options"