add skeleton:get_color(), skeleton:set_color(...)
This commit is contained in:
parent
0c4cdeaa87
commit
52c39d25d0
@ -141,6 +141,20 @@ rig:set_texture(key: str, value: str)
|
|||||||
|
|
||||||
-- Returns the bone index by name or nil
|
-- Returns the bone index by name or nil
|
||||||
rig:index(name: str) -> int
|
rig:index(name: str) -> int
|
||||||
|
|
||||||
|
-- Checks the visibility status of a bone by index
|
||||||
|
-- or the skeleton if no index is specified
|
||||||
|
rig:is_visible([optional] index: int) -> bool
|
||||||
|
|
||||||
|
-- Sets the visibility status of a bone by index
|
||||||
|
-- or the skeleton if no index is specified
|
||||||
|
rig:set_visible([optional] index: int, status: bool)
|
||||||
|
|
||||||
|
-- Returns the color of the entity
|
||||||
|
rig:get_color() -> vec3
|
||||||
|
|
||||||
|
-- Sets the color of the entity
|
||||||
|
rig:set_color(color: vec3)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Component events
|
## Component events
|
||||||
|
|||||||
@ -150,6 +150,12 @@ rig:is_visible([optional] index: int) -> bool
|
|||||||
-- Устанавливает статус видимости кости по индексу
|
-- Устанавливает статус видимости кости по индексу
|
||||||
-- или всего скелета, если индекс не указан
|
-- или всего скелета, если индекс не указан
|
||||||
rig:set_visible([optional] index: int, status: bool)
|
rig:set_visible([optional] index: int, status: bool)
|
||||||
|
|
||||||
|
-- Возвращает цвет сущности
|
||||||
|
rig:get_color() -> vec3
|
||||||
|
|
||||||
|
-- Устанавливает цвет сущности
|
||||||
|
rig:set_color(color: vec3)
|
||||||
```
|
```
|
||||||
|
|
||||||
## События компонента
|
## События компонента
|
||||||
|
|||||||
@ -112,6 +112,22 @@ static int l_set_visible(lua::State* L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_get_color(lua::State* L) {
|
||||||
|
if (auto entity = get_entity(L, 1)) {
|
||||||
|
auto& skeleton = entity->getSkeleton();
|
||||||
|
return lua::pushvec(L, skeleton.tint);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int l_set_color(lua::State* L) {
|
||||||
|
if (auto entity = get_entity(L, 1)) {
|
||||||
|
auto& skeleton = entity->getSkeleton();
|
||||||
|
skeleton.tint = lua::tovec3(L, 2);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const luaL_Reg skeletonlib [] = {
|
const luaL_Reg skeletonlib [] = {
|
||||||
{"get_model", lua::wrap<l_get_model>},
|
{"get_model", lua::wrap<l_get_model>},
|
||||||
{"set_model", lua::wrap<l_set_model>},
|
{"set_model", lua::wrap<l_set_model>},
|
||||||
@ -122,5 +138,7 @@ const luaL_Reg skeletonlib [] = {
|
|||||||
{"index", lua::wrap<l_index>},
|
{"index", lua::wrap<l_index>},
|
||||||
{"is_visible", lua::wrap<l_is_visible>},
|
{"is_visible", lua::wrap<l_is_visible>},
|
||||||
{"set_visible", lua::wrap<l_set_visible>},
|
{"set_visible", lua::wrap<l_set_visible>},
|
||||||
|
{"get_color", lua::wrap<l_get_color>},
|
||||||
|
{"set_color", lua::wrap<l_set_color>},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -99,7 +99,7 @@ void SkeletonConfig::render(
|
|||||||
}
|
}
|
||||||
model = modelOverride.model ? modelOverride.model : model;
|
model = modelOverride.model ? modelOverride.model : model;
|
||||||
if (model) {
|
if (model) {
|
||||||
batch.draw(skeleton.calculated.matrices[i], glm::vec3(1.0f), model,
|
batch.draw(skeleton.calculated.matrices[i], skeleton.tint, model,
|
||||||
&skeleton.textures);
|
&skeleton.textures);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,6 +75,7 @@ namespace rigging {
|
|||||||
std::unordered_map<std::string, std::string> textures;
|
std::unordered_map<std::string, std::string> textures;
|
||||||
std::vector<ModelReference> modelOverrides;
|
std::vector<ModelReference> modelOverrides;
|
||||||
bool visible;
|
bool visible;
|
||||||
|
glm::vec3 tint {1.0f, 1.0f, 1.0f};
|
||||||
|
|
||||||
Skeleton(const SkeletonConfig* config);
|
Skeleton(const SkeletonConfig* config);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user