add skeleton:get_color(), skeleton:set_color(...)
This commit is contained in:
@@ -112,6 +112,22 @@ static int l_set_visible(lua::State* L) {
|
||||
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 [] = {
|
||||
{"get_model", lua::wrap<l_get_model>},
|
||||
{"set_model", lua::wrap<l_set_model>},
|
||||
@@ -122,5 +138,7 @@ const luaL_Reg skeletonlib [] = {
|
||||
{"index", lua::wrap<l_index>},
|
||||
{"is_visible", lua::wrap<l_is_visible>},
|
||||
{"set_visible", lua::wrap<l_set_visible>},
|
||||
{"get_color", lua::wrap<l_get_color>},
|
||||
{"set_color", lua::wrap<l_set_color>},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -99,7 +99,7 @@ void SkeletonConfig::render(
|
||||
}
|
||||
model = modelOverride.model ? modelOverride.model : 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace rigging {
|
||||
std::unordered_map<std::string, std::string> textures;
|
||||
std::vector<ModelReference> modelOverrides;
|
||||
bool visible;
|
||||
glm::vec3 tint {1.0f, 1.0f, 1.0f};
|
||||
|
||||
Skeleton(const SkeletonConfig* config);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user