FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   newbie problem with textures...
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: newbie problem with textures...  (Read 282 times)
olekristensen

WWW
newbie problem with textures...
« on: Oct 26th, 2004, 5:55pm »

i am doing some little 3-d maps for the documentation of the spatial configuration of scene elements in a theatrelab here in copenhagen.
 
wanting to learn processing i am using this task as a way to get started...
 
but i cannot make texturing compute in my code.
i.e. in other code, such as the examples in posted online elswhere on this site texturing works, even if i use my own .jpg that i cannot see in my own code.
 
so i hope that some of you guys can lead me on the way by looking through my code below as i figure i must have done _something_ wrong:
 
 
 
BImage a;
 
float xmag, ymag = 0;
float newXmag, newYmag = 0;
 
void setup()
{
  size(400, 300);
  noStroke();
  colorMode(RGB, 1);
  //skal være 200*200 jpg
  a = loadImage("gulv.jpg");
}
 
void loop()
{
  background(1,1,1);
 
  push();
 
  translate(width/2, (height/2)+40, -50);
 
  newXmag = mouseX/float(width) * TWO_PI;
  newYmag = mouseY/float(height) * TWO_PI;
 
  float diff = xmag-newXmag;
if (abs(diff) >  0.01) { xmag -= diff/4.0; }
 
  diff = ymag-newYmag;
if (abs(diff) >  0.01) { ymag -= diff/4.0; }
 
  //rotateX(-ymag);
  rotateY(-xmag);
 
  //scale(ymag);
  scale(4);
 
  //GULV
 
  beginShape(QUADS);
  texture(a);
  vertex(30,0,-30,   0,0);
  vertex(30,0,30,   0,200);
  vertex(-30,0,30, 200,0);
  vertex(-30,0,-30,  200,200);
  endShape();
   
  //RAMME
 
  push();
 
  scale(1.5);
 
  rotateY(0.5);
 
  beginShape(QUADS);
 
  fill(0.1, 0.1, 0.1);
 
  //front
 
  vertex(0,  0,  0);
  vertex(1.5,  0,  0);
  vertex(1.5,  -10,  0);
  vertex(0,  -10,  0);
 
  vertex(1.5,  -8.5,  0);
  vertex(8.5,  -8.5,  0);
  vertex(8.5,  -10,  0);
  vertex(1.5,  -10,  0);
 
  vertex(8.5,  0,  0);
  vertex(10,  0,  0);
  vertex(10,  -10,  0);
  vertex(8.5,  -10,  0);
 
  vertex(1.5,  -1.5,  0);
  vertex(8.5,  -1.5,  0);
  vertex(8.5,  0,  0);
  vertex(1.5,  0,  0);
 
  //bagside
 
  vertex(0,  0,  -1.5);
  vertex(1.5,  0,  -1.5);
  vertex(1.5,  -10,  -1.5);
  vertex(0,  -10,  -1.5);
 
  vertex(1.5,  -8.5,  -1.5);
  vertex(8.5,  -8.5,  -1.5);
  vertex(8.5,  -10,  -1.5);
  vertex(1.5,  -10,  -1.5);
 
  vertex(8.5,  0,  -1.5);
  vertex(10,  0,  -1.5);
  vertex(10,  -10,  -1.5);
  vertex(8.5,  -10,  -1.5);
 
  vertex(1.5,  -1.5,  -1.5);
  vertex(8.5,  -1.5,  -1.5);
  vertex(8.5,  0,  -1.5);
  vertex(1.5,  0,  -1.5);
 
  //inderside
 
  vertex(1.5,  -1.5,  -1.5);
  vertex(1.5,  -8.5,  -1.5);
  vertex(1.5,  -8.5,  0);
  vertex(1.5, -1.5, 0);
 
  vertex(1.5,  -1.5,  -1.5);
  vertex(8.5,  -1.5,  -1.5);
  vertex(8.5,  -1.5,  0);
  vertex(1.5, -1.5, 0);
 
  vertex(8.5,  -1.5,  -1.5);
  vertex(8.5,  -8.5,  -1.5);
  vertex(8.5,  -8.5,  0);
  vertex(8.5, -1.5, 0);
 
  vertex(1.5,  -8.5,  -1.5);
  vertex(8.5,  -8.5,  -1.5);
  vertex(8.5,  -8.5,  0);
  vertex(1.5, -8.5, 0);
 
  endShape();
 
  pop();
  pop();
}
 
 

ole kristensen - tabla.dk
http://ole.kristensen.name
http://tabla.dk
fjen

WWW
Re: newbie problem with textures...
« Reply #1 on: Oct 26th, 2004, 9:20pm »

just add this:
 
Code:

...
//GULV  
 
  fill(1.);  // <---  add this, sets fill to white in (RGB, 1)
 
   beginShape(QUADS);  
   texture(a);
...

 
the reason for this: when you use a texture it's actually added onto the current fill-color of the polygon you are drawing. your's was black, so you just coudn't see the texture.
 
/F
 
Pages: 1 

« Previous topic | Next topic »