Custom Mesh Plane - Inversed Texture

Hello Monkeys,

Maybe this is an easy question but there’s a good chance that my brain is a bit heated by thinking a while for different coordinate solutions :blush:
I have made a custom plane and now I’m trying to generate the texCoords:

Vector2f[] texCoord = new Vector2f[vertMax]; count = 0; float vert_xmaxf = (float)vert_xmax; float vert_zmaxf = (float)vert_zmax; for (int z = 0; z < vert_zmax; z++) { for (int x = 0; x < vert_xmax; x++) { texCoord[count] = new Vector2f(x/(vert_xmaxf-1), z/(vert_zmaxf-1)); System.out.println("Cnt: " + count); System.out.println("x: " + x/(vert_xmaxf-1)); System.out.println("z: " + z/(vert_zmaxf-1)); count++; } }

The code reverses the texture like a mirror does (two times mirrored). Any ideas why it does that?

Yeah, I only searched for any pic I could use and so the Anno screenshot was just okay :smiley:

Edit: Seems like this was the wrong way to post code. How can I insert these nice scrollable Codeboxes?

There is a sticky post at the top of the main forum page that no one reads. You could be the one person who does. :slight_smile:

As for the texture, it seems like it is y flipped… or your texture coordinates are. Usually, 0 is the bottom of the texture so I guess where you loaded it you didn’t set the invertY properly.

My plane stretches along the x and z axis.

So if you look down from the top, the jME world coordinates start at the top left, but the u v textures inside the texture start from the top bottom?

Then flip the texture the other way. This is not rocket science. I don’t know how you define your material or load your texture or whatever… but if you set yFlip=true and get this then set it false. If you set yFlip-false and get this then set it true.

…then move on to real problems.