LiangliangNan / Easy3D

A lightweight, easy-to-use, and efficient C++ library for processing and rendering 3D data
GNU General Public License v3.0
1.35k stars 243 forks source link

[Question] - Is there a quick way to draw 3D line given 2 vec3 ? #160

Closed KenKenhehe closed 1 year ago

KenKenhehe commented 1 year ago

I am trying to use orientedline for checking if it intersect with a face, and I want to visualize this line, is there a quick way? Or do I need to implement that from scratch?

LiangliangNan commented 1 year ago

Below is an example:

    // Create a LinesDrawable to visualize your line
    auto drawable = new LinesDrawable("line");
    // The two vertices of a line
    const std::vector<vec3> vertices = { a, b };  // assume the two endpoints of the line are: a and b
    // Upload the vertices of the line to GPU.
    drawable->update_vertex_buffer(vertices);
    // Set color (here we want a blue color)
    drawable->set_uniform_coloring(vec4(0.0f, 0.0f, 1.0f, 1.0f));    // r, g, b, a
    // Set the width of the line (here 5 pixels)
    drawable->set_line_width(5.0f);
    // Add the drawable to the viewer
    viewer.add_drawable(drawable);

More examples are in the tutorials, e.g., Tutorial_301_Drawables.

KenKenhehe commented 1 year ago

Thank you! This is really helpful