Author Topic: How to bring a Texture on the Model?  (Read 2105 times)

Offline Yerst

  • byte
  • *
  • Posts: 38
    • View Profile
How to bring a Texture on the Model?
« on: July 09, 2013, 04:53:10 pm »
Hey!
I'm new to jpct and i don't get how to allocate a texure to a Object3D.
I'm working with blender, and want to use the texture mapping blender applies to the model.
This is where i'm currently stuck:

Code: [Select]
TextureManager tm = TextureManager.getInstance();
tm.addTexture("sand",new Texture(BitmapHelper.rescale(BitmapHelper.convert(this.context.getResources().getDrawable(R.drawable.img1348666104)), 64, 64)));
InputStream dsStream = manager.open("untitled.3ds");
cube = Loader.load3DS(dsStream, 1);

world.addObjects(cube);
As expected it only shows a grey object, not my beautiful sand ;)

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: How to bring a Texture on the Model?
« Reply #1 on: July 09, 2013, 05:24:12 pm »
Code: [Select]
cube.setTexture("sand");

Offline Yerst

  • byte
  • *
  • Posts: 38
    • View Profile
Re: How to bring a Texture on the Model?
« Reply #2 on: July 09, 2013, 05:40:18 pm »
Code: [Select]
TextureManager tm = TextureManager.getInstance();
tm.addTexture("sand",new Texture(BitmapHelper.rescale(BitmapHelper.convert(this.context.getResources().getDrawable(R.drawable.img1348666104)), 64, 64)));
InputStream dsStream = manager.open("untitled.3ds");
cube = Loader.load3DS(dsStream, 1);
for (int i = 0;i<cube.length;i++)
{
cube[i].setTexture("sand");
}
world.addObjects(cube);
nothing changed...

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: How to bring a Texture on the Model?
« Reply #3 on: July 09, 2013, 05:53:10 pm »
Are these models black? You can try to call cube.calcTextureWrap(), if it helps your models have no texture coordinates.

Offline Yerst

  • byte
  • *
  • Posts: 38
    • View Profile
Re: How to bring a Texture on the Model?
« Reply #4 on: July 11, 2013, 09:34:05 pm »
Hey!
Thanks for your help!
I forget to unwrap the model in blender  :-[
The second problem was that i used BitmapHelper.rescale, withouth needing it.
I don't know why, but i had problem by choosing other measurements than 64x64.
Looks fine now!