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

Public Member Functions

 primvis (zb_action &a_zb)
 
virtual ~primvis ()
 
 primvis (const primvis &a_from)
 
primvisoperator= (const primvis &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)
 

Protected Member Functions

virtual bool project (float &a_x, float &a_y, float &a_z, float &a_w)
 
virtual bool add_point (float a_x, float a_y, float a_z, float)
 
virtual bool add_point (float a_x, float a_y, float a_z, float, float a_r, float a_g, float a_b, float a_a)
 
virtual bool add_line (float a_bx, float a_by, float a_bz, float, float a_ex, float a_ey, float a_ez, float)
 
virtual bool add_line (float a_bx, float a_by, float a_bz, float, float a_br, float a_bg, float a_bb, float a_ba, float a_ex, float a_ey, float a_ez, float, float, float, float, float)
 
virtual bool add_triangle (float a_p1x, float a_p1y, float a_p1z, float a_p1w, float a_p2x, float a_p2y, float a_p2z, float a_p2w, float a_p3x, float a_p3y, float a_p3z, float a_p3w)
 
virtual bool add_triangle (float a_p1x, float a_p1y, float a_p1z, float a_p1w, 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_r2, float a_g2, float a_b2, float a_a2, float a_p3x, float a_p3y, float a_p3z, float a_p3w, float a_r3, float a_g3, float a_b3, float a_a3)
 
virtual bool project_normal (float &, float &, float &)
 
virtual bool add_point_normal (float a_x, float a_y, float a_z, float a_w, float, float, float)
 
virtual bool add_point_normal (float a_x, float a_y, float a_z, float a_w, float, float, float, 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, float, float, float a_ex, float a_ey, float a_ez, float a_ew, float, float, float)
 
virtual bool add_line_normal (float a_bx, float a_by, float a_bz, float a_bw, float, float, float, 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, float, float, 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, float, float, float a_p2x, float a_p2y, float a_p2z, float a_p2w, float, float, float, float a_p3x, float a_p3y, float a_p3z, float a_p3w, float, float, float)
 
virtual bool add_triangle_normal (float a_p1x, float a_p1y, float a_p1z, float a_p1w, float, float, float, 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, float, float, 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, float, float, float a_r3, float a_g3, float a_b3, float a_a3)
 
unsigned int npix (float a_size)
 
bool _add_point (float a_x, float a_y, float a_z, const colorf &a_color)
 
bool _add_triangle (float a_p1x, float a_p1y, float a_p1z, float a_p1w, float a_p2x, float a_p2y, float a_p2z, float a_p2w, float a_p3x, float a_p3y, float a_p3z, float a_p3w, const colorf &a_color)
 

Static Protected Member Functions

static void zinit (zb::point &a_p, float a_x, float a_y, float a_z)
 

Protected Attributes

zb_actionm_zb_action
 
- Protected Attributes inherited from tools::sg::primitive_visitor
gl::mode_t m_mode
 

Detailed Description

Definition at line 396 of file zb_action.

Constructor & Destructor Documentation

◆ primvis() [1/2]

tools::sg::zb_action::primvis::primvis ( zb_action a_zb)
inline

Definition at line 556 of file zb_action.

556 :m_zb_action(a_zb){}

◆ ~primvis()

virtual tools::sg::zb_action::primvis::~primvis ( )
inlinevirtual

Definition at line 557 of file zb_action.

557 {}

◆ primvis() [2/2]

tools::sg::zb_action::primvis::primvis ( const primvis a_from)
inline

Definition at line 559 of file zb_action.

560  :primitive_visitor(a_from)
561  ,m_zb_action(a_from.m_zb_action)
562  {}

Member Function Documentation

◆ _add_point()

bool tools::sg::zb_action::primvis::_add_point ( float  a_x,
float  a_y,
float  a_z,
const colorf a_color 
)
inlineprotected

Definition at line 588 of file zb_action.

588  {
590 
591  m_zb_action.m_vp_mtx.mul_3f(a_x,a_y,a_z);
592  a_z *= -1;
593 
594  zb::point p;
595  zinit(p,a_x,a_y,a_z);
596 
597  float alpha = a_color.a();
599  if(alpha<1.0f) {
600  zb::buffer::ZPixel old_px = 0;
601  if(!m_zb_action.m_zb.get_pixel(p,old_px)) return false;
602  colorf old_color;
603  if(!m_zb_action.find_color(old_px,old_color)) return false;
604  float one_alpha = 1.0f-alpha;
605  colorf _color;
606  _color.set_r(a_color.r()*alpha+old_color.r()*one_alpha);
607  _color.set_g(a_color.g()*alpha+old_color.g()*one_alpha);
608  _color.set_b(a_color.b()*alpha+old_color.b()*one_alpha);
609  px = m_zb_action.get_pix(_color);
610  } else {
611  px = m_zb_action.get_pix(a_color);
612  }
614 
615  return true;
616  }

◆ _add_triangle()

bool tools::sg::zb_action::primvis::_add_triangle ( float  a_p1x,
float  a_p1y,
float  a_p1z,
float  a_p1w,
float  a_p2x,
float  a_p2y,
float  a_p2z,
float  a_p2w,
float  a_p3x,
float  a_p3y,
float  a_p3z,
float  a_p3w,
const colorf a_color 
)
inlineprotected

Definition at line 618 of file zb_action.

621  {
622 
623  float p1x = a_p1x;float p1y = a_p1y;float p1z = a_p1z;//float p1w = a_p1w;
624  float p2x = a_p2x;float p2y = a_p2y;float p2z = a_p2z;//float p2w = a_p2w;
625  float p3x = a_p3x;float p3y = a_p3y;float p3z = a_p3z;//float p3w = a_p3w;
626 
627  m_zb_action.m_vp_mtx.mul_3f(p1x,p1y,p1z);
628  m_zb_action.m_vp_mtx.mul_3f(p2x,p2y,p2z);
629  m_zb_action.m_vp_mtx.mul_3f(p3x,p3y,p3z);
630  p1z *= -1;
631  p2z *= -1;
632  p3z *= -1;
633 
635  // zs are in [-1,1]
636  float epsil = 1e-5f;
637  //float epsil = 1e-4f;
638  p1z -= epsil;
639  p2z -= epsil;
640  p3z -= epsil;
641  }
642 
643  typedef zb::ZZ ZZ; //double
644 
645  plane<vec3d> pn(
646  vec3<ZZ>(p1x,p1y,p1z),
647  vec3<ZZ>(p2x,p2y,p2z),
648  vec3<ZZ>(p3x,p3y,p3z)
649  );
650  if(!pn.is_valid()) return true;
651 
652  // norm[0]*x+norm[1]*y+norm[2]*z = dist
653  // A*x+B*y+C*z+D = 0
654 
655  ZZ C = pn.normal()[2];
656 
657  if(m_zb_action.m_CULL_FACE){ // check back facing or by the edge :
658  if(m_zb_action.m_ccw) {
659  if(C<=0) return true;
660  } else {
661  if(C>=0) return true;
662  }
663  }
664 
665  ZZ A = pn.normal()[0];
666  ZZ B = pn.normal()[1];
667  ZZ D = -pn.distance_from_origin();
668 
669  //ZZ zmn = mn<ZZ>(mn<ZZ>(p1z,p2z),p3z);
670  //ZZ zmx = mx<ZZ>(mx<ZZ>(p1z,p2z),p3z);
671 
672  zb::point list[3];
673  zinit(list[0],p1x,p1y,p1z);
674  zinit(list[1],p2x,p2y,p2z);
675  zinit(list[2],p3x,p3y,p3z);
676 
678 
679  if(m_zb_action.m_light_on) {
680 
681  float _p1x = a_p1x;float _p1y = a_p1y;float _p1z = a_p1z;float _p1w = a_p1w;
682  float _p2x = a_p2x;float _p2y = a_p2y;float _p2z = a_p2z;float _p2w = a_p2w;
683  float _p3x = a_p3x;float _p3y = a_p3y;float _p3z = a_p3z;float _p3w = a_p3w;
684 
685  _p1x *= _p1w;_p1y *= _p1w;_p1z *= _p1w;
686  _p2x *= _p2w;_p2y *= _p2w;_p2z *= _p2w;
687  _p3x *= _p3w;_p3y *= _p3w;_p3z *= _p3w;
688 
689  m_zb_action.m_proj_1.mul_4f(_p1x,_p1y,_p1z,_p1w);
690  m_zb_action.m_proj_1.mul_4f(_p2x,_p2y,_p2z,_p2w);
691  m_zb_action.m_proj_1.mul_4f(_p3x,_p3y,_p3z,_p3w);
692 
693  plane<vec3d> _pn(
694  vec3<ZZ>(_p1x,_p1y,_p1z),
695  vec3<ZZ>(_p2x,_p2y,_p2z),
696  vec3<ZZ>(_p3x,_p3y,_p3z)
697  );
698  if(_pn.is_valid()) {
699  vec3f npn(float(_pn.normal().x()),
700  float(_pn.normal().y()),
701  float(_pn.normal().z()));
702  vec3f d = m_zb_action.m_light_direction;
703  float dx = m_zb_action.m_light_direction.x();
704  float dy = m_zb_action.m_light_direction.y();
705  float dz = m_zb_action.m_light_direction.z();
706  m_zb_action.m_model.mul_3f(dx,dy,dz);
707  d.set_value(dx,dy,dz);
708  if(d.normalize()) {
709  float dot = npn.dot(d);
710  if((-1<=dot)&&(dot<=0)) {
711  dot *= -1;
712 
713 // colorf c
714 // (a_color.r()*dot,a_color.g()*dot,a_color.b()*dot,a_color.a());
715 
716  float h,l,s;
717  rgb_to_hls(a_color.r(),a_color.g(),a_color.b(),h,l,s);
718  l *= dot;
719  float r,g,b;
720  hls_to_rgb(h,l,s,r,g,b);
721 
722  colorf c(r,g,b,a_color.a());
723 
724  m_zb_action.m_zb.draw_polygon(3,list,A,B,C,D,m_zb_action.get_pix(c));
725  //m_zb_action.m_zb.draw_polygon(3,list,A,B,C,D,m_zb_action.get_pix(a_color));
726  }
727  }
728  }
729 
730  } else {
731  m_zb_action.m_zb.draw_polygon(3,list,A,B,C,D,m_zb_action.get_pix(a_color));
732  }
733 
734  return true;
735  }

◆ add_line() [1/2]

virtual bool tools::sg::zb_action::primvis::add_line ( float  a_bx,
float  a_by,
float  a_bz,
float  ,
float  a_br,
float  a_bg,
float  a_bb,
float  a_ba,
float  a_ex,
float  a_ey,
float  a_ez,
float  ,
float  ,
float  ,
float  ,
float   
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 430 of file zb_action.

433  {
434  m_zb_action.m_vp_mtx.mul_3f(a_bx,a_by,a_bz);
435  m_zb_action.m_vp_mtx.mul_3f(a_ex,a_ey,a_ez);
436  a_bz *= -1;
437  a_ez *= -1;
438 
439  zb::point beg;
440  zinit(beg,a_bx,a_by,a_bz);
441 
442  zb::point end;
443  zinit(end,a_ex,a_ey,a_ez);
444 
446 
447  // interpolate color with beg,end ?
448  m_zb_action.m_zb.draw_line(beg,end,m_zb_action.get_pix(colorf(a_br,a_bg,a_bb,a_ba)),npix(m_zb_action.m_line_width));
449 
450  return true;
451  }

◆ add_line() [2/2]

virtual bool tools::sg::zb_action::primvis::add_line ( float  a_bx,
float  a_by,
float  a_bz,
float  ,
float  a_ex,
float  a_ey,
float  a_ez,
float   
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 411 of file zb_action.

412  {
413  m_zb_action.m_vp_mtx.mul_3f(a_bx,a_by,a_bz);
414  m_zb_action.m_vp_mtx.mul_3f(a_ex,a_ey,a_ez);
415  a_bz *= -1;
416  a_ez *= -1;
417 
418  zb::point beg;
419  zinit(beg,a_bx,a_by,a_bz);
420 
421  zb::point end;
422  zinit(end,a_ex,a_ey,a_ez);
423 
426 
427  return true;
428  }

◆ add_line_normal() [1/2]

virtual bool tools::sg::zb_action::primvis::add_line_normal ( float  a_bx,
float  a_by,
float  a_bz,
float  a_bw,
float  ,
float  ,
float  ,
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  ,
float  ,
float  ,
float  a_er,
float  a_eg,
float  a_eb,
float  a_ea 
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 508 of file zb_action.

513  {
514  add_line(a_bx,a_by,a_bz,a_bw, a_br,a_bg,a_bb,a_ba, a_ex,a_ey,a_ez,a_ew, a_er,a_eg,a_eb,a_ea);
515  //m_this.m_lines.add_normal(a_bnx,a_bny,a_bnz);
516  //m_this.m_lines.add_normal(a_enx,a_eny,a_enz);
517  return true;
518  }

◆ add_line_normal() [2/2]

virtual bool tools::sg::zb_action::primvis::add_line_normal ( float  a_bx,
float  a_by,
float  a_bz,
float  a_bw,
float  ,
float  ,
float  ,
float  a_ex,
float  a_ey,
float  a_ez,
float  a_ew,
float  ,
float  ,
float   
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 499 of file zb_action.

502  {
503  add_line(a_bx,a_by,a_bz,a_bw, a_ex,a_ey,a_ez,a_ew);
504  //m_this.m_lines.add_normal(a_bnx,a_bny,a_bnz);
505  //m_this.m_lines.add_normal(a_enx,a_eny,a_enz);
506  return true;
507  }

◆ add_point() [1/2]

virtual bool tools::sg::zb_action::primvis::add_point ( float  a_x,
float  a_y,
float  a_z,
float   
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 401 of file zb_action.

401  {
402  return _add_point(a_x,a_y,a_z,m_zb_action.m_rgba);
403  }

◆ add_point() [2/2]

virtual bool tools::sg::zb_action::primvis::add_point ( float  a_x,
float  a_y,
float  a_z,
float  ,
float  a_r,
float  a_g,
float  a_b,
float  a_a 
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 405 of file zb_action.

406  {
407  colorf c(a_r,a_g,a_b,a_a);
408  return _add_point(a_x,a_y,a_z,c);
409  }

◆ add_point_normal() [1/2]

virtual bool tools::sg::zb_action::primvis::add_point_normal ( float  a_x,
float  a_y,
float  a_z,
float  a_w,
float  ,
float  ,
float   
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 486 of file zb_action.

487  {
488  add_point(a_x,a_y,a_z,a_w);
489  //m_this.m_points.add_normal(a_nx,a_ny,a_nz);
490  return true;
491  }

◆ add_point_normal() [2/2]

virtual bool tools::sg::zb_action::primvis::add_point_normal ( float  a_x,
float  a_y,
float  a_z,
float  a_w,
float  ,
float  ,
float  ,
float  a_r,
float  a_g,
float  a_b,
float  a_a 
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 492 of file zb_action.

494  {
495  add_point(a_x,a_y,a_z,a_w,a_r,a_g,a_b,a_a);
496  //m_this.m_points.add_normal(a_nx,a_ny,a_nz);
497  return true;
498  }

◆ add_triangle() [1/2]

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

Implements tools::sg::primitive_visitor.

Definition at line 453 of file zb_action.

455  {
456  return _add_triangle(a_p1x,a_p1y,a_p1z,a_p1w,
457  a_p2x,a_p2y,a_p2z,a_p2w,
458  a_p3x,a_p3y,a_p3z,a_p3w,
460  }

◆ add_triangle() [2/2]

virtual bool tools::sg::zb_action::primvis::add_triangle ( float  a_p1x,
float  a_p1y,
float  a_p1z,
float  a_p1w,
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_r2,
float  a_g2,
float  a_b2,
float  a_a2,
float  a_p3x,
float  a_p3y,
float  a_p3z,
float  a_p3w,
float  a_r3,
float  a_g3,
float  a_b3,
float  a_a3 
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 462 of file zb_action.

468  {
469 
470  float r = (a_r1+a_r2+a_r3)/3.0f;
471  float g = (a_g1+a_g2+a_g3)/3.0f;
472  float b = (a_b1+a_b2+a_b3)/3.0f;
473  float a = (a_a1+a_a2+a_a3)/3.0f;
474  colorf col(r,g,b,a);
475 
476  return _add_triangle(a_p1x,a_p1y,a_p1z,a_p1w,
477  a_p2x,a_p2y,a_p2z,a_p2w,
478  a_p3x,a_p3y,a_p3z,a_p3w,
479  col);
480  }

◆ add_triangle_normal() [1/2]

virtual bool tools::sg::zb_action::primvis::add_triangle_normal ( float  a_p1x,
float  a_p1y,
float  a_p1z,
float  a_p1w,
float  ,
float  ,
float  ,
float  a_p2x,
float  a_p2y,
float  a_p2z,
float  a_p2w,
float  ,
float  ,
float  ,
float  a_p3x,
float  a_p3y,
float  a_p3z,
float  a_p3w,
float  ,
float  ,
float   
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 519 of file zb_action.

525  {
526  add_triangle(a_p1x,a_p1y,a_p1z,a_p1w,
527  a_p2x,a_p2y,a_p2z,a_p2w,
528  a_p3x,a_p3y,a_p3z,a_p3w);
529  //m_this.m_triangles.add_normal(a_n1x,a_n1y,a_n1z);
530  //m_this.m_triangles.add_normal(a_n2x,a_n2y,a_n2z);
531  //m_this.m_triangles.add_normal(a_n3x,a_n3y,a_n3z);
532  return true;
533  }

◆ add_triangle_normal() [2/2]

virtual bool tools::sg::zb_action::primvis::add_triangle_normal ( float  a_p1x,
float  a_p1y,
float  a_p1z,
float  a_p1w,
float  ,
float  ,
float  ,
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  ,
float  ,
float  ,
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  ,
float  ,
float  ,
float  a_r3,
float  a_g3,
float  a_b3,
float  a_a3 
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 534 of file zb_action.

543  {
544  add_triangle(a_p1x,a_p1y,a_p1z,a_p1w,
545  a_r1,a_g1,a_b1,a_a1,
546  a_p2x,a_p2y,a_p2z,a_p2w,
547  a_r2,a_g2,a_b2,a_a2,
548  a_p3x,a_p3y,a_p3z,a_p3w,
549  a_r3,a_g3,a_b3,a_a3);
550  //m_this.m_triangles.add_normal(a_n1x,a_n1y,a_n1z);
551  //m_this.m_triangles.add_normal(a_n2x,a_n2y,a_n2z);
552  //m_this.m_triangles.add_normal(a_n3x,a_n3y,a_n3z);
553  return true;
554  }

◆ npix()

unsigned int tools::sg::zb_action::primvis::npix ( float  a_size)
inlineprotected

Definition at line 574 of file zb_action.

574  {
575  // 0 -> 0
576  // 1 -> 0
577  // 2 -> 1 3x3
578  // 3 -> 1 3x3
579  // 4 -> 2 5x5
580  // 5 -> 2 5x5
581  // 6 -> 3 7x7
582  unsigned int num = (unsigned int)a_size;
583  unsigned int num_2 = num/2;
584  if(2*num_2==num) {num++;num_2 = num/2;}
585  return num_2;
586  }

◆ operator=()

primvis& tools::sg::zb_action::primvis::operator= ( const primvis a_from)
inline

Definition at line 563 of file zb_action.

563  {
565  return *this;
566  }

◆ project()

virtual bool tools::sg::zb_action::primvis::project ( float &  a_x,
float &  a_y,
float &  a_z,
float &  a_w 
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 398 of file zb_action.

398  {
399  return m_zb_action.project_point(a_x,a_y,a_z,a_w);
400  }

◆ project_normal()

virtual bool tools::sg::zb_action::primvis::project_normal ( float &  ,
float &  ,
float &   
)
inlineprotectedvirtual

Implements tools::sg::primitive_visitor.

Definition at line 482 of file zb_action.

482  {
483  //return m_zb_action.project_normal(a_x,a_y,a_z);
484  return true;
485  }

◆ zinit()

static void tools::sg::zb_action::primvis::zinit ( zb::point a_p,
float  a_x,
float  a_y,
float  a_z 
)
inlinestaticprotected

Definition at line 568 of file zb_action.

568  {
569  a_p.x = fround(a_x); //float -> int
570  a_p.y = fround(a_y); //float -> int
571  a_p.z = (zb::ZZ)a_z; //float -> double
572  }

Member Data Documentation

◆ m_zb_action

zb_action& tools::sg::zb_action::primvis::m_zb_action
protected

Definition at line 737 of file zb_action.


The documentation for this class was generated from the following file:
tools::zb::buffer::set_depth_test
void set_depth_test(bool a_on)
Definition: buffer:184
tools::zb::buffer::get_pixel
bool get_pixel(const point &a_p, ZPixel &a_pixel)
Definition: buffer:291
tools::sg::zb_action::find_color
bool find_color(zb::buffer::ZPixel a_pix, colorf &a_rgba) const
Definition: zb_action:273
tools::mat4f::mul_3f
void mul_3f(float &a_x, float &a_y, float &a_z) const
Definition: mat4f:58
tools::sg::zb_action::m_proj_1
mat4f m_proj_1
Definition: zb_action:745
tools::sg::zb_action::m_CULL_FACE
bool m_CULL_FACE
Definition: zb_action:758
tools::sg::zb_action::m_ccw
bool m_ccw
Definition: zb_action:756
tools::sg::zb_action::primvis::_add_triangle
bool _add_triangle(float a_p1x, float a_p1y, float a_p1z, float a_p1w, float a_p2x, float a_p2y, float a_p2z, float a_p2w, float a_p3x, float a_p3y, float a_p3z, float a_p3w, const colorf &a_color)
Definition: zb_action:618
tools::sg::zb_action::m_light_direction
vec3f m_light_direction
Definition: zb_action:749
tools::sg::zb_action::m_DEPTH_TEST
bool m_DEPTH_TEST
Definition: zb_action:764
tools::sg::zb_action::m_line_width
float m_line_width
Definition: zb_action:761
tools::zb::ZZ
double ZZ
Definition: point:11
tools::zb::buffer::draw_point
void draw_point(const point &a_p, ZPixel a_pixel, unsigned int a_size)
Definition: buffer:286
tools::sg::matrix_action::end
bool end() const
Definition: matrix_action:75
tools::vec3::y
const T & y() const
Definition: vec3:85
tools::mat4f::mul_4f
void mul_4f(float &a_x, float &a_y, float &a_z, float &a_w) const
Definition: mat4f:61
tools::sg::zb_action::primvis::m_zb_action
zb_action & m_zb_action
Definition: zb_action:737
tools::sg::zb_action::project_point
bool project_point(float &a_x, float &a_y, float &a_z, float &a_w)
Definition: zb_action:380
tools::rgb_to_hls
void rgb_to_hls(T rr, T gg, T bb, T &hue, T &light, T &satur)
Definition: hls:55
tools::vec3::x
const T & x() const
Definition: vec3:84
tools::sg::zb_action::m_zb
zb::buffer m_zb
Definition: zb_action:743
tools::sg::primitive_visitor::operator=
primitive_visitor & operator=(const primitive_visitor &)
Definition: primitive_visitor:61
tools::sg::zb_action::m_model
mat4f m_model
Definition: zb_action:754
tools::sg::zb_action::m_rgba
colorf m_rgba
Definition: zb_action:755
tools::sg::zb_action::primvis::npix
unsigned int npix(float a_size)
Definition: zb_action:574
tools::sg::zb_action::m_point_size
float m_point_size
Definition: zb_action:762
tools::sg::zb_action::primvis::zinit
static void zinit(zb::point &a_p, float a_x, float a_y, float a_z)
Definition: zb_action:568
tools::zb::buffer::ZPixel
unsigned int ZPixel
Definition: buffer:22
tools::sg::zb_action::primvis::add_line
virtual bool add_line(float a_bx, float a_by, float a_bz, float, float a_ex, float a_ey, float a_ez, float)
Definition: zb_action:411
tools::zb::buffer::draw_line
void draw_line(const point &a_beg, const point &a_end, ZPixel a_pixel, unsigned int a_size)
Definition: buffer:296
tools::sg::zb_action::m_light_on
bool m_light_on
Definition: zb_action:763
tools::sg::zb_action::m_POLYGON_OFFSET_FILL
bool m_POLYGON_OFFSET_FILL
Definition: zb_action:757
tools::sg::zb_action::get_pix
zb::buffer::ZPixel get_pix(const colorf &a_rgba)
Definition: zb_action:267
tools::sg::zb_action::primvis::_add_point
bool _add_point(float a_x, float a_y, float a_z, const colorf &a_color)
Definition: zb_action:588
tools::zb::buffer::draw_polygon
void draw_polygon(int a_number, const point *a_list, ZZ a_A, ZZ a_B, ZZ a_C, ZZ a_D, ZPixel a_pixel)
Definition: buffer:323
tools::sg::zb_action::m_vp_mtx
mat4f m_vp_mtx
Definition: zb_action:742
tools::hls_to_rgb
void hls_to_rgb(T hue, T light, T satur, T &a_r, T &a_g, T &a_b)
Definition: hls:24
tools::vec3::z
const T & z() const
Definition: vec3:86
tools::sg::zb_action::primvis::add_point
virtual bool add_point(float a_x, float a_y, float a_z, float)
Definition: zb_action:401
tools::fround
int fround(const float &a_x)
Definition: mathf:27
tools::sg::zb_action::primvis::add_triangle
virtual bool add_triangle(float a_p1x, float a_p1y, float a_p1z, float a_p1w, float a_p2x, float a_p2y, float a_p2z, float a_p2w, float a_p3x, float a_p3y, float a_p3z, float a_p3w)
Definition: zb_action:453
tools::sg::primitive_visitor::primitive_visitor
primitive_visitor()
Definition: primitive_visitor:57