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.
IndexSuggestions & BugsSoftware Bugs › P3D/openGL shape fill issue
Page Index Toggle Pages: 1
P3D/openGL shape fill issue (Read 5378 times)
P3D/openGL shape fill issue
May 7th, 2005, 7:37pm
 
pretty sure it's related to SAITO's post ( http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1114158993;start=0 ), but it looks like P3D and openGL are having a bit of trouble filling shapes.

Code:

import processing.opengl.*;

float rx, rz = 0; //x, z current rotation
float tgtX, tgtZ = 0; //x, z target rotation
float rSpeed = .06f; //rotation speed
float zoomVal = 0; //zoom value
float zoomInc = 10; //zoom increment (per keypress)
float tgtZoom = 0; //target zoom value
float zoomSpeed = .06f; //zoom speed

void setup () {
size(800, 800, OPENGL);
//size(800, 800, P3D);
}

void draw () {
background(0);
pushMatrix();
zoom();
rotateCamera();
drawCurve();
popMatrix();
}

void drawCurve () {
//-----------CURVE ONE-----------//
stroke(0, 0, 0);
fill(0.3333*255, 0.5569*255, 0.6667*255);
beginShape();
vertex(253.0698, height-673.2793);
bezierVertex(163.5347,height-629.0933, 163.5347,height-629.0933, 171.6743,height-582.5815);
bezierVertex(179.814,height-536.0698, 230.9766,height-461.6509, 285.6279,height-502.3486);
bezierVertex(340.2793,height-543.0464, 386.79,height-569.7905, 354.2324,height-618.6279);
bezierVertex(321.6748,height-667.4653, 283.3022,height-684.9072, 253.0698,height-673.2793);
endShape();


//----------CURVE THREE----------//
stroke(0.7882*255, 0.1843*255, 0*255);
fill(0.9569*255, 0.698*255, 0.1176*255);
beginShape();
vertex(272.8374,height-212.8145);
vertex(203.0698,height-215.1396);
vertex(201.9067,height-151.1865);
bezierVertex(229.8135,height-102.3477, 263.5347,height-120.9531, 263.5347,height-120.9531);
bezierVertex(297.2559,height-139.5586, 329.8135,height-187.2324, 329.8135,height-187.2324);
bezierVertex(326.3262,height-238.3945, 308.8838,height-240.7207, 308.8838,height-240.7207);
bezierVertex(291.4419,height-243.0469, 272.8374,height-212.8145, 272.8374,height-212.8145);
endShape();
}

void rotateCamera () {
translate(width/2, height/2);
if (mousePressed) {
tgtZ = ((float)(mouseX-width/2)/(width/2)*PI);
tgtX = ((float)(mouseY-height/2)/(height/2)*PI);
}
rx += (tgtX-rx) * rSpeed;
rz += (tgtZ-rz) * rSpeed;

rotateX(-rx);
rotateZ(-rz);
translate(-width/2, -height/2);
}

void zoom () {
if (keyPressed) {
if (key == 'a') { tgtZoom += zoomInc; }
else if (key == 'z') { tgtZoom -= zoomInc; }
}
zoomVal += (tgtZoom - zoomVal) * zoomSpeed;
translate(0, 0, zoomVal);
}


in openGL, poly edges are visible in the middle of the shapes.  this may be something intrinsic to openGL, i dunno....

in both openGL and P3D, the orange shape doesn't completely fill.  i tried taking polygons off the xy-plane (perp to z-axis) per SAITO's suggestion in the above post, but no luck getting that lower-left corner on the orange shape to fill in either openGL or P3D.

oh, and all of this works great in P2D.

-d
Re: P3D/openGL shape fill issue
Reply #1 - May 7th, 2005, 7:43pm
 
Where's your MODE for beginShape? If you're using POLYGON it's a known issue.
Re: P3D/openGL shape fill issue
Reply #2 - May 7th, 2005, 8:11pm
 
(beginShape() with no params is beginShape(POLYGON))

make sure that your shapes aren't duplicating points, because that confuses the triangulator. i.e. if bezierVertex() ends on a particular point, don't have a vertex() there too. also don't make vertices loop back to the beginning or you might have trouble there too.
Re: P3D/openGL shape fill issue
Reply #3 - May 7th, 2005, 8:14pm
 
oh right.  i didn't use a mode, not sure what it defaults to but i think prolly POLYGON.  i modified code from the texture() example, which has no mode for beginShape().

so i guess it's a known issue.  sorry bout that...
Re: P3D/openGL shape fill issue
Reply #4 - May 7th, 2005, 8:25pm
 
oops, fry beat me to it.

okay, so if there shouldn't be a bezierVertex() anchor point at the same coords as a vertex(), how do i close a shape with a curve?

also, is it known to cause trouble with the triangulator to have duplicate control points?  or to have a control and anchor point within bezierVertex() at the same point?  i.e.:

Code:

bezierVertex(10,10, 10,10, 20,20);
//or:
bezierVertex(10,10, 20,20, 20,20);


the former is the way flash draws curves, the latter one of the ways illustrator/EPS draws them...
Re: P3D/openGL shape fill issue
Reply #5 - May 7th, 2005, 8:26pm
 
well, it may be a syntax issue.. that if you're duplicating points then it's gonna cause trouble. we'll eventually fix this to be less finicky, but of course in the meantime we'd rather get your sketch working Wink
Re: P3D/openGL shape fill issue
Reply #6 - Jul 28th, 2005, 5:15am
 
same issue as here, i believe:
http://dev.processing.org/bugs/show_bug.cgi?id=97
closing thread.
Page Index Toggle Pages: 1