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_
   Suggestions
   Software Suggestions
(Moderator: fry)
   Texture quad
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Texture quad  (Read 690 times)
skloopy

WWW
Texture quad
« on: Jan 24th, 2003, 11:30am »

Hi
 
Does proce55ing allow for mapping an image to a quad in 3d? I was checking the reference but i didn't see how or if it's possible... If not, what is the fastest way to do that in Proce55ing?
 
fry


WWW
Re:  Texture quad
« Reply #1 on: Jan 24th, 2003, 2:49pm »

the commands are: textureImage(Bimage theImage); and then vertexTexture(x, y); just before any calls to vertex() while drawing your shape.. only really works inside beginShape()/endShape().  
 
textureImage sets the image to be used, and vertexTexture says what x, y coord of the image is assigned to that vertex.
 
Code:
beginShape(QUADS);
textureImage(image);
vertexTexture(u1, v1); vertex(x1, y1);
vertexTexture(u1, v2); vertex(x1, y2);
vertexTexture(u2, v2); vertex(x2, y2);
vertexTexture(u2, v1); vertex(x2, y1);
endShape();

 
where the u/v coords are relative to the width/height of the image.
« Last Edit: Jan 24th, 2003, 2:50pm by fry »  
skloopy

WWW
Re:  Texture quad
« Reply #2 on: Jan 24th, 2003, 6:27pm »

So then to make a textured triangle strip you would write
 
beginShape(TRIANGLE_STRIP);
textureImage(im)
vertexTexture(u1, v1); vertex(x1, y1);
vertexTexture(u1, v2); vertex(x1, y2);
vertexTexture(u2, v2); vertex(x2, y2);
vertexTexture(u2, v1); vertex(x2, y1);
endShape();
 
Right?
 
I'm guessing it's not possiible to change the texture afterward, is it?
 
THanks!
« Last Edit: Jan 24th, 2003, 6:41pm by skloopy »  
fry


WWW
Re:  Texture quad
« Reply #3 on: Jan 24th, 2003, 7:47pm »

yep, something like that.
 
can't change afterward since you set the textureImage beforehand.. so only once per beginShape()/endShape()
 
but there's nothing to keep you from changing to a different image next time you come through loop(), though it'd be flicker city if not done right.
 
skloopy

WWW
Re:  Texture quad
« Reply #4 on: Jan 25th, 2003, 7:11pm »

Okay, cool. Thanks!
 
Pages: 1 

« Previous topic | Next topic »