g4tools  5.4.0
atb_vertices
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
2 // See the file tools.license for terms.
3 
4 #ifndef tools_sg_atb_vertices
5 #define tools_sg_atb_vertices
6 
7 #include "vertices"
8 
9 namespace tools {
10 namespace sg {
11 
12 class atb_vertices : public vertices {
14 public:
20 public:
21  virtual const desc_fields& node_desc_fields() const {
23  static const desc_fields s_v(parent::node_desc_fields(),5, //WARNING : take care of count.
29  );
30  return s_v;
31  }
32  virtual void protocol_one_fields(std::vector<field*>& a_fields) const {
33  parent::protocol_one_fields(a_fields);
34  const field* _draw_edges = static_cast<const field*>(&draw_edges);
35  removep<field>(a_fields,_draw_edges);
36  }
37 private:
38  void add_fields(){
39  add_field(&rgbas);
40  add_field(&nms);
44  }
45 protected: //gstos
46  virtual unsigned int create_gsto(std::ostream&,sg::render_manager& a_mgr) {
47  //unsigned int npt = xyzs.values().size()/3;
48  //::printf("debug : atb_vertices : %lu : create_gsto : %u\n",this,npt);
49 
50  std::vector<float> gsto_data;
51 
52  if(rgbas.size()) {
53  if(nms.size()) {
54  if(do_back.value()) {
55  append(gsto_data,xyzs.values());
56  append(gsto_data,nms.values());
57  append(gsto_data,m_back_xyzs);
58  append(gsto_data,m_back_nms);
59  append(gsto_data,rgbas.values());
60  } else {
61  append(gsto_data,xyzs.values());
62  append(gsto_data,nms.values());
63  append(gsto_data,rgbas.values());
64  }
65  if(draw_edges.value()) {
66  // allocate edges :
67  size_t pos_edges = gsto_data.size();
68  append(gsto_data,xyzs.values());
69  append(gsto_data,xyzs.values());
70  float* pxyz = vec_data<float>(xyzs.values());
71  float* pedges = vec_data<float>(gsto_data)+pos_edges;
72  size_t npt = xyzs.values().size()/3;
73  size_t ntri = npt/3;
74  for(size_t itri=0;itri<ntri;itri++) {
75  // first edge :
76  *pedges = *(pxyz+0);pedges++;
77  *pedges = *(pxyz+1);pedges++;
78  *pedges = *(pxyz+2);pedges++;
79 
80  *pedges = *(pxyz+3);pedges++;
81  *pedges = *(pxyz+4);pedges++;
82  *pedges = *(pxyz+5);pedges++;
83 
84  // second edge :
85  *pedges = *(pxyz+3);pedges++;
86  *pedges = *(pxyz+4);pedges++;
87  *pedges = *(pxyz+5);pedges++;
88 
89  *pedges = *(pxyz+6);pedges++;
90  *pedges = *(pxyz+7);pedges++;
91  *pedges = *(pxyz+8);pedges++;
92 
93  // third edge :
94  *pedges = *(pxyz+6);pedges++;
95  *pedges = *(pxyz+7);pedges++;
96  *pedges = *(pxyz+8);pedges++;
97 
98  *pedges = *(pxyz+0);pedges++;
99  *pedges = *(pxyz+1);pedges++;
100  *pedges = *(pxyz+2);pedges++;
101 
102  pxyz += 9;
103  }
104 
105  }
106  } else {
107  append(gsto_data,xyzs.values());
108  append(gsto_data,rgbas.values());
109  }
110  } else {
111  if(nms.size()) {
112  append(gsto_data,xyzs.values());
113  append(gsto_data,nms.values());
114  } else {
115  append(gsto_data,xyzs.values());
116  }
117  }
118  return a_mgr.create_gsto_from_data(gsto_data);
119  }
120 
121 public:
122  virtual void render(render_action& a_action) {
123  if(touched()) {
124  if(do_back.value()) gen_back();
125  if(draw_edges.value()) gen_edges();
126 #ifdef __APPLE__
127  m_all_a_one = true;
128  {tools_vforcit_npp(float,rgbas.values(),it) {
129  if(*(it+3)!=1) {m_all_a_one = false;break;}
130  it += 4;
131  }}
132 #endif //__APPLE__
133  clean_gstos();
134  reset_touched();
135  }
136  if(xyzs.empty()) return;
137 
138  const state& state = a_action.state();
139 
140  if(state.m_use_gsto) {
141  unsigned int _id = get_gsto_id(a_action.out(),a_action.render_manager());
142  if(_id) {
143  a_action.begin_gsto(_id);
144  if(rgbas.size()) {
145 #ifdef __APPLE__
146  bool restore_blend = check_set_blend(a_action);
147 #endif
148  if(nms.size()) {
149  size_t npt = xyzs.values().size()/3;
150  bufpos pos_xyzs = 0;
151  bufpos pos_nms = 0;
152  bufpos pos_back_xyzs = 0;
153  bufpos pos_back_nms = 0;
154  bufpos pos_rgbas = 0;
155  bufpos pos_edges = 0;
156  {size_t sz = npt*3;
157  if(do_back.value()) {
158  pos_xyzs = 0;
159  pos_nms = pos_xyzs+sz*sizeof(float); //bytes
160  pos_back_xyzs = pos_nms+sz*sizeof(float);
161  pos_back_nms = pos_back_xyzs+sz*sizeof(float);
162  pos_rgbas = pos_back_nms+sz*sizeof(float);
163  } else {
164  pos_xyzs = 0;
165  pos_nms = pos_xyzs+sz*sizeof(float);
166  pos_rgbas = pos_nms+sz*sizeof(float);
167  }}
168  if(draw_edges.value()) {
169  pos_edges = pos_rgbas+npt*4*sizeof(float);
170  }
171  if(gl::is_line(mode.value())) {
172  //Same logic as Inventor SoLightModel.model = BASE_COLOR.
173  a_action.set_lighting(false);
174  if(do_back.value()) a_action.draw_gsto_vcn(mode.value(),npt,pos_back_xyzs,pos_rgbas,pos_back_nms);
175  a_action.draw_gsto_vcn(mode.value(),npt,pos_xyzs,pos_rgbas,pos_nms);
176  a_action.set_lighting(state.m_GL_LIGHTING);
177  } else if(mode.value()==gl::triangles()) {
178  if(draw_edges.value()) {
179  a_action.color4f(0,0,0,1);
180  a_action.line_width(1);
181  a_action.draw_gsto_v(gl::lines(),2*npt,pos_edges);
182  //pushes back the filled polygons to avoid z-fighting with lines
183  a_action.set_polygon_offset(true);
184 
185  a_action.color4f(state.m_color);
186  a_action.line_width(state.m_line_width);
187  //a_action.set_lighting(state.m_GL_LIGHTING);
188  }
189  if(do_back.value()) a_action.draw_gsto_vcn(mode.value(),npt,pos_back_xyzs,pos_rgbas,pos_back_nms);
190  a_action.draw_gsto_vcn(mode.value(),npt,pos_xyzs,pos_rgbas,pos_nms);
192  } else {
193  if(do_back.value()) a_action.draw_gsto_vcn(mode.value(),npt,pos_back_xyzs,pos_rgbas,pos_back_nms);
194  a_action.draw_gsto_vcn(mode.value(),npt,pos_xyzs,pos_rgbas,pos_nms);
195  }
196 
197  } else {
198  size_t npt = xyzs.values().size()/3;
199  bufpos pos_xyzs = 0;
200  bufpos pos_rgbas = npt*3*sizeof(float);
201  if(gl::is_line(mode.value())) {
202  //Same logic as Inventor SoLightModel.model = BASE_COLOR.
203  a_action.set_lighting(false);
204  a_action.draw_gsto_vc(mode.value(),npt,pos_xyzs,pos_rgbas);
205  a_action.set_lighting(state.m_GL_LIGHTING);
206  } else {
207  a_action.draw_gsto_vc(mode.value(),npt,pos_xyzs,pos_rgbas);
208  }
209  }
210 #ifdef __APPLE__
211  if(restore_blend) a_action.set_blend(true);
212 #endif
213  } else { //rgbas.empty()
214  if(nms.size()) {
215  size_t npt = xyzs.values().size()/3;
216  bufpos pos_xyzs = 0;
217  bufpos pos_nms = npt*3*sizeof(float);
218  if(gl::is_line(mode.value())) {
219  //Same logic as Inventor SoLightModel.model = BASE_COLOR.
220  a_action.set_lighting(false);
221  a_action.draw_gsto_vn(mode.value(),npt,pos_xyzs,pos_nms);
222  a_action.set_lighting(state.m_GL_LIGHTING);
223  } else {
224  a_action.draw_gsto_vn(mode.value(),npt,pos_xyzs,pos_nms);
225  }
226  } else {
227  size_t npt = xyzs.values().size()/3;
228  bufpos pos = 0;
229  if(gl::is_line(mode.value())) {
230  //Same logic as Inventor SoLightModel.model = BASE_COLOR.
231  a_action.set_lighting(false);
232  a_action.draw_gsto_v(mode.value(),npt,pos);
233  a_action.set_lighting(state.m_GL_LIGHTING);
234  } else {
235  a_action.draw_gsto_v(mode.value(),npt,pos);
236  }
237  }
238  }
239  a_action.end_gsto();
240  return;
241 
242  } else {
243  // use immediate rendering.
244  }
245 
246  } else {
247  clean_gstos(&a_action.render_manager());
248  }
249 
250  // immediate rendering :
251  if(rgbas.size()) {
252 
253 #ifdef __APPLE__
254  bool restore_blend = check_set_blend(a_action);
255 #endif
256 
257  if(nms.size()) {
258  if(gl::is_line(mode.value())) {
259  //Same logic as Inventor SoLightModel.model = BASE_COLOR.
260  a_action.set_lighting(false);
261  if(do_back.value())
264  a_action.set_lighting(state.m_GL_LIGHTING);
265  } else if(mode.value()==gl::triangles()) {
266  if(draw_edges.value()) {
267  a_action.color4f(0,0,0,1);
268  a_action.line_width(1);
269  a_action.draw_vertex_array(gl::lines(),m_edges);
270  a_action.set_polygon_offset(true);
271  a_action.color4f(state.m_color);
272  a_action.line_width(state.m_line_width);
273  }
277  } else {
280  }
281 
282  } else {
283  if(gl::is_line(mode.value())) {
284  //Same logic as Inventor SoLightModel.model = BASE_COLOR.
285  a_action.set_lighting(false);
287  a_action.set_lighting(state.m_GL_LIGHTING);
288  } else {
290  }
291  }
292 
293 #ifdef __APPLE__
294  if(restore_blend) a_action.set_blend(true);
295 #endif
296  } else { //rgbas.empty()
297  if(nms.size()) {
298  if(gl::is_line(mode.value())) {
299  //Same logic as Inventor SoLightModel.model = BASE_COLOR.
300  a_action.set_lighting(false);
302  a_action.set_lighting(state.m_GL_LIGHTING);
303  } else {
305  }
306  } else {
307  if(gl::is_line(mode.value())) {
308  //Same logic as Inventor SoLightModel.model = BASE_COLOR.
309  a_action.set_lighting(false);
310  a_action.draw_vertex_array(mode.value(),xyzs.values());
311  a_action.set_lighting(state.m_GL_LIGHTING);
312  } else {
313  a_action.draw_vertex_array(mode.value(),xyzs.values());
314  }
315  }
316 
317  }
318 
319  }
320 public:
322  :parent()
323  ,do_back(false)
324  ,epsilon(0)
325  ,draw_edges(false)
326  ,m_xyzs_pos(0)
327  ,m_rgbas_pos(0)
328  ,m_nms_pos(0)
329 #ifdef __APPLE__
330  ,m_all_a_one(true)
331 #endif
332  {
333 #ifdef TOOLS_MEM
334  mem::increment(s_class().c_str());
335 #endif
336  add_fields();
337  }
338  virtual ~atb_vertices(){
339 #ifdef TOOLS_MEM
340  mem::decrement(s_class().c_str());
341 #endif
342  }
343 public:
344  atb_vertices(const atb_vertices& a_from)
345  :parent(a_from)
346  ,rgbas(a_from.rgbas)
347  ,nms(a_from.nms)
348  ,do_back(a_from.do_back)
349  ,epsilon(a_from.epsilon)
350  ,draw_edges(a_from.draw_edges)
351  ,m_xyzs_pos(a_from.m_xyzs_pos)
352  ,m_rgbas_pos(a_from.m_rgbas_pos)
353  ,m_nms_pos(a_from.m_nms_pos)
354 #ifdef __APPLE__
355  ,m_all_a_one(true)
356 #endif
357  {
358 #ifdef TOOLS_MEM
359  mem::increment(s_class().c_str());
360 #endif
361  add_fields();
362  }
364  parent::operator=(a_from);
365  rgbas = a_from.rgbas;
366  nms = a_from.nms;
367  do_back = a_from.do_back;
368  epsilon = a_from.epsilon;
369  draw_edges = a_from.draw_edges;
370  m_xyzs_pos = a_from.m_xyzs_pos;
371  m_rgbas_pos = a_from.m_rgbas_pos;
372  m_nms_pos = a_from.m_nms_pos;
373  return *this;
374  }
375 public:
376  void add_pos_color(float a_x,float a_y,float a_z,float a_r,float a_g,float a_b,float a_a) {
377  xyzs.add(a_x);
378  xyzs.add(a_y);
379  xyzs.add(a_z);
380  rgbas.add(a_r);
381  rgbas.add(a_g);
382  rgbas.add(a_b);
383  rgbas.add(a_a);
384  }
385 
386  template <class COLOR>
387  void add_pos_color(float a_x,float a_y,float a_z,const COLOR& a_col) {
388  xyzs.add(a_x);
389  xyzs.add(a_y);
390  xyzs.add(a_z);
391  rgbas.add(a_col.r());
392  rgbas.add(a_col.g());
393  rgbas.add(a_col.b());
394  rgbas.add(a_col.a());
395  }
396 
397  template <class VEC,class COLOR>
398  void add_pos_color(const VEC& a_pos,const COLOR& a_col) {
399  xyzs.add(a_pos.x());
400  xyzs.add(a_pos.y());
401  xyzs.add(a_pos.z());
402  rgbas.add(a_col.r());
403  rgbas.add(a_col.g());
404  rgbas.add(a_col.b());
405  rgbas.add(a_col.a());
406  }
407 
408  void allocate_pos_color(size_t a_npt) {
409  xyzs.values().resize(a_npt*3);
410  rgbas.values().resize(a_npt*4);
411  m_xyzs_pos = 0;
412  m_rgbas_pos = 0;
413  }
414 
415  template <class VEC,class COLOR>
416  void add_pos_color_allocated(const VEC& a_pos,const COLOR& a_col) {
417  {std::vector<float>& v = xyzs.values();
418  v[m_xyzs_pos] = a_pos.x();m_xyzs_pos++;
419  v[m_xyzs_pos] = a_pos.y();m_xyzs_pos++;
420  v[m_xyzs_pos] = a_pos.z();m_xyzs_pos++;
421  xyzs.touch();}
422  {std::vector<float>& v = rgbas.values();
423  v[m_rgbas_pos] = a_col.r();m_rgbas_pos++;
424  v[m_rgbas_pos] = a_col.g();m_rgbas_pos++;
425  v[m_rgbas_pos] = a_col.b();m_rgbas_pos++;
426  v[m_rgbas_pos] = a_col.a();m_rgbas_pos++;
427  rgbas.touch();}
428  }
429 
430  template <class VEC,class COLOR>
431  void add_pos_color_normal(const VEC& a_pos,const COLOR& a_col,const VEC& a_nm) {
432  xyzs.add(a_pos.x());
433  xyzs.add(a_pos.y());
434  xyzs.add(a_pos.z());
435  rgbas.add(a_col.r());
436  rgbas.add(a_col.g());
437  rgbas.add(a_col.b());
438  rgbas.add(a_col.a());
439  nms.add(a_nm.x());
440  nms.add(a_nm.y());
441  nms.add(a_nm.z());
442  }
443 
444  void allocate_pos_color_normal(size_t a_npt) {
445  xyzs.values().resize(a_npt*3);
446  rgbas.values().resize(a_npt*4);
447  nms.values().resize(a_npt*3);
448  m_xyzs_pos = 0;
449  m_rgbas_pos = 0;
450  m_nms_pos = 0;
451  }
452 
453  template <class VEC,class COLOR>
454  void add_pos_color_normal_allocated(const VEC& a_pos,const COLOR& a_col,const VEC& a_nm) {
455  {std::vector<float>& v = xyzs.values();
456  v[m_xyzs_pos] = a_pos.x();m_xyzs_pos++;
457  v[m_xyzs_pos] = a_pos.y();m_xyzs_pos++;
458  v[m_xyzs_pos] = a_pos.z();m_xyzs_pos++;
459  xyzs.touch();}
460  {std::vector<float>& v = rgbas.values();
461  v[m_rgbas_pos] = a_col.r();m_rgbas_pos++;
462  v[m_rgbas_pos] = a_col.g();m_rgbas_pos++;
463  v[m_rgbas_pos] = a_col.b();m_rgbas_pos++;
464  v[m_rgbas_pos] = a_col.a();m_rgbas_pos++;
465  rgbas.touch();}
466  {std::vector<float>& v = nms.values();
467  v[m_nms_pos] = a_nm.x();m_nms_pos++;
468  v[m_nms_pos] = a_nm.y();m_nms_pos++;
469  v[m_nms_pos] = a_nm.z();m_nms_pos++;
470  nms.touch();}
471  }
472 
473  void add_rgba(float a_r,float a_g,float a_b,float a_a) {
474  rgbas.add(a_r);
475  rgbas.add(a_g);
476  rgbas.add(a_b);
477  rgbas.add(a_a);
478  }
479  void add_color(const colorf& a_col) {
480  rgbas.add(a_col.r());
481  rgbas.add(a_col.g());
482  rgbas.add(a_col.b());
483  rgbas.add(a_col.a());
484  }
485 
486  void add_normal(float a_x,float a_y,float a_z) {
487  nms.add(a_x);
488  nms.add(a_y);
489  nms.add(a_z);
490  }
491  template <class VEC>
492  void add_normal(const VEC& a_nm) {
493  nms.add(a_nm.x());
494  nms.add(a_nm.y());
495  nms.add(a_nm.z());
496  }
497 
498  void add_rgba_allocated(size_t& a_pos,float a_r,float a_g,float a_b,float a_a) {
499  std::vector<float>& v = rgbas.values();
500  v[a_pos] = a_r;a_pos++;
501  v[a_pos] = a_g;a_pos++;
502  v[a_pos] = a_b;a_pos++;
503  v[a_pos] = a_a;a_pos++;
504  rgbas.touch();
505  }
506  void add_normal_allocated(size_t& a_pos,float a_x,float a_y,float a_z) {
507  std::vector<float>& v = nms.values();
508  v[a_pos] = a_x;a_pos++;
509  v[a_pos] = a_y;a_pos++;
510  v[a_pos] = a_z;a_pos++;
511  nms.touch();
512  }
513 
514  template <class VEC>
515  void add_pos_normal(const VEC& a_pos,const VEC& a_nm) {
516  xyzs.add(a_pos.x());
517  xyzs.add(a_pos.y());
518  xyzs.add(a_pos.z());
519  nms.add(a_nm.x());
520  nms.add(a_nm.y());
521  nms.add(a_nm.z());
522  }
523 
524  bool add_dashed_line_rgba(float a_bx,float a_by,float a_bz,
525  float a_ex,float a_ey,float a_ez,
526  unsigned int a_num_dash,
527  float a_r,float a_g,float a_b,float a_a) {
528  if(!parent::add_dashed_line(a_bx,a_by,a_bz,a_ex,a_ey,a_ez,a_num_dash)) return false;
529  for(unsigned int index=0;index<a_num_dash;index++) {
530  add_rgba(a_r,a_g,a_b,a_a);
531  add_rgba(a_r,a_g,a_b,a_a);
532  }
533  return true;
534  }
535 
536  void clear() {
537  rgbas.clear();
538  nms.clear();
539  parent::clear();
540  }
541 protected:
542  void gen_back(){
543  m_back_xyzs.clear();
544  m_back_nms.clear();
545 
546  clean_gstos(); //must reset for all render_manager.
547 
548  std::vector<float>& _xyzs = xyzs.values();
549  std::vector<float>& _nms = nms.values();
550 
551  if(_xyzs.empty()) return;
552 
553  m_back_xyzs.resize(_xyzs.size(),0);
554  m_back_nms.resize(_nms.size(),0);
555 
556  float epsil = epsilon.value();
557 
558  if(mode.value()==gl::triangle_fan()) { //reverse after first point.
559 
560  m_back_xyzs[0] = _xyzs[0] - _nms[0] * epsil;
561  m_back_xyzs[1] = _xyzs[1] - _nms[1] * epsil;
562  m_back_xyzs[2] = _xyzs[2] - _nms[2] * epsil;
563 
564  {std::vector<float>::const_iterator it = _xyzs.begin()+3;
565  std::vector<float>::const_iterator _end = _xyzs.end();
566  std::vector<float>::const_iterator itn = _nms.begin()+3;
567  std::vector<float>::reverse_iterator it2 = m_back_xyzs.rbegin();
568  for(;it!=_end;it2+=3) {
569  *(it2+2) = *it - *itn * epsil; it++;itn++; //x
570  *(it2+1) = *it - *itn * epsil; it++;itn++; //y
571  *(it2+0) = *it - *itn * epsil; it++;itn++; //z
572  }}
573 
574  m_back_nms[0] = _nms[0] * -1.0f;
575  m_back_nms[1] = _nms[1] * -1.0f;
576  m_back_nms[2] = _nms[2] * -1.0f;
577 
578  {std::vector<float>::const_iterator it = _nms.begin()+3;
579  std::vector<float>::const_iterator _end = _nms.end();
580  std::vector<float>::reverse_iterator it2 = m_back_nms.rbegin();
581  for(;it!=_end;it2+=3) {
582  *(it2+2) = *it * -1.0f; it++;
583  *(it2+1) = *it * -1.0f; it++;
584  *(it2+0) = *it * -1.0f; it++;
585  }}
586 
587  } else {
588 
589  {std::vector<float>::const_iterator it = _xyzs.begin();
590  std::vector<float>::const_iterator _end = _xyzs.end();
591  std::vector<float>::const_iterator itn = _nms.begin();
592  std::vector<float>::reverse_iterator it2 = m_back_xyzs.rbegin();
593  for(;it!=_end;it2+=3) {
594  *(it2+2) = *it - *itn * epsil; it++;itn++; //x
595  *(it2+1) = *it - *itn * epsil; it++;itn++; //y
596  *(it2+0) = *it - *itn * epsil; it++;itn++; //z
597  }}
598 
599  {std::vector<float>::const_iterator it = _nms.begin();
600  std::vector<float>::const_iterator _end = _nms.end();
601  std::vector<float>::reverse_iterator it2 = m_back_nms.rbegin();
602  for(;it!=_end;it2+=3) {
603  *(it2+2) = *it * -1.0f; it++;
604  *(it2+1) = *it * -1.0f; it++;
605  *(it2+0) = *it * -1.0f; it++;
606  }}
607 
608  }
609  }
610 
611  void gen_edges(){
612  m_edges.clear();
613 
614  clean_gstos(); //must reset for all render_manager.
615 
616  std::vector<float>& _xyzs = xyzs.values();
617  if(_xyzs.empty()) return;
618 
619  m_edges.resize(2*_xyzs.size(),0);
620 
621  float* pxyz = vec_data<float>(xyzs.values());
622  float* pedges = vec_data<float>(m_edges);
623 
624  size_t npt = xyzs.values().size()/3;
625  size_t ntri = npt/3;
626  for(size_t itri=0;itri<ntri;itri++) {
627  // first edge :
628  *pedges = *(pxyz+0);pedges++;
629  *pedges = *(pxyz+1);pedges++;
630  *pedges = *(pxyz+2);pedges++;
631 
632  *pedges = *(pxyz+3);pedges++;
633  *pedges = *(pxyz+4);pedges++;
634  *pedges = *(pxyz+5);pedges++;
635 
636  // second edge :
637  *pedges = *(pxyz+3);pedges++;
638  *pedges = *(pxyz+4);pedges++;
639  *pedges = *(pxyz+5);pedges++;
640 
641  *pedges = *(pxyz+6);pedges++;
642  *pedges = *(pxyz+7);pedges++;
643  *pedges = *(pxyz+8);pedges++;
644 
645  // third edge :
646  *pedges = *(pxyz+6);pedges++;
647  *pedges = *(pxyz+7);pedges++;
648  *pedges = *(pxyz+8);pedges++;
649 
650  *pedges = *(pxyz+0);pedges++;
651  *pedges = *(pxyz+1);pedges++;
652  *pedges = *(pxyz+2);pedges++;
653 
654  pxyz += 9;
655  }
656  }
657 #ifdef __APPLE__
658 protected:
659  // macOS/Mojave : on this version, points are blended even if alpha is one !
660  bool check_set_blend(render_action& a_action) {
661  bool restore_blend = false;
662  const state& state = a_action.state();
663  if(state.m_GL_BLEND) {
664  /*
665  bool all_a_one = true;
666  tools_vforcit_npp(float,rgbas.values(),it) {
667  if(*(it+3)!=1) {all_a_one = false;break;}
668  it += 4;
669  }
670  if(all_a_one) {
671  a_action.set_blend(false);
672  restore_blend = true;
673  }
674  */
675  if(m_all_a_one) {
676  a_action.set_blend(false);
677  restore_blend = true;
678  }
679  }
680  return restore_blend;
681  }
682 #endif
683 protected:
684  std::vector<float> m_back_xyzs;
685  std::vector<float> m_back_nms;
686  std::vector<float> m_edges;
687 protected:
688  size_t m_xyzs_pos;
689  size_t m_rgbas_pos;
690  size_t m_nms_pos;
691 #ifdef __APPLE__
692  bool m_all_a_one;
693 #endif
694 };
695 
696 }}
697 
698 #endif
tools::sg::atb_vertices::add_normal
void add_normal(float a_x, float a_y, float a_z)
Definition: atb_vertices:486
tools::sg::field::touch
void touch()
Definition: field:59
tools::sg::atb_vertices::~atb_vertices
virtual ~atb_vertices()
Definition: atb_vertices:338
tools::sg::atb_vertices::gen_back
void gen_back()
Definition: atb_vertices:542
tools::sg::atb_vertices::draw_edges
sf< bool > draw_edges
Definition: atb_vertices:19
tools::sg::atb_vertices::add_rgba
void add_rgba(float a_r, float a_g, float a_b, float a_a)
Definition: atb_vertices:473
tools::sg::atb_vertices::allocate_pos_color_normal
void allocate_pos_color_normal(size_t a_npt)
Definition: atb_vertices:444
tools::sg::render_action::draw_gsto_v
virtual void draw_gsto_v(gl::mode_t, size_t, bufpos)=0
tools::sg::render_action::draw_vertex_array
virtual void draw_vertex_array(gl::mode_t, size_t, const float *)=0
tools::sg::state
Definition: state:25
tools::sg::render_action::set_lighting
virtual void set_lighting(bool)=0
tools::sg::bmf::empty
bool empty() const
Definition: bmf:70
tools::gl::is_line
bool is_line(mode_t a_mode)
Definition: glprims:31
tools::sg::state::m_GL_LIGHTING
bool m_GL_LIGHTING
Definition: state:248
tools::sg::vertices::mode
sf< gl::mode_t > mode
Definition: vertices:26
tools::sg::atb_vertices::add_dashed_line_rgba
bool add_dashed_line_rgba(float a_bx, float a_by, float a_bz, float a_ex, float a_ey, float a_ez, unsigned int a_num_dash, float a_r, float a_g, float a_b, float a_a)
Definition: atb_vertices:524
tools::gl::triangles
mode_t triangles()
Definition: glprims:20
tools::sg::atb_vertices::m_xyzs_pos
size_t m_xyzs_pos
Definition: atb_vertices:688
tools::sg::bmf::add
void add(const T &a_value)
Definition: bmf:73
tools::sg::atb_vertices::add_color
void add_color(const colorf &a_col)
Definition: atb_vertices:479
tools::sg::atb_vertices::allocate_pos_color
void allocate_pos_color(size_t a_npt)
Definition: atb_vertices:408
tools::sg::render_action::draw_gsto_vc
virtual void draw_gsto_vc(gl::mode_t, size_t, bufpos, bufpos)=0
tools::colorf
Definition: colorf:11
tools::sg::atb_vertices::add_rgba_allocated
void add_rgba_allocated(size_t &a_pos, float a_r, float a_g, float a_b, float a_a)
Definition: atb_vertices:498
tools::sg::atb_vertices::m_rgbas_pos
size_t m_rgbas_pos
Definition: atb_vertices:689
tools::sg::atb_vertices::protocol_one_fields
virtual void protocol_one_fields(std::vector< field * > &a_fields) const
Definition: atb_vertices:32
tools::sg::state::m_GL_POLYGON_OFFSET_FILL
bool m_GL_POLYGON_OFFSET_FILL
Definition: state:250
tools::gl::triangle_fan
mode_t triangle_fan()
Definition: glprims:22
tools::sg::gstos::clean_gstos
void clean_gstos()
Definition: gstos:89
tools::sg::render_action::draw_gsto_vcn
virtual void draw_gsto_vcn(gl::mode_t, size_t, bufpos, bufpos, bufpos)=0
tools::gl::lines
mode_t lines()
Definition: glprims:17
TOOLS_NODE
#define TOOLS_NODE(a__class, a__sclass, a__parent)
Definition: node:324
tools::sg::render_action::draw_vertex_color_normal_array
virtual void draw_vertex_color_normal_array(gl::mode_t, size_t, const float *, const float *, const float *)=0
tools::sg::atb_vertices::operator=
atb_vertices & operator=(const atb_vertices &a_from)
Definition: atb_vertices:363
tools::sg::field
Definition: field:25
tools::sg::atb_vertices::atb_vertices
atb_vertices(const atb_vertices &a_from)
Definition: atb_vertices:344
tools::sg::atb_vertices::add_pos_normal
void add_pos_normal(const VEC &a_pos, const VEC &a_nm)
Definition: atb_vertices:515
tools::sg::desc_fields
Definition: field_desc:148
tools::sg::render_action::color4f
virtual void color4f(float, float, float, float)=0
tools::colorf::g
float g() const
Definition: colorf:33
tools::sg::atb_vertices::m_edges
std::vector< float > m_edges
Definition: atb_vertices:686
tools::sg::bmf::values
const std::vector< T > & values() const
Definition: bmf:71
tools::sg::render_action::set_blend
virtual void set_blend(bool)=0
tools::sg::render_manager::create_gsto_from_data
virtual unsigned int create_gsto_from_data(size_t, const float *)=0
tools::sg::atb_vertices::atb_vertices
atb_vertices()
Definition: atb_vertices:321
tools::sg::mf< float >
tools::sg::atb_vertices::epsilon
sf< float > epsilon
Definition: atb_vertices:18
tools::sg::state::m_use_gsto
bool m_use_gsto
Definition: state:256
tools::append
void append(std::vector< T > &a_vec, const std::vector< T > &a_from)
Definition: vmanip:66
tools::sg::render_manager
Definition: render_manager:16
tools::sg::render_action::set_polygon_offset
virtual void set_polygon_offset(bool)=0
tools::sg::atb_vertices::add_normal_allocated
void add_normal_allocated(size_t &a_pos, float a_x, float a_y, float a_z)
Definition: atb_vertices:506
tools::sg::render_action::render_manager
virtual sg::render_manager & render_manager()=0
tools::sg::atb_vertices::clear
void clear()
Definition: atb_vertices:536
tools::colorf::a
float a() const
Definition: colorf:35
tools::sg::atb_vertices::add_normal
void add_normal(const VEC &a_nm)
Definition: atb_vertices:492
tools::sg::atb_vertices::add_pos_color_allocated
void add_pos_color_allocated(const VEC &a_pos, const COLOR &a_col)
Definition: atb_vertices:416
tools::sg::render_action
Definition: render_action:24
tools::sg::gstos::get_gsto_id
unsigned int get_gsto_id(std::ostream &a_out, render_manager &a_mgr)
Definition: gstos:60
tools::sg::render_action::begin_gsto
virtual void begin_gsto(gstoid)=0
VBO /////////////////////////////////////////////////////////.
tools::sg::render_action::draw_gsto_vn
virtual void draw_gsto_vn(gl::mode_t, size_t, bufpos, bufpos)=0
tools_vforcit_npp
#define tools_vforcit_npp(a__T, a__v, a__it)
Definition: forit:22
tools::sg::atb_vertices::nms
mf< float > nms
Definition: atb_vertices:16
tools::sg::render_action::draw_vertex_color_array
virtual void draw_vertex_color_array(gl::mode_t, size_t, const float *, const float *)=0
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
vertices
tools::sg::bmf::clear
void clear()
Definition: bmf:108
tools::sg::node::add_field
void add_field(field *a_field)
Definition: node:128
tools::sg::atb_vertices::add_pos_color
void add_pos_color(float a_x, float a_y, float a_z, float a_r, float a_g, float a_b, float a_a)
Definition: atb_vertices:376
tools::sg::atb_vertices::m_back_xyzs
std::vector< float > m_back_xyzs
Definition: atb_vertices:684
tools::sg::atb_vertices::gen_edges
void gen_edges()
Definition: atb_vertices:611
tools::sg::render_action::end_gsto
virtual void end_gsto()=0
TOOLS_FIELD_DESC_NODE_CLASS
#define TOOLS_FIELD_DESC_NODE_CLASS(a__class)
Definition: field:68
tools::sg::vertices::xyzs
mf< float > xyzs
Definition: vertices:27
tools::sg::atb_vertices::m_back_nms
std::vector< float > m_back_nms
Definition: atb_vertices:685
tools::sg::atb_vertices::add_pos_color
void add_pos_color(float a_x, float a_y, float a_z, const COLOR &a_col)
Definition: atb_vertices:387
tools::sg::atb_vertices::render
virtual void render(render_action &a_action)
Definition: atb_vertices:122
tools::sg::atb_vertices
Definition: atb_vertices:12
tools::colorf::r
float r() const
Definition: colorf:32
tools::sg::render_action::draw_vertex_normal_array
virtual void draw_vertex_normal_array(gl::mode_t, size_t, const float *, const float *)=0
tools::sg::atb_vertices::add_pos_color_normal
void add_pos_color_normal(const VEC &a_pos, const COLOR &a_col, const VEC &a_nm)
Definition: atb_vertices:431
tools::sg::bsf::value
T & value()
Definition: bsf:98
tools::sg::action::out
std::ostream & out() const
Definition: action:51
tools::sg::bufpos
size_t bufpos
Definition: render_action:22
tools::sg::state::m_line_width
float m_line_width
Definition: state:267
tools::sg::bmf::size
size_t size() const
Definition: bmf:69
tools::sg::atb_vertices::do_back
sf< bool > do_back
Definition: atb_vertices:17
tools::sg::state::m_color
colorf m_color
Definition: state:259
tools::sg::render_action::line_width
virtual void line_width(float)=0
tools::sg::state::m_GL_BLEND
bool m_GL_BLEND
Definition: state:254
tools::sg::atb_vertices::create_gsto
virtual unsigned int create_gsto(std::ostream &, sg::render_manager &a_mgr)
Definition: atb_vertices:46
tools::sg::states::state
const sg::state & state() const
Definition: states:76
tools::sg::atb_vertices::add_pos_color_normal_allocated
void add_pos_color_normal_allocated(const VEC &a_pos, const COLOR &a_col, const VEC &a_nm)
Definition: atb_vertices:454
tools::sg::atb_vertices::add_pos_color
void add_pos_color(const VEC &a_pos, const COLOR &a_col)
Definition: atb_vertices:398
tools::sg::node::touched
virtual bool touched()
Definition: node:96
tools::sg::atb_vertices::rgbas
mf< float > rgbas
Definition: atb_vertices:15
tools::sg::atb_vertices::node_desc_fields
virtual const desc_fields & node_desc_fields() const
Definition: atb_vertices:21
tools::sg::sf< bool >
TOOLS_ARG_FIELD_DESC
#define TOOLS_ARG_FIELD_DESC(a__field)
Definition: field:71
tools::sg::node::reset_touched
virtual void reset_touched()
Definition: node:102
tools::sg::atb_vertices::m_nms_pos
size_t m_nms_pos
Definition: atb_vertices:690
tools::colorf::b
float b() const
Definition: colorf:34
tools::sg::vertices
Definition: vertices:22