mmatl / pyrender

Easy-to-use glTF 2.0-compliant OpenGL renderer for visualization of 3D scenes.
http://pyrender.readthedocs.io/
MIT License
1.31k stars 225 forks source link

How to render a line ? #190

Open manuel-koch opened 3 years ago

manuel-koch commented 3 years ago

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

Any help or hint appreciated !

manuel-koch commented 3 years ago

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) ?

Edwinzero commented 2 years ago

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