Ejemplo n.º 1
0
def warpsurface( srf, tv ):
    usize = irit.FetchRealObject(irit.nth( irit.ffmsize( srf ), 1 ))
    vsize = irit.FetchRealObject(irit.nth( irit.ffmsize( srf ), 2 ))
    clr = irit.getattr( srf, "color" )
    i = 0
    while ( i <= usize * vsize - 1 ):
        pt = irit.coord( srf, i )
        x = irit.FetchRealObject(irit.coord( pt, 1 ))
        y = irit.FetchRealObject(irit.coord( pt, 2 ))
        z = irit.FetchRealObject(irit.coord( pt, 3 ))
        pt = irit.teval( tv, x, y, z )
        v = math.floor( i/float(usize) )
        u = i - v * usize
        srf = irit.seditpt( srf, pt, u, v )
        i = i + 1
    irit.attrib( srf, "color", clr )
    retval = srf
    return retval
Ejemplo n.º 2
0
def warpsrf(origsrf, tv):
    srf = (-irit.sreparam( irit.sreparam( origsrf, irit.ROW, 0, 1 ), irit.COL, 0,\
    1 ) )
    srf = irit.srefine( irit.srefine( srf, irit.COL, 0, irit.list( 0.111, 0.222, 0.333, 0.444, 0.555, 0.666,\
    0.777, 0.888 ) ), irit.ROW, 0, irit.list( 0.111, 0.222, 0.333, 0.444, 0.555, 0.666,\
    0.777, 0.888 ) )
    usize = irit.FetchRealObject(irit.nth(irit.ffmsize(srf), 1))
    vsize = irit.FetchRealObject(irit.nth(irit.ffmsize(srf), 2))
    i = 0
    while (i <= usize * vsize - 1):
        pt = irit.coord(srf, i)
        x = irit.FetchRealObject(irit.coord(pt, 1))
        y = irit.FetchRealObject(irit.coord(pt, 2))
        z = irit.FetchRealObject(irit.coord(pt, 3))
        pt = irit.teval(tv, x, y, z)
        v = math.floor(i / usize)
        u = i - v * usize
        srf = irit.seditpt(srf, pt, u, v)
        i = i + 1
    retval = srf
    irit.cpattr(retval, origsrf)
    return retval
Ejemplo n.º 3
0
z = 1
while (z >= (-1)):
    pt = irit.point(0, 0, z)
    irit.adwidth(pt, 3)
    irit.color(pt, irit.YELLOW)
    bisect = irit.sbisector(s2, irit.Fetch3TupleObject(pt))
    irit.color(bisect, irit.CYAN)
    irit.view(irit.list(s2, pt, bisect), irit.ON)
    z = z + (-0.03)

irit.pause()

z = 3
while (z >= (-1)):
    s2a = irit.seditpt(s2, irit.ctlpt(irit.E3, 0, 0, z), 1, 1)
    irit.color(s2a, irit.RED)
    bisect = irit.sbisector(s2a, irit.Fetch3TupleObject(pt))
    irit.color(bisect, irit.CYAN)
    irit.view(irit.list(s2a, pt, bisect), irit.ON)
    z = z + (-0.03)

irit.free(s2)
irit.free(s2a)
irit.pause()

# ############################################################################
#
#  A bicubic surface (region of a glass)
#
Ejemplo n.º 4
0
save_res = irit.GetResolution()
save_mat = irit.GetViewMatrix()

irit.SetViewMatrix(irit.rx(2) * irit.ry(2) * irit.sc(0.5))
irit.viewobj(irit.GetViewMatrix())

irit.SetViewMatrix(save_mat)

# ############################################################################

s = irit.ruledsrf( irit.ctlpt( irit.E3, (-1 ), (-1 ), 0 ) + \
                   irit.ctlpt( irit.E3, 1, (-1 ), 0 ), \
                   irit.ctlpt( irit.E3, (-1 ), 1, 0 ) + \
                   irit.ctlpt( irit.E3, 1, 1, 0 ) ) * irit.rx( 90 )
s = irit.sraise(irit.sraise(s, irit.ROW, 3), irit.COL, 3)
s = (-irit.seditpt(s, irit.ctlpt(irit.E3, 0, 1, 0), 1, 1))
irit.color(s, irit.MAGENTA)

reflectlns = irit.nil()
x = (-1.6)
while (x <= 1.6):
    irit.snoc( irit.ctlpt( irit.E3, x, 2, (-10 ) ) + \
                irit.ctlpt( irit.E3, x, 2, 10 ), reflectlns )
    x = x + 0.8
irit.color(reflectlns, irit.CYAN)
irit.adwidth(reflectlns, 2)

irit.SetResolution(30)
#  highlight lines - view is zero vector.
hl = irit.rflctln(
    s, (0, 0, 0),
Ejemplo n.º 5
0
                                           irit.ctlpt( irit.E3, 1, (-1 ), 0 ) ), irit.list( \
                                           irit.ctlpt( irit.E3, (-1 ), 0, 0.3 ), \
                                           irit.ctlpt( irit.E3, 0, 0, 0.6 ), \
                                           irit.ctlpt( irit.E3, 1, 0, 0.3 ) ), irit.list( \
                                           irit.ctlpt( irit.E3, (-1 ), 1, 0 ), \
                                           irit.ctlpt( irit.E3, 0, 1, 0.3 ), \
                                           irit.ctlpt( irit.E3, 1, 1, 0 ) ) ) )
irit.attrib(srf, "color", irit.GenRealObject(14))

#
#  Modifying the surface.
#
irit.viewobj(view_mat3d)
a = (-0.5)
while (a <= 1.5):
    newsrf = irit.seditpt(srf, irit.ctlpt(irit.E3, 0, 0, a), 1, 1)
    orth = irit.orthotomc(newsrf, irit.Fetch3TupleObject(pt), 2)
    irit.color(orth, irit.GREEN)
    irit.view(irit.list(orth, newsrf, pt), irit.ON)
    a = a + 0.03

irit.pause()

# ############################################################################
#
#  A biquartic surface
#

wiggle = irit.sbspline( 3, 3, irit.list( irit.list( irit.ctlpt( irit.E3, 0.013501, 0.46333, (-1.01136 ) ), \
                                                    irit.ctlpt( irit.E3, 0.410664, (-0.462427 ), (-0.939545 ) ), \
                                                    irit.ctlpt( irit.E3, 0.699477, 0.071974, (-0.381915 ) ) ), irit.list( \
Ejemplo n.º 6
0
crv4 = crv1 * irit.sc(0.5) * irit.tx((-0.5)) * irit.ty(1.6)
crvs = irit.list(crv1, crv2, crv3, crv4)
irit.view(irit.list(crvs), irit.ON)

tris = raytraptris(crvs, 0.001, (-1e-010))
irit.interact(irit.list(crvs, tris))
irit.save("raytrap4", irit.list(crvs, tris))

# ############################################################################
#
#  This one can take some seconds.
#
srf1 = irit.planesrf((-1), (-1), 1, 1)
srf1 = irit.coerce(irit.sraise(irit.sraise(srf1, irit.ROW, 3), irit.COL, 3),
                   irit.E3)
srf1 = irit.seditpt(srf1, irit.ctlpt(irit.E3, 0, 0, 4), 1, 1) * irit.tz(
    (-2)) * irit.rx(12) * irit.ry(23)
srf1 = irit.sregion(irit.sregion(srf1, irit.ROW, 0.2, 0.8), irit.COL, 0.2, 0.8)

srf2 = srf1 * irit.ry(110) * irit.rx(23)
srf3 = srf1 * irit.ry(230) * irit.rx((-24))
srfs = irit.list(srf1, srf2, srf3)

tris1 = raytraptris3d(srfs, 0.001, 1e-010)

irit.interact(irit.list(srfs, tris1))
irit.save("rytrp3d1", irit.list(srfs, tris1))

# ############################################################################
#
#  This one is much slower (minutes).
Ejemplo n.º 7
0
# #############################################################################
#
#  Spikes like texture
#

srftext1 = irit.ruledsrf( irit.ctlpt( irit.E2, 0, 0 ) + \
                          irit.ctlpt( irit.E2, 0, 1 ), \
                          irit.ctlpt( irit.E2, 1, 0 ) + \
                          irit.ctlpt( irit.E2, 1, 1 ) )
srftext1 = irit.sraise(irit.sraise(srftext1, irit.ROW, 3), irit.COL, 3)
srftext1 = irit.srefine(srftext1, irit.ROW, 0, irit.list(0.25, 0.5, 0.75))
srftext1 = irit.srefine(srftext1, irit.COL, 0, irit.list(0.25, 0.5, 0.75))
srftext1 = irit.coerce(srftext1, irit.E3)

#  Make a spike out of the four interior points.
srftext1 = irit.seditpt(srftext1, irit.ctlpt(irit.E3, 0.5, 0.5, 1), 2, 2)
srftext1 = irit.seditpt(srftext1, irit.ctlpt(irit.E3, 0.5, 0.5, 1), 2, 3)
srftext1 = irit.seditpt(srftext1, irit.ctlpt(irit.E3, 0.5, 0.5, 1), 3, 2)
srftext1 = irit.seditpt(srftext1, irit.ctlpt(irit.E3, 0.5, 0.5, 1), 3, 3)

irit.SetResolution(6)

srf1 = irit.sddmmap(srf, irit.gpolygon((-srftext1) * irit.sz(0.1), 1), 4, 8, 1)
irit.interact(srf1)

srf1 = irit.sddmmap(srf, irit.gpolygon((-srftext1) * irit.sz(0.2), 1), 8, 12,
                    1)
irit.interact(srf1)
irit.save("disp1map", srf1)

irit.free(srftext1)
Ejemplo n.º 8
0
#
#  A simple simulation of page flipping.
#
#                                Gershon Elber, March 1994.
#

page1 = irit.ruledsrf( irit.ctlpt( irit.E2, 0, 0 ) + \
                       irit.ctlpt( irit.E2, 1, 0 ), \
                       irit.ctlpt( irit.E2, 0, 1.5 ) + \
                       irit.ctlpt( irit.E2, 1, 1.5 ) )
page1 = irit.sraise(irit.sraise(page1, irit.ROW, 4), irit.COL, 4)
irit.color(page1, irit.GREEN)
irit.viewobj(page1)

page2 = irit.seditpt(irit.coerce(page1, irit.E3),
                     irit.ctlpt(irit.E3, 0.9, 1.35, 0.5), 3, 3)
irit.color(page2, irit.RED)
irit.viewobj(page2)

page3 = irit.srefine(page2, irit.COL, 0, irit.list(0.3, 0.6))
page3 = irit.seditpt(irit.coerce(page3, irit.E3),
                     irit.ctlpt(irit.E3, 0.6, 1.5, 0.4), 5, 3)
page3 = irit.seditpt(irit.coerce(page3, irit.E3),
                     irit.ctlpt(irit.E3, 0.6, 1, 0.4), 5, 2)
page3 = irit.seditpt(irit.coerce(page3, irit.E3),
                     irit.ctlpt(irit.E3, 0.6, 0.5, 0.4), 5, 1)
page3 = irit.seditpt(irit.coerce(page3, irit.E3),
                     irit.ctlpt(irit.E3, 0.6, 0, 0.4), 5, 0)
irit.color(page3, irit.CYAN)
irit.viewobj(page3)