Showing/Hiding Textures using python + need help on using vidTexture module

Hi, I am trying to find a way to enable and disable texture channels of a material on an object inside a game using python. However I can’t seem to yield anything straight forward from google. Does anyone know any good tutorials around? thank you very much.
Also Is there a way I can change the opacity of an entire object without having to go through every materials on it?

Thank you very much in advance and please excuse my lack of knowledge if I am not using the correct terms :smiley:

Texture control through python is fairly limited. You could look at the videoTexture module, I’ve never used it so can’t help you there.

Opacity can be controlled through ipo curves, which in turn can be manipulated with python, and it might be possible to control texture channels the same way.

Thanks for your suggestions, I will definitely look in to those! :smiley:

Excuse me, does anyone know how to apply video Texture to just one object but not all the objects in the scene that share the same material?

Thanks in advance

I think that you should be able to create ‘dummy’ textures in all of the other objects, and point those textures’ sources to the first object’s texture source. I think it would look like:

obj[‘dummytexture’] = VideoTexture.Texture()
obj[‘dummytexture’].source = logic.grouptexture

Sorry but would you be able to explain this to me please
I am guessing “dummytexture” is an attribute/property you assign to the object that is to be changed and it holds the reference to a texture, but as far as I am aware .source points to the image to be used for the texture, and I am not sure what logic.grouptexture really does…

Is there any way to declare a new material base on an existing one…?

I have tried every source and documentation that I can find on google but none of them actually helped my dilemma. But I have a feeling that it must be a technique that is somewhat common and people are using it all the time, not necessarily via the videoTexture module.


logic.grouptexture is the texture source from the first object. It might be best if I made a blend for this… By the way, an easy way to implement this might be to just make (Alt-D) instance duplicates of the first object - all other objects will share the mesh, so they should all share textures. Do you want to be able to select the texture on a case-by-case process, or do you just want all the ‘secondary’ objects to share the same texture as the first, ‘base’ object?

Case by Case I guess. I think I am slightly confused, but just to clarify my situation:

  • I have multiple objects that share a single material “Material1”
  • Material1 contains an image texture channel
  • Basically what I want to do is to be able to change the image on any one object one at a time using python.
  • Without affecting any other objects which also uses Material1

Because at the moment, when I change the image on one object, all the other objects change as well.

Thank you very much SolorLune :wink:

Ooh… Well, you’ll have to separate the materials for each individual object - since they all share materials (and so all share images), changing one will (naturally) change them all.

EDIT: So, you should create a new material (and a new image) for each object.

Haha okay, Thanks a lot for trying to help :stuck_out_tongue: I guess I wasn’t explaining clearly enough
I will probably do exactly that then