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.
Page Index Toggle Pages: 1
3D problem (Read 595 times)
3D problem
May 14th, 2010, 5:06am
 
hi,
I've got a problem with the source exposed in this site in learning-3D-ShapeTransorm section.
I simple wanted to switch the cilinder height orientation through the y-axis (in the source it is oriented through the z-axis) so I exchanged the content of  vertices[].y  with vertices[].z .
The lateral faces of the cilinder are well drawn but the ends simple disappeared and I don't know why (and this happen only for certain values of the variable pts-number of lateral segments, for example pts=3,7,8,300,18)

help me please Cry
Re: 3D problem
Reply #1 - May 14th, 2010, 9:45am
 
We can't tell you why, because WE CAN'T SEE THE CHANGES YOU'VE MADE TO THE CODE.

Please, please, PLEASE, post the code you're talking about.
Re: 3D problem
Reply #2 - May 14th, 2010, 9:51am
 
THIS IS THE SOURCE TO CALL IN THE DRAW method: playing with pts variable you can see the problem (for example turning it from 5 to 7)


void cilindro_penta(){
 //------------------------------------------
 // PYRAMID PARAMETERS
 //------------------------------------------
 
 //# base vertices  
 int pts = 18;
 
 //don't change this!!!
 float angle = 0;
 
 //radius amplitude;    
 float radius = 20;
 
 //pyramid height
 float cylinderLength = radius-5;
 
 // initialize vertex arrays
 PVector vertices[][] = new PVector[2][pts+1];

 // fill arrays
 for (int i = 0; i < 2; i++){
   angle = 0;
   for(int j = 0; j <= pts; j++){
     vertices[i][j] = new PVector();
     vertices[i][j].x = cos(radians(angle)) * radius;
     vertices[i][j].z = sin(radians(angle)) * radius;
     vertices[i][j].y = cylinderLength;
     // the .0 after the 360 is critical
     angle += 360.00/pts;
   }
   cylinderLength *= -1;
 }

 // draw cylinder tube
 beginShape(QUAD_STRIP);
 for(int j = 0; j <= pts; j++){
   vertex(vertices[0][j].x, vertices[0][j].y, vertices[0][j].z);
   vertex(vertices[1][j].x, vertices[1][j].y, vertices[1][j].z);
 }
 endShape();

 //draw cylinder ends
 for (int i = 0; i < 2; i++){
   beginShape();
   for(int j = 0; j < pts; j++){
     vertex(vertices[i][j].x, vertices[i][j].y, vertices[i][j].z);
   }
   endShape(CLOSE);
 }
}


Page Index Toggle Pages: 1