How to disable material specified in egg?

How to disable material specified in the egg file? :question:

Remove it from the egg file?

You can loop through the NodePath children and call clearMaterial on every nodepath you encounter. Or, use find() to find the node which has a material applied.

I made this function but this doesn’t help neither with clearMaterial() nor with setMaterialOff():

def disableMaterials(np):
    np.clearMaterial()
    #np.setMaterialOff()
    for i in range(np.getNumChildren()):
        disableMaterials(np.getChild(i))
disableMaterials(self.model)

The function does iterate through children correctly, but the materials are still displayed.
Editing egg file is not an option: I look for way to do it in code.
EDIT: np.hasMaterial() on the node and its children returns 0. It seems that materials that are specified in egg are not recognized at all.

It’s been propagated down the Geoms, like all of the other state you load from an egg file. You could either iterate through the Geoms and call setGeomState() with an updated state, but it’s probably much easier just to use setMaterialOff() at a higher level, with an override:

np.setMaterialOff(1)

This is, of course, assuming that by “material” you are referring to entries, and not some other state definition.

David

Thank you, David! It worked. I simply forgot to send “1” to setMaterialOff() method :blush: