Image texture on a softbody

Hi, I want to make a image fly like an paper blow by the wind…
Do you know if it’s possible to apply a texture on a softbody, for exemple using pixelflow lib?
Thanks!
A.

Ok, I found a way, I though it would be very hard, but it’s more easy than what I was thinking :wink:
A.

You can’t leave us hanging!

Ah ah sorry :wink:

For exemple, in the Softboy2D_cloth example from the PixelFlow lib, just change

    texture.beginDraw();
    {
      texture.background(cloth.material_color);
  
      // grid
      int num_lines = nodex_x;
      float dx = tex_w/(float)(num_lines-1);
      float dy = tex_h/(float)(num_lines-1);
      texture.strokeWeight(1f);
      texture.stroke(0);
      for(int ix = 0; ix < num_lines; ix++){
        texture.line((int)(dx*ix), 0,(int)(dx*ix), tex_h);
        texture.line(0, (int)(dy*ix), tex_w, (int)(dy*ix));
      }
      
      // text
      texture.fill(0);
      texture.textFont(font);
      texture.textAlign(CENTER, CENTER);
      texture.textFont(font);
      texture.text(text, tex_w/2, tex_h/2);
  
      // border
      texture.noFill();
      texture.stroke(0);
      texture.strokeWeight(5);
      texture.rect(0, 0, tex_w, tex_h);
    }
    texture.endDraw();
    
    cloth.texture_XYp = texture;

with something like

  texture.beginDraw();
  {
    texture.background(0, 0);
    texture.image(imgText, 0, 0, tex_w, tex_h);
  }
  texture.endDraw();

  cloth.texture_XYp = texture;

where imgText is your PImage…and here you go :wink:

1 Like