import pygalfunc as pgf
import pygalview as pgv

# relpath = pgf.var_string("../assets/bunny_large.obj")
relpath = pgv.textField("relpath")
path = pgf.absPath(relpath)
mesh = pgf.loadObjFile(path)
scale = pgf.var_float(10.0)
scaled = pgf.scale(mesh, scale)

pt = pgv.sliderVec3("point", 0., 1., .5)
norm = pgv.sliderVec3("normal", 0., 1., .5)
plane = pgf.plane(pt, norm)
clipped = pgf.clipMesh(scaled, plane)

area = pgf.area(clipped)
centroid = pgf.centroid(clipped)

pgv.show("Plane", plane)
pgv.show("Clipped Mesh", clipped)
pgv.print("Original triangle count", pgf.numFaces(scaled))
pgv.print("Final triangle count", pgf.numFaces(clipped))
pgv.print("Mesh Area", area)
pgv.print("Mesh Centroid", centroid)
Exemplo n.º 2
0
import pygalfunc as pgf
import pygalview as pgv

relpath = pgf.var_string("../assets/bunny_large.obj")
# relpath = pgv.textField("Relative file path");
path = pgf.absPath(relpath)
mesh = pgf.loadObjFile(path)
box = pgf.bounds(mesh)
pgv.show("mesh", mesh)
pgv.show("bounds", box)
pgv.show("centroid", pgf.centroid(mesh))

pgv.runCommands("""
perspective off
wireframe on
""")
Exemplo n.º 3
0
def test_meshCentroid():
    mesh = loadLargeBunny()
    centroid = pgf.read(pgf.centroid(mesh))
    assert tu.equalf(
        centroid,
        [-0.4187779128551483, -0.21727733314037323, 0.7404823899269104])
Exemplo n.º 4
0
def test_meshCentroid():
    mesh = loadLargeBunny()
    centroid = pgf.read(pgf.centroid(mesh))
    assert tu.equalf(
        centroid,
        [-0.46018099784851074, -0.17610645294189453, 0.8226389288902283])