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 › fill / texture question...
Page Index Toggle Pages: 1
fill / texture question... (Read 785 times)
fill / texture question...
Feb 6th, 2006, 10:33pm
 
Hi All:
i'm a stuck newbie...trying to create "half a cube" using the beginShape() / endShape(), but two of my sides aren't filling.
any/all help appreciated!
code is pasted below
THANXS,
amb

=========================================================
float ang = 0;
void setup(){
   size(800,800,P3D);
   framerate(22);
} // end method setup...
void draw() {
 background(100);
 translate(width/2,height/2,0);
 rotateX(radians(ang-=PI/2.0));
 rotateY(radians(ang));
 beginShape();
   fill(255,0,0);  // mr. red...
   vertex(0,0,0);
   vertex(100,0,0);
   vertex(100,0,100);
   vertex(0,0,100);
 endShape();
 beginShape();  // mr. green...
   fill(0,255,0);
   vertex(0,0,0);
   vertex(100,0,0);
   vertex(100,100,0);
   vertex(0,100,0);
 endShape();
 beginShape();  // mr. blue...
   fill(0,0,255);
   vertex(0,0,0);
   vertex(0,100,0);
   vertex(0,100,100);
   vertex(0,0,100);
 endShape();
} // end method draw...
Re: fill / texture question...
Reply #1 - Feb 7th, 2006, 12:52pm
 
If you explicitly say what type of shape you're trying to draw, it works.

e.g.:
Code:
 float ang = 0;
void setup(){
size(800,800,P3D);
framerate(22);
} // end method setup...
void draw() {
background(100);
translate(width/2,height/2,0);
rotateX(radians(ang-=PI/2.0));
rotateY(radians(ang));
beginShape(QUADS);
fill(255,1,0); // mr. red...
vertex(0,0,0);
vertex(100,0,0);
vertex(100,0,100);
vertex(0,0,100);
endShape();
beginShape(QUADS); // mr. green...
fill(0,255,0);
vertex(0,0,0);
vertex(100,0,0);
vertex(100,100,0);
vertex(0,100,0);
endShape();
beginShape(QUADS); // mr. blue...
fill(0,1,255);
vertex(0,0,0);
vertex(0,100,0);
vertex(0,100,100);
vertex(0,0,100);
endShape();
} // end method draw...


You can even get rid of 2 of the begin/endShape calls:
Code:
  beginShape(QUADS);  
fill(255,1,0); // mr. red...
vertex(0,0,0);
vertex(100,0,0);
vertex(100,0,100);
vertex(0,0,100);
fill(0,255,0);
vertex(0,0,0);
vertex(100,0,0);
vertex(100,100,0);
vertex(0,100,0);
fill(0,1,255);
vertex(0,0,0);
vertex(0,100,0);
vertex(0,100,100);
vertex(0,0,100);
endShape();
Re: fill / texture question...
Reply #2 - Feb 7th, 2006, 3:35pm
 
cool, thanks!
amb
Page Index Toggle Pages: 1