How to reapply textures from TextureManager?

Started by dudo24, May 14, 2014, 10:03:00 PM

Previous topic - Next topic

dudo24

The concept of my project is that I have a textured 3D model of a car.
And I want to be able to change textures on the 3d model by press of a button (like a yellow car after button press turns to blue for example).
I have my textured 3D model rendered, that wasn't a problem.
My approach to the texture change was that I have two .3ds files of the same model but each file has different textures (but same names).
So I would remove all the textures which belong to the model from the TextureManager and load new textures from file and store them in the TextureManager.
But now I don't know how to tell TextureManager to apply all those textures.
Because it does automatically and I couldn't find function for this in the specification.
Only way I got it to work was to reload the whole object with the new textures. But that is not very efficient.

So my question: Am I using the right approach? and: How to tell TextureManager to reapply textures on a 3D model.

Thank you


dudo24

#2
It didn't quite work. I'll give it a few hours tomorrow and we'll see.

kkl

Hi Egon,

Does the method proposed process sequentially per texture during the next render pass? Or all textures are loaded first, then remove the existing textures? Or vice-versa?

EgonOlsen

It will removes all old textures at once in the new frame and then upload the new ones on demand.

dudo24

Ok, so I successfully replaced textures. First I unloaded them and then I replaced them. Thank you for your advice.

I also figured out how to change material color. I just needed to find out how does TextureManager store materials. The process was the same I unloaded the material and replaced it with a new texture of set color that i created.

But I have more questions regarding this topic. I can only replace already existing textures. If I add new textures into TextureManager it has no effect, those textures do not render. So I was thinking that when creating 3D model (a cube lets say) in Blender I add a fully transparent texture layer on each side of the cube on top of material. And then later I'm able to replace those transparent textures with other textures if needed. But when I rendered the cube the whole object was transparent the material layer underneath was not visible. And I couldn't quite figure out how to use the TextureInfo class if I wanted the TextureManager to automatically apply the textures on the cube model.

So my question is how to effectively solve problem of adding texture on already rendered 3D object in a way that TextureManager does all the work for me like when I first load the object.
If I'm not clear enough I can try to explain myself better.

Thank you. I appreciate your help.

EgonOlsen

I'm not sure what the exact question is, but i'll give some general hints. Maybe they help...

jPCT's file importers load either the texture or the diffuse color of a material. They don't load both. So once you assign a texture to a polygon, this will be taken instead of the material's color.

Before the first rendering, the object will be compiled. After that, you can still change the textures but what should become an individual texture can only do so if it was one before compilation. An example: A six sided cube that had the same texture on all sides can't be changed in a way that each side gets its own texture. If you want that, you have to assign an individual texture to each side before the compilation happens.

dudo24

Ok, now I get it completely. Thank you very much for your advice and your time.