Archive 17/01/2023.

Set texture for all materials a model has

GodMan

I was trying to figure the best way to set a texture for all materials on a model.

I know you can get one material, and set it like so.

`Texture2D* concretebubble = cache->GetResource<Texture2D>("Textures/concrete_bubble.tga");`
`Material* tutorialGround = `cache->GetResource<Material>`("Materials/foun_concrete_orangestripe.xml"); // Was tutorial ground material`
`tutorialGround->SetTexture(TU_DETAIL, concretebubble);`

But what is the best method, for setting the detail texture for all materials without declaring each material.

Modanung

You could wrap a for-loop into a function that uses the model’s GetNumGeometries() as the range of the loop along with a naming convention for easy generalisation.

GodMan

Sounds like a good idea. Thanks