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 › Get Rid of Jagged Edges
Page Index Toggle Pages: 1
Get Rid of Jagged Edges (Read 748 times)
Get Rid of Jagged Edges
Mar 19th, 2008, 5:52am
 
Is there anyway to get rid of those nasty jagged edges? Smooth() works well for 2D but there doesn't seem to be a 3D version. I read somewhere that blurring the cross sections might help, but I don't know how to do that. Any ideas or suggestions would be great.
Re: Get Rid of Jagged Edges
Reply #1 - Mar 19th, 2008, 8:06am
 
I think this might help
http://processing.org/reference/hint_.html

specifically

Code:
hint(ENABLE_OPENGL_4X_SMOOTH); 


that is if your using OPENGL...

MattD
Re: Get Rid of Jagged Edges
Reply #2 - Mar 21st, 2008, 3:40am
 
Thanks for the reply. The only problem is that I was working in P3D. I turned over to openGL and there seems to be a problem. When you zoom in all the way there is a lot of white space. Here is my code.
Change opengl to P3D and get rid of the import to see what it looks like in P3D.
Quote:


import processing.opengl.*;

float[] tr = new float[20];
void setup(){
size(1000, 1000, OPENGL);
background(255);

for(int i=0; i<tr.length; i++){
tr[i]= 94;
}

}



void draw() {
lights();
 background(255);
 float cameraY = height/2.0;
 float fov = mouseX/float(width) * PI;
 float cameraZ = cameraY / tan(fov / 2.0);
 float aspect = float(width)/float(height);
 if(mousePressed) {
   aspect = aspect / 2.0;
 }
 perspective(fov, aspect, cameraZ/10.0, cameraZ*10.0);
 
 translate(width/2+30, height/2, 0);
 rotateX(-PI/6);
 rotateY(PI/3 + mouseY/float(height) * PI);
pushMatrix();
 for(int i=0; i<tr.length; i++){
 box(tr[i]);
 }
 popMatrix();



for(int i=0; i<tr.length; i++){

tr[i]+= i+1;
pushMatrix();
//translate(height/2, width/2);





if (mousePressed == true) {
 
 
   noStroke();
   fill(100,i+100,i+100,i+25);
}
else {
  stroke(100,i+100,i+100,i+50);
 noFill();
 
 }
   translate(-200, 200, -200);
 beginShape();
 curveVertex(tr[i],  mouseY+100, tr[i]);
curveVertex(mouseY+50,  mouseX, tr[i]);
curveVertex(68+tr[i],  19, tr[i]);
curveVertex(-21,  -100, tr[i]);
curveVertex(-50, -mouseY);
curveVertex(-tr[i], -tr[i] );
endShape();
if (tr[i]>width*9){
 tr[i]=0-1;
 
}
popMatrix();
}

}


Re: Get Rid of Jagged Edges
Reply #3 - Mar 21st, 2008, 10:30pm
 
I'm not sure I completely understand the problem. There was a lot of white in the P3D one too. Are you referring to the near and far clipping plane in the OPENGL version? If so you should look at increasing the numbers that you are providing in perspective();

If not, I think I need some more info.
Page Index Toggle Pages: 1