Author Topic: why my texture can't show on md2 model?  (Read 2618 times)

Offline Davi

  • byte
  • *
  • Posts: 33
    • View Profile
why my texture can't show on md2 model?
« on: October 28, 2011, 04:34:20 am »
public void onSurfaceCreated(GL10 gl, EGLConfig config) {

      world = new World(); 
      world.setAmbientLight(150, 150, 150);   
      TextureManager.getInstance().addTexture("tris3", new Texture(BitmapFactory.decodeResource(this.getResources(), R.drawable.tris3))); 
      snork = Loader.loadMD2(LoadAssets.loadf("tris3.md2"), scale); 
      snork.setTexture("tris3");
      snork.strip(); 
      snork.build(); 
      world.addObject(snork);
}
public void onSurfaceChanged(GL10 gl, int width, int height) {
      if (fb != null) { 
         fb = null; 
      } 

      this.width=width;
      this.height=height;
      fb = new FrameBuffer(gl,width, height); 
}
onDrawFrame(GL10 gl) {
      doAnim(); 
      world.renderScene(fb);
      world.draw(fb);
      fb.display();
}
above is my key code to show texture,the md2 model loading is ok,but the texture can't show on the model,I don't know what wrong is?
Please help me ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: why my texture can't show on md2 model?
« Reply #1 on: October 28, 2011, 08:24:39 am »
Can you post the complete output log please.

Offline Davi

  • byte
  • *
  • Posts: 33
    • View Profile
Re: why my texture can't show on md2 model?
« Reply #2 on: October 28, 2011, 10:25:57 am »
can you see that log

[attachment deleted by admin]

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: why my texture can't show on md2 model?
« Reply #3 on: October 28, 2011, 10:42:37 am »
That's not the important part. I would like to see the part where it actually loads the texture. And please post logs as text in code-tags, not as a jpg...

Offline Davi

  • byte
  • *
  • Posts: 33
    • View Profile
Re: why my texture can't show on md2 model?
« Reply #4 on: October 28, 2011, 11:25:46 am »
jPCT-AE  Loading Texture...
[ 131979264098] - WARNING: Unsupported Texture width (384)... resizing to 256
Loading file from InputStream
....
Skin width:256
Skin height:256
Frame size:1612
Number of skins:5
Number of Vertices:393
Number of Texture coordinates:561
Number of triangles:764
Number of GL_COMMANDS:3833
Number of Frames:198
Reading Texture coordinates
Done!


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: why my texture can't show on md2 model?
« Reply #5 on: October 28, 2011, 12:13:03 pm »
??? Which version of jPCT-AE is that? This message doesn't appear in the last ones. The automatic rescale has been removed and the message has been changed to an error....this can't be from any current version...???

Offline Davi

  • byte
  • *
  • Posts: 33
    • View Profile
Re: why my texture can't show on md2 model?
« Reply #6 on: October 28, 2011, 05:43:33 pm »
oh,I am sorry,my engine is older one, I have download the jpct-ae1.23, and change it as a new one. and then,when I run it,my project has been crashed!!!it is very strange. the older engine doesn't crash,why the new one can crash!
the error log as blew:

ERROR: Unsupported Texture width:171
ERROR:java.lang.RuntimeException
at  com.thread.jpct.Logger.log
at  com.thread.jpct.Texture.loadTexture
at  com.thread.jpct.Texture.<init>

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: why my texture can't show on md2 model?
« Reply #7 on: October 28, 2011, 05:57:08 pm »
That's by design. As said, rescaling of textures isn't supported anymore for various reasons. It's up to you to provide properly sized textures. Texture width and height have to be a power of 2. Everything else will be treated as an error.

Offline Davi

  • byte
  • *
  • Posts: 33
    • View Profile
Re: why my texture can't show on md2 model?
« Reply #8 on: October 28, 2011, 06:03:28 pm »
but my texture has a proper size, 256*256, why the log  show error message that my width is 171?? :( ,it's so strange,
« Last Edit: October 28, 2011, 06:18:58 pm by Davi »

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
Re: why my texture can't show on md2 model?
« Reply #9 on: October 28, 2011, 06:19:44 pm »
Are your textures in a 'drawable-xxdpi' folder?

Place your textures in 'drawable-nodpi' to stop Android from resizing the textures automatically.

Offline Davi

  • byte
  • *
  • Posts: 33
    • View Profile
Re: why my texture can't show on md2 model?
« Reply #10 on: October 28, 2011, 06:36:19 pm »
yeh,it works,Thanks very much. ;)
but the model is still white, the texture can't show on the model, my key code is on the first floor,can you help to find where the wrong is?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: why my texture can't show on md2 model?
« Reply #11 on: October 28, 2011, 10:23:37 pm »
No idea. The code looks fine at first glance. Maybe you can upload the model and the texture, so that i can see for myself?

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
Re: why my texture can't show on md2 model?
« Reply #12 on: October 29, 2011, 06:09:51 pm »
How did you create the 3D Model?

Maybe it's missing UV texture co-ordinates.

Try using the jPCT Object3D function to calculate the texture using sphere mapping to get around invalid UV co-ordinates.