Im working on a project with processing, im struggling in programing a globe to be interactive. I want to click on a country and make it give me information about it. For example, if i click on Spain (on the 3D globe) i want to see the population.
Here’s what i have so far, if someone can help me i would really appreaciate it. Thanks in advance!
float rotx = PI/4;
float roty = PI/4;
float rotz = PI/4;
PShape tierra;
PImage texturaTierra;
int x = 0;
int y = 0;
int z = 0;
void setup() {
size(800,600,P3D);
noStroke();
fill(255);
sphereDetail(200);
texturaTierra = loadImage(“Tierra2.jpg”);
tierra = createShape(SPHERE,150);
tierra.setTexture(texturaTierra);
}
void draw() {
background(0);
lights();
pushMatrix(); //esfera
translate(width/2,height/2);
rotateX(rotx);
rotateY(roty);
shape(tierra);
popMatrix();
}
void mouseDragged() {
float rate = 0.005; //velocidad de rotacion
rotx += (pmouseY-mouseY) * rate;
roty += (mouseX-pmouseX) * rate;
}