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 › Unwanted holes in a shape
Page Index Toggle Pages: 1
Unwanted holes in a shape (Read 1033 times)
Unwanted holes in a shape
Dec 20th, 2009, 1:21pm
 
Hi,

i created a 3d shape with beginshape but unfortunately there are some erros in it.
take a look at it: dl.dropbox.com/u/2409265/line-2318.png

what's the reason for this?
i use this code:
Code:

for (int q=0; q<NUM_PARTICLES; q++){
for(int i=0; i<NUM_HAIRS; i++) {
beginShape();
if (i+1<NUM_HAIRS && q+1<NUM_PARTICLES){
VerletParticle p=(VerletParticle)hairs[i][q];
vertex(p.x,p.y, p.z);
p=(VerletParticle)hairs[i+1][q];
vertex(p.x,p.y, p.z);
p=(VerletParticle)hairs[i+1][q+1];
vertex(p.x,p.y, p.z);
p=(VerletParticle)hairs[i][q+1];
vertex(p.x,p.y, p.z);
}
endShape();
}
}
Re: Unwanted holes in a shape
Reply #1 - Dec 20th, 2009, 1:51pm
 
> there are some erros in it.

you'll have to be clearer than this.
Re: Unwanted holes in a shape
Reply #2 - Dec 21st, 2009, 1:38am
 
If you take a look at the picture you can see some black triangles in the shape. They look quite interesting but I don't want them. Wink
Re: Unwanted holes in a shape
Reply #3 - Dec 21st, 2009, 6:42am
 
I must be going blind I can't see any black triangles in the image perhaps you might want to edit the picture to indicate where these are.
There are some visual effects due to the image resolution / level of detail and the angle you are viewing the shape.

You might try declaring the type of shape with
Code:
beginShape(QUADS); 

rather than using the default value.
Re: Unwanted holes in a shape
Reply #4 - Dec 21st, 2009, 6:55am
 
Well you may not have seen the black triangles but you gave me the right hint! The holes are gone since I use QUADS. Thanks! Smiley

Looks much better now: dl.dropbox.com/u/2409265/line-0324.png

Another question: Is it possible to smooth the surface by calculating other normals?
Re: Unwanted holes in a shape
Reply #5 - Dec 22nd, 2009, 6:44am
 
Looking good.

Quote:
Is it possible to smooth the surface by calculating other normals?

In some areas you have very smooth color transitions between QUADS and in some it is noticeably different.
There are 3 ways to get the smooth color transitions
(1) using the fill() to set a fill color for  each vertex
(2) use normal for each vertex. Correctly calculated normals can be quite effective if you are using lights.
(3) a combination of (1) & (2)
To give a better answer it would be useful to see the code you now have between
Code:

beginShape(QUADS);

endShape(CLOSE)


Yes the CLOSE is useful if you are drawing it as wire frame so might as well include it.
Smiley
Page Index Toggle Pages: 1