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

Public Member Functions

 add_prm (std::ostream &a_out, std::vector< float > &a_norms)
 
virtual ~add_prm ()
 
 add_prm (const add_prm &a_from)
 
add_prmoperator= (const add_prm &a_from)
 
- Public Member Functions inherited from tools::sg::primitive_visitor
 primitive_visitor ()
 
virtual ~primitive_visitor ()
 
 primitive_visitor (const primitive_visitor &)
 
primitive_visitoroperator= (const primitive_visitor &)
 
void add_one_point (float a_x, float a_y, float a_z)
 
void add_one_point (float a_x, float a_y, float a_z, float a_r, float a_g, float a_b, float a_a)
 
bool add_triangle_fan (size_t a_floatn, const float *a_xyzs, bool a_stop=false)
 
bool add_triangle_fan_normal (size_t a_floatn, const float *a_xyzs, const float *a_nms, bool a_stop=false)
 
bool add_triangle_fan_normal_rgba (size_t a_floatn, const float *a_xyzs, const float *a_nms, const float *a_rgbas, bool a_stop=false)
 
bool add_triangle_strip (size_t a_floatn, const float *a_xyzs, bool a_stop=false)
 
bool add_triangles (size_t a_floatn, const float *a_xyzs, bool a_stop=false)
 
bool add_triangle_strip_normal (size_t a_floatn, const float *a_xyzs, const float *a_nms, bool a_stop=false)
 
bool add_triangle_strip_normal_rgba (size_t a_floatn, const float *a_xyzs, const float *a_nms, const float *a_rgbas, bool a_stop=false)
 
bool add_triangles_normal (size_t a_floatn, const float *a_xyzs, const float *a_nms, bool a_stop=false)
 
bool add_triangles_rgba (size_t a_floatn, const float *a_xyzs, const float *a_rgbas, bool a_stop=false)
 
bool add_triangles_normal_rgba (size_t a_floatn, const float *a_xyzs, const float *a_nms, const float *a_rgbas, bool a_stop=false)
 
bool add_line_strip (size_t a_floatn, const float *a_xyzs, bool a_stop=false)
 
bool add_line_strip_rgba (size_t a_floatn, const float *a_xyzs, const float *a_rgbas, bool a_stop=false)
 
bool add_line_strip_normal (size_t a_floatn, const float *a_xyzs, const float *a_nms, bool a_stop=false)
 
bool add_line_strip_normal_rgba (size_t a_floatn, const float *a_xyzs, const float *a_nms, const float *a_rgbas, bool a_stop=false)
 
bool add_line_loop (size_t a_floatn, const float *a_xyzs, bool a_stop=false)
 
bool add_line_loop_rgba (size_t a_floatn, const float *a_xyzs, const float *a_rgbas, bool a_stop=false)
 
bool add_line_loop_normal (size_t a_floatn, const float *a_xyzs, const float *a_nms, bool a_stop=false)
 
bool add_line_loop_normal_rgba (size_t a_floatn, const float *a_xyzs, const float *a_nms, const float *a_rgbas, bool a_stop=false)
 
bool add_lines (size_t a_floatn, const float *a_xyzs, bool a_stop=false)
 
bool add_lines_rgba (size_t a_floatn, const float *a_xyzs, const float *a_rgbas, bool a_stop=false)
 
bool add_lines_normal (size_t a_floatn, const float *a_xyzs, const float *a_nms, bool a_stop=false)
 
bool add_lines_normal_rgba (size_t a_floatn, const float *a_xyzs, const float *a_nms, const float *a_rgbas, bool a_stop=false)
 
bool add_points (size_t a_floatn, const float *a_xyzs, bool a_stop=false)
 
bool add_points_rgba (size_t a_floatn, const float *a_xyzs, const float *a_rgbas, bool a_stop=false)
 
bool add_points_normal (size_t a_floatn, const float *a_xyzs, const float *a_nms, bool a_stop=false)
 
bool add_points_normal_rgba (size_t a_floatn, const float *a_xyzs, const float *a_nms, const float *a_rgbas, bool a_stop=false)
 
bool add_primitive (gl::mode_t a_mode, size_t a_floatn, const float *a_xyzs, bool a_stop=false)
 
bool add_primitive_rgba (gl::mode_t a_mode, size_t a_floatn, const float *a_xyzs, const float *a_rgbas, bool a_stop=false)
 
bool add_primitive_normal (gl::mode_t a_mode, size_t a_floatn, const float *a_xyzs, const float *a_nms, bool a_stop=false)
 
bool add_primitive_normal_rgba (gl::mode_t a_mode, size_t a_floatn, const float *a_xyzs, const float *a_nms, const float *a_rgbas, bool a_stop=false)
 
bool add_points_xy (size_t a_floatn, const float *a_xys, bool a_stop=false)
 points with x,y only /////////////////////////////// More...
 
bool add_triangle_fan_xy (size_t a_floatn, const float *a_xys, bool a_stop=false, bool a_triangle_revert=false)
 
bool add_triangle_strip_xy (size_t a_floatn, const float *a_xys, bool a_stop=false, bool a_triangle_revert=false)
 
bool add_triangles_xy (size_t a_floatn, const float *a_xys, bool a_stop=false, bool a_triangle_revert=false)
 
bool add_line_loop_xy (size_t a_floatn, const float *a_xys, bool a_stop=false)
 
bool add_line_strip_xy (size_t a_floatn, const float *a_xys, bool a_stop=false)
 
bool add_lines_xy (size_t a_floatn, const float *a_xys, bool a_stop=false)
 
bool add_primitive_xy (gl::mode_t a_mode, size_t a_floatn, const float *a_xys, bool a_stop=false, bool a_triangle_revert=false)
 
bool add_primitive (gl::mode_t a_mode, const std::vector< float > &a_xyzs, bool a_stop=false)
 
bool add_primitive_xy (gl::mode_t a_mode, const std::vector< float > &a_xys, bool a_stop=false, bool a_triangle_revert=false)
 
bool add_line_strip (const std::vector< float > &a_xyzs, bool a_stop=false)
 
bool add_line_loop (const std::vector< float > &a_xyzs, bool a_stop=false)
 
bool add_lines (const std::vector< float > &a_xyzs, bool a_stop=false)
 
bool add_points (const std::vector< float > &a_xyzs, bool a_stop=false)
 
bool add_triangle_strip (const std::vector< float > &a_xyzs, bool a_stop=false)
 
bool add_points_xy (const std::vector< float > &a_xys, bool a_stop=false)
 
bool add_lines_xy (const std::vector< float > &a_xys, bool a_stop=false)
 
bool add_triangle_strip_xy (const std::vector< float > &a_xys, bool a_stop=false)
 
bool add_triangle_fan_texture_normal (size_t a_floatn, const float *a_xyzs, const float *a_nms, unsigned int, const float *)
 
bool add_triangle_strip_texture_normal (size_t a_floatn, const float *a_xyzs, const float *a_nms, unsigned int, const float *)
 
bool add_triangle_strip_as_triangles (size_t a_floatn, const float *a_xyzs, const float *a_nms)
 
void add_texture (std::ostream &a_out, size_t a_xyzn, const float *a_xyzs, const img_byte &a_img, const float *a_tcs)
 

Public Attributes

std::vector< float > & m_norms
 

Protected Member Functions

virtual bool project (float &, float &, float &, float &)
 
virtual bool add_point (float, float, float, float)
 
virtual bool add_point (float, float, float, float, float, float, float, float)
 
virtual bool add_line (float, float, float, float, float, float, float, float)
 
virtual bool add_line (float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float)
 
virtual bool add_triangle (float a_p1x, float a_p1y, float a_p1z, float, float a_p2x, float a_p2y, float a_p2z, float, float a_p3x, float a_p3y, float a_p3z, float)
 
virtual bool add_triangle (float a_p1x, float a_p1y, float a_p1z, float a_p1w, float, float, float, float, float a_p2x, float a_p2y, float a_p2z, float a_p2w, float, float, float, float, float a_p3x, float a_p3y, float a_p3z, float a_p3w, float, float, float, float)
 
virtual bool project_normal (float &a_x, float &a_y, float &a_z)
 
virtual bool add_point_normal (float a_x, float a_y, float a_z, float a_w, float a_nx, float a_ny, float a_nz)
 
virtual bool add_point_normal (float a_x, float a_y, float a_z, float a_w, float a_nx, float a_ny, float a_nz, float a_r, float a_g, float a_b, float a_a)
 
virtual bool add_line_normal (float a_bx, float a_by, float a_bz, float a_bw, float a_bnx, float a_bny, float a_bnz, float a_ex, float a_ey, float a_ez, float a_ew, float a_enx, float a_eny, float a_enz)
 
virtual bool add_line_normal (float a_bx, float a_by, float a_bz, float a_bw, float a_bnx, float a_bny, float a_bnz, float a_br, float a_bg, float a_bb, float a_ba, float a_ex, float a_ey, float a_ez, float a_ew, float a_enx, float a_eny, float a_enz, float a_er, float a_eg, float a_eb, float a_ea)
 
virtual bool add_triangle_normal (float a_p1x, float a_p1y, float a_p1z, float a_p1w, float a_n1x, float a_n1y, float a_n1z, float a_p2x, float a_p2y, float a_p2z, float a_p2w, float a_n2x, float a_n2y, float a_n2z, float a_p3x, float a_p3y, float a_p3z, float a_p3w, float a_n3x, float a_n3y, float a_n3z)
 
virtual bool add_triangle_normal (float a_p1x, float a_p1y, float a_p1z, float a_p1w, float a_n1x, float a_n1y, float a_n1z, float a_r1, float a_g1, float a_b1, float a_a1, float a_p2x, float a_p2y, float a_p2z, float a_p2w, float a_n2x, float a_n2y, float a_n2z, float a_r2, float a_g2, float a_b2, float a_a2, float a_p3x, float a_p3y, float a_p3z, float a_p3w, float a_n3x, float a_n3y, float a_n3z, float a_r3, float a_g3, float a_b3, float a_a3)
 

Protected Attributes

std::ostream & m_out
 
- Protected Attributes inherited from tools::sg::primitive_visitor
gl::mode_t m_mode
 

Detailed Description

Definition at line 292 of file tessellate.

Constructor & Destructor Documentation

◆ add_prm() [1/2]

tools::sg::tessellate::add_prm::add_prm ( std::ostream &  a_out,
std::vector< float > &  a_norms 
)
inline

Definition at line 470 of file tessellate.

471  :m_out(a_out)
472  ,m_norms(a_norms)
473  {}

◆ ~add_prm()

virtual tools::sg::tessellate::add_prm::~add_prm ( )
inlinevirtual

Definition at line 474 of file tessellate.

474 {}

◆ add_prm() [2/2]

tools::sg::tessellate::add_prm::add_prm ( const add_prm a_from)
inline

Definition at line 476 of file tessellate.

476 :primitive_visitor(a_from),m_out(a_from.m_out),m_norms(a_from.m_norms) {}

Member Function Documentation

◆ add_line() [1/2]

virtual bool tools::sg::tessellate::add_prm::add_line ( float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float   
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 298 of file tessellate.

299  {return false;}

◆ add_line() [2/2]

virtual bool tools::sg::tessellate::add_prm::add_line ( float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float   
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 300 of file tessellate.

301  {
302  return false;
303  }

◆ add_line_normal() [1/2]

virtual bool tools::sg::tessellate::add_prm::add_line_normal ( float  a_bx,
float  a_by,
float  a_bz,
float  a_bw,
float  a_bnx,
float  a_bny,
float  a_bnz,
float  a_br,
float  a_bg,
float  a_bb,
float  a_ba,
float  a_ex,
float  a_ey,
float  a_ez,
float  a_ew,
float  a_enx,
float  a_eny,
float  a_enz,
float  a_er,
float  a_eg,
float  a_eb,
float  a_ea 
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 413 of file tessellate.

418  {
419  (void)a_bx;(void)a_by;(void)a_bz;(void)a_bw;
420  (void)a_bnx;(void)a_bny;(void)a_bnz;
421  (void)a_br;(void)a_bg;(void)a_bb;(void)a_ba;
422  (void)a_ex;(void)a_ey;(void)a_ez;(void)a_ew;
423  (void)a_enx;(void)a_eny;(void)a_enz;
424  (void)a_er;(void)a_eg;(void)a_eb;(void)a_ea;
425  return false;
426  }

◆ add_line_normal() [2/2]

virtual bool tools::sg::tessellate::add_prm::add_line_normal ( float  a_bx,
float  a_by,
float  a_bz,
float  a_bw,
float  a_bnx,
float  a_bny,
float  a_bnz,
float  a_ex,
float  a_ey,
float  a_ez,
float  a_ew,
float  a_enx,
float  a_eny,
float  a_enz 
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 403 of file tessellate.

406  {
407  (void)a_bx;(void)a_by;(void)a_bz;(void)a_bw;
408  (void)a_bnx;(void)a_bny;(void)a_bnz;
409  (void)a_ex;(void)a_ey;(void)a_ez;(void)a_ew;
410  (void)a_enx;(void)a_eny;(void)a_enz;
411  return false;
412  }

◆ add_point() [1/2]

virtual bool tools::sg::tessellate::add_prm::add_point ( float  ,
float  ,
float  ,
float   
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 295 of file tessellate.

295 {return false;}

◆ add_point() [2/2]

virtual bool tools::sg::tessellate::add_prm::add_point ( float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float  ,
float   
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 296 of file tessellate.

297  {return false;}

◆ add_point_normal() [1/2]

virtual bool tools::sg::tessellate::add_prm::add_point_normal ( float  a_x,
float  a_y,
float  a_z,
float  a_w,
float  a_nx,
float  a_ny,
float  a_nz 
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 389 of file tessellate.

390  {
391  (void)a_x;(void)a_y;(void)a_z;(void)a_w;
392  (void)a_nx;(void)a_ny;(void)a_nz;
393  return false;
394  }

◆ add_point_normal() [2/2]

virtual bool tools::sg::tessellate::add_prm::add_point_normal ( float  a_x,
float  a_y,
float  a_z,
float  a_w,
float  a_nx,
float  a_ny,
float  a_nz,
float  a_r,
float  a_g,
float  a_b,
float  a_a 
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 395 of file tessellate.

397  {
398  (void)a_x;(void)a_y;(void)a_z;(void)a_w;
399  (void)a_nx;(void)a_ny;(void)a_nz;
400  (void)a_r;(void)a_g;(void)a_b;(void)a_a;
401  return false;
402  }

◆ add_triangle() [1/2]

virtual bool tools::sg::tessellate::add_prm::add_triangle ( float  a_p1x,
float  a_p1y,
float  a_p1z,
float  a_p1w,
float  ,
float  ,
float  ,
float  ,
float  a_p2x,
float  a_p2y,
float  a_p2z,
float  a_p2w,
float  ,
float  ,
float  ,
float  ,
float  a_p3x,
float  a_p3y,
float  a_p3z,
float  a_p3w,
float  ,
float  ,
float  ,
float   
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 374 of file tessellate.

379  {
380  return add_prm::add_triangle(a_p1x,a_p1y,a_p1z,a_p1w,
381  a_p2x,a_p2y,a_p2z,a_p2w,
382  a_p3x,a_p3y,a_p3z,a_p3w);
383  }

◆ add_triangle() [2/2]

virtual bool tools::sg::tessellate::add_prm::add_triangle ( float  a_p1x,
float  a_p1y,
float  a_p1z,
float  ,
float  a_p2x,
float  a_p2y,
float  a_p2z,
float  ,
float  a_p3x,
float  a_p3y,
float  a_p3z,
float   
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 305 of file tessellate.

307  {
308 
309  float vx = a_p2x-a_p1x;
310  float vy = a_p2y-a_p1y;
311  float vz = a_p2z-a_p1z;
312 
313  float wx = a_p3x-a_p2x;
314  float wy = a_p3y-a_p2y;
315  float wz = a_p3z-a_p2z;
316 
317  // vx wx
318  // vy ^ wy
319  // vz wz
320  float cx = vy*wz-vz*wy;
321  float cy = vz*wx-vx*wz;
322  float cz = vx*wy-vy*wx;
323 
324  float len = (float)::sqrt(cx*cx + cy*cy + cz*cz);
325  if(!len) {
326  //m_out << "tools::sg::tessellate::add_prm : null normal."
327  // << std::endl;
328  } else {
329  cx /= len;
330  cy /= len;
331  cz /= len;
332  }
333 
334  if(m_mode==gl::triangles()) {
335 
336  m_norms.push_back(cx);
337  m_norms.push_back(cy);
338  m_norms.push_back(cz);
339 
340  m_norms.push_back(cx);
341  m_norms.push_back(cy);
342  m_norms.push_back(cz);
343 
344  m_norms.push_back(cx);
345  m_norms.push_back(cy);
346  m_norms.push_back(cz);
347 
348  } else if( (m_mode==gl::triangle_strip()) ||
349  (m_mode==gl::triangle_fan()) ){
350 
351  if(m_norms.empty()) { //startup : three vertices.
352  m_norms.push_back(cx);
353  m_norms.push_back(cy);
354  m_norms.push_back(cz);
355 
356  m_norms.push_back(cx);
357  m_norms.push_back(cy);
358  m_norms.push_back(cz);
359 
360  m_norms.push_back(cx);
361  m_norms.push_back(cy);
362  m_norms.push_back(cz);
363 
364  } else { //one vertex :
365  m_norms.push_back(cx);
366  m_norms.push_back(cy);
367  m_norms.push_back(cz);
368  }
369  }
370 
371  return true;
372  }

◆ add_triangle_normal() [1/2]

virtual bool tools::sg::tessellate::add_prm::add_triangle_normal ( float  a_p1x,
float  a_p1y,
float  a_p1z,
float  a_p1w,
float  a_n1x,
float  a_n1y,
float  a_n1z,
float  a_p2x,
float  a_p2y,
float  a_p2z,
float  a_p2w,
float  a_n2x,
float  a_n2y,
float  a_n2z,
float  a_p3x,
float  a_p3y,
float  a_p3z,
float  a_p3w,
float  a_n3x,
float  a_n3y,
float  a_n3z 
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 427 of file tessellate.

433  {
434  add_triangle(a_p1x,a_p1y,a_p1z,a_p1w,
435  a_p2x,a_p2y,a_p2z,a_p2w,
436  a_p3x,a_p3y,a_p3z,a_p3w);
437  //m_this.m_triangles.add_normal(a_n1x,a_n1y,a_n1z);
438  //m_this.m_triangles.add_normal(a_n2x,a_n2y,a_n2z);
439  //m_this.m_triangles.add_normal(a_n3x,a_n3y,a_n3z);
440  (void)a_n1x;(void)a_n1y;(void)a_n1z;
441  (void)a_n2x;(void)a_n2y;(void)a_n2z;
442  (void)a_n3x;(void)a_n3y;(void)a_n3z;
443  return true;
444  }

◆ add_triangle_normal() [2/2]

virtual bool tools::sg::tessellate::add_prm::add_triangle_normal ( float  a_p1x,
float  a_p1y,
float  a_p1z,
float  a_p1w,
float  a_n1x,
float  a_n1y,
float  a_n1z,
float  a_r1,
float  a_g1,
float  a_b1,
float  a_a1,
float  a_p2x,
float  a_p2y,
float  a_p2z,
float  a_p2w,
float  a_n2x,
float  a_n2y,
float  a_n2z,
float  a_r2,
float  a_g2,
float  a_b2,
float  a_a2,
float  a_p3x,
float  a_p3y,
float  a_p3z,
float  a_p3w,
float  a_n3x,
float  a_n3y,
float  a_n3z,
float  a_r3,
float  a_g3,
float  a_b3,
float  a_a3 
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 445 of file tessellate.

454  {
455  add_triangle(a_p1x,a_p1y,a_p1z,a_p1w,
456  a_r1,a_g1,a_b1,a_a1,
457  a_p2x,a_p2y,a_p2z,a_p2w,
458  a_r2,a_g2,a_b2,a_a2,
459  a_p3x,a_p3y,a_p3z,a_p3w,
460  a_r3,a_g3,a_b3,a_a3);
461  //m_this.m_triangles.add_normal(a_n1x,a_n1y,a_n1z);
462  //m_this.m_triangles.add_normal(a_n2x,a_n2y,a_n2z);
463  //m_this.m_triangles.add_normal(a_n3x,a_n3y,a_n3z);
464  (void)a_n1x;(void)a_n1y;(void)a_n1z;
465  (void)a_n2x;(void)a_n2y;(void)a_n2z;
466  (void)a_n3x;(void)a_n3y;(void)a_n3z;
467  return true;
468  }

◆ operator=()

add_prm& tools::sg::tessellate::add_prm::operator= ( const add_prm a_from)
inline

Definition at line 477 of file tessellate.

477  {
479  return *this;
480  }

◆ project()

virtual bool tools::sg::tessellate::add_prm::project ( float &  ,
float &  ,
float &  ,
float &   
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 294 of file tessellate.

294 {return true;}

◆ project_normal()

virtual bool tools::sg::tessellate::add_prm::project_normal ( float &  a_x,
float &  a_y,
float &  a_z 
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 385 of file tessellate.

385  {
386  (void)a_x;(void)a_y;(void)a_z;
387  return true;
388  }

Member Data Documentation

◆ m_norms

std::vector<float>& tools::sg::tessellate::add_prm::m_norms

Definition at line 484 of file tessellate.

◆ m_out

std::ostream& tools::sg::tessellate::add_prm::m_out
protected

Definition at line 482 of file tessellate.


The documentation for this class was generated from the following file:
tools::sg::tessellate::add_prm::m_norms
std::vector< float > & m_norms
Definition: tessellate:484
tools::gl::triangles
mode_t triangles()
Definition: glprims:20
tools::gl::triangle_fan
mode_t triangle_fan()
Definition: glprims:22
tools::gl::triangle_strip
mode_t triangle_strip()
Definition: glprims:21
tools::sg::primitive_visitor::operator=
primitive_visitor & operator=(const primitive_visitor &)
Definition: primitive_visitor:61
tools::sg::primitive_visitor::m_mode
gl::mode_t m_mode
Definition: primitive_visitor:2134
tools::sg::tessellate::add_prm::add_triangle
virtual bool add_triangle(float a_p1x, float a_p1y, float a_p1z, float, float a_p2x, float a_p2y, float a_p2z, float, float a_p3x, float a_p3y, float a_p3z, float)
Definition: tessellate:305
tools::sg::tessellate::add_prm::m_out
std::ostream & m_out
Definition: tessellate:482
tools::sg::primitive_visitor::primitive_visitor
primitive_visitor()
Definition: primitive_visitor:57