Exemple #1
0
def blkFace(obj):

    cameraPos = rs.ViewCamera()

    cameraPos.Z = 0

    xform = rs.BlockInstanceXform(obj)
    plane = rs.PlaneTransform(rs.WorldXYPlane(), xform)

    viewdir = rs.VectorUnitize(cameraPos - plane.Origin)

    angle = rs.VectorAngle(viewdir, plane.YAxis)

    newXform = rs.XformRotation3(plane.YAxis, viewdir, plane.Origin)

    rs.TransformObject(obj, newXform)
Exemple #2
0
def blkFace(obj):

    cameraPos = rs.ViewCamera()

    cameraPos.Z = 0

    plane = rs.WorldXYPlane()

    if rs.IsBlockInstance(obj):
        plane = blkPlane(obj)
    elif rs.IsSurface(obj):
        plane = srfPlane(obj)

    targetpos = plane.Origin
    targetpos.Z = 0

    viewdir = rs.VectorUnitize(cameraPos - targetpos)

    angle = rs.VectorAngle(viewdir, plane.YAxis)

    newXform = rs.XformRotation3(plane.YAxis, viewdir, plane.Origin)

    rs.TransformObject(obj, newXform)
Exemple #3
0
rs.AddLayer("Cactus")
rs.CurrentLayer("Cactus")
surf = rs.AddLoftSrf(sections)
rs.CapPlanarHoles(surf)

#Draw spines
cone = rs.AddCone([0, 0, -sh], sh, sr)
basis = []
theta = ma.pi / 8
dphi = 2 * ma.pi / m
for k in range(0, m):
    phi = k * dphi
    x = ma.sin(theta) * ma.cos(phi)
    y = ma.sin(theta) * ma.sin(phi)
    z = ma.cos(theta)
    matrix = rs.XformRotation3([0, 0, 1], [x, y, z], [0, 0, 0])
    basis.append(rs.TransformObject(cone, matrix, True))
rs.DeleteObject(cone)

for crv in ridges:
    domain = rs.CurveDomain(crv)
    dt = (domain[1] - domain[0]) / 10
    for j in range(1, 10):
        t = domain[0] + j * dt
        point = rs.EvaluateCurve(crv, t)
        xaxis = rs.CurveTangent(crv, t)
        yaxis = rs.VectorCrossProduct(xaxis, point)
        zaxis = rs.VectorCrossProduct(xaxis, yaxis)
        matrix = rs.XformRotation3([0, 0, 1], zaxis, [0, 0, 0])
        copy = rs.TransformObjects(basis, matrix, True)
        matrix = rs.XformTranslation(point)