Same 3ds object with different textures

Started by zed, May 19, 2008, 07:10:27 PM

Previous topic - Next topic

zed

Hey! A question concerning texturing:

I'm loading a textured 3ds model and it's respective textures. So far everything works fine and the model is displayed correctly. Now I'm running into problems, since I want to use the same model again in the scene, but with a different texture attached to it. Is there any way I can alter the names of the textures referenced by the 3ds model, so I can add another texture to the TextureManager without replacing my old one.

Appreciate any help!

zed

EgonOlsen

You can simply make a copy of that object (using new Object3D(<Object3D>) or Object3D.cloneObject()) and assign the other texture to that. If the model uses more than one texture, it's getting more complicated but should be doable with the PolygonManager.

zed

OK, I wasn't aware of the fact that I could replace the object's texture and keep it correctly mapped just by calling setTexture(), so sorry to bother you with such trivia.

But since you came up with the problem of replacing textures on objects using multiple textures at once, I'm wondering how you would do so. PolygonManager provides a means to get information about every polygons texturing. This would mean I'd have to iterate through all the polygons of an object, putting them in groups of "same texture" and afterwards changing every single polygon's texture accordingly. Would this be the right way to do it, or are there any other, cleverer strategies?

EgonOlsen

No, that's what i thought of. Not very nice, but it should work...