40 #ifndef H_OGF_MESH_GFX_SHADERS_MESH_GROB_SHADER_H
41 #define H_OGF_MESH_GFX_SHADERS_MESH_GROB_SHADER_H
43 #include <OGF/mesh_gfx/common/common.h>
68 enum CullingMode {NO_CULL, CULL_FRONT, CULL_BACK};
70 enum PaintingMode {SOLID_COLOR, ATTRIBUTE, COLOR, TEXTURE};
75 gom_attribute(
abstract,
"true")
100 virtual void pick(MeshElementsFlags what);
163 bool get_has_edges()
const {
165 mesh_grob() !=
nullptr &&
166 mesh_grob()->edges.nb() != 0;
178 mesh_grob() !=
nullptr &&
179 mesh_grob()->facets.nb() != 0;
191 mesh_grob() !=
nullptr &&
192 mesh_grob()->cells.nb() != 0;
205 mesh_grob() !=
nullptr &&
206 mesh_grob()->cells.nb() != 0 &&
207 !mesh_grob()->cells.are_simplices();
222 mesh_grob() !=
nullptr &&
223 mesh_grob()->vertices.dimension() >= 6;
226 bool get_has_vertices_selection()
const {
227 return mesh_grob() !=
nullptr &&
228 mesh_grob()->vertices.attributes().is_defined(
"selection");
232 bool get_has_weird_cells()
const {
233 return mesh_grob() !=
nullptr &&
234 mesh_grob()->cells.attributes().is_defined(
"weird");
237 std::string get_scalar_attributes()
const {
239 if(mesh_grob() !=
nullptr) {
240 result = mesh_grob()->get_scalar_attributes();
245 std::string get_vector_attributes()
const {
247 if(mesh_grob() !=
nullptr) {
248 result = mesh_grob()->get_vector_attributes(3);
259 return static_cast<MeshGrob*
>(grob());
289 void pick(MeshElementsFlags what)
override;
348 bool get_attributes()
const {
349 return (painting_mode_ == ATTRIBUTE);
357 gom_attribute(visible_if,
"attributes")
367 void set_time_smooth(
double x) {
388 void set_painting(PaintingMode value);
395 return painting_mode_;
403 gom_attribute(visible_if,
"attributes")
404 void set_attribute_min(
double value) {
405 attribute_min_ = value;
415 return attribute_min_;
423 gom_attribute(visible_if,
"attributes")
424 void set_attribute_max(
double value) {
425 attribute_max_ = value;
435 return attribute_max_;
443 gom_attribute(visible_if,
"attributes")
444 gom_attribute(handler, "combo_box")
445 gom_attribute(values, "$scalar_attributes")
446 void set_attribute(const std::
string& value);
452 const std::
string& get_attribute()
const {
460 gom_attribute(visible_if,
"attributes")
462 colormap_style_ = value;
463 colormap_texture_.reset();
468 return colormap_style_;
477 return (painting_mode_ == TEXTURE);
486 return (painting_mode_ == COLOR);
495 gom_attribute(visible_if,
"texturing")
497 texture_filename_ = value;
508 return texture_filename_;
515 gom_attribute(visible_if,
"texturing")
516 gom_attribute(handler, "combo_box")
517 gom_attribute(values, "$vector_attributes")
518 void set_tex_coords(const std::
string& value);
524 const std::
string& get_tex_coords()
const {
525 return tex_coord_attribute_;
533 gom_attribute(visible_if,
"coloring")
534 gom_attribute(handler, "combo_box")
535 gom_attribute(values, "$vector_attributes")
536 void set_colors(const std::
string& value) {
540 set_tex_coords(value);
551 return get_tex_coords();
559 gom_attribute(visible_if,
"texturing")
561 tex_coord_repeat_ = value;
571 return tex_coord_repeat_;
581 gom_attribute(visible_if,
"texturing")
582 void set_normal_map(
bool value) {
583 tex_normal_mapping_ = value;
593 return tex_normal_mapping_;
602 gfx_.set_lighting(value);
612 return gfx_.get_lighting();
642 gom_attribute(visible_if,
"has_facets")
644 surface_style_ = value;
653 return surface_style_;
660 gom_attribute(visible_if,
"has_facets")
661 void set_facets_filter(
bool value) {
662 facets_filter_ = value;
664 MESH_FACETS, value ?
"filter" :
""
669 bool get_facets_filter()
const {
670 return facets_filter_;
677 gom_attribute(visible_if,
"has_facets")
678 void set_culling_mode(const CullingMode value) {
679 culling_mode_ = value;
688 return culling_mode_;
696 gom_attribute(visible_if,
"has_facets or has_cells")
721 gom_attribute(visible_if,
"has_facets")
722 void set_two_sided(
bool value) {
741 gom_attribute(visible_if,
"has_cells")
743 volume_style_ = value;
754 return volume_style_;
762 gom_attribute(visible_if,
"has_cells")
763 void set_cells_filter(
bool value) {
765 MESH_CELLS, value ?
"filter" :
""
767 cells_filter_ = value;
771 bool get_cells_filter()
const {
772 return cells_filter_;
782 gom_attribute(visible_if,
"is_hybrid")
783 void set_colored_cells(
bool value) {
784 colored_cells_ = value;
794 return colored_cells_;
803 gom_attribute(visible_if,
"is_hybrid")
804 void set_tets(
bool value) {
823 gom_attribute(visible_if,
"is_hybrid")
824 void set_hexes(
bool value) {
844 gom_attribute(visible_if,
"is_hybrid")
845 void set_prisms(
bool value) {
865 gom_attribute(visible_if,
"is_hybrid")
866 void set_pyramids(
bool value) {
886 gom_attribute(visible_if,
"is_hybrid")
887 void set_connectors(
bool value) {
906 gom_attribute(visible_if,
"has_edges")
908 edges_style_ = value;
929 gom_attribute(visible_if,
"has_facets or has_cells")
953 gom_attribute(visible_if,
"has_facets")
955 border_style_ = value;
966 return border_style_;
975 vertices_style_ = value;
985 return vertices_style_;
995 MESH_VERTICES, value ?
"filter" :
""
997 vertices_filter_ = value;
1001 bool get_vertices_filter()
const {
1002 return vertices_filter_;
1012 vertices_transparency_ = value;
1022 return vertices_transparency_;
1030 gom_attribute(visible_if,
"has_vertices_selection")
1032 vertices_selection_style_ = value;
1041 return vertices_selection_style_;
1050 gom_attribute(visible_if,
"has_cells")
1052 gfx_.set_shrink(
double(value)/10.0);
1063 return index_t(gfx_.get_shrink()*10.0);
1077 gom_attribute(visible_if,
"has_time")
1078 void set_animate(
bool value) {
1102 gom_attribute(visible_if,
"has_time and animate")
1103 gom_attribute(handler, "slider_int")
1104 gom_attribute(min, "0")
1105 gom_attribute(max, "20")
1107 time_ = double(value) / 20.0;
1120 gom_attribute(visible_if,
"has_cells")
1121 void set_slivers(
double value) {
1126 double get_slivers()
const {
1130 gom_attribute(visible_if,
"has_weird_cells")
1131 void set_weird_cells(
bool x) {
1136 bool get_weird_cells()
const {
1137 return weird_cells_;
1140 bool get_glsl_source_visible()
const {
1144 gom_attribute(visible_if,
"glsl_source_visible")
1145 void set_glsl_source(const std::
string& value) {
1146 glsl_source_ = value;
1147 update_glsl_program();
1150 const std::string& get_glsl_source()
const {
1151 return glsl_source_;
1155 void draw_slivers();
1156 void draw_weird_cells();
1157 void draw_surface_with_glsl_shader();
1158 void update_glsl_program();
1163 PaintingMode painting_mode_;
1165 std::string attribute_;
1166 MeshElementsFlags attribute_subelements_;
1167 std::string attribute_name_;
1168 double attribute_min_;
1169 double attribute_max_;
1170 ColormapStyle colormap_style_;
1171 Texture_var colormap_texture_;
1173 MeshElementsFlags tex_coord_subelements_;
1174 std::string tex_coord_attribute_;
1175 std::string tex_coord_name_;
1177 bool tex_normal_mapping_;
1178 Texture_var texture_;
1181 SurfaceStyle surface_style_;
1182 bool facets_filter_;
1183 CullingMode culling_mode_;
1187 SurfaceStyle volume_style_;
1189 bool colored_cells_;
1196 EdgeStyle edges_style_;
1197 EdgeStyle mesh_style_;
1198 EdgeStyle border_style_;
1199 PointStyle vertices_style_;
1200 bool vertices_filter_;
1201 double vertices_transparency_;
1202 PointStyle vertices_selection_style_;
1210 bool glsl_program_changed_;
1211 double glsl_start_time_;
1213 std::string glsl_source_;
1214 GLuint glsl_program_;
1238 gom_attribute(handler,
"combo_box")
1239 gom_attribute(values, "$scalar_attributes")
1240 void set_region(const std::
string& value) {
1246 const std::string& get_region()
const {
1250 void set_amount(
index_t value) {
1264 std::string region_;
Draws a mesh using OpenGL.
Exploded view, moves regions apart.
void draw() override
Draws the Grob.
~ExplodedViewMeshGrobShader() override
PlainMeshGrobShader destructor.
ExplodedViewMeshGrobShader(MeshGrob *grob)
PlainMeshGrobShader constructor.
Base class for drawing and picking MeshGrob.
virtual void hide_borders()
Makes surface borders invisible and triggers a drawing event.
virtual void hide_vertices()
Makes vertices invisible and triggers a drawing event.
virtual void show_borders()
Makes surface borders visible and triggers a drawing event.
void pick_object(index_t object_id) override
Draws the Grob in picking mode.
MeshGrobShader(MeshGrob *grob)
MeshGrobShader constructor.
bool get_has_cells() const
Tests whether the MeshGrob attached to this shader has cells.
virtual void hide_mesh()
Makes the mesh invisible and triggers a drawing event.
virtual void show_mesh()
Makes the mesh visible and triggers a drawing event.
virtual void show_vertices()
Makes vertices visible and triggers a drawing event.
virtual void show_vertices_selection()
Makes vertices selection visible and triggers a drawing event.
virtual void pick(MeshElementsFlags what)
Picks an element of a mesh.
void blink() override
Draws the current object several times, while chaning the value of one graphic attribute (e....
bool get_has_time() const
Tests whether the MeshGrob attached to this shader stores a time evolution.
virtual void hide_vertices_selection()
Makes vertices selection invisible and triggers a drawing event.
bool get_is_hybrid() const
Tests whether the MeshGrob attached to this shader is a volumetric hybrid mesh.
void draw() override
Draws the Grob.
~MeshGrobShader() override
MeshGrobShader destructor.
bool get_has_facets() const
Tests whether the MeshGrob attached to this shader has facets.
MeshGrob * mesh_grob() const
Gets the MeshGrob.
A Grob wrapper around Geogram's Mesh class.
The default implementation of MeshGrobShader.
~PlainMeshGrobShader() override
PlainMeshGrobShader destructor.
void blink() override
Draws the current object several times, while chaning the value of one graphic attribute (e....
bool get_clipping() const
Gets whether clipping should be used.
index_t get_specular() const
Gets the current surface specular factor.
void hide_mesh() override
Makes the mesh invisible and triggers a drawing event.
bool get_tets() const
Tests whether tetrahedra are displayed.
const ImageFileName & get_tex_image() const
Gets the image used for texturing.
const PointStyle & get_vert_select_style() const
Gets the vertices selection style.
void hide_borders() override
Makes surface borders invisible and triggers a drawing event.
bool get_texturing() const
Tests whether texturing is active.
const PointStyle & get_vertices_style() const
Gets the style used to draw the vertices.
void show_mesh() override
Makes the mesh visible and triggers a drawing event.
bool get_coloring() const
Tests whether coloring is active.
bool get_hexes() const
Tests whether hexahedra are displayed.
const EdgeStyle & get_mesh_style() const
Gets the style used to draw the mesh in the facets and in the cells.
PlainMeshGrobShader(MeshGrob *grob)
PlainMeshGrobShader constructor.
PaintingMode get_painting() const
Gets painting mode.
void hide_vertices() override
Makes vertices invisible and triggers a drawing event.
index_t get_time() const
Gets the time parameter used for time interpolation.
bool get_colored_cells() const
Tests whether volumetric cells are colored by type.
void show_borders() override
Makes surface borders visible and triggers a drawing event.
double get_attribute_min() const
Gets the minimum of the displayed range for attribute values.
void set_lighting(bool value)
Sets whether lighting should be used.
const std::string & get_colors() const
Gets the name of the displayed attribute.
void show_vertices() override
Makes vertices visible and triggers a drawing event.
void draw() override
Draws the Grob.
const EdgeStyle & get_edges_style() const
Gets the style used to draw the edges.
const SurfaceStyle & get_volume_style() const
Gets the style used to draw the volumetric cells.
bool get_lighting() const
Gets whether lighting is used.
index_t get_shrink() const
Gets the shrinking coefficient of the volumetric cells.
const SurfaceStyle & get_surface_style() const
Gets the current surface drawing style.
bool get_normal_map() const
Gets normal mapping mode.
void show_vertices_selection() override
Makes vertices selection visible and triggers a drawing event.
bool get_two_sided() const
Tests whether different colors are used for inside/outside.
void pick(MeshElementsFlags what) override
Picks an element of a mesh.
bool get_animate() const
Tests whether time interpolation should be used.
bool get_pyramids() const
Tests whether pyramids are displayed.
const EdgeStyle & get_border_style() const
Gets the style used to draw the border of the surface.
double get_attribute_max() const
Gets the maximum of the displayed range for attribute values.
void pick_object(index_t object_id) override
Draws the Grob in picking mode.
bool get_prisms() const
Tests whether prisms are displayed.
void set_vertices_transparency(double value)
Sets the transparency of the vertices (use with dark background).
CullingMode get_culling_mode() const
Gets the current culling mode.
bool get_connectors() const
Tests whether connectors are displayed.
double get_time_smooth() const
Gets the time as floating point parameter.
void set_vertices_filter(bool value)
Sets vertices filtering.
index_t get_tex_repeat() const
Gets the texture repeat factor.
void set_vertices_style(const PointStyle &value)
Sets the style used to draw the vertices.
void hide_vertices_selection() override
Makes vertices selection invisible and triggers a drawing event.
double get_vertices_transparency() const
Gets the transparency of the vertices.
void set_clipping(bool value)
Sets whether clipping should be active.
Base class for Grob shader.
A class to display a mesh using OpenGL/GLUP.
Global Vorpaline namespace.
geo_index_t index_t
The type for storing and manipulating indices.
Global Graphite namespace.
Name< File< Image * > > ImageFileName
The name of an existing file that contains an Image.
The base class for all object shaders.
The style used to display colormapped colors.
Drawing style for mesh edges.
Drawing style for points.
Drawing style for polygons.