处理 P3D 动画留下伪影 [英] Processing P3D Animation leaving artifacts behind
本文介绍了处理 P3D 动画留下伪影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用以下代码在 Processing 的 P3D 中制作一个旋转立方体:
I am trying to make a spinning cube in Processing's P3D with this code:
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);
}
当我运行它时,立方体确实按照我的意愿旋转,但是在它的边缘后面留下了奇怪的人工制品"(因为没有更好的名字).
When I run it the cube does spin as I wanted, but there are strange 'artifacts' (for lack of a better name) left behind its edges.
是什么导致了这个问题,能否解决?
What causes this issue, and can it be solved?
推荐答案
我试过了,它奏效了.也许不使用backround(0),而是像background 函数一样手动将每个像素设置为黑色.
I tried this and it worked. Maybe instead of using backround(0), set every pixel to black like the background function does manually.
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);
}
这篇关于处理 P3D 动画留下伪影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文