add assets.parse_model
This commit is contained in:
parent
ac337a4e65
commit
407184250c
@ -56,7 +56,7 @@ local function load_models_list(packs)
|
|||||||
for _, filename in ipairs(file.list("models")) do
|
for _, filename in ipairs(file.list("models")) do
|
||||||
local ext = file.ext(filename)
|
local ext = file.ext(filename)
|
||||||
if ext == "xml" then
|
if ext == "xml" then
|
||||||
registry[filename] = {type="model"}
|
registry[filename] = {type="model", unit=file.stem(filename)}
|
||||||
table.insert(export.filenames, filename)
|
table.insert(export.filenames, filename)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
#include "assets/Assets.hpp"
|
#include "assets/Assets.hpp"
|
||||||
#include "coders/png.hpp"
|
#include "coders/png.hpp"
|
||||||
|
#include "coders/vcm.hpp"
|
||||||
#include "debug/Logger.hpp"
|
#include "debug/Logger.hpp"
|
||||||
#include "engine/Engine.hpp"
|
#include "engine/Engine.hpp"
|
||||||
|
#include "graphics/commons/Model.hpp"
|
||||||
#include "graphics/core/Texture.hpp"
|
#include "graphics/core/Texture.hpp"
|
||||||
#include "util/Buffer.hpp"
|
#include "util/Buffer.hpp"
|
||||||
|
|
||||||
@ -44,7 +46,21 @@ static int l_load_texture(lua::State* L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_parse_model(lua::State* L) {
|
||||||
|
auto format = lua::require_lstring(L, 1);
|
||||||
|
auto string = lua::require_lstring(L, 2);
|
||||||
|
auto name = lua::require_string(L, 3);
|
||||||
|
|
||||||
|
if (format == "xml") {
|
||||||
|
engine->getAssets()->store(vcm::parse(name, string), name);
|
||||||
|
} else {
|
||||||
|
throw std::runtime_error("unknown format " + util::quote(std::string(format)));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const luaL_Reg assetslib[] = {
|
const luaL_Reg assetslib[] = {
|
||||||
{"load_texture", lua::wrap<l_load_texture>},
|
{"load_texture", lua::wrap<l_load_texture>},
|
||||||
|
{"parse_model", lua::wrap<l_parse_model>},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user