home processing download documents tutorial python tutorial gallery source about
 Tutorials (back to the list of tutorials)

Panelization Examples

     Panelization Example7

The following is an example of extruding circles with its depth controlled by a bitmap image.

surface7.3dm

The input bitmap used in the example is this.

import processing.opengl.*;
import igeo.*;

size(480, 360, IG.GL);

IG.open("surface7.3dm");
ISurface[] surfaces = IG.surfaces();

IImageMap map = new IImageMap("map4.jpg");

for (ISurface surf : surfaces) {
  int unum = 100, vnum = 50;
  double uinc = 1.0/unum, vinc = 1.0/vnum;

  for (int i=0; i < unum; i++) {
    for (int j=0; j < vnum; j++) {
      double val = map.get( i*uinc, j*vinc );

      IVec pt = surf.pt( i*uinc, j*vinc );
      IVec nml = surf.nml( i*uinc, j*vinc );

      ICircle cir = new ICircle(pt, nml, 0.1);
      
      IG.extrude(cir, val*-2).clr(0);
    }
  }
  surf.del();
}

Then the generation of circles and surfaces are also controlled by a probabilistic switch responding to the bitmap input.

import processing.opengl.*;
import igeo.*;

size(480, 360, IG.GL);

IG.open("surface7.3dm");
ISurface[] surfaces = IG.surfaces();

IImageMap map = new IImageMap("map4.jpg");

for (ISurface surf : surfaces) {
  int unum = 200, vnum = 100;
  double uinc = 1.0/unum, vinc = 1.0/vnum;

  for (int i=0; i < unum; i++) {
    for (int j=0; j < vnum; j++) {
      double val = map.get( i*uinc, j*vinc );

      if (IRandom.percent(val*100)) {
        IVec pt = surf.pt( i*uinc, j*vinc );
        IVec nml = surf.nml( i*uinc, j*vinc );
        ICircle cir = new ICircle(pt, nml, 0.05);

        IG.extrude(cir, -2*val).clr(0);
      }
    }
  }
  surf.del();
}


(back to the list of tutorials)

HOME
FOR PROCESSING
DOWNLOAD
DOCUMENTS
TUTORIALS (Java / Python)
GALLERY
SOURCE CODE(GitHub)
ABOUT