transform # show the mesh appended with its oriented bounding box # the bounding box is a object, which subclasses # Trimesh and lazily evaluates to fill in vertices and faces when requested # (press w in viewer to see triangles) ( mesh + mesh. extents # a minimum volume oriented bounding box also available # primitives are subclasses of Trimesh objects which automatically generate # faces and vertices from data stored in the 'primitive' attribute mesh. random_rotation_matrix ()) # axis aligned bounding box is available mesh. show () # transform method can be passed a (4, 4) matrix and will cleanly apply the transform mesh. random_color () # preview mesh in an opengl window if you installed pyglet and scipy with pip mesh. split () # facets are groups of coplanar adjacent faces # set each facet to a random color # colors are 8 bit RGBA by default (n, 4) np.uint8 for facet in mesh. moment_inertia # if there are multiple bodies in the mesh we can split the mesh by # connected components of face adjacency # since this example mesh is a single watertight body we get a list of one mesh mesh. center_mass # what's the moment of inertia for the mesh? mesh. volume ) # since the mesh is watertight, it means there is a # volumetric center of mass which we can set as the origin for our mesh mesh. euler_number # the convex hull is another Trimesh object that is available as a property # lets compare the volume of our mesh with the volume of its convex hull print ( mesh. is_watertight # what's the euler number for the mesh? mesh. load ( './models/featuretype.STL' ) # is the current mesh watertight? mesh. load ( 'models/CesiumMilkTruck.glb', force = 'mesh' ) # mesh objects can be loaded from a file name or from a buffer # you can pass any of the kwargs for the `Trimesh` constructor # to `trimesh.load`, including `process=False` if you would like # to preserve the original loaded data without merging vertices # STL files will be a soup of disconnected triangles without # merging vertices however and will not register as watertight mesh = trimesh. # if you *always* want a straight `trimesh.Trimesh` you can ask the # loader to "force" the result into a mesh through concatenation mesh = trimesh. Trimesh ( vertices =, , ], faces = ], process = False ) # some formats represent multiple meshes with multiple instances # the loader tries to return the datatype which makes the most sense # which will for scene-like files will return a `trimesh.Scene` object. Trimesh ( vertices =, , ], faces = ]) # by default, Trimesh will do a light processing, which will # remove any NaN values and merge vertices that share position # if you want to not do this on load, you can pass `process=False` mesh = trimesh. attach_to_log () # mesh objects can be created from existing faces and vertex data mesh = trimesh. Import numpy as np import trimesh # attach to logger so trimesh messages will be printed to console trimesh. With just numpy, pip can generally install trimesh cleanly on Packages adds functionality but is not required. Keeping trimesh easy to install is a core goal, thus the only hard Here’s a quick developmentĪnd contributing guide. Things not on that list are also welcome. To contribute, here is an up to date list of potential Pull requests are appreciated and responded to promptly! If you’d like Guaranteed: install a specific version if you plan on deploying The API is mostly stable, but this should not be relied on and is not Manipulation and analysis, in the style of the Polygon object in the The goal of the library is to provide a fullįeatured and well tested Trimesh object which allows for easy Trimesh is a pure Python 3.7+ library for loading and using triangular Projects that support python<3.7 should update requirement to Testing with pip install -pre trimesh would be much Trimesh >= 4.0.0 on release-candidate makes minimum Python
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |