pyrender icon indicating copy to clipboard operation
pyrender copied to clipboard

How to render a line ?

Open manuel-koch opened this issue 3 years ago • 2 comments

I was wondering how one can draw a line like it is possible in trimesh using Path3D instance ? Unfortunately pyrender will not accept a Path3d instance when calling pyrender.Mesh.from_trimesh().

I tried creating a pyrender.Primitive with mode pyrender.constants.GLTF.LINE or pyrender.constants.GLTF.LINE_STRIP and adding it to my pyrender.Scene instance. But unfortunately my naive approach doesn't seem to work, i.e. I don't see anything rendered nor any error.

line = pyrender.Primitive(positions=[[0, 0, 0], [100, 0, 0], [100, 100, 0]], mode=pyrender.constants.GLTF.LINE)
line_mesh = pyrender.Mesh([line])
line_mesh_node = scene.add(line_mesh)

Is there any simple example code available that would show how to

  • render a line given list of 3d points using pyrender.Primitive
  • or convert a trimesh Path3d into something that pyrender can handle/draw

Any help or hint appreciated !

manuel-koch avatar Jun 08 '21 11:06 manuel-koch

At least the following example renders two parallel lines in red color:

    line = pyrender.Primitive(
        positions=[[200, 0, 75], [200, 0, 100], [150, 0, 100], [150, 0, 75]],
        color_0=[255, 0, 0],
        mode=pyrender.constants.GLTF.LINES)
    line_mesh = pyrender.Mesh([line])
    line_mesh_node = scene.add(line_mesh)

Is it possible to control the thickness of the line(s) ?

manuel-koch avatar Jun 08 '21 12:06 manuel-koch

@manuel-koch I met the same problem, do you find any solutions?

Edwinzero avatar Jan 10 '22 07:01 Edwinzero