示例#1
0
def dominos(path, scl, piecetimestep):
    retval = irit.nil()
    animtime = 0
    dominopiece = irit.box(
        (-0.01, -0.006, 0), 0.02, 0.006, 0.05) * irit.sc(scl)
    rot_x = irit.cbezier( irit.list( irit.ctlpt( irit.E1, 0 ), \
                                     irit.ctlpt( irit.E1, 80 ) ) )
    crvdomain = irit.pdomain(path)
    t = irit.FetchRealObject(irit.nth(crvdomain, 1))
    dpath = irit.cderive(path)
    while (t < irit.FetchRealObject(irit.nth(crvdomain, 2))):
        d = irit.Fetch3TupleObject(
            irit.coerce(irit.ceval(dpath, t), irit.POINT_TYPE))
        dlen = math.sqrt(DotProd(d, d))

        rot_x = irit.creparam(rot_x, animtime, animtime + piecetimestep)
        irit.attrib(dominopiece, "animation", irit.list(rot_x))
        irit.setname(irit.getattr(dominopiece, "animation"), 0, "rot_x")

        dp = dominopiece * irit.rz(
            -math.atan2(d[0], d[1]) * 180 / math.pi) * irit.trans(
                irit.Fetch3TupleObject(
                    irit.coerce(irit.ceval(path, t), irit.VECTOR_TYPE)))
        irit.snoc(dp, retval)

        t = t + 0.04 * scl / dlen
        animtime = animtime + piecetimestep * 0.6
    return retval
示例#2
0
def treebranch(pt1, pt2, r):
    retval = irit.swpsclsrf( irit.circle( ( 0, 0, 0 ), 1 ),
        irit.coerce( pt1, irit.E3 ) + \
        irit.coerce( pt2, irit.E3 ),
        irit.ctlpt( irit.E2, 0, r ) + \
        irit.ctlpt( irit.E2, 1, r * wfactor ), irit.GenRealObject(0), 1 )
    return retval
示例#3
0
def antanim(scl):
    save_res = irit.GetResolution()
    bodyall = antbody()
    body = irit.nth(bodyall, 1)
    eyes = irit.nth(bodyall, 2)
    llegs = irit.list(
        antlleganim(1) * irit.sc(1.1) * irit.sx(1.3) * irit.ry(
            (-45)) * irit.trans((0.1, 0, 1.02)),
        antlleganim((-1)) * irit.sc(1.3) * irit.ry(10) * irit.trans(
            (0.1, 0.05, 1)),
        antlleganim(1) * irit.sc(1.2) * irit.sx(1.4) * irit.ry(40) *
        irit.trans((0.1, 0.02, 0.95)))
    rlegs = irit.list(
        antrleganim(
            (-1)) * irit.sc(1.1) * irit.sx(1.3) * irit.ry(45) * irit.trans(
                ((-0.1), 0, 1.02)),
        antrleganim(1) * irit.sc(1.3) * irit.ry((-10)) * irit.trans(
            ((-0.1), 0.05, 1)),
        antrleganim((-1)) * irit.sc(1.2) * irit.sx(1.4) * irit.ry(
            (-40)) * irit.trans(((-0.1), 0.02, 0.95)))
    irit.SetResolution(20)
    antennas = irit.list(
        antantenna() * irit.ry((-110)) * irit.trans(((-0.02), 0.2, 1.6)),
        antantenna() * irit.ry((-70)) * irit.trans((0.02, 0.2, 1.6)))
    irit.attrprop(antennas, "u_resolution", irit.GenRealObject(0.2))
    body = (body + irit.gpolygon(antennas, 1))
    irit.attrib(body, "rgb", irit.GenStrObject("255,50,50"))
    irit.SetResolution(save_res)
    retval = irit.list(
        body, llegs, rlegs,
        eyes) * irit.sz(1.3) * irit.sc(1) * irit.ty(0.28785) * irit.rx(90)
    mov_y = irit.creparam( irit.ctlpt( irit.E1, 0 ) + \
                            irit.ctlpt( irit.E1, (-1 ) ), 0, 1.2 )
    irit.attrib(retval, "animation", mov_y)
    return retval
示例#4
0
def cnvrtcrvs2domains( crvs, theta ):
    retval = irit.nil(  )
    i = 1
    while ( i <= irit.SizeOf( crvs ) ):
        dm = irit.pdomain( irit.nth( crvs, i ) )
        irit.snoc( irit.ctlpt( irit.E2, theta, irit.nth( dm, 1 ) ) + \
                    irit.ctlpt( irit.E2, theta, irit.nth( dm, 2 ) ), retval )
        i = i + 1
    return retval
示例#5
0
def genanimationorthomatchcrvpts(ppl, crv, scl):
    pt1 = irit.point(0, 0, 0)
    pt2 = irit.point(0, 0, 0)
    vec1 = ( irit.ctlpt( irit.E2, 0, 0 ) + \
              irit.ctlpt( irit.E2, 0, scl ) )
    irit.color(vec1, irit.YELLOW)
    vec2 = ( \
              irit.ctlpt( irit.E2, 0, 0 ) + \
              irit.ctlpt( irit.E2, 0, scl ) )
    irit.color(vec2, irit.CYAN)
    pos1 = irit.nil()
    pos2 = irit.nil()
    rot1 = irit.nil()
    rot2 = irit.nil()
    i = 0
    while (i <= irit.SizeOf(ppl) - 1):
        pl = irit.coord(ppl, i)
        j = 0
        while (j <= irit.SizeOf(pl) - 1):
            pt = irit.coord(pl, j)
            t1 = irit.coord(pt, 0)
            t2 = irit.coord(pt, 1)
            if (t1 > t2):
                irit.snoc(
                    irit.coerce(irit.ceval(crv, irit.FetchRealObject(t1)),
                                irit.POINT_TYPE), pos1)
                irit.snoc(
                    irit.coerce(irit.ceval(crv, irit.FetchRealObject(t2)),
                                irit.POINT_TYPE), pos2)
                n1 = irit.cnormal(crv, irit.FetchRealObject(t1))
                n2 = irit.cnormal(crv, irit.FetchRealObject(t2))
                irit.snoc(
                    irit.vector(
                        math.atan2(irit.FetchRealObject(irit.coord(n1, 0)),
                                   irit.FetchRealObject(irit.coord(n1, 1))) *
                        180 / math.pi, 0, 0), rot1)
                irit.snoc(
                    irit.vector(
                        math.atan2(irit.FetchRealObject(irit.coord(n2, 0)),
                                   irit.FetchRealObject(irit.coord(n2, 1))) *
                        180 / math.pi, 0, 0), rot2)
            j = j + 1
        if (t1 > t2):
            irit.snoc(irit.vector(10000, 0, 0), pos1)
            irit.snoc(irit.vector(10000, 0, 0), pos2)
            irit.snoc(irit.vector(0, 0, 0), rot1)
            irit.snoc(irit.vector(0, 0, 0), rot2)
        i = i + 1
    irit.attrib(pt1, "animation", makerottransanimobj(irit.nil(), pos1))
    irit.attrib(pt2, "animation", makerottransanimobj(irit.nil(), pos2))
    irit.attrib(vec1, "animation", makerottransanimobj(rot1, pos1))
    irit.attrib(vec2, "animation", makerottransanimobj(rot2, pos2))
    retval = irit.list(pt1, pt2, vec1, vec2)
    return retval
示例#6
0
def centerunitdrawer( w, d, h, legw, drawerelev ):
    drawerw = w/3
    drawerh = ( ( h - 0.204 - legw )/3 - 0.01 )
    drawerbox = ( irit.box( ( drawerw, 0, drawerelev ), drawerw, d - legw, drawerh ) - irit.box( ( drawerw + 0.01, 0.01, drawerelev + 0.01 ), drawerw - 0.02, d - legw - 0.02, drawerh ) )
    mov_y = ( irit.ctlpt( irit.E1, 0 ) + \
               irit.ctlpt( irit.E1, (-d ) + legw + 0.05 ) )
    irit.attrib( drawerbox, "animation", irit.list( mov_y ) )
    irit.attrib( drawerbox, "ptexture", woodtext )
    irit.attrib( drawerbox, "rgb", woodclr )
    retval = irit.list( drawerbox )
    return retval
示例#7
0
def createcubicbezier(x1, y1, x2, y2, x3, y3):
    x1 = x1 / 1000.0
    y1 = y1 / 1000.0
    x2 = x2 / 1000.0
    y2 = y2 / 1000.0
    x3 = x3 / 1000.0
    y3 = y3 / 1000.0
    retval = irit.cbezier( irit.list( irit.ctlpt( irit.E2, x1, y1 ), \
                                       irit.ctlpt( irit.E2, x1 + ( x2 - x1 ) * 2/3.0, y1 + ( y2 - y1 ) * 2/3.0 ), \
                                       irit.ctlpt( irit.E2, x3 + ( x2 - x3 ) * 2/3.0, y3 + ( y2 - y3 ) * 2/3.0 ), \
                                       irit.ctlpt( irit.E2, x3, y3 ) ) )
    return retval
示例#8
0
def cornerunitshelf( w, h, legw, legd ):
    prof1 = ( irit.ctlpt( irit.E3, legd, legd, 0 ) + \
               irit.ctlpt( irit.E3, legd, 2 * w - legd, 0 ) + \
               irit.ctlpt( irit.E3, 2 * w - legd, 2 * w - legd, 0 ) )
    prof2 = ( \
               irit.ctlpt( irit.E3, legd, legd, 0 ) + irit.arc( ( w - legd, legd, 0 ), ( w, w, 0 ), ( 2 * w - legd, w - legd, 0 ) ) + \
               irit.ctlpt( irit.E3, 2 * w - legd, 2 * w - legd, 0 ) )
    shelfframe = irit.list( irit.extrude( prof1 + (-prof2 ), ( 0, 0, 0.03 ), 0 ), irit.ruledsrf( prof1, prof2 ), irit.ruledsrf( prof1, prof2 ) * irit.tz( 0.03 ) )
    irit.attrib( shelfframe, "ptexture", woodtext )
    irit.attrib( shelfframe, "rgb", woodclr )
    retval = irit.list( shelfframe ) * irit.tz( h )
    return retval
示例#9
0
def mergeverticaltwocrvs( c1, c2 ):
    x = irit.coord( irit.coord( c1, 1 ), 1 )
    if ( apxeq( irit.coord( irit.coord( c1, 1 ), 2 ), 1 ) * apxeq( irit.coord( irit.coord( c2, 0 ), 2 ), 0 ) ):
        retval = irit.ctlpt( irit.E2, x, irit.coord( irit.coord( c1, 0 ), 2 ) - 1 ) + \
                  irit.ctlpt( irit.E2, x, irit.coord( irit.coord( c2, 1 ), 2 ) )
    else:
        if ( apxeq( irit.coord( irit.coord( c2, 1 ), 2 ), 1 ) * apxeq( irit.coord( irit.coord( c1, 0 ), 2 ), 0 ) ):
            retval = \
                  irit.ctlpt( irit.E2, x, irit.coord( irit.coord( c2, 0 ), 2 ) - 1 ) + \
                  irit.ctlpt( irit.E2, x, irit.coord( irit.coord( c1, 1 ), 2 ) )
        else:
            retval = c1 * irit.tx( 0 )
    return retval
示例#10
0
def centerunitdoors( w, d, h, legw, legd ):
    intwidth = w/3
    leftdoor = irit.box( ( legw + 0.002, 0, 0.202 ), intwidth - legw + 0.0096, 0.01, h - 0.204 - legw )
    rot_z1 = ( irit.ctlpt( irit.E1, 0 ) + \
                irit.ctlpt( irit.E1, 100 ) )
    irit.attrib( leftdoor, "animation", irit.list( irit.tx( (-legw ) ), rot_z1, irit.tx( legw ) ) )
    rightdoor = irit.box( ( intwidth * 2 + 0.002, 0, 0.202 ), intwidth - legw - 0.004, 0.01, h - 0.204 - legw )
    rot_z2 = ( \
                irit.ctlpt( irit.E1, 0 ) + \
                irit.ctlpt( irit.E1, (-100 ) ) )
    irit.attrib( rightdoor, "animation", irit.list( irit.tx( (-w ) + legw ), rot_z2, irit.tx( w - legw ) ) )
    retval = irit.list( leftdoor, rightdoor )
    irit.attrprop( retval, "ptexture", woodtext )
    irit.attrprop( retval, "rgb", woodclr )
    return retval
示例#11
0
def displayposnormal(crv, t1, t2, scl, bg_obj):
    pt1 = irit.ceval(crv, irit.FetchRealObject(t1))
    pt2 = irit.ceval(crv, irit.FetchRealObject(t2))
    n1 = irit.cnormal(crv, irit.FetchRealObject(t1))
    n2 = irit.cnormal(crv, irit.FetchRealObject(t2))
    ptt1 = (irit.ctlpt(irit.E2, t1, t2) + irit.ctlpt(irit.E2, t1, 0))
    irit.color(ptt1, irit.YELLOW)
    ptt2 = (irit.ctlpt(irit.E2, t1, t2) + irit.ctlpt(irit.E2, 0, t2))
    irit.color(ptt2, irit.CYAN)
    n1 = (irit.coerce(
        irit.coerce(pt1, irit.POINT_TYPE) + n1 * irit.sc(scl), irit.E2) + pt1)
    irit.color(n1, irit.YELLOW)
    n2 = (irit.coerce(
        irit.coerce(pt2, irit.POINT_TYPE) + n2 * irit.sc(scl), irit.E2) + pt2)
    irit.color(n2, irit.CYAN)
    irit.view(irit.list(n1, n2, pt1, pt2, ptt1, ptt2, bg_obj), irit.ON)
示例#12
0
def makelinefromc( lc, x0, y0, r0, x1, y1,\
    r1 ):
    det = (x0 * y1 - x1 * y0)
    la = (y1 * (r0 - lc) - y0 * (r1 - lc)) / float(det)
    lb = (x0 * (r1 - lc) - x1 * (r0 - lc)) / float(det)
    if (abs(la) > abs(lb)):
        pt1 = irit.ctlpt(irit.E2, ((-lc) - lb * 10) / la, 10)
        pt2 = \
               irit.ctlpt( irit.E2, ( (-lc ) + lb * 10 )/la, (-10 ) )
    else:
        pt1 = \
               irit.ctlpt( irit.E2, 10, ( (-lc ) - la * 10 )/lb )
        pt2 = \
               irit.ctlpt( irit.E2, (-10 ), ( (-lc ) + la * 10 )/lb )
    retval = (pt1 + pt2)
    return retval
示例#13
0
def antrleganim(s):
    retval = antleg() * irit.ry(180)
    t = 0.2 * (s + 1) / 2
    rot_y = irit.creparam( irit.cbspline( 2, irit.list( irit.ctlpt( irit.E1, 13 * s ), \
                                                         irit.ctlpt( irit.E1, (-13 ) * s ), \
                                                         irit.ctlpt( irit.E1, (-13 ) * s ), \
                                                         irit.ctlpt( irit.E1, 13 * s ) ), irit.list( 0, 0, 1.3, 1.7, 3, 3 ) ),\
    0 + t, 1 + t )
    rot_z = irit.creparam( irit.cbspline( 2, irit.list( \
                                                         irit.ctlpt( irit.E1, 0 ), \
                                                         irit.ctlpt( irit.E1, 7 + 7 * s ), \
                                                         irit.ctlpt( irit.E1, 0 ), \
                                                         irit.ctlpt( irit.E1, 0 ), \
                                                         irit.ctlpt( irit.E1, 7 - 7 * s ), \
                                                         irit.ctlpt( irit.E1, 0 ) ), irit.list( irit.KV_OPEN ) ), 0 + t, 1 + t )
    irit.attrib(retval, "animation", irit.list(rot_z, rot_y))
    return retval
示例#14
0
def sideunitwalls( w, d, h, legw, legd ):
    backwall = irit.box( ( legd, d - legd - 0.018, 0.2 ), w - 2 * legd, 0.002, h - 0.3 )
    irit.attrib( backwall, "ptexture", woodtext )
    irit.attrib( backwall, "rgb", woodclr )
    leftwall = irit.box( ( legd + 0.001, legd, 0.2 ), 0.002, d - 2 * legd, h - 0.3 )
    rightwall = irit.box( ( w - legd - 0.003, legd, 0.2 ), 0.002, d - 2 * legd, h - 0.3 )
    irit.attrib( leftwall, "transp", irit.GenRealObject(0.3 ))
    irit.attrib( rightwall, "transp", irit.GenRealObject(0.3 ))
    frontdoorframe = ( irit.box( ( legw + 0.001, 0, 0.201 ), w - 2 * legw - 0.002, 0.015, h - 0.302 ) - irit.box( ( legw + 0.03, (-0.1 ), 0.23 ), w - 2 * legw - 0.062, 0.5, h - 0.362 ) - irit.box( ( legw + 0.02, 0.01, 0.22 ), w - 2 * legw - 0.04, 0.1, h - 0.34 ) )
    irit.attrib( frontdoorframe, "ptexture", woodtext )
    irit.attrib( frontdoorframe, "rgb", woodclr )
    frontdoorglass = irit.box( ( legw + 0.021, 0.011, 0.221 ), w - 2 * legw - 0.042, 0.003, h - 0.342 )
    irit.attrib( frontdoorglass, "transp", irit.GenRealObject(0.3) )
    frontdoor = irit.list( frontdoorframe, frontdoorglass )
    rot_z = ( irit.ctlpt( irit.E1, 0 ) + \
               irit.ctlpt( irit.E1, 100 ) )
    irit.attrib( frontdoor, "animation", irit.list( irit.tx( (-legw ) ), rot_z, irit.tx( legw ) ) )
    retval = irit.list( backwall, leftwall, rightwall, frontdoor )
    return retval
示例#15
0
def cornerunitbars( w, h, legw, legd ):
    sbar = irit.box( ( legw, 0, 0 ), w - 2 * legw, legd, legw )
    lbar = irit.box( ( legd, 0, 0 ), 2 * w - legd - legw, legd, legw )
    arcbar1 = irit.arc( ( w, 0, 0 ), ( w, w, 0 ), ( 2 * w, w, 0 ) )
    arcbar2 = irit.offset( arcbar1, (-legd ), 0.1, 0 )
    arcbar = irit.list( irit.extrude( arcbar1 + (-arcbar2 ) + irit.ctlpt( irit.E3, w, 0, 0 ), ( 0, 0, legw ), 0 ), irit.ruledsrf( arcbar1, arcbar2 ), irit.ruledsrf( arcbar1, arcbar2 ) * irit.tz( legw ) )
    barframe = irit.list( arcbar, sbar, sbar * irit.tx( w ) * irit.rz( 90 ) * irit.tx( 2 * w ), lbar * irit.rz( 90 ) * irit.tx( legd ), lbar * irit.tx( legw - legd ) * irit.ty( 2 * w - legd ) )
    retval = irit.list( barframe * irit.tz( 0.1 ), barframe * irit.tz( h - 0.1 ) )
    irit.attrprop( retval, "ptexture", woodtext )
    irit.attrprop( retval, "rgb", woodclr )
    return retval
示例#16
0
def extracte3pts(uvxyzpts):
    retval = irit.nil()
    irit.printf("found %d points\n", irit.list(irit.SizeOf(uvxyzpts)))
    i = 1
    while (i <= irit.SizeOf(uvxyzpts)):
        uvxyzpt = irit.nth(uvxyzpts, i)
        irit.snoc(
            irit.ctlpt(irit.E3, irit.coord(uvxyzpt, 3), irit.coord(uvxyzpt, 4),
                       irit.coord(uvxyzpt, 5)), retval)
        i = i + 1
    return retval
示例#17
0
def marbleshelfunit( w, h ):
    prof1 = ( irit.ctlpt( irit.E3, 2 * w, 0, 0 ) + irit.cbspline( 3, irit.list( \
               irit.ctlpt( irit.E3, 2 * w, w, 0 ), \
               irit.ctlpt( irit.E3, 2 * w, 2 * w, 0 ), \
               irit.ctlpt( irit.E3, w, 2 * w, 0 ) ), irit.list( irit.KV_OPEN ) ) + \
               irit.ctlpt( irit.E3, 0, 2 * w, 0 ) )
    prof2 = ( \
               irit.ctlpt( irit.E3, 0, 2 * w, 0 ) + \
               irit.ctlpt( irit.E3, 0, 0, 0 ) + \
               irit.ctlpt( irit.E3, 2 * w, 0, 0 ) )
    retval = irit.list( irit.extrude( prof1 + prof2, ( 0, 0, 0.025 ), 0 ), irit.ruledsrf( prof1, (-prof2 ) ), irit.ruledsrf( prof1, (-prof2 ) ) * irit.tz( 0.025 ) ) * irit.tz( h )
    irit.attrprop( retval, "ptexture", marbletext )
    irit.attrprop( retval, "rgb", marbleclr )
    return retval
示例#18
0
def genrandomcrv(d, n, size):
    ctlpts = irit.nil()
    i = 1
    while (i <= n):
        irit.snoc(
            irit.ctlpt(irit.E2, irit.random((-size), size),
                       irit.random((-size), size)), ctlpts)
        i = i + 1
    retval = irit.cbspline(
        d,
        ctlpts * irit.tx(irit.random((-1), 1)) * irit.ty(irit.random((-1), 1)),
        irit.list(irit.KV_PERIODIC))
    retval = irit.coerce(retval, irit.KV_OPEN)
    return retval
示例#19
0
def randomctlpt3(n):
    l = irit.nil()
    i = 1
    while (i <= n):
        r = irit.random((-0.5), 0.5)
        t = irit.random(0, 2 * math.pi)
        irit.snoc(
            irit.ctlpt(irit.E3,
                       math.cos(t) * r, irit.random(0.5, 1.5),
                       math.sin(t) * r), l)
        i = i + 1
    retval = l
    irit.color(retval, irit.GREEN)
    irit.adwidth(retval, 3)
    return retval
示例#20
0
def cornerunitwalls( w, h, legw, legd ):
    lwall = irit.box( ( legd, 0, 0.2 ), 2 * w - 2 * legd, 0.002, h - 0.3 )
    irit.attrib( lwall, "ptexture", woodtext )
    irit.attrib( lwall, "rgb", woodclr )
    swall = irit.box( ( legd, 0, 0.2 ), w - 2 * legd, 0.002, h - 0.3 )
    irit.attrib( swall, "transp", irit.GenRealObject(0.3 ))
    arcbar1 = irit.arc( ( w, 0, 0 ), ( w, w, 0 ), ( 2 * w, w, 0 ) )
    arcbar2 = irit.offset( arcbar1, irit.GenRealObject(-0.03 ), 0.1, 0 )
    arcbar = irit.list( irit.extrude( arcbar1 + (-arcbar2 ) + irit.ctlpt( irit.E3, w, 0, 0 ), ( 0, 0, 0.03 ), 0 ), irit.ruledsrf( arcbar1, arcbar2 ), irit.ruledsrf( arcbar1, arcbar2 ) * irit.tz( 0.03 ) )
    rdoorframe = irit.list( irit.box( ( w, 0, 0.2 ), 0.03, 0.03, h - 0.3 ),\
    irit.box( ( 2 * w - 0.03, w - 0.03, 0.2 ), 0.03, 0.03, h - 0.3 ),\
    arcbar * irit.tz( 0.2 ), arcbar * irit.tz( h - 0.1 - 0.03 ) )
    irit.attrib( rdoorframe, "ptexture", woodtext )
    irit.attrib( rdoorframe, "rgb", woodclr )
    rdoorglass = irit.extrude( irit.offset( arcbar1, irit.GenRealObject(-0.02 ), 0.1, 0 ) + (-irit.offset( arcbar1, irit.GenRealObject(-0.03 ), 0.1, 0 ) ) + \
                                                               irit.ctlpt( irit.E3, w - 0.02, 0, 0 ), ( 0, 0, h - 0.3 - 0.04 ), 0 ) * irit.tz( 0.22 )
    irit.attrib( rdoorglass, "transp", irit.GenRealObject(0.3 ))
    rdoor = irit.list( rdoorframe, rdoorglass )
    rot_z = ( \
                                                               irit.ctlpt( irit.E1, 0 ) + \
                                                               irit.ctlpt( irit.E1, 130 ) )
    irit.attrib( rdoor, "animation", irit.list( irit.tx( (-w ) ), rot_z, irit.tx( w ) ) )
    retval = irit.list( lwall * irit.ty( 2 * w ), swall * irit.rz( 90 ) * irit.tx( 2 * w ) * irit.ty( w ), lwall * irit.rz( 90 ), swall, rdoor )
    return retval
示例#21
0
def genanimationorthomatchprmpts(ppl):
    prm1 = ( irit.ctlpt( irit.E2, 0, 0 ) + \
              irit.ctlpt( irit.E2, 0, 1 ) )
    irit.color(prm1, irit.YELLOW)
    prm2 = ( \
              irit.ctlpt( irit.E2, 0, 0 ) + \
              irit.ctlpt( irit.E2, 1, 0 ) )
    irit.color(prm2, irit.CYAN)
    pos1 = irit.nil()
    pos2 = irit.nil()
    pos12 = irit.nil()
    i = 0
    while (i <= irit.SizeOf(ppl) - 1):
        pl = irit.coord(ppl, i)
        j = 0
        while (j <= irit.SizeOf(pl) - 1):
            pt = irit.coord(pl, j)
            t1 = irit.coord(pt, 0)
            t2 = irit.coord(pt, 1)
            if (t1 > t2):
                irit.snoc(irit.vector(irit.FetchRealObject(t1), 0, 0), pos1)
                irit.snoc(irit.vector(0, irit.FetchRealObject(t2), 0), pos2)
                irit.snoc(pt, pos12)
            j = j + 1
        if (t1 > t2):
            irit.snoc(irit.vector(10000, 0, 0), pos1)
            irit.snoc(irit.vector(10000, 0, 0), pos2)
        i = i + 1
    pt = irit.point(0, 0, 0)
    irit.color(pt, irit.RED)
    irit.adwidth(pt, 3)
    irit.attrib(pt, "animation", makerottransanimobj(irit.nil(), pos12))
    irit.attrib(prm1, "animation", makerottransanimobj(irit.nil(), pos1))
    irit.attrib(prm2, "animation", makerottransanimobj(irit.nil(), pos2))
    retval = irit.list(pt, prm1, prm2)
    return retval
示例#22
0
def genrandomcrv(d, n, size):
    ctlpts = irit.nil()
    i = 1
    while (i <= n):
        irit.snoc(
            irit.ctlpt(irit.E2, irit.random((-size), size),
                       irit.random((-size), size)), ctlpts)
        i = i + 1
    if (irit.random(0, 1) > 0.3):
        kv = irit.KV_PERIODIC
    else:
        kv = irit.KV_OPEN
    retval = irit.cbspline(
        d,
        ctlpts * irit.tx(irit.random(
            (-0.2), 0.2)) * irit.ty(irit.random((-0.2), 0.2)), irit.list(kv))
    retval = irit.coerce(retval, irit.KV_OPEN)
    return retval
示例#23
0
irit.pause(  )

# ############################################################################
# 
#  Curves
#  
# ############################################################################

view_mat1 = irit.sc( 0.5 )

irit.viewobj( view_mat1 )

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

c = irit.cbezier( irit.list( irit.ctlpt( irit.E2, 0, (-1 ) ), \
                             irit.ctlpt( irit.E2, 0, 1 ) ) ) * irit.tx( 0.3 ) * irit.ty( 0.5 )
irit.adwidth( c, 3 )

k = irit.crvkernel( c, 15, 0, irit.GenIntObject(2), 2 )
irit.color( k, irit.YELLOW )

irit.interact( irit.list( c, k, irit.GetAxes() ) )

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

c = irit.cbezier( irit.list( irit.ctlpt( irit.E2, (-1 ), 1 ), \
                             irit.ctlpt( irit.E2, 0, (-1 ) ), \
                             irit.ctlpt( irit.E2, 1, 1 ) ) )
irit.adwidth( c, 3 )
irit.color( c, irit.RED )
示例#24
0
# 
#  Examples of constructing uniform point distributions on freeforms.
# 
#                                        Gershon Elber, August 1996.
# 

save_mat = irit.GetViewMatrix()
irit.SetViewMatrix(  irit.rotx( 0 ))
irit.viewobj( irit.GetViewMatrix() )

# 
#  Some examples for curves.
# 

c1 = irit.cbezier( irit.list( irit.ctlpt( irit.E2, (-1 ), 0 ), \
                              irit.ctlpt( irit.E2, (-1 ), 0.1 ), \
                              irit.ctlpt( irit.E2, (-0.9 ), (-0.1 ) ), \
                              irit.ctlpt( irit.E2, 0.9, 0 ) ) )
irit.color( c1, irit.MAGENTA )

pts = irit.ffptdist( c1, 0, 1000 )
e2pts = irit.nil(  )
i = 1
while ( i <= irit.SizeOf( pts ) ):
    pt = irit.ceval( c1, irit.FetchRealObject(irit.coord( irit.nth( pts, i ), 0 ) ))
    irit.snoc( pt, e2pts )
    i = i + 10
irit.interact( irit.list( e2pts, c1 ) )

irit.save( "ffptdst1", irit.list( e2pts, c1 ) )
示例#25
0
#This is an IRIT script and as such requires both math and irit import:
#
import math
import irit
#

#
#  Examples of ruled ruled surface intersection approximations.
#
#                                        Gershon Elber, February 1998
#

genaxes = irit.list( irit.ctlpt( irit.E3, 0, 0, 0 ) + \
                     irit.ctlpt( irit.E3, 0, 0, 0.4 ), \
                     irit.ctlpt( irit.E3, 0, 0, 0 ) + \
                     irit.ctlpt( irit.E3, 0, 1.1, 0 ), \
                     irit.ctlpt( irit.E3, 0, 0, 0 ) + \
                     irit.ctlpt( irit.E3, 1.1, 0, 0 ) )
irit.awidth(genaxes, 0.005)
irit.color(genaxes, irit.GREEN)


def evaluvtoe3(srf, uvs, clr):
    retval = irit.nil()
    i = 1
    while (i <= irit.SizeOf(uvs)):
        uv = irit.nth(uvs, i)
        irit.snoc(
            irit.seval(srf, irit.FetchRealObject(irit.coord(uv, 1)),
                       irit.FetchRealObject(irit.coord(uv, 2))), retval)
        i = i + 1
示例#26
0
            irit.FetchRealObject(irit.nth(bb, 2)) > 0):
        res = "successful"
    else:
        res = "failed"
    all3 = irit.list(irit.nth(bb, 1), irit.nth(bb, 2), res)
    irit.printf("projection on srf2nrml bound from %8.5lf to %8.5lf  (%s)\n",
                all3)
    irit.pause()
    retval = irit.list(all1, all2, all3)
    return retval


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


crv1a = irit.cbezier( irit.list( irit.ctlpt( irit.E1, 0.2 ), \
                                 irit.ctlpt( irit.E2, 0.5, 4 ), \
                                 irit.ctlpt( irit.E2, 1.3, 0.05 ) ) ) * irit.sy( 0.2 )
crv2a = irit.cbezier( irit.list( \
                                 irit.ctlpt( irit.E1, (-0.2 ) ), \
                                 irit.ctlpt( irit.E2, 0.25, 1.9 ), \
                                 irit.ctlpt( irit.E2, 1.3, 0.05 ) ) ) * irit.ty( 0.3 ) * irit.sx( 1.5 )
crv1b = irit.cbezier( irit.list( \
                                 irit.ctlpt( irit.E2, 0.2, (-0.5 ) ), \
                                 irit.ctlpt( irit.E2, 0.5, 4 ), \
                                 irit.ctlpt( irit.E2, 1.3, (-0.45 ) ) ) ) * irit.sy( 0.2 )
crv2b = irit.cbezier( irit.list( \
                                 irit.ctlpt( irit.E2, (-0 ), (-0.5 ) ), \
                                 irit.ctlpt( irit.E2, 0.25, 1.09 ), \
                                 irit.ctlpt( irit.E2, 1.1, (-0.5 ) ) ) ) * irit.ty( 0.3 ) * irit.sx( 1.5 )
irit.save(
示例#27
0
irit.attrib(legs, "rgb", irit.GenStrObject("244,164,96"))
irit.free(leg1)
irit.free(leg2)

skel = irit.list( irit.box( ( (-1 ), (-1 ), 25 ), 80, 2, 20 ),\
irit.box( ( (-1 ), (-1 ), 25 ), 2, 190, 20 ),\
irit.box( ( (-1 ), 189, 25 ), 80, 2, 20 ),\
irit.box( ( 79, (-1 ), 25 ), 2, 190, 20 ),\
irit.box( ( (-1 ), 90, 25 ), 80, 2, 20 ) )
irit.attrib(skel, "rgb", irit.GenStrObject("255,255,100"))
irit.viewobj(skel)

cover = irit.box((0, 0, 45), 80, 190, 1)
irit.attrib(cover, "rgb", irit.GenStrObject("244,164,96"))

backcross = irit.cbspline( 3, irit.list( irit.ctlpt( irit.E3, 0, 0, 75 ), \
                                         irit.ctlpt( irit.E3, 15, 0, 75 ), \
                                         irit.ctlpt( irit.E3, 30, 0, 95 ), \
                                         irit.ctlpt( irit.E3, 50, 0, 95 ), \
                                         irit.ctlpt( irit.E3, 65, 0, 75 ), \
                                         irit.ctlpt( irit.E3, 80, 0, 75 ) ), irit.list( irit.KV_OPEN ) )
backcrosspts = irit.list(irit.vector(80, 0, 75), irit.vector(80, 0, 45),
                         irit.vector(0, 0, 45))

heartcross = ( irit.cbspline( 3, irit.list( irit.ctlpt( irit.E3, 0, 0, (-10 ) ), \
                                            irit.ctlpt( irit.E3, 3, 0, 0 ), \
                                            irit.ctlpt( irit.E3, 12, 0, 5 ), \
                                            irit.ctlpt( irit.E3, 12, 0, 15 ), \
                                            irit.ctlpt( irit.E3, 3, 0, 15 ), \
                                            irit.ctlpt( irit.E3, 0, 0, 10 ) ), irit.list( irit.KV_OPEN ) ) + irit.cbspline( 3, irit.list( \
                                            irit.ctlpt( irit.E3, 0, 0, 10 ), \
示例#28
0
def cubeat(x, y, z):
    retval = irit.box((x - size / 2.0, y - size / 2.0, z - size / 2.0), size,
                      size, size)
    irit.attrib(
        retval, "rgb",
        irit.GenStrObject(
            str(int(irit.random(64, 255))) + "," +
            str(int(irit.random(64, 255))) + "," +
            str(int(irit.random(64, 255)))))
    return retval


stage1 = irit.list(cubeat(0, 0, 0), cubeat(0, (-size), 0),
                   cubeat(0, (-2) * size, 0))
rot_x = irit.creparam( irit.cbezier( irit.list( irit.ctlpt( irit.E1, 0 ), \
                                                irit.ctlpt( irit.E1, 90 ) ) ), 0, 1 )
irit.attrib(stage1, "animation", irit.list(rot_x))
irit.free(rot_x)

stage2 = irit.list(cubeat(0, 0, 0), cubeat(size, 0, 0),
                   stage1 * irit.trans((2 * size, 0, 0)))
rot_y = irit.creparam( irit.cbezier( irit.list( irit.ctlpt( irit.E1, 0 ), \
                                                irit.ctlpt( irit.E1, 90 ) ) ), 1, 2 )
irit.attrib(stage2, "animation", irit.list(rot_y))
irit.free(rot_y)
irit.free(stage1)

stage3 = irit.list(cubeat(0, 0, 0), cubeat(0, size, 0),
                   stage2 * irit.trans((0, 2 * size, 0)))
rot_z = irit.creparam( irit.cbezier( irit.list( irit.ctlpt( irit.E1, 0 ), \
示例#29
0
#
#  Set states.
#
save_mat = irit.GetViewMatrix()
irit.SetViewMatrix(irit.GetViewMatrix() * irit.sc(0.35))
irit.viewobj(irit.GetViewMatrix())

#  Faster product using Bezier decomposition.
iprod = irit.iritstate("bspprodmethod", irit.GenIntObject(0))

# ############################################################################
#
#  A point and a line in the XY plane
#
c1 = irit.cbezier( irit.list( irit.ctlpt( irit.E2, (-0.3 ), (-1 ) ), \
                              irit.ctlpt( irit.E2, (-0.3 ), 1 ) ) )
pt2 = irit.point(0.4, 0.2, 0)
irit.color(c1, irit.RED)
irit.adwidth(c1, 3)
irit.color(pt2, irit.RED)
irit.adwidth(pt2, 3)

t = 0
while (t <= 1):
    bisectcrv = irit.calphasector(irit.list(c1, pt2), t)
    irit.color(bisectcrv, irit.GREEN)
    irit.view(irit.list(c1, pt2, bisectcrv), irit.ON)
    t = t + 0.03

irit.save(
示例#30
0
t3 = irit.surfrevaxs(plgcross, (1, 1, 1))
irit.interact(irit.list(pllcross, irit.GetAxes(), t3))

t4 = irit.surfrevax2(plgcross, 90, 360, (1, 0, 1))
irit.interact(irit.list(pllcross, irit.GetAxes(), t4))

#  T9 = surfRevAxs( PlgCross, vector( 0, 1, 0 ) );

irit.free(pllcross)
irit.free(plgcross)

#
#  Surface of revolution of freeform curves.
#

gcross = irit.cbspline( 3, irit.list( irit.ctlpt( irit.E3, 0.3, 0, 0 ), \
                                      irit.ctlpt( irit.E3, 0.3, 0, 0.05 ), \
                                      irit.ctlpt( irit.E3, 0.1, 0, 0.05 ), \
                                      irit.ctlpt( irit.E3, 0.1, 0, 0.4 ), \
                                      irit.ctlpt( irit.E3, 0.5, 0, 0.4 ), \
                                      irit.ctlpt( irit.E3, 0.6, 0, 0.8 ) ), irit.list( 0, 0, 0, 1, 2, 3,\
4, 4, 4 ) )
irit.color(gcross, irit.GREEN)
irit.adwidth(gcross, 5)

glass1 = irit.surfrev(gcross)
irit.interact(irit.list(gcross, irit.GetAxes(), glass1))

glass2 = irit.surfrev2(gcross, 45, 180)
irit.interact(irit.list(gcross, irit.GetAxes(), glass2))