Change dynamically texture in jptc android

Started by hemant, July 23, 2014, 07:11:49 AM

Previous topic - Next topic

hemant

I want to change dynamically texture on 3d model.

I have one bottle 3d object and i want to change dynamically bottle lable.

code:

// Create a texture out of the icon...:-)
Texture texture = new Texture(BitmapHelper
.rescale(BitmapHelper.convert(getResources()
.getDrawable(R.drawable.icon)), 64, 64));
TextureManager.getInstance().addTexture("texture", texture);



I am changing cocacola lable to custom dynamically. Is there any way to possible in android.

Please help me.

EgonOlsen

This code for loading a texture is right from the HelloWorld example. The HelloWorld example abuses the app's icon as texture, which is why this looks to complicated. For normal usage, you don't what this. All you need to load a texture is a texture file either res/raw or assets (which i prefer) and load it for example like


Texture t = new Texture(context.getAssets().open(name), true);


To change a part of the bottle, the easiest way would be to split the bottle model into two and retexture the one with the label. Another approach is to use different textures or use an implementation of an ITextureEffect to swap parts of the texture on a pixel level. There are other approaches too, like remapping the uv-coordinates of the label ar runtime, but those are more complicated and maybe not needed in this case. How mayne different labels are you going to use and how large are the textures supposed to be?