Как отобразить точки на фигуру в режиме P3D? - PullRequest
0 голосов
/ 07 апреля 2020

Как мне сопоставить мои координаты с объектом-боксом, который я использовал в следующем наброске. Я хочу создать что-то вроде этого: enter image description here

Я получил следующий результат: enter image description here

Ниже приведены коды, которые я написал до сих пор:

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);  
  //rotateX(-PI/4);

  for(int row = 0; row < rowCount; row++) {
    float USALatitude = table.getFloat(row, 3);
    float USALongitude = table.getFloat(row, 4);
    String countryName = table.getString(row,1);

    //Mapped Within X-axis of the left side map box
    float mappedLatitude = map(USALatitude,-90, 90, 0, 650);
    System.out.println("USALatitude: " + mappedLatitude);
    float mappedLongitude = map(USALongitude, -180, 180, 0, 300);
    System.out.println("USALongitude: " + mappedLongitude);
    x1 = mappedLatitude;
    y1 = mappedLongitude;
    z1 = -50;

    float tripCountryLatitude = table.getFloat(row, 5);
    float tripCountryLongitude = table.getFloat(row, 6);     
    float tripLatitude = map(tripCountryLatitude, -90, 90, 0, 650);
    System.out.println("TripCountryLatitude: " + tripLatitude);
    float tripLongitude = map(tripCountryLongitude, -180, 180, 0, 300);
    System.out.println("TripCountryLongitude: " + tripLongitude);
    x2 = 700 + tripLatitude;
    y2 = tripLongitude;
    z2 = 250;

    //int tripCountryOccurance = table.getInt(row, 2);  

    //bezierDetail(120);
    noFill();
    stroke(255, 120);
    strokeWeight(1);


    pushMatrix();    
    stroke(#F05252);
    bezier(x1, y1, z1, // First point
           x1 - 150, y1 - 150, z1 - 150, // First intermediate point
           x2 - 150, y2 - 150, z2 - 150, // Second intermediate point
           x2, y2, z2); // Final point
    popMatrix();

  }
}

Как я могу отобразить правильные координаты одной страны на карте в левой части и проецировать безье в страну назначения на карте на правой стороне (Скажите происхождение США слева и пункт назначения Австралия справа)?

...