How to change assimp model's texture in runtime?

I have an ofxassimp model. I want to change its texture image in runtime. But I can not find something like this pseudo command:

assimpmodel.getMeshHelper(0).getTexturePtr().setImage(ofimage);

How I can do that?

I found a way;

//loading texture images
ofImage textureimage[2];
textureimage[0].loadImage("texture0.jpg")
textureimage[1].loadImage("texture1.jpg");

//a variable to select the texture image to be used
short tno = 0;

//the command to load the selected texture    
assimpmodel.getMeshHelper(0).getTexturePtr()->loadData(textureimage[tno].getPixels(), textureimage[tno].width, textureimage[tno].height, textureimage[tno].getTextureReference().getTextureData().glTypeInternal);

Is there another way which can run faster then this “oftexture.loadData()” method? I mean a faster way, for example, which can simply switch a pointer to the ofimage.

you can probably just do:

*assimpmodel.getMeshHelper(0).getTexturePtr() = textureimage[tno].getTextureReference()

Wohoo it works with no fps loss. Thank you Arturo.

hey guys,

i tried this but it seems that the texture is not wraped correctly arround my object. my mesh gets colored in one color depending of what texture i use. is there something i am missing? i tried it with the assimp example and used the given textures which are allready used for the models in the example.

//loading texture images
ofImage textureimage[2];
textureimage[0].loadImage("texture0.jpg")
textureimage[1].loadImage("texture1.jpg");

*assimpmodel.getMeshHelper(0).getTexturePtr() = textureimage[tno].getTextureReference()

It works like a charm. Try it first on a simple textured box. Then you can try again on more complex meshes.
(My mesh is not simple, it is an animated human character)

tried this in of 0.9 and it won’t work:
*assimpmodel.getMeshHelper(0).getTexturePtr() = textureimage[tno].getTextureReference()"

gives this error:

“no member named getTextureptr in ofxAssimpMeshHelper”

Any ideas - I’ve had no luck :((

TIA