| 93 | } |
| 94 | |
| 95 | model::StringList ScriptModelNode::getActiveMaterials() |
| 96 | { |
| 97 | model::ModelNodePtr modelNode = Node_getModel(*this); |
| 98 | if (modelNode == NULL) return model::StringList(); |
| 99 | |
| 100 | // Get the list of default shaders from this model, this is without any skins applied |
| 101 | model::StringList materials = modelNode->getIModel().getActiveMaterials(); |
| 102 | |
| 103 | // Check if the model is a skinned one, so let's check for active skins |
| 104 | auto skinnedModel = std::dynamic_pointer_cast<SkinnedModel>(modelNode); |
| 105 | |
| 106 | if (skinnedModel) |
| 107 | { |
| 108 | // This is a skinned model, get the surface remap |
| 109 | std::string curSkin = skinnedModel->getSkin(); |
| 110 | |
| 111 | auto skin = GlobalModelSkinCache().findSkin(curSkin); |
| 112 | |
| 113 | if (skin) |
| 114 | { |
| 115 | for (auto& material : materials) |
| 116 | { |
| 117 | std::string remap = skin->getRemap(material); |
| 118 | |
| 119 | if (remap.empty()) continue; |
| 120 | |
| 121 | // Remapping found, use this material instead of the default material |
| 122 | material = remap; |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | return materials; |
| 128 | } |
| 129 | |
| 130 | // Checks if the given SceneNode structure is a ModelNode |
| 131 | bool ScriptModelNode::isModel(const ScriptSceneNode& node) { |