g4tools  5.4.0
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
tools::sg::atb_vertices Class Reference
Inheritance diagram for tools::sg::atb_vertices:
Inheritance graph
[legend]
Collaboration diagram for tools::sg::atb_vertices:
Collaboration graph
[legend]

Public Member Functions

virtual const desc_fieldsnode_desc_fields () const
 
virtual void protocol_one_fields (std::vector< field * > &a_fields) const
 
virtual void render (render_action &a_action)
 
 atb_vertices ()
 
virtual ~atb_vertices ()
 
 atb_vertices (const atb_vertices &a_from)
 
atb_verticesoperator= (const atb_vertices &a_from)
 
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)
 
template<class COLOR >
void add_pos_color (float a_x, float a_y, float a_z, const COLOR &a_col)
 
template<class VEC , class COLOR >
void add_pos_color (const VEC &a_pos, const COLOR &a_col)
 
void allocate_pos_color (size_t a_npt)
 
template<class VEC , class COLOR >
void add_pos_color_allocated (const VEC &a_pos, const COLOR &a_col)
 
template<class VEC , class COLOR >
void add_pos_color_normal (const VEC &a_pos, const COLOR &a_col, const VEC &a_nm)
 
void allocate_pos_color_normal (size_t a_npt)
 
template<class VEC , class COLOR >
void add_pos_color_normal_allocated (const VEC &a_pos, const COLOR &a_col, const VEC &a_nm)
 
void add_rgba (float a_r, float a_g, float a_b, float a_a)
 
void add_color (const colorf &a_col)
 
void add_normal (float a_x, float a_y, float a_z)
 
template<class VEC >
void add_normal (const VEC &a_nm)
 
void add_rgba_allocated (size_t &a_pos, float a_r, float a_g, float a_b, float a_a)
 
void add_normal_allocated (size_t &a_pos, float a_x, float a_y, float a_z)
 
template<class VEC >
void add_pos_normal (const VEC &a_pos, const VEC &a_nm)
 
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)
 
void clear ()
 
- Public Member Functions inherited from tools::sg::vertices
virtual void pick (pick_action &a_action)
 
virtual void bbox (bbox_action &a_action)
 
virtual void is_visible (visible_action &a_action)
 
 vertices ()
 
virtual ~vertices ()
 
 vertices (const vertices &a_from)
 
verticesoperator= (const vertices &a_from)
 
template<class VEC >
void add (const VEC &a_v)
 
void add (float a_x, float a_y, float a_z)
 
void add_allocated (size_t &a_pos, float a_x, float a_y, float a_z)
 
bool add (const std::vector< float > &a_v)
 
size_t number () const
 
void clear ()
 
bool add_dashed_line (float a_bx, float a_by, float a_bz, float a_ex, float a_ey, float a_ez, unsigned int a_num_dash)
 
bool center ()
 
- Public Member Functions inherited from tools::sg::node
virtual void * cast (const std::string &a_class) const
 
virtual const std::string & s_cls () const =0
 
virtual nodecopy () const =0
 
virtual unsigned int cls_version () const
 
virtual void search (search_action &a_action)
 
virtual void get_matrix (get_matrix_action &a_action)
 
virtual bool write (write_action &a_action)
 
virtual void event (event_action &)
 
virtual bool read (read_action &a_action)
 
virtual bool draw_in_frame_buffer () const
 
virtual bool touched ()
 
virtual void reset_touched ()
 
 node ()
 
virtual ~node ()
 
void touch ()
 
fieldfield_from_desc (const field_desc &a_desc) const
 
void dump_field_descs (std::ostream &a_out) const
 
fieldfind_field_by_name (const std::string &a_name) const
 
- Public Member Functions inherited from tools::sg::gstos
size_t num_gstos () const
 

Public Attributes

mf< float > rgbas
 
mf< float > nms
 
sf< bool > do_back
 
sf< float > epsilon
 
sf< bool > draw_edges
 
- Public Attributes inherited from tools::sg::vertices
sf< gl::mode_tmode
 
mf< float > xyzs
 

Protected Member Functions

virtual unsigned int create_gsto (std::ostream &, sg::render_manager &a_mgr)
 
void gen_back ()
 
void gen_edges ()
 
- Protected Member Functions inherited from tools::sg::vertices
bool _is_visible (const matrix_action &a_action)
 
- Protected Member Functions inherited from tools::sg::node
 node (const node &)
 
nodeoperator= (const node &)
 
void add_field (field *a_field)
 
bool write_fields (write_action &a_action)
 
bool read_fields (read_action &a_action)
 
field_desc::offset_t field_offset (const field *a_field) const
 
fieldfind_field (const field_desc &a_rdesc) const
 
void check_fields (std::ostream &a_out) const
 
- Protected Member Functions inherited from tools::sg::gstos
 gstos ()
 
virtual ~gstos ()
 
 gstos (const gstos &)
 
gstosoperator= (const gstos &a_from)
 
unsigned int get_tex_id (std::ostream &a_out, render_manager &a_mgr, const img_byte &a_img, bool a_NEAREST)
 
unsigned int get_gsto_id (std::ostream &a_out, render_manager &a_mgr)
 
void clean_gstos ()
 
void clean_gstos (render_manager *a_mgr)
 
unsigned int _find (render_manager *a_mgr)
 

Protected Attributes

std::vector< float > m_back_xyzs
 
std::vector< float > m_back_nms
 
std::vector< float > m_edges
 
size_t m_xyzs_pos
 
size_t m_rgbas_pos
 
size_t m_nms_pos
 
- Protected Attributes inherited from tools::sg::gstos
std::vector< std::pair< unsigned int, render_manager * > > m_gstos
 

Detailed Description

Definition at line 12 of file atb_vertices.

Constructor & Destructor Documentation

◆ atb_vertices() [1/2]

tools::sg::atb_vertices::atb_vertices ( )
inline

Definition at line 321 of file atb_vertices.

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  }

◆ ~atb_vertices()

virtual tools::sg::atb_vertices::~atb_vertices ( )
inlinevirtual

Definition at line 338 of file atb_vertices.

338  {
339 #ifdef TOOLS_MEM
340  mem::decrement(s_class().c_str());
341 #endif
342  }

◆ atb_vertices() [2/2]

tools::sg::atb_vertices::atb_vertices ( const atb_vertices a_from)
inline

Definition at line 344 of file atb_vertices.

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  }

Member Function Documentation

◆ add_color()

void tools::sg::atb_vertices::add_color ( const colorf a_col)
inline

Definition at line 479 of file atb_vertices.

479  {
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  }

◆ add_dashed_line_rgba()

bool tools::sg::atb_vertices::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 
)
inline

Definition at line 524 of file atb_vertices.

527  {
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  }

◆ add_normal() [1/2]

template<class VEC >
void tools::sg::atb_vertices::add_normal ( const VEC &  a_nm)
inline

Definition at line 492 of file atb_vertices.

492  {
493  nms.add(a_nm.x());
494  nms.add(a_nm.y());
495  nms.add(a_nm.z());
496  }

◆ add_normal() [2/2]

void tools::sg::atb_vertices::add_normal ( float  a_x,
float  a_y,
float  a_z 
)
inline

Definition at line 486 of file atb_vertices.

486  {
487  nms.add(a_x);
488  nms.add(a_y);
489  nms.add(a_z);
490  }

◆ add_normal_allocated()

void tools::sg::atb_vertices::add_normal_allocated ( size_t &  a_pos,
float  a_x,
float  a_y,
float  a_z 
)
inline

Definition at line 506 of file atb_vertices.

506  {
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  }

◆ add_pos_color() [1/3]

template<class VEC , class COLOR >
void tools::sg::atb_vertices::add_pos_color ( const VEC &  a_pos,
const COLOR &  a_col 
)
inline

Definition at line 398 of file atb_vertices.

398  {
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  }

◆ add_pos_color() [2/3]

template<class COLOR >
void tools::sg::atb_vertices::add_pos_color ( float  a_x,
float  a_y,
float  a_z,
const COLOR &  a_col 
)
inline

Definition at line 387 of file atb_vertices.

387  {
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  }

◆ add_pos_color() [3/3]

void tools::sg::atb_vertices::add_pos_color ( float  a_x,
float  a_y,
float  a_z,
float  a_r,
float  a_g,
float  a_b,
float  a_a 
)
inline

Definition at line 376 of file atb_vertices.

376  {
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  }

◆ add_pos_color_allocated()

template<class VEC , class COLOR >
void tools::sg::atb_vertices::add_pos_color_allocated ( const VEC &  a_pos,
const COLOR &  a_col 
)
inline

Definition at line 416 of file atb_vertices.

416  {
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  }

◆ add_pos_color_normal()

template<class VEC , class COLOR >
void tools::sg::atb_vertices::add_pos_color_normal ( const VEC &  a_pos,
const COLOR &  a_col,
const VEC &  a_nm 
)
inline

Definition at line 431 of file atb_vertices.

431  {
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  }

◆ add_pos_color_normal_allocated()

template<class VEC , class COLOR >
void tools::sg::atb_vertices::add_pos_color_normal_allocated ( const VEC &  a_pos,
const COLOR &  a_col,
const VEC &  a_nm 
)
inline

Definition at line 454 of file atb_vertices.

454  {
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  }

◆ add_pos_normal()

template<class VEC >
void tools::sg::atb_vertices::add_pos_normal ( const VEC &  a_pos,
const VEC &  a_nm 
)
inline

Definition at line 515 of file atb_vertices.

515  {
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  }

◆ add_rgba()

void tools::sg::atb_vertices::add_rgba ( float  a_r,
float  a_g,
float  a_b,
float  a_a 
)
inline

Definition at line 473 of file atb_vertices.

473  {
474  rgbas.add(a_r);
475  rgbas.add(a_g);
476  rgbas.add(a_b);
477  rgbas.add(a_a);
478  }

◆ add_rgba_allocated()

void tools::sg::atb_vertices::add_rgba_allocated ( size_t &  a_pos,
float  a_r,
float  a_g,
float  a_b,
float  a_a 
)
inline

Definition at line 498 of file atb_vertices.

498  {
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  }

◆ allocate_pos_color()

void tools::sg::atb_vertices::allocate_pos_color ( size_t  a_npt)
inline

Definition at line 408 of file atb_vertices.

408  {
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  }

◆ allocate_pos_color_normal()

void tools::sg::atb_vertices::allocate_pos_color_normal ( size_t  a_npt)
inline

Definition at line 444 of file atb_vertices.

444  {
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  }

◆ clear()

void tools::sg::atb_vertices::clear ( )
inline

Definition at line 536 of file atb_vertices.

536  {
537  rgbas.clear();
538  nms.clear();
539  parent::clear();
540  }

◆ create_gsto()

virtual unsigned int tools::sg::atb_vertices::create_gsto ( std::ostream &  ,
sg::render_manager a_mgr 
)
inlineprotectedvirtual

Reimplemented from tools::sg::vertices.

Definition at line 46 of file atb_vertices.

46  {
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  }

◆ gen_back()

void tools::sg::atb_vertices::gen_back ( )
inlineprotected

Definition at line 542 of file atb_vertices.

542  {
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  }

◆ gen_edges()

void tools::sg::atb_vertices::gen_edges ( )
inlineprotected

Definition at line 611 of file atb_vertices.

611  {
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  }

◆ node_desc_fields()

virtual const desc_fields& tools::sg::atb_vertices::node_desc_fields ( ) const
inlinevirtual

Reimplemented from tools::sg::vertices.

Definition at line 21 of file atb_vertices.

21  {
23  static const desc_fields s_v(parent::node_desc_fields(),5, //WARNING : take care of count.
29  );
30  return s_v;
31  }

◆ operator=()

atb_vertices& tools::sg::atb_vertices::operator= ( const atb_vertices a_from)
inline

Definition at line 363 of file atb_vertices.

363  {
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  }

◆ protocol_one_fields()

virtual void tools::sg::atb_vertices::protocol_one_fields ( std::vector< field * > &  a_fields) const
inlinevirtual

Reimplemented from tools::sg::node.

Definition at line 32 of file atb_vertices.

32  {
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  }

◆ render()

virtual void tools::sg::atb_vertices::render ( render_action a_action)
inlinevirtual

_id

Reimplemented from tools::sg::vertices.

Definition at line 122 of file atb_vertices.

122  {
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);
191  if(draw_edges.value()) a_action.set_polygon_offset(state.m_GL_POLYGON_OFFSET_FILL);
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())
262  a_action.draw_vertex_color_normal_array(mode.value(),m_back_xyzs,rgbas.values(),m_back_nms);
263  a_action.draw_vertex_color_normal_array(mode.value(),xyzs.values(),rgbas.values(),nms.values());
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  }
274  if(do_back.value()) a_action.draw_vertex_color_normal_array(mode.value(),m_back_xyzs,rgbas.values(),m_back_nms);
275  a_action.draw_vertex_color_normal_array(mode.value(),xyzs.values(),rgbas.values(),nms.values());
276  if(draw_edges.value()) a_action.set_polygon_offset(state.m_GL_POLYGON_OFFSET_FILL);
277  } else {
278  if(do_back.value()) a_action.draw_vertex_color_normal_array(mode.value(),m_back_xyzs,rgbas.values(),m_back_nms);
279  a_action.draw_vertex_color_normal_array(mode.value(),xyzs.values(),rgbas.values(),nms.values());
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);
286  a_action.draw_vertex_color_array(mode.value(),xyzs.values(),rgbas.values());
287  a_action.set_lighting(state.m_GL_LIGHTING);
288  } else {
289  a_action.draw_vertex_color_array(mode.value(),xyzs.values(),rgbas.values());
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);
301  a_action.draw_vertex_normal_array(mode.value(),xyzs.values(),nms.values());
302  a_action.set_lighting(state.m_GL_LIGHTING);
303  } else {
304  a_action.draw_vertex_normal_array(mode.value(),xyzs.values(),nms.values());
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  }

Member Data Documentation

◆ do_back

sf<bool> tools::sg::atb_vertices::do_back

Definition at line 17 of file atb_vertices.

◆ draw_edges

sf<bool> tools::sg::atb_vertices::draw_edges

Definition at line 19 of file atb_vertices.

◆ epsilon

sf<float> tools::sg::atb_vertices::epsilon

Definition at line 18 of file atb_vertices.

◆ m_back_nms

std::vector<float> tools::sg::atb_vertices::m_back_nms
protected

Definition at line 685 of file atb_vertices.

◆ m_back_xyzs

std::vector<float> tools::sg::atb_vertices::m_back_xyzs
protected

Definition at line 684 of file atb_vertices.

◆ m_edges

std::vector<float> tools::sg::atb_vertices::m_edges
protected

Definition at line 686 of file atb_vertices.

◆ m_nms_pos

size_t tools::sg::atb_vertices::m_nms_pos
protected

Definition at line 690 of file atb_vertices.

◆ m_rgbas_pos

size_t tools::sg::atb_vertices::m_rgbas_pos
protected

Definition at line 689 of file atb_vertices.

◆ m_xyzs_pos

size_t tools::sg::atb_vertices::m_xyzs_pos
protected

Definition at line 688 of file atb_vertices.

◆ nms

mf<float> tools::sg::atb_vertices::nms

Definition at line 16 of file atb_vertices.

◆ rgbas

mf<float> tools::sg::atb_vertices::rgbas

Definition at line 15 of file atb_vertices.


The documentation for this class was generated from the following file:
tools::sg::field::touch
void touch()
Definition: field:59
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::bmf::empty
bool empty() const
Definition: bmf:70
tools::gl::is_line
bool is_line(mode_t a_mode)
Definition: glprims:31
tools::sg::vertices::mode
sf< gl::mode_t > mode
Definition: vertices:26
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::m_rgbas_pos
size_t m_rgbas_pos
Definition: atb_vertices:689
tools::gl::triangle_fan
mode_t triangle_fan()
Definition: glprims:22
tools::sg::gstos::clean_gstos
void clean_gstos()
Definition: gstos:89
tools::gl::lines
mode_t lines()
Definition: glprims:17
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::atb_vertices::epsilon
sf< float > epsilon
Definition: atb_vertices:18
tools::append
void append(std::vector< T > &a_vec, const std::vector< T > &a_from)
Definition: vmanip:66
tools::sg::gstos::get_gsto_id
unsigned int get_gsto_id(std::ostream &a_out, render_manager &a_mgr)
Definition: gstos:60
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::bmf::clear
void clear()
Definition: bmf:108
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_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
Definition: atb_vertices:12
tools::sg::bsf::value
T & value()
Definition: bsf:98
tools::sg::bufpos
size_t bufpos
Definition: render_action:22
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::node::touched
virtual bool touched()
Definition: node:96
tools::sg::atb_vertices::rgbas
mf< float > rgbas
Definition: atb_vertices:15
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