File: render.py

package info (click to toggle)
trimesh 4.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 33,416 kB
  • sloc: python: 35,596; makefile: 96; javascript: 85; sh: 38
file content (26 lines) | stat: -rw-r--r-- 783 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from pyglet import gl

import trimesh

if __name__ == "__main__":
    # print logged messages
    trimesh.util.attach_to_log()

    # make a sphere
    mesh = trimesh.creation.icosphere()

    # get a scene object containing the mesh, this is equivalent to:
    # scene = trimesh.scene.Scene(mesh)
    scene = mesh.scene()

    # set a GL config that fixes a depth buffer issue in xvfb
    window_conf = gl.Config(double_buffer=True, depth_size=24)
    # run the actual render call
    png = scene.save_image(resolution=[1920, 1080], window_conf=window_conf)

    # the PNG is just bytes data
    trimesh.util.log.info("rendered bytes:", len(png))

    # write the render to a volume we should have docker mounted
    with open("/output/output.png", "wb") as f:
        f.write(png)