cgv
Loading...
Searching...
No Matches
gl_implicit_surface_drawable_base.cxx
1#include "gl_implicit_surface_drawable_base.h"
2#include <cgv/media/mesh/marching_cubes.h>
3#include <cgv/media/mesh/dual_contouring.h>
4
5#include <cgv/render/drawable.h>
6#include <cgv/render/shader_program.h>
7#include <cgv/render/attribute_array_binding.h>
8#include <cgv/math/ftransform.h>
9#include <cgv_gl/gl/gl.h>
10
11#include <fstream>
12
13using namespace cgv::math;
14using namespace cgv::media;
15
16namespace cgv {
17 namespace render {
18 namespace gl {
19
21{
22 obj_out = 0;
23 triangulate = false;
24 nr_faces = 0;
25 nr_vertices = 0;
26#ifdef _DEBUG
27 res = 10;
28#else
29 res = 25;
30#endif
31 func_ptr = 0;
32 show_vertices = false;
33 show_wireframe = false;
34 show_surface = true;
35 contouring_type = DUAL_CONTOURING;
36 show_sampling_grid = false;
37 show_sampling_locations = false;
38 normal_computation_type = FACE_NORMALS;
39// normal_computation_type = GRADIENT_NORMALS;
40 brs.culling_mode = CM_FRONTFACE;
41 brs.illumination_mode = IM_TWO_SIDED;
42 brs.map_color_to_material = CM_COLOR;
43 srs.radius = 0.13f;
44 srs.surface_color = rgb(1, 1, 0.5f);
45 crs.radius = 0.04f;
46 crs.surface_color = rgb(0.3f, 0.46f, 0.43f);
47 crs.rounded_caps = true;
48 ars.radius_relative_to_length = 0.05f;
49 consistency_threshold = 0.01;
50 max_nr_iters = 8;
51 normal_threshold = 0.73;
52 show_box = true;
53 show_mesh_normals = false;
54 show_gradient_normals = false;
55 sm_ptr = 0;
56 epsilon = 1e-8;
57 grid_epsilon = 0.01;
58 ix=iy=iz=0;
59 show_mini_box = false;
60 sampling_grid_alpha = 0.4f;
61 material.set_diffuse_reflectance(rgb(0.1f, 0.6f, 1.0f));
62 material.set_specular_reflectance(rgb(0.7f,0.7f,0.7f));
63 material.set_roughness(0.6f);
64}
65
67bool gl_implicit_surface_drawable_base::save(const std::string& file_name)
68{
69 std::ofstream os(file_name.c_str());
70 if (os.fail())
71 return false;
72 obj_out = &os;
73 normal_index = 0;
75 obj_out = 0;
76 return true;
77}
78
79void gl_implicit_surface_drawable_base::set_function(F* _func_ptr)
80{
81 func_ptr = _func_ptr;
83}
84
85
86gl_implicit_surface_drawable_base::F* gl_implicit_surface_drawable_base::get_function() const
87{
88 return func_ptr;
89}
90
91void gl_implicit_surface_drawable_base::set_resolution(unsigned int _res)
92{
93 res = _res;
95}
96
97unsigned int gl_implicit_surface_drawable_base::get_resolution() const
98{
99 return res;
100}
101
102void gl_implicit_surface_drawable_base::enable_wireframe(bool do_enable)
103{
104 if (show_wireframe == do_enable)
105 return;
106 show_wireframe = do_enable;
107 post_redraw();
108}
109
110void gl_implicit_surface_drawable_base::enable_sampling_grid(bool do_enable)
111{
112 if (show_sampling_grid == do_enable)
113 return;
114 show_sampling_grid = do_enable;
115 post_redraw();
116}
117
118bool gl_implicit_surface_drawable_base::is_sampling_grid_enabled() const
119{
120 return show_sampling_grid;
121}
122
123void gl_implicit_surface_drawable_base::enable_sampling_locations(bool do_enable)
124{
125 if (show_sampling_locations == do_enable)
126 return;
127 show_sampling_locations = do_enable;
128 post_redraw();
129}
130
131bool gl_implicit_surface_drawable_base::is_sampling_locations_enabled() const
132{
133 return show_sampling_locations;
134}
135
136void gl_implicit_surface_drawable_base::enable_box(bool do_enable)
137{
138 if (show_box == do_enable)
139 return;
140 show_box = do_enable;
141 post_redraw();
142}
143
144bool gl_implicit_surface_drawable_base::is_box_enabled() const
145{
146 return show_box;
147}
148
149void gl_implicit_surface_drawable_base::enable_normals(bool do_enable)
150{
151 if (show_mesh_normals == do_enable &&
152 show_gradient_normals == do_enable)
153 return;
154 show_mesh_normals = show_gradient_normals = do_enable;
155 post_redraw();
156}
157
158bool gl_implicit_surface_drawable_base::are_normals_enabled() const
159{
160 return show_gradient_normals;
161}
162
163
164
165bool gl_implicit_surface_drawable_base::is_wireframe_enabled() const
166{
167 return show_wireframe;
168}
169
170
171void gl_implicit_surface_drawable_base::set_epsilon(double _epsilon)
172{
173 epsilon = _epsilon;
174 post_rebuild();
175}
176
177double gl_implicit_surface_drawable_base::get_epsilon() const
178{
179 return epsilon;
180}
181
182void gl_implicit_surface_drawable_base::set_grid_epsilon(double _grid_epsilon)
183{
184 grid_epsilon = _grid_epsilon;
185 post_rebuild();
186}
187
188double gl_implicit_surface_drawable_base::get_grid_epsilon() const
189{
190 return grid_epsilon;
191}
192
193
194void gl_implicit_surface_drawable_base::set_box(const dbox3& _box)
195{
196 box = _box;
197 post_rebuild();
198}
199
200const dbox3& gl_implicit_surface_drawable_base::get_box() const
201{
202 return box;
203}
204
205unsigned int gl_implicit_surface_drawable_base::get_nr_triangles_of_last_extraction() const
206{
207 return nr_faces;
208}
209
210unsigned int gl_implicit_surface_drawable_base::get_nr_vertices_of_last_extraction() const
211{
212 return nr_vertices;
213}
214
215
216void gl_implicit_surface_drawable_base::add_normal(const dvec3& p, const dvec3& n, std::vector<vec3>& nml_gradient_geometry) const
217{
218 nml_gradient_geometry.push_back(vec3(p));
219 nml_gradient_geometry.push_back(vec3(p+n/res));
220}
221
223void gl_implicit_surface_drawable_base::new_polygon(const std::vector<unsigned> &vertex_indices)
224{
225 unsigned n = (unsigned)vertex_indices.size();
226 mesh.start_face();
227
228 // compute face normal
229 if (normal_computation_type == FACE_NORMALS) {
230 dvec3 ctr;
231 dvec3 nml = compute_face_normal(vertex_indices, &ctr);
232 if (obj_out) {
233 ++normal_index;
234 (*obj_out) << "vn " << nml(0) << " " << nml(1) << " " << nml(2) << std::endl;
235 if (triangulate) {
236 for (unsigned i = 0; i < n - 2; ++i) {
237 (*obj_out) << "f " << vertex_indices[0] + 1 << "//" << normal_index;
238 (*obj_out) << " " << vertex_indices[i + 1] + 1 << "//" << normal_index;
239 (*obj_out) << " " << vertex_indices[i + 2] + 1 << "//" << normal_index << std::endl;
240 }
241 }
242 else {
243 (*obj_out) << "f";
244 for (unsigned i = 0; i < n; ++i) {
245 (*obj_out) << " " << vertex_indices[i] + 1 << "//" << normal_index;
246 }
247 (*obj_out) << std::endl;
248 }
249 }
250 else {
251 int ni = mesh.new_normal(nml);
252 for (unsigned i = 0; i < n; ++i)
253 mesh.new_corner(vertex_indices[i], ni);
254 add_normal(ctr, nml, nml_mesh_geometry);
255 }
256 return;
257 }
258
259 if (obj_out) {
260 if (triangulate) {
261 for (unsigned i = 0; i < n - 2; ++i) {
262 (*obj_out) << "f " << vertex_indices[0] + 1 << "//" << vertex_indices[0] + 1;
263 (*obj_out) << " " << vertex_indices[i + 1] + 1 << "//" << vertex_indices[i + 1] + 1;
264 (*obj_out) << " " << vertex_indices[i + 2] + 1 << "//" << vertex_indices[i + 2] + 1 << std::endl;
265 }
266 }
267 else {
268 (*obj_out) << "f";
269 for (unsigned i = 0; i < n; ++i) {
270 (*obj_out) << " " << vertex_indices[i] + 1 << "//" << vertex_indices[i] + 1;
271 }
272 (*obj_out) << std::endl;
273 }
274 return;
275 }
276
277 std::vector<int> nis;
278 for (unsigned i=0; i<n; ++i) {
279 // compute corner normal
280 vec3 nml = compute_corner_normal(sm_ptr->vertex_location(vertex_indices[(i+n-1)%n]),
281 sm_ptr->vertex_location(vertex_indices[i]),
282 sm_ptr->vertex_location(vertex_indices[(i+1)%n]),
283 sm_ptr->vertex_normal(vertex_indices[i]));
284
285 // check whether we saw it before
286 int ni = -1;
287 for (int nj : nis)
288 if ((nml - mesh.normal(nj)).length() < 1e-6f) {
289 ni = nj;
290 break;
291 }
292 // if not add new normal
293 if (ni == -1) {
294 ni = mesh.new_normal(nml);
295 nis.push_back(ni);
296 }
297 mesh.new_corner(vertex_indices[i], ni);
298 }
299}
300
303{
304 dvec3 p = sm_ptr->vertex_location(vi);
305 mesh.new_position(p);
306 if (normal_computation_type != FACE_NORMALS) {
307 dvecn grad = func_ptr->evaluate_gradient(p.to_vec());
308 dvec3 n(grad.size(), grad.data());
309 n.normalize();
310 sm_ptr->vertex_normal(vi) = n;
311 if (obj_out)
312 (*obj_out) << "v " << p(0) << " " << p(1) << " " << p(2) << "\n"
313 << "vn " << n(0) << " " << n(1) << " " << n(2) << std::endl;
314 else
315 add_normal(p,n,nml_gradient_geometry);
316 }
317 else {
318 if (obj_out) {
319 dvec3 p = sm_ptr->vertex_location(vi);
320 (*obj_out) << "v " << p(0) << " " << p(1) << " " << p(2) << std::endl;
321 }
322 }
323 ++nr_vertices;
324}
325
326dvec3 gl_implicit_surface_drawable_base::compute_face_normal(const std::vector<unsigned int> &vis, dvec3* _c) const
327{
328 std::vector<const dvec3*> p_pis;
329 for (unsigned int i=0; i<vis.size(); ++i)
330 p_pis.push_back(&sm_ptr->vertex_location(vis[i]));
331 dvec3 c(0,0,0);
332 dvec3 n(0,0,0);
333 for (unsigned int i=0; i<p_pis.size(); ++i) {
334 c += *p_pis[i];
335 n += cross(*p_pis[i], *p_pis[(i+1)%p_pis.size()]);
336 }
337 c *= 1.0/p_pis.size();
338 if (_c)
339 *_c = c;
340 n.normalize();
341 return n;
342}
343
346{
347}
348
349dvec3 gl_implicit_surface_drawable_base::compute_corner_normal(const dvec3& pj, const dvec3& pi, const dvec3& pk, const dvec3& ni)
350{
351 if (normal_computation_type == FACE_NORMALS)
352 return dvec3(0.0);
353
354 if (normal_computation_type == GRADIENT_NORMALS)
355 return ni;
356
357 dvec3 n = cross(pk-pi, pj-pi);
358 double l = n.length();
359 if ((normal_computation_type != CORNER_GRADIENTS) && (l > 1e-6) && (dot(n,ni) > l*normal_threshold))
360 return ni;
361 else {
362 dvec3 p = pi;
363 if (normal_computation_type == CORNER_GRADIENTS) {
364 p = (2.0/3)*pi+(1.0/6)*(pj+pk);
365 dvecn grad = func_ptr->evaluate_gradient(p.to_vec());
366 n = dvec3(grad.size(),grad.data());
367 n.normalize();
368 }
369 else {
370 if (l < 1e-6)
371 return ni;
372 n /= l;
373 }
374 add_normal(p, n, nml_mesh_geometry);
375 return n;
376 }
377}
378
380{
381 outofdate = true;
382 post_redraw();
383}
384
386{
387 nr_faces = 0;
388 nr_vertices = 0;
389 switch (contouring_type) {
390 case MARCHING_CUBES :
391 {
392 cgv::media::mesh::marching_cubes<double,double> mc(*func_ptr,this,grid_epsilon,epsilon);
393 sm_ptr = &mc;
394 mc.extract(0,box,res,res,res,res>40);
395 nr_vertices = mc.get_nr_vertices();
396 nr_faces = mc.get_nr_faces();
397 }
398 break;
399 case DUAL_CONTOURING :
400 {
401 cgv::media::mesh::dual_contouring<double,double> dc(*func_ptr,this,consistency_threshold, max_nr_iters, epsilon);
402 sm_ptr = &dc;
403 dc.extract(0,box,res,res,res,res>40);
404 nr_vertices = dc.get_nr_vertices();
405 nr_faces = dc.get_nr_faces();
406 }
407 break;
408 }
409}
410
412{
413 if (!func_ptr)
414 return;
415
416 mesh.clear();
417 nml_gradient_geometry.clear();
418 nml_mesh_geometry.clear();
419
421
422 crs.radius_scale = srs.radius_scale = 0.5f * float(box.get_extent().length()/res);
423}
424
426{
427 ref_box_renderer(ctx, 1);
428 ref_sphere_renderer(ctx, 1);
429 ref_cone_renderer(ctx, 1);
430 ref_arrow_renderer(ctx, 1);
431 return true;
432}
433
435{
436 ref_box_renderer(ctx, -1);
437 ref_cone_renderer(ctx, -1);
438 ref_sphere_renderer(ctx, -1);
439 ref_arrow_renderer(ctx, -1);
440}
441
444{
445 if (outofdate) {
446 extract_mesh();
447 mri.destruct(ctx);
448 if (mesh.get_nr_faces() > 0) {
449 mri.construct(ctx, mesh);
450 mri.bind(ctx, ctx.ref_surface_shader_program(false), true);
451 mri.bind_wireframe(ctx, ref_cone_renderer(ctx).ref_prog(), true);
452 }
453 outofdate = false;
454 }
455
456 std::vector<box3> boxes;
457 std::vector<rgb> box_colors;
458 if (show_box) {
459 boxes.push_back(box);
460 box_colors.push_back(rgb(0.8f, 0.7f, 0.0f));
461 }
462 if (show_mini_box) {
463 dvec3 d = box.get_extent() / double(res - 1);
464 dvec3 b0 = box.get_corner(0);
465 b0(0) += ix * d(0);
466 b0(1) += iy * d(1);
467 b0(2) += iz * d(2);
468 boxes.push_back(dbox3(b0, b0 + d));
469 box_colors.push_back(rgb(0.8f, 0.6f, 1.0f));
470 }
471 if (!boxes.empty()) {
472 auto& br = ref_box_renderer(ctx);
473 br.set_render_style(brs);
474 br.set_box_array(ctx, boxes);
475 br.set_color_array(ctx, box_colors);
476 br.render(ctx, 0, boxes.size());
477 }
478
480
481 if (show_gradient_normals || show_mesh_normals) {
482 auto& ar = ref_arrow_renderer(ctx);
483 ar.set_render_style(ars);
484 if (show_gradient_normals && !nml_gradient_geometry.empty()) {
485 ar.set_position_array(ctx, &nml_gradient_geometry.front(), nml_gradient_geometry.size() / 2, 2 * sizeof(vec3));
486 ar.set_end_point_array(ctx, &nml_gradient_geometry[1], nml_gradient_geometry.size() / 2, 2 * sizeof(vec3));
487 if (ar.validate_and_enable(ctx)) {
488 ctx.set_color(rgb(1, 0.5f, 0));
489 ar.draw(ctx, 0, nml_gradient_geometry.size() / 2);
490 ar.disable(ctx);
491 }
492 }
493 if (show_mesh_normals && !nml_mesh_geometry.empty()) {
494 ar.set_position_array(ctx, &nml_mesh_geometry.front(), nml_mesh_geometry.size() / 2, 2 * sizeof(vec3));
495 ar.set_end_point_array(ctx, &nml_mesh_geometry[1], nml_mesh_geometry.size() / 2, 2 * sizeof(vec3));
496 if (ar.validate_and_enable(ctx)) {
497 ctx.set_color(rgb(1, 0, 1));
498 ar.draw(ctx, 0, nml_mesh_geometry.size() / 2);
499 ar.disable(ctx);
500 }
501 }
502 }
503 if (show_sampling_locations) {
504 vec3 p = box.get_corner(0);
505 vec3 q = box.get_corner(7);
506 vec3 d = box.get_extent();
507 d /= float(res - 1);
508 std::vector<vec3> G;
509 std::vector<vec3> G_out;
510 for (unsigned int i = 0; i < res; ++i)
511 for (unsigned int j = 0; j < res; ++j)
512 for (unsigned int k = 0; k < res; ++k) {
513 vec3 r(p(0) + i * d(0), p(1) + j * d(1), p(2) + k * d(2));
514 if (func_ptr->evaluate(r.to_vec()) > 0)
515 G_out.push_back(r);
516 else
517 G.push_back(r);
518 }
519 auto& sr = ref_sphere_renderer(ctx);
520 sr.set_render_style(srs);
521 sr.set_position_array(ctx, G);
522 if (sr.validate_and_enable(ctx)) {
523 ctx.set_color(rgb(1, 0.3f, 0.3f));
524 sr.draw(ctx, 0, G.size());
525 sr.disable(ctx);
526 }
527 sr.set_position_array(ctx, G_out);
528 if (sr.validate_and_enable(ctx)) {
529 ctx.set_color(rgb(0.3f, 0.3f, 1));
530 sr.draw(ctx, 0, G_out.size());
531 sr.disable(ctx);
532 }
533 }
534}
535
537{
538 if (show_sampling_grid) {
539 vec3 p = box.get_corner(0);
540 vec3 q = box.get_corner(7);
541 vec3 d = box.get_extent();
542 d /= float(res - 1);
543 std::vector<vec3> G;
544 G.clear();
545 for (unsigned int i=0; i<res; ++i)
546 for (unsigned int j=0; j<res; ++j) {
547 G.push_back(vec3(p(0) + i * d(0), p(1) + j * d(1), p(2)));
548 G.push_back(vec3(p(0) + i * d(0), p(1) + j * d(1), q(2)));
549 G.push_back(vec3(p(0), p(1) + i * d(1), p(2) + j * d(2)));
550 G.push_back(vec3(q(0), p(1) + i * d(1), p(2) + j * d(2)));
551 G.push_back(vec3(p(0) + i * d(0), p(1), p(2) + j * d(2)));
552 G.push_back(vec3(p(0) + i * d(0), q(1), p(2) + j * d(2)));
553 }
554 glEnable(GL_BLEND);
555 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
556 auto& cr = ref_cone_renderer(ctx);
557 cr.set_render_style(crs);
558 cr.set_position_array(ctx, G);
559 if (cr.validate_and_enable(ctx)) {
560 ctx.set_color(rgba(0.7f, 0.7f, 0.7f, sampling_grid_alpha));
561 cr.draw(ctx, 0, G.size());
562 cr.disable(ctx);
563 }
564 glDisable(GL_BLEND);
565 }
566}
567
569{
570 if (show_vertices && mesh.get_nr_positions() > 0) {
572 sr.set_render_style(srs);
573 sr.set_position_array(ctx, mesh.get_positions());
574 sr.render(ctx, 0, mesh.get_nr_positions());
575 }
576 if (show_wireframe && mesh.get_nr_faces() > 0) {
578 cr.set_render_style(crs);
579 if (cr.enable(ctx)) {
580 mri.draw_wireframe(ctx);
581 cr.disable(ctx);
582 }
583 }
584 if (show_surface && (mesh.get_nr_faces() > 0)) {
585 GLboolean cull_face;
586 glGetBooleanv(GL_CULL_FACE, &cull_face);
587 auto& prog = ctx.ref_surface_shader_program(false);
588 prog.enable(ctx);
589 ctx.set_material(material);
590 prog.set_uniform(ctx, "illumination_mode", 2);
591 prog.set_uniform(ctx, "map_color_to_material", 0);
592 glDisable(GL_CULL_FACE);
593 mri.draw_all(ctx);
594 if (cull_face)
595 glEnable(GL_CULL_FACE);
596 prog.disable(ctx);
597 }
598}
599
600
601 }
602 }
603}
T normalize()
normalize the vector using the L2-Norm and return the length
Definition fvec.h:302
T length() const
length of the vector L2-Norm
Definition fvec.h:249
vec< T > to_vec() const
conversion to vector type
Definition fvec.h:730
static cgv::type::uint32_type size()
return number of elements
Definition fvec.h:179
virtual vec_type evaluate_gradient(const pnt_type &p) const
interface for evaluation of the gradient of the multivariate function.
Definition mfunc.h:31
virtual T evaluate(const pnt_type &p) const =0
interface for evaluation of the multivariate function
A column vector class.
Definition vec.h:28
unsigned size() const
number of elements
Definition vec.h:59
T * data()
cast into non const array
Definition vec.h:192
fpnt_type get_corner(int i) const
return the i-th corner where the lower N bits of i are used to select between min (bit = 0) and max (...
fvec_type get_extent() const
return a vector with the extents in the different dimensions
class used to perform the marching cubes algorithm
void extract(const T &_iso_value, const axis_aligned_box< X, 3 > &box, unsigned int _resx, unsigned int _resy, unsigned int _resz, bool show_progress=false)
extract iso surface and send quads to dual contouring handler
class used to perform the marching cubes algorithm
idx_type start_face()
Create a new empty face to which new corners are added.
idx_type new_corner(idx_type position_index, idx_type normal_index=-1, idx_type tex_coord_index=-1)
Create a new corner with the given attributes.
idx_type get_nr_faces() const
return the number of faces
idx_type get_nr_positions() const
access to positions
void clear()
clear simple mesh
idx_type new_position(const vec3_type &p)
add a new position and return position index
idx_type new_normal(const vec3_type &n)
add a new normal and return normal index
unsigned int get_nr_vertices() const
return the number of vertices
const vec_type & vertex_normal(unsigned int vi) const
read access to vertex normals
pnt_type & vertex_location(unsigned int vi)
write access to vertex locations
unsigned int get_nr_faces() const
return the number of faces
renderer that supports raycasting of cones
bool disable(context &ctx)
disable renderer
bool enable(context &ctx)
enables renderer
base class for all drawables, which is independent of the used rendering API.
Definition context.h:621
virtual void set_color(const rgba &clr)
set the current color
Definition context.cxx:1617
virtual void set_material(const cgv::media::illum::surface_material &mat)
set the current material
Definition context.cxx:1632
virtual shader_program & ref_surface_shader_program(bool texture_support=false)=0
return a reference to the default shader program used to render surfaces
void post_redraw()
posts a redraw event to the current context if one is available
Definition drawable.cxx:43
std::ostream * obj_out
of this output stream is defined, use it to write currently extracted surface to it
bool save(const std::string &file_name)
function used to save to obj file
gl_implicit_surface_drawable_base()
standard constructor does not initialize the function pointer such that nothing is drawn
void draw_implicit_surface(context &ctx)
helper function to tesselate the implicit surface
void before_drop_vertex(unsigned int vertex_index)
drop the currently first vertex that has the given global vertex index
dvec3 compute_face_normal(const std::vector< unsigned int > &vis, dvec3 *c=0) const
compute the normal of a face
void post_rebuild()
use this as callback to ask for a re-tesselation of the implicit surface
void draw(context &ctx)
overload to draw the content of this drawable
bool init(context &ctx)
this method is called after creation or recreation of the context, return whether all necessary funct...
void new_vertex(unsigned int vi)
allows to augment a newly computed vertex by additional data
void finish_frame(context &ctx)
this method is called in one pass over all drawables after drawing
virtual void extract_mesh()
helper function to extract mesh from implicit surface
virtual void surface_extraction()
call the selected surface extraction method
void new_polygon(const std::vector< unsigned int > &vertex_indices)
announces a new quad
cgv::math::v3_func< double, double > F
type of the function describing the implicit surface
void clear(context &ctx)
clear all objects living in the context like textures or display lists
void draw_wireframe(cgv::render::context &ctx)
draw array elements forming the edges of the wireframe
bool bind_wireframe(context &ctx, shader_program &prog, bool force_success)
bind all or specific aa to the passed shader program
bool bind(context &ctx, shader_program &prog, bool force_success, int aa_index=-1)
override to restrict bind function to first aa as second is used for wireframe rendering
void destruct(cgv::render::context &ctx)
destruct render mesh info and free vertex buffer objects
void construct(cgv::render::context &ctx, cgv::media::mesh::simple_mesh< T > &mesh, std::vector< idx_type > *tuple_pos_indices=nullptr, std::vector< idx_type > *tuple_normal_indices=nullptr, int *num_floats_in_vertex=nullptr)
Construct mesh render info from a given simple mesh and store all vertex attributes in interleaved in...
void draw_all(context &ctx, bool skip_opaque=false, bool skip_blended=false, bool use_materials=true)
execute all draw calls
void set_position_array(const context &ctx, const std::vector< T > &positions)
templated method to set the position attribute from a vector of positions of type T
Definition renderer.h:176
void set_render_style(const render_style &rs)
reference given render style
Definition renderer.cxx:140
virtual bool render(context &ctx, size_t start, size_t count, bool use_strips=false, bool use_adjacency=false, uint32_t strip_restart_index=-1)
Convenience function that draws vertex or indexed element with this renderer.
Definition renderer.cxx:342
bool enable(context &ctx)
enable the shader program
renderer that supports splatting of spheres
cone_renderer & ref_cone_renderer(context &ctx, int ref_count_change)
reference to a singleton cone renderer that is shared among drawables
box_renderer & ref_box_renderer(context &ctx, int ref_count_change)
reference to a singleton box renderer that is shared among drawables
arrow_renderer & ref_arrow_renderer(context &ctx, int ref_count_change)
reference to a singleton surfel renderer that can be shared among drawables
sphere_renderer & ref_sphere_renderer(context &ctx, int ref_count_change)
reference to a singleton sphere renderer that can be shared among drawables
the cgv namespace
Definition print.h:11
cgv::media::color< float, cgv::media::RGB, cgv::media::OPACITY > rgba
declare rgba color type with 32 bit components
Definition color.h:855
cgv::math::fvec< double, 3 > dvec3
declare type of 3d double precision floating point vectors
Definition fvec.h:676
cgv::media::axis_aligned_box< double, 3 > dbox3
declare type of 3d double precision floating point axis-aligned boxes
cgv::media::color< float, cgv::media::RGB > rgb
declare rgb color type with 32 bit components
Definition color.h:853
cgv::math::fvec< float, 3 > vec3
declare type of 3d single precision floating point vectors
Definition fvec.h:669
float radius
default value assigned to radius attribute in enable method of cone renderer, set to 1 in constructor
float radius_scale
multiplied to the sphere radii, initialized to 1
float radius
default value assigned to radius attribute in enable method of sphere renderer, set to 1 in construct...
float radius_scale
multiplied to the sphere radii, initialized to 1
CullingMode culling_mode
culling mode for point splats, set to CM_OFF in constructor
ColorMapping map_color_to_material
material side[s] where color is to be mapped to the diffuse material component, defaults to MS_FRONT_...
IlluminationMode illumination_mode
illumination mode defaults to IM_ONE_SIDED
cgv::media::illum::surface_material::color_type surface_color
default value for color when map color to material is used