How to set a texture within a defined group to a material?

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
Jac00b
Gnoblar
Posts: 3
Joined: Thu Aug 02, 2012 9:50 pm

How to set a texture within a defined group to a material?

Post by Jac00b »

Hi,

I need to manage multiple resources with same name.
I saw in this post (http://www.ogre3d.org/forums/viewtopic.php?f=4&t=43302) that this was now possible by using resource groups.

The problem is, when I want to set a texture to my material, I have no way to define the group in which my textureName should be searched.

This is what I can do :

Code: Select all

Ogre::TextureUnitState* t = myMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0);
t->setTextureName(myTextureName);
This is what I would like to do :

Code: Select all

Ogre::TextureUnitState* t = myMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0);
t->setTextureName(myTextureName, myGroup);
I also saw that it's possible to retrieve a TexturePtr from a name and a groupName with TextureManager's getByName function but once I have the texturePtr I have no way to apply it to my material.

Am I missing something ? Is there another way to do that ?

Thanks.
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: How to set a texture within a defined group to a materia

Post by areay »

Jac00b wrote: I also saw that it's possible to retrieve a TexturePtr from a name and a groupName with TextureManager's getByName function but once I have the texturePtr I have no way to apply it to my material.

Am I missing something ? Is there another way to do that ?
Just get a TexturePtr and apply it using

Code: Select all

 void Ogre::TextureUnitState::setTexture (const TexturePtr &texPt) 
The online doco doesn't have that API feature but my local 1.8.0 doco does have it ?!!? The online doco also says it was last updated in 2010 for version 1.7.1 so something screwy might be afoot. I'll ask the moderators in another forum. Anyway, try what I suggested anyway.
Jac00b
Gnoblar
Posts: 3
Joined: Thu Aug 02, 2012 9:50 pm

Re: How to set a texture within a defined group to a materia

Post by Jac00b »

Hi Areay,

Thanks for your solution, unfortunately I don't have the setTexture function in my 1.7.4 version. Don't know why.

But, I saw that setTextureName function is loading the texture from its parent group, so maybe if I create my material in the appropriate group I'll be able to load the proper texture. I'll try this and let you know.

If you have any other solution, please let me know.
Thanks.
Jac00b
Gnoblar
Posts: 3
Joined: Thu Aug 02, 2012 9:50 pm

Re: How to set a texture within a defined group to a materia

Post by Jac00b »

Hi,

I tried changing material's group using

Code: Select all

myMaterial->changeGroupOwnership(myGroup);
It works fine, but for the first loading only.
If I load myTexture.jpg in group groupA then I reload my application and try to load myTexture.jpg in group groupB everything is fine, in both cases the correct texture is loaded.
But, when I load textures one after the other, the first loaded texture is always loaded afterwards, no matter on which material or what is the material's group.

Any idea ? advice ?
Thanks.
Post Reply