add skeleton:get_texture
This commit is contained in:
parent
e506d17c50
commit
ffb0ab2f05
@ -110,7 +110,7 @@ body:set_body_type(type: str)
|
||||
|
||||
### Skeleton
|
||||
|
||||
Компонент отвечает за скелет сущности. См. [риггинг](rigging.md).
|
||||
Компонент отвечает за скелет сущности. См. [риггинг](../rigging.md).
|
||||
|
||||
```lua
|
||||
-- Сокращение
|
||||
|
||||
@ -41,6 +41,7 @@ local Skeleton = {__index={
|
||||
get_model=function(self, i) return __skeleton.get_model(self.eid, i) end,
|
||||
get_matrix=function(self, i) return __skeleton.get_matrix(self.eid, i) end,
|
||||
set_matrix=function(self, i, m) return __skeleton.set_matrix(self.eid, i, m) end,
|
||||
get_texture=function(self, s) return __skeleton.get_texture(self.eid, s) end,
|
||||
set_texture=function(self, s, s2) return __skeleton.set_texture(self.eid, s, s2) end,
|
||||
}}
|
||||
|
||||
|
||||
@ -39,6 +39,18 @@ static int l_set_matrix(lua::State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_get_texture(lua::State* L) {
|
||||
if (auto entity = get_entity(L, 1)) {
|
||||
auto& skeleton = entity->getSkeleton();
|
||||
skeleton.textures[lua::require_string(L, 2)] = lua::require_string(L, 3);
|
||||
const auto& found = skeleton.textures.find(lua::require_string(L, 2));
|
||||
if (found != skeleton.textures.end()) {
|
||||
return lua::pushstring(L, found->second);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_set_texture(lua::State* L) {
|
||||
if (auto entity = get_entity(L, 1)) {
|
||||
auto& skeleton = entity->getSkeleton();
|
||||
@ -51,6 +63,7 @@ const luaL_Reg skeletonlib [] = {
|
||||
{"get_model", lua::wrap<l_get_model>},
|
||||
{"get_matrix", lua::wrap<l_get_matrix>},
|
||||
{"set_matrix", lua::wrap<l_set_matrix>},
|
||||
{"get_texture", lua::wrap<l_get_texture>},
|
||||
{"set_texture", lua::wrap<l_set_texture>},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user