www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: zed on May 19, 2008, 07:10:27 pm

Title: Same 3ds object with different textures
Post by: zed on May 19, 2008, 07:10:27 pm
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
Title: Re: Same 3ds object with different textures
Post by: EgonOlsen on May 19, 2008, 07:38:33 pm
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.
Title: Re: Same 3ds object with different textures
Post by: zed on May 20, 2008, 02:21:17 pm
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?
Title: Re: Same 3ds object with different textures
Post by: EgonOlsen on May 20, 2008, 02:48:59 pm
No, that's what i thought of. Not very nice, but it should work...