How can I adjust the UVs of my quad so my texture isn't flipped?

| | August 6, 2015

My sprite geometry is reversed using matrix so that it is in the XZ plane. This results in the image used for the sprite to also be reversed, which I don’t want:

enter image description here

(source : http://www.badlogicgames.com/wordpress/?p=2032 )

The image is then upside-down (note the 2 and 4):

enter image description here

Would you know how to switch the UVs, or apply a matrix on the image only?

Here is my code to draw the new image (the broken one):

curPix.drawPixmap(modelPix, newX, newY, modelX, modelY, tileResolution, tileResolution);

This is how the plane is modified in “render:”

batch.setProjectionMatrix(cam.combined);
batch.setTransformMatrix(matrix);
batch.begin();
getMap(0).draw(batch);
batch.end();

One Response to “How can I adjust the UVs of my quad so my texture isn't flipped?”

  1. It seems as though you’re just seeing the back of the quad, which will be the reverse of the front.

    To fix this, simply rotate -90 degrees about the z-axis, so the quad is facing up instead of down. You’ll have to move it down the x plane a little after that though.

    Otherwise you can rotate the quad 90 degrees about the z-axis, and then 180 degrees about the x-axis to get it facing up. You probably shouldn’t mess around with the UV coordinates if you’re using a spriteBatch interface.

Leave a Reply to Ben