One weird problem

Hi, all! I wrote the following simple program and it works well with the texturing, however if I comment out the red part, the two lines of code, the texture will not be rendered properly. Pls have a try of that, the "url_texture " should be changed to your own path of texture whatever you like. Thanks a lot.


import com.jme.scene.shape.Box;

import com.jme.math.Vector3f;

You've actually exposed a bug, but unfortunately it's not what you think.  The texture shouldn't show up at all on your trimesh, even with the box in the scene.  The reason you don't get a texture on your TriMesh is because you are not specifying texcoords.

Try adding this to your app:


        Vector2f[] texCoords = {
            new Vector2f(0,0),
            new Vector2f(1,0),
            new Vector2f(0,1),
            new Vector2f(1,1),

And then using this variable, texCoords in the reconstruct method.

Happy coding!

FYI for anyone else reading this post, the aforementioned bug which inadvertantly carried texcoords over from objects that have coords to those that don't is now fixed and in cvs.

It works :D, Thanks a lot. 

But does that mean I have to set texCoords for every TriMesh objects that I create? Originally, the reconstruct method could be used with only the vertices and indices and it worked quite well.

If it worked before it was a bug.

If you are creating a TriMesh from scratch, you MUST also give texcoords.  How else would it know where to map the texture?