Texture on primitive object appear inverted?

I have used a primitive box and textured it, though the texture appears to be inverted.

How do I flip it horizontally? I think its got something to do with transformation but it confused me a lot.

Here is the code

PImage worldMap;
PShape box;

Table table;
int rowCount;
float x1, y1, z1, x2, y2, z2;

void setup() {
  size(1400, 800, P3D);
  table = new Table("From_USA_Coordinates.tsv");
  rowCount = table.getRowCount();
  worldMap = loadImage("world.topo.bathy.200406.3x5400x2700.jpg"); 
  worldMap.resize(500, 300);
  textureMode(NORMAL);
  fill(255);
  stroke(color(44,48,32));
  box = createShape(BOX, 650, 300, 30);
  box.beginShape(BOX);
  box.endShape();
  box.setTexture(worldMap);
}

void draw() {
  background(255);
  noStroke();
  translate(350, 600, -50);
  rotateX(PI/4);
  //rotateY(PI);
  //rotateZ(PI/4);
  
  shape(box);  
  //Second Box:
  translate(700,0,0);
  shape(box);
  //translate(-1400, 0);  
  //rotate(radians(-10));
1 Like

Hello,

Try this:
box = createShape(BOX, -650, 300, 30);

You could also create your own box and map a texture onto the geometry:
https://processing.org/reference/vertex_.html

:)

1 Like

Thanks @glv This did the trick.

1 Like