OpenMotionLab/MotionGPT
118
1.. _quickstart_guide:2 3Quickstart4==========5 6 7Minimal Example for 3D Viewer8-----------------------------9Here is a minimal example of loading and viewing a triangular mesh model10in pyrender.11 12>>> import trimesh13>>> import pyrender14>>> fuze_trimesh = trimesh.load('examples/models/fuze.obj')15>>> mesh = pyrender.Mesh.from_trimesh(fuze_trimesh)16>>> scene = pyrender.Scene()17>>> scene.add(mesh)18>>> pyrender.Viewer(scene, use_raymond_lighting=True)19 20.. image:: /_static/fuze.png21 22 23Minimal Example for Offscreen Rendering24---------------------------------------25.. note::26 If you're using a headless server, make sure that you followed the guide27 for installing OSMesa. See :ref:`osmesa`.28 29Here is a minimal example of rendering a mesh model offscreen in pyrender.30The only additional necessities are that you need to add lighting and a camera.31 32>>> import numpy as np33>>> import trimesh34>>> import pyrender35>>> import matplotlib.pyplot as plt36 37>>> fuze_trimesh = trimesh.load('examples/models/fuze.obj')38>>> mesh = pyrender.Mesh.from_trimesh(fuze_trimesh)39>>> scene = pyrender.Scene()40>>> scene.add(mesh)41>>> camera = pyrender.PerspectiveCamera(yfov=np.pi / 3.0, aspectRatio=1.0)42>>> s = np.sqrt(2)/243>>> camera_pose = np.array([44... [0.0, -s, s, 0.3],45... [1.0, 0.0, 0.0, 0.0],46... [0.0, s, s, 0.35],47... [0.0, 0.0, 0.0, 1.0],48... ])49>>> scene.add(camera, pose=camera_pose)50>>> light = pyrender.SpotLight(color=np.ones(3), intensity=3.0,51... innerConeAngle=np.pi/16.0,52... outerConeAngle=np.pi/6.0)53>>> scene.add(light, pose=camera_pose)54>>> r = pyrender.OffscreenRenderer(400, 400)55>>> color, depth = r.render(scene)56>>> plt.figure()57>>> plt.subplot(1,2,1)58>>> plt.axis('off')59>>> plt.imshow(color)60>>> plt.subplot(1,2,2)61>>> plt.axis('off')62>>> plt.imshow(depth, cmap=plt.cm.gray_r)63>>> plt.show()64 65.. image:: /_static/minexcolor.png66 :width: 45%67 :align: left68.. image:: /_static/minexdepth.png69 :width: 45%70 :align: right71 72 