why my texture can't show on md2 model?

Started by Davi, October 28, 2011, 04:34:20 AM

Previous topic - Next topic

Davi

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 ?

EgonOlsen

Can you post the complete output log please.

Davi

can you see that log

[attachment deleted by admin]

EgonOlsen

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...

Davi

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!


EgonOlsen

??? 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...???

Davi

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>

EgonOlsen

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.

Davi

#8
but my texture has a proper size, 256*256, why the log  show error message that my width is 171?? :( ,it's so strange,

K24A3

Are your textures in a 'drawable-xxdpi' folder?

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

Davi

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?

EgonOlsen

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?

K24A3

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.