www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Davi on October 28, 2011, 04:34:20 am

Title: why my texture can't show on md2 model?
Post by: Davi 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 ?
Title: Re: why my texture can't show on md2 model?
Post by: EgonOlsen on October 28, 2011, 08:24:39 am
Can you post the complete output log please.
Title: Re: why my texture can't show on md2 model?
Post by: Davi on October 28, 2011, 10:25:57 am
can you see that log

[attachment deleted by admin]
Title: Re: why my texture can't show on md2 model?
Post by: EgonOlsen 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...
Title: Re: why my texture can't show on md2 model?
Post by: Davi 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!

Title: Re: why my texture can't show on md2 model?
Post by: EgonOlsen 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...???
Title: Re: why my texture can't show on md2 model?
Post by: Davi 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>
Title: Re: why my texture can't show on md2 model?
Post by: EgonOlsen 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.
Title: Re: why my texture can't show on md2 model?
Post by: Davi 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,
Title: Re: why my texture can't show on md2 model?
Post by: K24A3 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.
Title: Re: why my texture can't show on md2 model?
Post by: Davi 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?
Title: Re: why my texture can't show on md2 model?
Post by: EgonOlsen 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?
Title: Re: why my texture can't show on md2 model?
Post by: K24A3 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.