Hi there!
I’m a real real beginner student…
I’ve got a problem while doing my homework.
the task is to
-
make 3D QUAD that can be textured in ‘class’ using
beginShape(QUADS), endShape(), vertex(x,y,z,tx,ty), texture(). -
make step 1 with ‘class array’ and use ‘for(){ }’ to create 3 object
-
prepare the texture image with ‘PImage’,
and the image file name using ‘String’ that’s going to be used inside ‘loadImage(" ")’ -
randomly bring the img file name from the ‘String’
and use it as a texture image of each 3 class objects that’s been made in step 2.
the problem is that I have a feeling that I’m doing this in a completely… wrong way…
I’ve been working on this for like… a week and still got no clue…
It’s an uncompleted version, but still could you please tell me
what parts should I fix in here?
<PImage img;
String pic= {“pk.png”, “bl.png”, “yl.png”};
void setup(){
size(800, 500, P3D);
background(0);
noStroke();
fl tx= new fl[3];
for(int i=0; i<tx.length; i++) {
img= loadImage(random(pic.length));
}
textureMode(NORMAL);
camera(70.0, 35.0, 120.0, 50.0, 50.0, 0.0,
0.0, 1.0, 0.0);
}
void draw(){
for(int i=0; i<tx.length; i++) {
TexturedQuad(tx);
}
}
class fl {
void TextureQuad(PImage img){
beginShape(QUADS);
texture(img);
vertex(-1, -1, 1, 0, 0);
vertex( 1, -1, 1, 1, 0);
vertex( 1, 1, 1, 1, 1);
vertex(-1, 1, 1, 0, 1);
endShape();
beginShape(QUADS);
texture(img);
vertex(-1, -1, -1, 0, 0);
vertex( 1, -1, -1, 1, 0);
vertex( 1, -1, 1, 1, 1);
vertex(-1, -1, 1, 0, 1);
endShape();
beginShape(QUADS);
texture(img);
vertex( 1, -1, 1, 0, 0);
vertex( 1, -1, -1, 1, 0);
vertex( 1, 1, -1, 1, 1);
vertex( 1, 1, 1, 0, 1);
endShape();
}>