正在处理P3D动画,而将工件留在后面

问题描述 投票:0回答:1

我正在尝试使用此代码在Processing的P3D中创建旋转的多维数据集:

int sizes = 500;
int rotation = 0;

void setup() {
  size(500, 500, P3D);
}

void draw() {
  lights();
  translate(sizes/2, sizes/2, 0);
  rotateY(rotation * (PI/180));
  rotateX(rotation * (PI/180));
  background(0);
  box(sizes/2);
  rotation = (rotation + 1);
}

当我运行它时,立方体会按我的意愿旋转,但是在其边缘后面留下了奇怪的“伪像”(由于缺少更好的名称)。

enter image description here

什么原因导致此问题,并且可以解决?

processing
1个回答
0
投票

我尝试过此方法,并且有效。也许不像使用backround(0)那样,而是像背景函数一样手动将每个像素设置为黑色。

int sizes = 500;
int rotation = 0;

void setup() {
  size(500, 500, P3D);
}

void draw() {
  fill(255);
  lights();
  translate(sizes/2, sizes/2, 0);
  rotateY(rotation * (PI/180));
  rotateX(rotation * (PI/180));

  loadPixels();
  for(int i = 0; i < pixels.length; i++) pixels[i] = color(0);

  box(sizes/2);
  rotation = (rotation + 1);
}
© www.soinside.com 2019 - 2024. All rights reserved.