问题
我尝试使用处理开发其中一个amazing 3d map visualization。我在我的椭圆上得到了闪烁的效果,我移动了地图。我该如何解决这个问题?
代码
PImage europeMapImage;
MercatorMap mercatorMap;
PVector berlin;
PVector london;
PVector venice;
PVector istanbul;
void setup() {
europeMapImage = loadImage("europe.jpg");
size(900, 500, P3D);
smooth();
MercatorMap mercatorMap = new MercatorMap(900, 500, 68.75, 33.86, -34.71, 85.34);
berlin = mercatorMap.getScreenLocation(new PVector(52.5, 13.34));
london = mercatorMap.getScreenLocation(new PVector(51.5f, -0.1f));
venice = mercatorMap.getScreenLocation(new PVector(45.44, 12.34));
istanbul = mercatorMap.getScreenLocation(new PVector(41.01, 28.98));
}
void draw() {
background(#000000);
camera(mouseX, 2*mouseY, 400, width/2, height/2, 0, 0, 1, 0);
image(europeMapImage, 0, 0, width, height);
fill(0, 255, 200, 200);
stroke(#ffffff, 200);
line(berlin.x, berlin.y, venice.x, venice.y);
noStroke();
ellipse(berlin.x, berlin.y, 12, 12);
ellipse(london.x, london.y, 12, 12);
ellipse(venice.x, venice.y, 12, 12);
ellipse(istanbul.x, istanbul .y, 12, 12);
}
答案 0 :(得分:2)
对我来说看起来像z-fighting,试着简单地将Z上的椭圆移动一点。
这是一个粗略的测试(没有测试 - z值可能是正面的或负面的):
PImage europeMapImage;
MercatorMap mercatorMap;
PVector berlin;
PVector london;
PVector venice;
PVector istanbul;
void setup() {
europeMapImage = loadImage("europe.jpg");
size(900, 500, P3D);
smooth();
MercatorMap mercatorMap = new MercatorMap(900, 500, 68.75, 33.86, -34.71, 85.34);
berlin = mercatorMap.getScreenLocation(new PVector(52.5, 13.34));
london = mercatorMap.getScreenLocation(new PVector(51.5f, -0.1f));
venice = mercatorMap.getScreenLocation(new PVector(45.44, 12.34));
istanbul = mercatorMap.getScreenLocation(new PVector(41.01, 28.98));
}
void draw() {
background(#000000);
camera(mouseX, 2*mouseY, 400, width/2, height/2, 0, 0, 1, 0);
image(europeMapImage, 0, 0, width, height);
fill(0, 255, 200, 200);
pushMatrix();//isolate coordinate system
translate(0,0,10);//play with the z value to for better results
stroke(#ffffff, 200);
line(berlin.x, berlin.y, venice.x, venice.y);
noStroke();
ellipse(berlin.x, berlin.y, 12, 12);
ellipse(london.x, london.y, 12, 12);
ellipse(venice.x, venice.y, 12, 12);
ellipse(istanbul.x, istanbul .y, 12, 12);
popMatrix();//return to Processing's regular coordinate system
}