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
Texture Syntax (Read 433 times)
Texture Syntax
Apr 11th, 2009, 3:37pm
 
Say I have a PImage array of stuff I want to use as textures(cubebg) and I want to use a different texture on every side of a cube I am drawing how do I get it to bind a texture to only one face of the cube? ATM it binds the last texture cmd to the entire cube.


beginShape(QUADS);
   texture(cubebg[0]);
   vertex(-w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ,0,0);
   vertex(w + shiftX, -h/2 + shiftY, -d/2 + shiftZ,1,0);
   vertex(w + shiftX, h + shiftY, -d/2 + shiftZ,1,1);
   vertex(-w/2 + shiftX, h + shiftY, -d/2 + shiftZ,0,1);
 
   
   
   // Back face
   texture(cubebg[1]);
   vertex(-w/2 + shiftX, -h/2 + shiftY, d + shiftZ,0,0);
   vertex(w + shiftX, -h/2 + shiftY, d + shiftZ,1,0);
   vertex(w + shiftX, h + shiftY, d + shiftZ,1,1);
   vertex(-w/2 + shiftX, h + shiftY, d + shiftZ,0,1);

   // Left face
   //texture(cubebg[2]);
   vertex(-w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ,0,0);
   vertex(-w/2 + shiftX, -h/2 + shiftY, d + shiftZ,1,0);
   vertex(-w/2 + shiftX, h + shiftY, d + shiftZ,1,1);
   vertex(-w/2 + shiftX, h + shiftY, -d/2 + shiftZ,0,1);

   // Right face
   //texture(cubebg[3]);
   vertex(w + shiftX, -h/2 + shiftY, -d/2 + shiftZ,0,0);
   vertex(w + shiftX, -h/2 + shiftY, d + shiftZ,1,0);
   vertex(w + shiftX, h + shiftY, d + shiftZ,1,1);
   vertex(w + shiftX, h + shiftY, -d/2 + shiftZ,0,1);

   // Top face
   vertex(-w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ,0,0);
   vertex(w + shiftX, -h/2 + shiftY, -d/2 + shiftZ,1,0);
   vertex(w + shiftX, -h/2 + shiftY, d + shiftZ,1,1);
   vertex(-w/2 + shiftX, -h/2 + shiftY, d + shiftZ,0,1);

   // Bottom face
   vertex(-w/2 + shiftX, h + shiftY, -d/2 + shiftZ,0,0);
   vertex(w + shiftX, h + shiftY, -d/2 + shiftZ,1,0);
   vertex(w + shiftX, h + shiftY, d + shiftZ,1,1);
   vertex(-w/2 + shiftX, h + shiftY, d + shiftZ,0,1);
   endShape();
Re: Texture Syntax
Reply #1 - Apr 12th, 2009, 5:30am
 
call a texture() for each beginShape/endShape.
draw each face on its own
Page Index Toggle Pages: 1