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

Panelization Examples

     Panelization Example6

The following is an example of drawing curves with multiple points on an input surface and extruding those curves. The sample input file used in the example is below.

surface8.3dm

add_library('igeo')

size(480, 360, IG.GL)

IG.open("surface8.3dm")
surfaces = IG.surfaces()

unum = 10
vnum = 30
uinc = 1.0/unum
vinc = 1.0/vnum

for surf in surfaces :
    for i in range(unum) : 
        pts = []

        for j in range(vnum+1) : 
            if j%2==0 : 
                pts.append(surf.pt(i*uinc, j*vinc))
            else :
                pts.append(surf.pt((i+1)*uinc, j*vinc))
        ICurve(pts).clr(0)
    surf.del()

Then amount of undulation is controlled by image mapping. The degree of the curve is also changed to create curvature. The input bitmap used in the example is this.


add_library('igeo')

size(480, 360, IG.GL)

IG.open("surface8.3dm")
surfaces = IG.surfaces()

unum = 20
vnum = 60
uinc = 1.0/unum
vinc = 1.0/vnum

map = IImageMap("map3.jpg")

for surf in surfaces : 
    for i in range(unum) : 
        pts = []
        
        for j in range(vnum+1) : 
            if j%2==0 : 
                pts.append(surf.pt(i*uinc, j*vinc))
            else : 
                # bitmap value is sampled. note that u and v is swapped to match with u-v of the input surface.
                val = map.get( j*vinc, i*uinc )
                
                pts.append(surf.pt((i+val)*uinc, j*vinc))
        ICurve(pts, 2).clr(0)
    surf.del()

Then the curves are extruded in the y-axis direction.

add_library('igeo')

size(480, 360, IG.GL)

IG.open("surface8.3dm")
surfaces = IG.surfaces()

unum = 20
vnum = 60
uinc = 1.0/unum
vinc = 1.0/vnum

map = IImageMap("map3.jpg")

for surf in surfaces :
    for i in range(unum) : 
        pts = []
        
        for j in range(vnum+1) :
            if j%2==0 : 
                pts.append( surf.pt(i*uinc, j*vinc) )
            else : 
                # bitmap value is sampled. note that u and v is swapped to match with u-v of the input surface.
                val = map.get( j*vinc, i*uinc )
                
                pts.append( surf.pt((i+val)*uinc, j*vinc) )
        crv = ICurve(pts, 2).clr(0)
        extrudeDir = IVec(0, -2, 0)
        IG.extrude(crv, extrudeDir).clr(0,0,i*uinc,0.5)
    surf.del()

Then the depth of extrusion is randomized and pipe geometry is added on the edge of the extruded surface.

add_library('igeo')

size(480, 360, IG.GL)

IG.open("surface8.3dm")
surfaces = IG.surfaces()

unum = 20
vnum = 60
uinc = 1.0/unum
vinc = 1.0/vnum

map = IImageMap("map3.jpg")

for surf in surfaces : 
    for i in range(unum) : 
        pts = []
        
        for j in range(vnum+1) : 
            if j%2==0 : 
                pts.append(surf.pt(i*uinc, j*vinc))
            else :
                # bitmap value is sampled. note that u and v is swapped to match with u-v of the input surface.
                val = map.get( j*vinc, i*uinc )
                pts.append(surf.pt((i+val)*uinc, j*vinc))
        crv = ICurve(pts, 2).clr(0)
        extrudeDir = IVec(0, IRand.get(-3, -1), 0)
        IG.extrude(crv, extrudeDir).clr(0,0,i*uinc,0.5)
        
        crv2 = crv.cp(extrudeDir)
        IG.pipe(crv2, 0.1).clr(0.2)
    surf.del()


(back to the list of tutorials)

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