28#include <easy3d/viewer/multi_viewer.h>
29#include <easy3d/core/model.h>
30#include <easy3d/renderer/renderer.h>
31#include <easy3d/renderer/drawable_points.h>
32#include <easy3d/renderer/drawable_lines.h>
33#include <easy3d/renderer/drawable_triangles.h>
34#include <easy3d/util/resource.h>
35#include <easy3d/util/initializer.h>
42int main(
int argc,
char** argv) {
51 const std::string file_graph = resource::directory() +
"/data/graph.ply";
52 auto graph = viewer.
add_model(file_graph,
true);
54 viewer.
assign(0, 0, graph);
56 LOG(ERROR) <<
"failed to load model from file: " << file_graph;
60 const std::string file_sphere = resource::directory() +
"/data/sphere.obj";
61 auto sphere = viewer.
add_model(file_sphere,
true);
64 viewer.
assign(0, 1, sphere_faces);
67 LOG(ERROR) <<
"failed to load model from file: " << file_sphere;
71 auto sphere_wireframe = sphere->renderer()->get_lines_drawable(
"edges");
72 sphere_wireframe->set_impostor_type(LinesDrawable::CYLINDER);
73 sphere_wireframe->set_line_width(5);
74 sphere_wireframe->set_uniform_coloring(
vec4(0.7f, 0.7f, 1.0f, 1.0f));
75 viewer.
assign(1, 0, sphere_wireframe);
79 auto sphere_vertices = sphere->renderer()->get_points_drawable(
"vertices");
80 sphere_vertices->set_impostor_type(PointsDrawable::SPHERE);
81 sphere_vertices->set_point_size(15);
82 viewer.
assign(1, 1, sphere_vertices);
Renderer * renderer()
Gets the renderer of this model.
Definition: model.h:94
A viewer that supports multiple views (arranged in a grid layout).
Definition: multi_viewer.h:44
void assign(int row, int col, const Model *m)
Assigns the model m to the view at position (row, col).
Definition: multi_viewer.cpp:74
TrianglesDrawable * get_triangles_drawable(const std::string &name) const
Definition: renderer.cpp:304
virtual Model * add_model(const std::string &file_name, bool create_default_drawables=true)
Add a model from a file to the viewer to be visualized. On success, the viewer will be in charge of t...
Definition: viewer.cpp:1204
int run(bool see_all=true)
Run the viewer.
Definition: viewer.cpp:1090
Definition: collider.cpp:182
void initialize(bool use_log_file, bool use_setting_file, const std::string &resource_dir)
Initialization of Easy3D.
Definition: initializer.cpp:35