首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >消除显示在三维空间上的二维物体的闪烁

消除显示在三维空间上的二维物体的闪烁
EN

Stack Overflow用户
提问于 2015-07-15 20:09:24
回答 1查看 143关注 0票数 1

问题

我试着用处理来开发这些惊人的三维地图可视化中的一个。我在我的椭圆上得到了闪烁的效果--我移动了地图。我怎么才能解决呢?

代码

代码语言:javascript
复制
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);

}
EN

回答 1

Stack Overflow用户

发布于 2015-07-15 23:42:13

在我看来,它就像Z格斗,尝试简单地将Z上的椭圆移高一点。

下面是一个粗略的测试(没有测试-z值可能是正的,也可能是负的):

代码语言:javascript
复制
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

}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31440065

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档