Change Texture of JME Model problem

Hi all,

I have the problem that I cannot solve and need your help.

I exported a model of car from 3DS to DAE. Then, I convert DAE to JME. The car has the texture for car's color,… The image library indicate the to the texture file (image file, skin.jpg for example). I can load the JME model with the texture is ok but the problem is:

I want to change to another texture after I loaded the model (for example, after the car run 100m, I need the car to change to Ferrari texture). If we have to reload the model and copy another texture file to replace the current texture file, I think it's not good for the Game because It will low down the performance. So, my question is how can we change or replace the texture after we loaded the model?

You can simply change the texture on the model with another TextureState.

If your model is a node and the original texture is on a child of this node you will have to set the new texture to this child … setting it only to the node will not override the child texturestate.





TextureState ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
ts.setTexture(TextureManager.loadTexture(this.getClass().getClassLoader().getResource("my new texture"));
model.setRenderState(ts);


Hellmaster.

Thanks guy, but you might misunderstand my problem. Please take a look at these pictures



The result we need to archive:





And this is the texture of the model above



















If we apply directly the Texture State to Node, I don’t think the texture will wrap and scale to fix to the model. I think we need to apply the Material State or Effect to archive that result. How can I do that?

There's no way you can do that automatically… In any 3d engine or framework. What you want is automatic mapping of UV coordinates (the texture guide points) of completelly different textures…



The only way of having it is to make youe second texture the same, lets say, shape/ditribution of parts as the original… You'll have to provide an alternative head texture, with the new eyes in the same place as the old one an so on…



This is because a texture is wrapped and glued to a model parametized by its UV coordinates, which are set at the modeling stage, at a modeling tool, such as 3D Max or Blender.



Maybe you know all this stuff and I'm really misunderstanding what your question is, but I think what you want is impossible for today's computer science…:slight_smile:

:smiley: If you mean generate 3D models from a photo/texture, I may be interested  XD XD :lol:



N.