Change textures of a multitexture mesh

Hi there,

As I do use chicken to export my multitextured mesh and load it in Panda as one block, I don’t apply textures with any Panda code and I don’t define any textureStage -> So, I don’t have a direct access to the specific tex I would like to change.

How can I change a specic texture ?
I tried to do it directly on my model which provide strange results + errors:

DirectStart: Starting the game.
Known pipe types:
  osxGraphicsPipe
(all display modules loaded.)
:gobj(error): created-shader: (24) : error C5108: unknown semantics "UNKNOWN" specified for "l_normal"
:gobj(error): created-shader: (24) : error C5041: cannot locate suitable resource to bind parameter "l_normal"
:gobj(error): created-shader: (64) : error C5108: unknown semantics "UNKNOWN" specified for "l_normal"
:gobj(error): created-shader: (64) : error C5041: cannot locate suitable resource to bind parameter "l_normal"
:gobj(error): created-shader: (24) : error C5108: unknown semantics "UNKNOWN" specified for "l_normal"
:gobj(error): created-shader: (24) : error C5041: cannot locate suitable resource to bind parameter "l_normal"
:gobj(error): created-shader: (64) : error C5108: unknown semantics "UNKNOWN" specified for "l_normal"
:gobj(error): created-shader: (25) : error C5108: unknown semantics "UNKNOWN" specified for "vtx_normal"

I imagine the answer may be something like read the .bam file and find the desired tex and change it but how ?

Thanks in advance

You can use nodePath.findTextureStage(‘name’) or nodePath.findAllTextureStages() to get the TextureStages that are automatically created for your model. When you know the name of the one you want, you can find it directly by name; or if you don’t know the name, you can iterate through the list returned by findAllTextureStages().

Anyway, when you find the TextureStage you’re looking for, you can use it to override the textures on the model.

David

Is there a similar way to find a specific set of UV (or polygons) ?
The aim here would be to apply a texture on top of an other with TextureStage.MDecal

I’m not sure what you’re looking for here. A UV set is a named set of coordinates that are applied to vertices. You want to look at a set of polygons and figure out what UV sets are applied to it? Or you want to figure out which set of polygons in a model have a given UV set applied?

Both of these are possible by iterating through the low-level geometry and examining the actual vertex data, but there’s not a high-level function to do it for you. Still, it’s a weird thing to do. Don’t you know what UV sets you have already applied to your geometry before you start? Just structure your model so that all of the pieces that have a particular UV set are grouped under a common node, and then you won’t have to do any hunting and searching at runtime.

David

There’s many possibilities to achieve the effect I’d like to perform (update a wall texture while Panda is running):
1- Change the texture itself - Disadvantage: The tex is used for different wall parts.
2- Create two wall-meshes and show the second wall with the new texture hiding the first wall mesh.
3- Apply the new texure with TextureStage.MDecal or TextureStage.MBlend to the desired polygon (one wall).

I know how to perform the two first ones but the third option looks the most obvious to me. In order to do it, I must say to panda to apply the textureStage to that specific polygon (wall)…
Now, how can I find it with panda ?

You have to isolate the polygon in question into its own node in the model, and then find that node at runtime, for instance using model.find(’**/mywall’).

David