27#include <easy3d/viewer/viewer.h>
28#include <easy3d/core/surface_mesh.h>
29#include <easy3d/renderer/drawable_lines.h>
30#include <easy3d/renderer/renderer.h>
31#include <easy3d/util/resource.h>
32#include <easy3d/util/initializer.h>
42int main(
int argc,
char **argv) {
48 Viewer viewer(EXAMPLE_TITLE);
51 const std::string file_name = resource::directory() +
"/data/sphere.obj";
54 LOG(ERROR) <<
"failed to load model. Please make sure the file exists and format is correct.";
60 const Box3 &box = mesh->bounding_box();
64 mesh->update_face_normals();
65 auto normals = mesh->get_face_property<
vec3>(
"f:normal");
68 std::vector<vec3> points;
69 for (
auto f : mesh->faces()) {
72 for (
auto v : mesh->vertices(f)) {
73 center += mesh->position(v);
77 const vec3 s = center / count;
84 auto drawable = mesh->renderer()->add_lines_drawable(
"normals");
86 drawable->update_vertex_buffer(points);
89 drawable->set_uniform_coloring(
vec4(0.0f, 1.0f, 0.0f, 1.0f));
92 drawable->set_line_width(3.0f);
95 mesh->renderer()->get_lines_drawable(
"edges")->set_visible(
true);
const Point & min_point() const
Definition: box.h:93
const Point & max_point() const
Definition: box.h:98
A halfedge data structure for polygonal meshes of 2-manifold.
Definition: surface_mesh.h:52
The built-in Easy3D viewer.
Definition: viewer.h:61
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
T length(const Vec< N, T > &v)
Computes the length/magnitude of a vector.
Definition: vec.h:289
void initialize(bool use_log_file, bool use_setting_file, const std::string &resource_dir)
Initialization of Easy3D.
Definition: initializer.cpp:35
FT norm(const Matrix< FT > &)
utilities
Definition: matrix.h:1424