We are about to switch to a new forum software. Until then we have removed the registration on this forum.
this code is cut down from a bigger example so it's probably a bit verbose.
it creates a bunch of coordinates and puts them in a pvector list.
it then uses this list to define the top (POLYGON) and then the sides (QUAD STRIP) of a cylinder using pshapes. it then puts both these child pshapes into a GROUP pshape.
and it looks fine in 3.0b7 but after upgrading to 3.1.1 there are extra lines in the image.
// bug?
String WIRE_COLOUR = "ff00ff00";
int SEGMENTS = 12;
int BUTTON_RADIUS = 25;
int TOP = 25;
PShape shape1, shape2;
void setup() {
size(600, 600, P3D);
shape1 = createKey(-50, 0);
shape2 = createKey(50, 0);
}
PShape createKey(float x, float y) {
ArrayList<PVector> points = new ArrayList();
for (int i = 0; i < 24; i++) {
float angle = i * TWO_PI / SEGMENTS;
points.add(new PVector(x + BUTTON_RADIUS * cos(angle), y + BUTTON_RADIUS * sin(angle)));
}
// top
PShape top = createShape();
top.beginShape(POLYGON);
top.noFill();
top.stroke(255, 0, 0);
top.strokeWeight(10);
for (PVector p : points) {
top.vertex(p.x, p.y, TOP);
}
// close circle
top.vertex(points.get(0).x, points.get(0).y, TOP);
top.endShape();
// sides
PShape sides = createShape();
sides.beginShape(QUAD_STRIP);
sides.noFill();
sides.stroke(unhex(WIRE_COLOUR));
sides.strokeWeight(2);
for (PVector p : points) {
sides.vertex(p.x, p.y, 0);
sides.vertex(p.x, p.y, TOP);
}
// close strip
sides.vertex(points.get(0).x, points.get(0).y, 0);
sides.vertex(points.get(0).x, points.get(0).y, TOP);
sides.endShape();
// add children to shape
PShape shape = createShape(GROUP);
shape.addChild(top);
shape.addChild(sides);
return shape;
}
void draw() {
background(0);
camera(100, 200, 100, 0, 0, 0, 0, 1, 0);
scale(2);
shape(shape1);
shape(shape2);
noLoop();
save("buttons.png");
}
it looks like the last point of every quad in a quad strip is being connected to the first point. will investigate.
i guess my question is 'am i doing something wrong?' or 'anybody else seen this?'
3.0b7
3.1.1
Answers
if i comment out line 53 then the lines go away.
if i swap lines 53 and 54 the lines go away.
Did you ever report this as a bug, and if so did you hear anything back?
Ran into a version of this recently, Processing 3.2.1 on OS X 10.10.5 -- think I figured it out.
I think you are right that there is a bug in QUAD_SHAPE. This was driving me nuts so I created a test sketch that uses the beginShape sample data for a QUAD_SHAPE to confirm. Detailed explanation in code comments.
Drag the mouse around to view the extra lines.
Also koogs, if you are glutton for debugging punishment, here is remixed version of your sample sketch with the line error in full glory. Press +/- to cycle segments down to 2, drag the mouse to get a good angle on the inter-child and first-child-to-origin buggy line drawing.
I reported it as bug 4656
@koogs -- the bug in quad edge closing code was found and this was resolved.
It was a single change to
addQuadStripEdges()
-- atrue
that should have beenfalse
.Cool, thanks.