PShape bezierVertex drawing multiple discreet beziers

edited November 2013 in Programming Questions

SOLVED. I needed to use createShape(GROUP) and then have each discreet bezier be it's own PShape that was made a child of the group. One final issue was that GROUP PShapes need no endShape call.

Wonder if i am missing something easy here. I am optimising an app. It draws >10K bezier curves currently through faux immediate mode. I've moved the bezier drawing over to retained mode using PShapes that are only regenerated when needed and then drawn each frame. It's really much faster.

But, as this little demo code piece shows, the bezier setup in PShape mode is different. One must have the first vertex in the bezier as a ".vertex(...)". But the renderer is drawing a straight line between the last anchor point of the previous bezier and the first anchor point of the next bezier

In the demo code the straight lines is what i don't want... just four bezier curves. What i am looking for is a single shape that holds multiple discreet bezier curves using a list of vertices.

    PShape bot;

void setup() {
  size(640, 360, P3D);
} 

void draw() {
  background(102);
  noFill();
  bot = createShape();
  bot.beginShape();


  for (int i =0; i <4; i++) {
    bot.vertex(width*0.25, 50+i*20, 0);
    bot.bezierVertex( width*0.25, 50+i*20, 0, 
                      mouseX, mouseY+50+i*20, 0, 
                      mouseX, mouseY, 0);
  }
  bot.endShape();

  shape(bot);
}

thanks.

Tagged:

Answers

  • blahblab, could you solve this problem? If so, could you please share with us as I have the same problem now. Thank you!

Sign In or Register to comment.