def test_meshBounds(): assetFiles = ["bunny_large.obj", "bunny.obj"] fpaths = pgf.var_string("") pgf.assign(fpaths, [tu.assetPath(a) for a in assetFiles]) meshes = pgf.loadObjFile(fpaths) bounds = pgf.bounds(meshes) pmins, pmaxs = pgf.boxPoints(bounds) vpmins = pgf.read(pmins) vpmaxs = pgf.read(pmaxs) assert tu.equalf( vpmins, [[-1.8937978744506836, -1.1759940385818481, -0.3402520418167114], [-0.09438041597604752, -0.058714643120765686, 0.033309899270534515]]) assert tu.equalf( vpmaxs, [[1.2201818227767944, 1.2374719381332397, 2.746419906616211], [0.060778796672821045, 0.061679162085056305, 0.18699601292610168]])
import pygalfunc as pgf import pygalview as pgv relpath = pgf.var_string("../assets/bunny.obj") path = pgf.absPath(relpath) mesh = pgf.loadObjFile(path) scale = pgf.var_float(10.0) scaled = pgf.scale(mesh, scale) center = pgv.sliderVec3("center", 0., 1., 0.) radius = pgv.sliderf32("radius", 0., 1., .5) sphere = pgf.sphere(center, radius) resultMesh, resultIndices, numResults = pgf.meshSphereQuery(scaled, sphere) pgv.print("Number of results", numResults) pgv.show("Queried faces", resultMesh) pgv.show("Sphere", sphere)
def loadMesh(assetFileName): fpath = pgf.var_string(tu.assetPath(assetFileName)) return pgf.loadObjFile(fpath)
def mesh(): relpath = pgf.var_string("../assets/bunny_large.obj") # relpath = pgv.textField("Relative file path"); path = pgf.absPath(relpath) return pgf.loadObjFile(path)