27#include <easy3d/viewer/viewer.h>
28#include <easy3d/core/surface_mesh.h>
29#include <easy3d/renderer/renderer.h>
30#include <easy3d/renderer/drawable_triangles.h>
31#include <easy3d/renderer/texture_manager.h>
32#include <easy3d/fileio/surface_mesh_io.h>
33#include <easy3d/util/resource.h>
34#include <easy3d/util/initializer.h>
44int main(
int argc,
char **argv) {
48 const std::string file_name = resource::directory() +
"/data/building.off";
52 Viewer viewer(EXAMPLE_TITLE);
57 LOG(ERROR) <<
"failed to load model. Please make sure the file exists and format is correct.";
67 auto elevation = mesh->add_vertex_property<
float>(
"v:elevation");
68 for (
auto v : mesh->vertices())
69 elevation[v] = mesh->position(v).z;
74 const std::string texture_file = resource::directory() +
"/colormaps/rainbow.png";
75 Texture *texture = TextureManager::request(texture_file);
77 LOG(ERROR) <<
"failed to create texture.";
82 drawable->set_texture(texture);
Renderer * renderer()
Gets the renderer of this model.
Definition: model.h:94
TrianglesDrawable * add_triangles_drawable(const std::string &name)
Definition: renderer.cpp:346
void set_scalar_coloring(Location scalar_location, const std::string &scalar_name, const Texture *texture=nullptr, float clamp_lower=0.05f, float clamp_upper=0.05f)
Definition: state.cpp:115
A halfedge data structure for polygonal meshes of 2-manifold.
Definition: surface_mesh.h:52
OpenGL texture.
Definition: texture.h:44
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
void initialize(bool use_log_file, bool use_setting_file, const std::string &resource_dir)
Initialization of Easy3D.
Definition: initializer.cpp:35