Author Topic: How to attach multiple textures to single .3ds file  (Read 544 times)

Offline mallikpavan

  • byte
  • *
  • Posts: 8
    • View Profile
How to attach multiple textures to single .3ds file
« on: March 13, 2015, 07:44:15 am »
Hi

   I tried to load a house.3ds file using JPCT-AE. i have multiple texture files to add. Below is the way how i am attaching the textures.


house= load3DSModel(
            mActivity.getResources().openRawResource(R.raw.cottagen131214),
            0.5f);

      TextureManager.getInstance().addTexture(
            "003.jpg",
            new Texture(
                  BitmapHelper.rescale(BitmapHelper.convert(mActivity
                        .getResources().getDrawable(R.drawable.c003)),
                        128, 128)));

      TextureManager.getInstance().addTexture(
            "009.jpg",
            new Texture(
                  BitmapHelper.rescale(BitmapHelper.convert(mActivity
                        .getResources().getDrawable(R.drawable.c009)),
                        128, 128)));

      TextureManager.getInstance().addTexture(
            "119.jpg",
            new Texture(
                  BitmapHelper.rescale(BitmapHelper.convert(mActivity
                        .getResources().getDrawable(R.drawable.c119)),
                        128, 128)));

      TextureManager.getInstance().addTexture(
            "221 roof gray.jpg",
            new Texture(BitmapHelper.rescale(BitmapHelper.convert(mActivity
                  .getResources().getDrawable(R.drawable.c221roofgray)),
                  128, 128)));

      TextureManager.getInstance().addTexture(
            "Doski113.jpg",
            new Texture(BitmapHelper.rescale(BitmapHelper.convert(mActivity
                  .getResources().getDrawable(R.drawable.doski113)), 128,
                  128)));

      TextureManager.getInstance().addTexture(
            "old3.jpg",
            new Texture(
                  BitmapHelper.rescale(BitmapHelper.convert(mActivity
                        .getResources().getDrawable(R.drawable.old3)),
                        128, 128)));

      TextureManager.getInstance().addTexture(
            "OLDMETAL.jpg",
            new Texture(BitmapHelper.rescale(BitmapHelper.convert(mActivity
                  .getResources().getDrawable(R.drawable.oldmetal)), 128,
                  128)));

      TextureManager.getInstance().addTexture(
            "stone_paving_01.jpg",
            new Texture(BitmapHelper.rescale(BitmapHelper
                  .convert(mActivity.getResources().getDrawable(
                        R.drawable.stone_paving_01)), 128, 128)));

It seems not working. Please help me to apply the multiple textures to my .3ds model. thanks in advance.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: How to attach multiple textures to single .3ds file
« Reply #1 on: March 13, 2015, 08:25:10 am »
You have to assign texture names when adding the textures to the manager that match the ones from the file (before loading the file). If you are unsure, how the textures are actually named in the file (these names aren't always identical to the file names!), have a look at the log output when loading the file. More information can be found here: http://www.jpct.net/wiki/index.php/Loading_models

In addition, try to get rid of this rescaling stuff in your loading code. Just save the textures in a power of two format and load them without any rescaling.

Offline mallikpavan

  • byte
  • *
  • Posts: 8
    • View Profile
Re: How to attach multiple textures to single .3ds file
« Reply #2 on: March 13, 2015, 10:28:19 am »
Thanks a lot for quick reply.

My exact problem is, I downloaded one .3ds model object from net. i found multiple textures in that folder i.e 003.jpg,009.jpg,119.jpg... .

My question is what are the names i need to give while loading textures.

ex:  TextureManager.getInstance().addTexture(
            "003.jpg",
            new Texture(
                  BitmapHelper.rescale(BitmapHelper.convert(mActivity
                        .getResources().getDrawable(R.drawable.c003)),
                        128, 128)));

         is the above is correct or is there any chance to know the given texture names of .3ds file? Please help me. i have been stuck from past 1 week.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: How to attach multiple textures to single .3ds file
« Reply #3 on: March 13, 2015, 12:22:53 pm »
As said: You should be able to see them in the log. If that's not sufficient, have a look here: http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Loader.html#readTextureNames3DS(java.io.InputStream)