A Renderer manages the drawables (and thus the rendering) of a model.
More...
#include <easy3d/renderer/renderer.h>
A Renderer manages the drawables (and thus the rendering) of a model.
Renderer also allow to create default drawables for most rendering purposes.
- See also
- Drawable, PointsDrawable, LinesDrawable, TrianglesDrawable
The following code shows how to use renderer:
model->set_renderer(std::make_shared<Renderer>(
model.get(), create));
Model * model()
The model to which this renderer is attached.
Definition renderer.h:86
◆ Renderer()
Constructor.
- Parameters
-
model | The model to which this renderer is attached. |
create_drawables | true to create default drawables for this model. Skip the creation if false . The supported default drawables are
- PointCloud: "vertices".
- SurfaceMesh: "faces", "vertices", "edges", and "borders".
- Graph: "vertices", and "edges".
- PolyMesh: "faces:border" and "faces:interior". After the
model has been changed or modified (in geometry, texture, color, etc.), client code can call update() for the rendering buffers of its default drawable to be automatically updated during the rendering stage. In case the default drawables don't meet a particular visualization purpose, client code should skip the creation of the default drawables (by passing false to create_drawables ). Instead, create a customized drawable and update the buffers accordingly. If the drawable changes or will be modified frequently and its visualization is expected to be automatically updated after each change, provide an update function.
|
- See also
- update(),
◆ add_lines_drawable()
Create a new lines drawable and add it to this renderer.
- Parameters
-
name | The name of the lines drawable to be created. |
- Returns
- The created lines drawable. If a lines drawable with 'name' already exists, the creation will be ignored and the existing drawable is returned.
◆ add_points_drawable()
Create a new points drawable and add it to this renderer.
- Parameters
-
name | The name of the points drawable to be created. |
- Returns
- The created points drawable. If a points drawable with 'name' already exists, the creation will be ignored and the existing drawable is returned.
◆ add_triangles_drawable()
Create a new triangles drawable and add it to this renderer.
- Parameters
-
name | The name of the triangles drawable to be created. |
- Returns
- The created triangles drawable. If a triangles drawable with 'name' already exists, the creation will be ignored and the existing drawable is returned.
◆ color_from_segmentation() [1/3]
Generates random colors for visualizing the segmentation of a PointCloud.
- Parameters
-
cloud | The point cloud. |
segments | The vertex property storing the segmentation of the point cloud. |
- Attention
- The face property
segments
must have a type of int
, {unsigned
int}, std::size_t
, bool
, or {unsigned
char}. Besides, any negative values are treated as out of range.
- Parameters
-
colors | The vertex property to store the colors. Must be allocated before hand. |
◆ color_from_segmentation() [2/3]
Generates random colors for visualizing face-based segmentation of a SurfaceMesh.
- Parameters
-
mesh | The surface mesh. |
segments | The face property storing the segmentation of the surface mesh. |
colors | The face property to store the colors. Must be allocated before hand. |
- Attention
- The face property
segments
must have a type of int
, {unsigned
int}, std::size_t
, bool
, or {unsigned
char}. Besides, any negative values are treated as out of range.
◆ color_from_segmentation() [3/3]
Generates random colors for visualizing vertex-based segmentation of a SurfaceMesh.
- Parameters
-
mesh | The surface mesh. |
segments | The vertex property storing the segmentation of the surface mesh. |
colors | The vertex property to store the colors. Must be allocated before hand. |
- Attention
- The face property
segments
must have a type of int
, {unsigned
int}, std::size_t
, bool
, or {unsigned
char}. Besides, any negative values are treated as out of range.
◆ get_lines_drawable()
LinesDrawable * get_lines_drawable |
( |
const std::string & | name, |
|
|
bool | warning_not_found = true ) const |
◆ get_points_drawable()
PointsDrawable * get_points_drawable |
( |
const std::string & | name, |
|
|
bool | warning_not_found = true ) const |
◆ get_triangles_drawable()
TrianglesDrawable * get_triangles_drawable |
( |
const std::string & | name, |
|
|
bool | warning_not_found = true ) const |
Get the triangles drawable with a given name. Return nullptr if the drawable does not exist.
◆ lines_drawables()
const std::vector< std::shared_ptr< LinesDrawable > > & lines_drawables |
( |
| ) |
const |
|
inline |
All available lines drawables managed by this renderer.
◆ points_drawables()
const std::vector< std::shared_ptr< PointsDrawable > > & points_drawables |
( |
| ) |
const |
|
inline |
All available points drawables managed by this renderer.
◆ triangles_drawables()
const std::vector< std::shared_ptr< TrianglesDrawable > > & triangles_drawables |
( |
| ) |
const |
|
inline |
◆ update()
Invalidates the rendering buffers of the model and thus updates the rendering (delayed in rendering).
This method triggers an update of the rendering buffers of all the drawables of the model to which this renderer is attached. The effect is equivalent to calling Drawable::update() functions for all the drawables of this model. todo: for better performance, it is wise to update only the affected drawables and buffers.
- See also
- Drawable::update()
- Examples
- Tutorial_312_MultiThread/main.cpp.
The documentation for this class was generated from the following files:
- G:/3_code/Easy3D/easy3d/renderer/renderer.h
- G:/3_code/Easy3D/easy3d/renderer/renderer.cpp