Set texture for all materials a model has

#1

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.

0 Likes

#2

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.

0 Likes

#3

Sounds like a good idea. Thanks

1 Like