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);
253 bool get_has_vertices_filter()
const {
255 mesh_grob()->vertices.nb() != 0 &&
256 mesh_grob()->vertices.attributes().is_defined(
"filter") ;
259 bool get_has_facets_filter()
const {
261 mesh_grob()->facets.nb() != 0 &&
262 mesh_grob()->facets.attributes().is_defined(
"filter") ;
265 bool get_has_cells_filter()
const {
267 mesh_grob()->cells.nb() != 0 &&
268 mesh_grob()->cells.attributes().is_defined(
"filter") ;
277 return static_cast<MeshGrob*
>(grob());
307 void pick(MeshElementsFlags what)
override;
366 bool get_attributes()
const {
367 return (painting_mode_ == ATTRIBUTE);
375 gom_attribute(visible_if,
"attributes")
385 void set_time_smooth(
double x) {
406 void set_painting(PaintingMode value);
413 return painting_mode_;
421 gom_attribute(visible_if,
"attributes")
422 void set_attribute_min(
double value) {
423 attribute_min_ = value;
433 return attribute_min_;
441 gom_attribute(visible_if,
"attributes")
442 void set_attribute_max(
double value) {
443 attribute_max_ = value;
453 return attribute_max_;
461 gom_attribute(visible_if,
"attributes")
462 gom_attribute(handler, "combo_box")
463 gom_attribute(values, "$scalar_attributes")
464 void set_attribute(const std::
string& value);
470 const std::
string& get_attribute()
const {
478 gom_attribute(visible_if,
"attributes")
480 colormap_style_ = value;
481 colormap_texture_.reset();
486 return colormap_style_;
495 return (painting_mode_ == TEXTURE);
504 return (painting_mode_ == COLOR);
513 gom_attribute(visible_if,
"texturing")
515 texture_filename_ = value;
526 return texture_filename_;
533 gom_attribute(visible_if,
"texturing")
534 gom_attribute(handler, "combo_box")
535 gom_attribute(values, "$vector_attributes")
536 void set_tex_coords(const std::
string& value);
542 const std::
string& get_tex_coords()
const {
543 return tex_coord_attribute_;
551 gom_attribute(visible_if,
"coloring")
552 gom_attribute(handler, "combo_box")
553 gom_attribute(values, "$vector_attributes")
554 void set_colors(const std::
string& value) {
558 set_tex_coords(value);
569 return get_tex_coords();
577 gom_attribute(visible_if,
"texturing")
579 tex_coord_repeat_ = value;
589 return tex_coord_repeat_;
599 gom_attribute(visible_if,
"texturing")
600 void set_normal_map(
bool value) {
601 tex_normal_mapping_ = value;
611 return tex_normal_mapping_;
620 gfx_.set_lighting(value);
630 return gfx_.get_lighting();
660 gom_attribute(visible_if,
"has_facets")
662 surface_style_ = value;
671 return surface_style_;
678 gom_attribute(visible_if,
"has_facets_filter")
679 void set_facets_filter(
bool value) {
680 facets_filter_ = value;
682 MESH_FACETS, value ?
"filter" :
""
687 bool get_facets_filter()
const {
688 return facets_filter_;
695 gom_attribute(visible_if,
"has_facets")
696 void set_culling_mode(const CullingMode value) {
697 culling_mode_ = value;
706 return culling_mode_;
714 gom_attribute(visible_if,
"has_facets or has_cells")
739 gom_attribute(visible_if,
"has_facets")
740 void set_two_sided(
bool value) {
759 gom_attribute(visible_if,
"has_cells")
761 volume_style_ = value;
772 return volume_style_;
780 gom_attribute(visible_if,
"has_cells_filter")
781 void set_cells_filter(
bool value) {
783 MESH_CELLS, value ?
"filter" :
""
785 cells_filter_ = value;
789 bool get_cells_filter()
const {
790 return cells_filter_;
800 gom_attribute(visible_if,
"is_hybrid")
801 void set_colored_cells(
bool value) {
802 colored_cells_ = value;
812 return colored_cells_;
821 gom_attribute(visible_if,
"is_hybrid")
822 void set_tets(
bool value) {
841 gom_attribute(visible_if,
"is_hybrid")
842 void set_hexes(
bool value) {
862 gom_attribute(visible_if,
"is_hybrid")
863 void set_prisms(
bool value) {
883 gom_attribute(visible_if,
"is_hybrid")
884 void set_pyramids(
bool value) {
904 gom_attribute(visible_if,
"is_hybrid")
905 void set_connectors(
bool value) {
924 gom_attribute(visible_if,
"has_edges")
926 edges_style_ = value;
947 gom_attribute(visible_if,
"has_facets or has_cells")
971 gom_attribute(visible_if,
"has_facets")
973 border_style_ = value;
984 return border_style_;
993 vertices_style_ = value;
1003 return vertices_style_;
1011 gom_attribute(visible_if,
"has_vertices_filter")
1012 void set_vertices_filter(
bool value) {
1014 MESH_VERTICES, value ?
"filter" :
""
1016 vertices_filter_ = value;
1020 bool get_vertices_filter()
const {
1021 return vertices_filter_;
1031 gom_attribute(visible_if,
"has_vertices_selection")
1032 void set_vert_select_style(const PointStyle& value) {
1033 vertices_selection_style_ = value;
1042 return vertices_selection_style_;
1051 gom_attribute(visible_if,
"has_cells")
1053 gfx_.set_shrink(
double(value)/10.0);
1064 return index_t(gfx_.get_shrink()*10.0);
1078 gom_attribute(visible_if,
"has_time")
1079 void set_animate(
bool value) {
1103 gom_attribute(visible_if,
"has_time and animate")
1104 gom_attribute(handler, "slider_int")
1105 gom_attribute(min, "0")
1106 gom_attribute(max, "20")
1108 time_ = double(value) / 20.0;
1121 gom_attribute(visible_if,
"has_cells")
1122 void set_slivers(
double value) {
1127 double get_slivers()
const {
1131 gom_attribute(visible_if,
"has_weird_cells")
1132 void set_weird_cells(
bool x) {
1137 bool get_weird_cells()
const {
1138 return weird_cells_;
1141 bool get_glsl_source_visible()
const {
1145 gom_attribute(visible_if,
"glsl_source_visible")
1146 void set_glsl_source(const std::
string& value) {
1147 glsl_source_ = value;
1148 update_glsl_program();
1151 const std::string& get_glsl_source()
const {
1152 return glsl_source_;
1160 void draw_slivers();
1161 void draw_weird_cells();
1162 void draw_surface_with_glsl_shader();
1163 void update_glsl_program();
1168 PaintingMode painting_mode_;
1170 std::string attribute_;
1171 MeshElementsFlags attribute_subelements_;
1172 std::string attribute_name_;
1173 double attribute_min_;
1174 double attribute_max_;
1178 MeshElementsFlags tex_coord_subelements_;
1179 std::string tex_coord_attribute_;
1180 std::string tex_coord_name_;
1182 bool tex_normal_mapping_;
1187 bool facets_filter_;
1188 CullingMode culling_mode_;
1194 bool colored_cells_;
1205 bool vertices_filter_;
1214 bool glsl_program_changed_;
1215 double glsl_start_time_;
1217 std::string glsl_source_;
1218 GLuint glsl_program_;
1242 gom_attribute(handler,
"combo_box")
1243 gom_attribute(values, "$scalar_attributes")
1244 void set_region(const std::
string& value) {
1250 const std::string& get_region()
const {
1254 void set_amount(
index_t value) {
1268 std::string region_;
Draws a mesh using OpenGL.
Vector with aligned memory allocation.
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.
MeshGrob * mesh_grob() const
Gets the MeshGrob.
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.
A Grob wrapper around Geogram's Mesh class.
The default implementation of MeshGrobShader.
const SurfaceStyle & get_volume_style() const
Gets the style used to draw the volumetric cells.
~PlainMeshGrobShader() override
PlainMeshGrobShader destructor.
const EdgeStyle & get_mesh_style() const
Gets the style used to draw the mesh in the facets and in the cells.
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.
void hide_borders() override
Makes surface borders invisible and triggers a drawing event.
bool get_texturing() const
Tests whether texturing is active.
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.
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.
const ImageFileName & get_tex_image() const
Gets the image used for texturing.
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 EdgeStyle & get_edges_style() const
Gets the style used to draw the edges.
void show_vertices() override
Makes vertices visible and triggers a drawing event.
void draw() override
Draws the Grob.
const SurfaceStyle & get_surface_style() const
Gets the current surface drawing style.
bool get_lighting() const
Gets whether lighting is used.
index_t get_shrink() const
Gets the shrinking coefficient of the volumetric cells.
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.
double get_attribute_max() const
Gets the maximum of the displayed range for attribute values.
const PointStyle & get_vert_select_style() const
Gets the vertices selection style.
void pick_object(index_t object_id) override
Draws the Grob in picking mode.
bool get_prisms() const
Tests whether prisms are displayed.
CullingMode get_culling_mode() const
Gets the current culling mode.
const std::string & get_colors() const
Gets the name of the displayed attribute.
bool get_connectors() const
Tests whether connectors are displayed.
double get_time_smooth() const
Gets the time as floating point parameter.
const PointStyle & get_vertices_style() const
Gets the style used to draw the vertices.
const EdgeStyle & get_border_style() const
Gets the style used to draw the border of the surface.
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.
void set_transparency(Transparency x) override
Transparent rendering mode.
update()
Redraws the scene.
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.
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.