How can I change the texture in my python program, without having to create lots of materials, each with one texture?
For instance, I have a background plane, with this material:
How can I change, with python, only the texture? (in the example, background12.jpg)
Or do I have to create the whole material by programming?
Regards in advance,
This is not a Python-Ogre specific question. You will get a quicker answer on the normal Ogre forum. I do know that the you can change materials at run time (you don't have to create new ones). Please see the API docs
EDIT: Fixed glaring logical and grammar mistakes.
Sorry, I forgot there were other forums hehe
Messing around with overlays, i made a very opportune mistake! instead of looking for overlayManager on the API I looked out for resourceManager and, after getting used to many manager functions I saw at some place in the forums a materialManager. I believe all the managers work the same, so I will try what I had done with the materialManager.
When I'm able to find the answer I'll post it here.
Heres some code to change an image at runtime:
oceanMat = ogre.MaterialManager.getSingleton().getByName("OceanCg_RTT")
mPass = oceanMat.getTechnique(0).getPass(0)
tState = mPass.getTextureUnitState(0)
and heres some to create a material with a specified texture:
mat = ogre.MaterialManager.getSingleton().create("RttMat",ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)
t = mat.getTechnique(0).getPass(0).createTextureUnitState('Water01.jpg')
Thank you very much!
I arrived at the same solution,
but I forgot to post. hehe
But mine has like, one line for pass another for technique...
and lots of useless variables hehe
So I will change that to your way.
I didn't know how to create materials entirely by programming,
That last piece of code might come in handy
you don't even need most of the variables / steps I've mentioned, but you would end up with quite a long line of code!