How to map 6 diffrent images in the 6 faces of a box.

edited June 2015 in How To...

Hello I m newby in processing. Please can you help me to map 6 images in the six faces of a box.

How to give a name to a new shape created with beginShape() and endShape(), for example:

//*******************************************
PShape Instrument;
PImage photo;
photo = loadImage("image.png");

beginShape()
    vertex...
    vertex...
    ....
    vertex..
endShape()

I want to affect this new shape to Instrument so that:

//*******************************************
Instrument.setTexture(photo);
Shape(Instrument);
//*******************************************

thank you

Tagged:

Answers

  • Thank you for your response. The problem with this solution is that we map the same image on every side of the box. I want to map a different image on each side. regards

  • yes, but think about it.

    it sets one texture at the top, then plainly draws 6 sets of vertices, 4 for each face.

    if you wanted each face to be different, how would you do it? maybe change the texture between each set of 4 points?

  • edited June 2015

    The Shapes3D library has a Box shape which supports different textures on each face. You can install the library through the PDE and the S3D4P_Showcase example demonstrates how to do it. The relevant code is shown below

      box = new Box(this);
      String[] faces = new String[] {
        "pd_9.jpg", "pd_a.jpg", "pd_10.jpg", 
        "pd_k.jpg", "pd_j.jpg", "pd_q.jpg"
      };
      box.setTextures(faces);
      box.fill(color(255));
      box.stroke(color(190));
      box.strokeWeight(1.2f);
      box.setSize(100, 100, 100);
      box.drawMode(S3D.TEXTURE | S3D.WIRE);
    
Sign In or Register to comment.