setTexture () method doesn't understand function

Can anyone help me explain what this method does? After looking at it for a long time, I can’t understand it. Especially for this TextureStage multi-texture state.

你好,

This version of set_texture allows you to assign a texture to a specific TextureStage, which is necessary for multitexturing. The simple version of set_texture assumes you want to assign the texture to the default TextureStage (TextureStage.get_default()).

If you want to know more about multitexturing, see this manual page.

For example, if a model has not only a regular color texture applied, but also a normal map, then the color texture is assigned to one TextureStage and the normal map is assigned to another TextureStage (because the latter needs to use a different texture mode):

model = base.loader.load_model("my_model")
color_tex = base.loader.load_texture("color.png")
normal_tex = base.loader.load_texture("normal.png")
ts_color = TextureStage("color")
ts_normal = TextureStage("normal")
ts_normal.set_mode(TextureStage.M_normal)
model.set_texture(ts_color, color_tex)
model.set_texture(ts_normal, normal_tex)

Hope this helps.

Hmm, I seem to understand, thank you very much!