-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Hi,
OS : W10
Processing 3.5.3 JAVA
While creating a new PShape using TRIANGLE_STRIP, some faces are generated but not expected. I'll try to explain it as clearly as possible using 2 examples.
The code below is generating a terrain using TRIANGLE_STRIP.
That terrain is computed every frame since no PShape object is used to store the data.
In this case, beginShape(TRIANGLE_STRIP) end endShape() are working the way we could excpect. No extra faces are created.
void setup() {
size(300, 300, P3D);
}
void draw() {
lights();
translate(height/2, width/2);
rotateX(PI/3);
scale(30);
for (int x = -2; x < 3; x++) {
beginShape(TRIANGLE_STRIP);
fill(200);
strokeWeight(1./30);
for (int y = -2; y < 3; y++) {
vertex(x, y, 2 * noise(x, y) - 1);
vertex(x + 1, y, 2 * noise(x + 1, y) - 1);
}
endShape();
}
}
The following image is the result of the code above. As you can see, the result is great.

If now, we start using PShape objects to create the same result as above, some extra faces are created.
The code below is working the same way as the first one but instead of computing the shape at every frame, it is now stored in a PShape object.
PShape s;
void setup() {
size(300, 300, P3D);
s = createShape();
for (int x = -2; x < 3; x++) {
s.beginShape(TRIANGLE_STRIP);
s.noFill();
for (int y = -2; y < 3; y++) {
s.vertex(x, y, 2 * noise(x, y) - 1);
s.vertex(x + 1, y, 2 * noise(x + 1, y) - 1);
}
s.endShape();
}
}
void draw() {
translate(height/2, width/2);
rotateX(PI/3);
scale(30);
lights();
shape(s);
}
The result of that code is shown on the following picture and the issue is clearly visible. Two of the extra created faces are highlighted in red but it goes on all along the terrain.

There was a thread opened here in August 2018: https://discourse.processing.org/t/how-to-prevent-a-pshape-object-to-close/2340
I have searched for a similar open issue with no success. My bad if there is already one created.