Exemplo n.º 1
0
def sphere():
    minCoord = pgf.var_float(-1.)
    maxCoord = pgf.var_float(1.)
    minpt = pgf.vec3(minCoord, minCoord, minCoord)
    maxpt = pgf.vec3(maxCoord, maxCoord, maxCoord)
    box = pgf.box3(minpt, maxpt)
    npts = pgv.slideri32("Point count", 5, 50, 25)
    cloud = pgf.randomPointsInBox(box, npts)
    pgv.show("Point Cloud", cloud)
    sphere, *_ = pgf.boundingSphere(cloud)
    return sphere
Exemplo n.º 2
0
def test_meshPlaneClipping():
    mesh = loadLargeBunny()
    half = pgf.var_float(0.5)
    plane = pgf.plane(pgf.vec3(half, half, half), pgf.vec3(half, half, half))
    clipped = pgf.clipMesh(mesh, plane)

    area = pgf.read(pgf.area(clipped))
    nfaces = pgf.read(pgf.numFaces(clipped))
    nverts = pgf.read(pgf.numVertices(clipped))

    assert tu.equalf(area, 19.79486274)
    assert nfaces == 59387
    assert nverts == 30013
Exemplo n.º 3
0
def test_meshSphereQuery():
    mesh = pgf.scale(loadSmallBunny(), pgf.var_float(10.0))
    zero = pgf.var_float(0.)
    center = pgf.vec3(zero, zero, zero)
    radius = pgf.var_float(.5)
    sphere = pgf.sphere(center, radius)

    rmesh, rindices, rcount = pgf.meshSphereQuery(mesh, sphere)

    nfaces = pgf.read(rcount)
    area = pgf.read(pgf.area(rmesh))
    assert tu.equalf(area, 0.4436888098716736)
    assert nfaces == 292