| 1 |
#include "SkinInterface.h" |
| 2 |
|
| 3 |
#include <pybind11/pybind11.h> |
| 4 |
|
| 5 |
#include "modelskin.h" |
| 6 |
|
| 7 |
namespace script |
| 8 |
{ |
| 9 |
|
| 10 |
ScriptModelSkin ModelSkinCacheInterface::capture(const std::string& name) |
| 11 |
{ |
| 12 |
return ScriptModelSkin(GlobalModelSkinCache().findSkin(name)); |
| 13 |
} |
| 14 |
|
| 15 |
StringList ModelSkinCacheInterface::getSkinsForModel(const std::string& model) |
| 16 |
{ |
| 17 |
return GlobalModelSkinCache().getSkinsForModel(model); |
| 18 |
} |
| 19 |
|
| 20 |
StringList ModelSkinCacheInterface::getAllSkins() |
| 21 |
{ |
| 22 |
return GlobalModelSkinCache().getAllSkins(); |
| 23 |
} |
| 24 |
|
| 25 |
void ModelSkinCacheInterface::refresh() |
| 26 |
{ |
| 27 |
GlobalModelSkinCache().refresh(); |
| 28 |
} |
| 29 |
|
| 30 |
void ModelSkinCacheInterface::registerInterface(py::module& scope, py::dict& globals) |
| 31 |
{ |
| 32 |
// Declare the model skin |
| 33 |
py::class_<ScriptModelSkin> skin(scope, "ModelSkin"); |
| 34 |
skin.def(py::init<const decl::ISkin::Ptr&>()); |
| 35 |
skin.def("getName", &ScriptModelSkin::getName); |
| 36 |
skin.def("getRemap", &ScriptModelSkin::getRemap); |
| 37 |
|
| 38 |
// Add the module declaration to the given python namespace |
| 39 |
py::class_<ModelSkinCacheInterface> cache(scope, "ModelSkinCache"); |
| 40 |
|
| 41 |
cache.def("getAllSkins", &ModelSkinCacheInterface::getAllSkins); |
| 42 |
cache.def("capture", &ModelSkinCacheInterface::capture); |
| 43 |
cache.def("getSkinsForModel", &ModelSkinCacheInterface::getSkinsForModel); |
| 44 |
cache.def("refresh", &ModelSkinCacheInterface::refresh); |
| 45 |
|
| 46 |
// Now point the Python variable "GlobalModelSkinCache" to this instance |
| 47 |
globals["GlobalModelSkinCache"] = this; |
| 48 |
} |
| 49 |
|
| 50 |
} // namespace script |