MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / getActiveMaterials

Method getActiveMaterials

plugins/script/interfaces/ModelInterface.cpp:95–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95model::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
131bool ScriptModelNode::isModel(const ScriptSceneNode& node) {

Callers 6

TEST_FFunction · 0.80
setSkinKeyAndCheckModelFunction · 0.80
preMethod · 0.80
preMethod · 0.80

Calls 5

Node_getModelFunction · 0.85
findSkinMethod · 0.80
getSkinMethod · 0.45
getRemapMethod · 0.45
emptyMethod · 0.45

Tested by 1

preMethod · 0.64