We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Workaround for polygon fill problems
Page Index Toggle Pages: 1
Workaround for polygon fill problems? (Read 613 times)
Workaround for polygon fill problems?
Feb 13th, 2006, 6:35pm
 
I'm trying to fill a polygon that has 2 bezier vertices and bumping into all kinds of trouble.  It's not Bug 111 (wherein polygons perpendicular to z-axis don't fill) and it's not quite bug 97 (wherein duplicate vertices cause trouble). Though the suggested fix for bug 97 (add some more vertices that aren't quite on the same spot as others) did cause more of my shape to be filled, but unfortunately not all of it.

here's the simplified version, any suggestions would be wonderful:

void setup(){
 size(500,500,P3D);
 stroke(0);
 fill(255,0,0);
}

void draw(){
 translate(width/2,height/2,0);
 background(255);
 for (int i=0; i<20; i++){
   pushMatrix();
   rotateZ(i*((2*PI)/20));
   translate(0,40,0);    
   beginShape(POLYGON);
   vertex(-5,0,0);
   bezierVertex((mouseX-250)/4,60,0,(mouseY-250)/4,65,0,-5,130,0);
   vertex(5,130,0);
   bezierVertex(10+(mouseY-250)/4,65,0,10+(mouseX-250)/4,60,0,5,0,0);
   endShape();
   popMatrix();
 }
}
Re: Workaround for polygon fill problems?
Reply #1 - Feb 13th, 2006, 7:06pm
 
workaround using Geomerative

hi there, I've written a library that can handle shapes, the filling works with it.

Although this should be also marked as a bug.

Instructions:
1 - download and install Geomerative (for any questions don't doubt on asking)
2 - use the following code:
Code:

import geomerative.*;

void setup(){
size(500,500,P3D);
stroke(0);
fill(255,0,0);
}

void draw(){
translate(width/2,height/2,0);
background(255);
for (int i=0; i<20; i++){
pushMatrix();
rotateZ(i*((2*PI)/20));
translate(0,40,0);
RShape shp = new RShape();
shp.addMoveTo(-5,0);
shp.addBezierTo((mouseX-250)/4,60,(mouseY-250)/4,65,-5,130);
shp.addLineTo(5,130);
shp.addBezierTo(10+(mouseY-250)/4,65,10+(mouseX-250)/4,60,5,0);
shp.draw(g);
popMatrix();
}
}
Re: Workaround for polygon fill problems?
Reply #2 - Feb 13th, 2006, 7:39pm
 
Worked like a charm!  I was a little nervous about defining it as a 2D shape, but it rotates every which way beautifully.

Thank you very much, Ricard.
Page Index Toggle Pages: 1