Author Topic: Few Textures are not loading into the model  (Read 1223 times)

Offline SumiGhosh

  • byte
  • *
  • Posts: 3
    • View Profile
Few Textures are not loading into the model
« on: August 20, 2015, 07:23:46 am »
Hi,

below is my code

Code: [Select]
TextureManager.getInstance().addTexture("james_body_lores.jpg", new Texture(getAssets().open("james_body_lores.jpg")));
TextureManager.getInstance().addTexture("james_face_color_lores.jpg", new          Texture(getAssets().open("james_face_color_lores.jpg")));
TextureManager.getInstance().addTexture("james_eye_green_lores.jpg", new Texture(getAssets().open("james_eye_green_lores.jpg")));
TextureManager.getInstance().addTexture("james_mouth_gum_lores.jpg", new Texture(getAssets().open("james_mouth_gum_lores.jpg")));
TextureManager.getInstance().addTexture("james_penis_lores.jpg", new Texture(getAssets().open("james_penis_lores.jpg")));
TextureManager.getInstance().addTexture("james_toenails_lores.jpg", new Texture(getAssets().open("james_toenails_lores.jpg")));
TextureManager.getInstance().addTexture("james_tongue_bump_lores.jpg", new Texture(getAssets().open("james_tongue_bump_lores.jpg")));
TextureManager.getInstance().addTexture("mpants2tex.jpg", new Texture(getAssets().open("mpants2tex.jpg")));
TextureManager.getInstance().addTexture("mcasshoe1tex.jpg", new Texture(getAssets().open("mcasshoe1tex.jpg")));
TextureManager.getInstance().addTexture("james_eye_inner_green.jpg", new Texture(getAssets().open("james_eye_inner_green.jpg")));
TextureManager.getInstance().addTexture("james_eyelashbottran.jpg", new Texture(getAssets().open("james_eyelashbottran.jpg")));
TextureManager.getInstance().addTexture("james_eyelashtoptran.jpg", new Texture(getAssets().open("james_eyelashtoptran.jpg")));
TextureManager.getInstance().addTexture("msock2rtex.jpg", new Texture(getAssets().open("msock2rtex.jpg")));
TextureManager.getInstance().addTexture("mtshirt3tex.jpg", new Texture(getAssets().open("mtshirt3tex.jpg")));
TextureManager.getInstance().addTexture("weavebumpbig4p6.jpg", new Texture(getAssets().open("weavebumpbig4p6.jpg")));
TextureManager.getInstance().addTexture("allback_blacktx.jpg", new Texture(getAssets().open("allback_blacktx.jpg")));
TextureManager.getInstance().addTexture("allback_tr.jpg", new Texture(getAssets().open("allback_tr.jpg")));


I am able to see only few textures on the model. I am using square images for all the texture. I have also attached log of the app.

Update:
I have also tried with loading images which not power of 2 like this

Code: [Select]
InputStream is=null;
    try {
is = getAssets().open("mcasshoe1tex.jpg");
Bitmap bitmap = BitmapHelper.rescale(BitmapFactory.decodeStream(is), 1024, 1024);
Texture texture = new Texture(bitmap);
bitmap.recycle();
TextureManager.getInstance().addTexture("mcasshoe1tex.jpg", texture);
           }catch(Exception e){}
« Last Edit: August 20, 2015, 08:47:16 am by SumiGhosh »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12011
    • View Profile
    • http://www.jpct.net
Re: Few Textures are not loading into the model
« Reply #1 on: August 20, 2015, 08:56:21 am »
It's better to rescale non-power-of-2-textures in a preprocessing step, not in the code itself. Anyway...a log output like this

Code: [Select]
08-20 10:40:57.657    1407-1455/com.threed.jpct.example I/jPCT-AE﹕ Texture named james_mouth_gum_lores.jpg added to TextureManager!

shows that there's no texture named "james_mouth_gum_lores.jpg" in the TextureManager. Looking at your code, I would assume that there is though. But then again, the log doesn't show this. I can only see two "loading texture" outputs in the log. Are you really sure that you are actually calling the texture load code that you've posted?

Offline SumiGhosh

  • byte
  • *
  • Posts: 3
    • View Profile
Re: Few Textures are not loading into the model
« Reply #2 on: August 20, 2015, 09:19:06 am »
Hi EgonOlsen,

I too have seen only two textures are loading out of 16 log output. Sorry, by the way what you meant by actually calling the texture load code.

I have attached hello world code.


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12011
    • View Profile
    • http://www.jpct.net
Re: Few Textures are not loading into the model
« Reply #3 on: August 20, 2015, 09:45:53 am »
I think that something goes wrong in the loading process, but you simply swallow the exception. Remove the try-catch-block around the loading code or at least do something like

Code: [Select]
}catch(Exception e){
throw new RuntimeException(e);
}

to see what's going on.

Offline SumiGhosh

  • byte
  • *
  • Posts: 3
    • View Profile
Re: Few Textures are not loading into the model
« Reply #4 on: August 20, 2015, 10:48:35 am »
Hi,

You were right, it was file not found exception, i have dropped few images in drawables instead of assets folder. That's why texture is not showing.