g4tools  5.4.0
zb_action
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_zb_action
5 #define tools_sg_zb_action
6 
7 #include "zb_manager"
8 
9 #include "render_action"
10 #include "primitive_visitor"
11 #include "../glprims"
12 
13 #include "../zb/buffer"
14 
15 #include "../lina/plane"
16 #include "../mathf"
17 #include "../hls"
18 #include "../colorfs"
19 #include "../lina/vec2f"
20 #include "../lina/vec3d" //ZZ=double
21 #include "../lina/geom2"
22 
23 namespace tools {
24 namespace sg {
25 
26 class zb_action : public render_action {
28 private:
29  zb_action& get_me() {return *this;}
30 public:
31  virtual void draw_vertex_array(gl::mode_t a_mode,size_t a_floatn,const float* a_xyzs){
32  m_pv.add_primitive(a_mode,a_floatn,a_xyzs);
33  }
34 
35  virtual void draw_vertex_array_xy(gl::mode_t a_mode,size_t a_floatn,const float* a_xys){
36  m_pv.add_primitive_xy(a_mode,a_floatn,a_xys);
37  }
38 
39  virtual void draw_vertex_color_array(gl::mode_t a_mode,size_t a_floatn,
40  const float* a_xyzs,const float* a_rgbas){
41  m_pv.add_primitive_rgba(a_mode,a_floatn,a_xyzs,a_rgbas);
42  }
43 
44  virtual void draw_vertex_normal_array(gl::mode_t a_mode,size_t a_floatn,
45  const float* a_xyzs,const float* a_nms){
46  m_pv.add_primitive_normal(a_mode,a_floatn,a_xyzs,a_nms);
47  }
48 
49  virtual void draw_vertex_color_normal_array(gl::mode_t a_mode,size_t a_floatn,
50  const float* a_xyzs,const float* a_rgbas,const float* a_nms){
51  // We expect a_nms of size : 3*(a_floatn/3)
52  // (then one normal per 3D point).
53  m_pv.add_primitive_normal_rgba(a_mode,a_floatn,a_xyzs,a_nms,a_rgbas);
54  }
55 
56  virtual void clear_color(float a_r,float a_g,float a_b,float a_a){
57  zb::buffer::ZPixel px = get_pix(colorf(a_r,a_g,a_b,a_a));
59  }
60  virtual void color4f(float a_r,float a_g,float a_b,float a_a){
61  m_rgba.set_value(a_r,a_g,a_b,a_a);
62  }
63  virtual void line_width(float a_v){m_line_width = a_v;}
64  virtual void point_size(float a_v) {m_point_size = a_v;}
65  virtual void set_polygon_offset(bool a_v) {m_POLYGON_OFFSET_FILL = a_v;}
66  virtual void normal(float a_x,float a_y,float a_z) {
67  m_normal.set_value(a_x,a_y,a_z);
68  }
69 
70  virtual void set_winding(winding_type a_v) {
71  m_ccw = (a_v==winding_ccw?true:false);
72  }
73  virtual void set_shade_model(shade_type) {}
74 
75  virtual void set_depth_test(bool a_on) {m_DEPTH_TEST = a_on;}
76 
77  virtual void set_cull_face(bool a_on) {m_CULL_FACE = a_on;}
78  virtual void set_point_smooth(bool a_on) {m_POINT_SMOOTH = a_on;}
79  virtual void set_line_smooth(bool a_on) {m_LINE_SMOOTH = a_on;}
80 
81  virtual void load_proj_matrix(const mat4f& a_mtx) {
82  m_proj = a_mtx;
83  if(!m_proj.invert(m_proj_1)){}
84  }
85 
86  virtual void load_model_matrix(const mat4f& a_mtx) {m_model = a_mtx;}
87 
88  virtual unsigned int max_lights() {return 1000;}
89 
90  virtual void enable_light(unsigned int,
91  float a_dx,float a_dy,float a_dz,
92  float a_r,float a_g,float a_b,float a_a){
93  m_light_color.set_value(a_r,a_g,a_b,a_a);
94  m_light_direction.set_value(a_dx,a_dy,a_dz);
95  m_light_on = true;
96  }
97 
98  virtual void set_lighting(bool a_on) {m_light_on = a_on;}
99  virtual void set_blend(bool) {}
100 
101  virtual void restore_state(unsigned int /*a_ret_num_light*/) {
102  const sg::state& _state = state();
103  m_proj = _state.m_proj;
104  m_model = _state.m_model;
105 
106  if(!m_proj.invert(m_proj_1)){}
107 
108  m_rgba = _state.m_color;
109  m_ccw = (_state.m_winding==winding_ccw?true:false);
111  m_CULL_FACE = _state.m_GL_CULL_FACE;
114  m_line_width = _state.m_line_width;
115  m_point_size = _state.m_point_size;
116  m_light_on = _state.m_GL_LIGHTING;
117  m_DEPTH_TEST = _state.m_GL_DEPTH_TEST;
118 
119 
120 /*
121  if(_state.m_GL_TEXTURE_2D) ::glEnable(GL_TEXTURE_2D);
122  else ::glDisable(GL_TEXTURE_2D);
123 
124  // The "return of separator" state had ret_num_light.
125  // The restored state has m_light.
126  // We have to glDisable lights with index in [m_light,ret_num_light-1]
127  for(unsigned int index=_state.m_light;index<a_ret_num_light;index++) {
128  ::glDisable(GL_LIGHT0+index);
129  }
130 */
131  }
132 
136  virtual void draw_vertex_array_texture(gl::mode_t,size_t a_xyzn,const float* a_xyzs,
137  gstoid a_id,const float* a_tcs) {
138  //::printf("debug : zb_action : 000 : %d\n",a_id);
139  img_byte img;
140  if(!m_mgr.find(a_id,img)) return;
141  m_pv.add_texture(m_out,a_xyzn,a_xyzs,img,a_tcs);
142  }
143 
145  size_t a_xyzn,const float* a_xyzs,const float* /*a_nms*/,
146  gstoid a_id,const float* a_tcs) {
147  draw_vertex_array_texture(a_mode,a_xyzn,a_xyzs,a_id,a_tcs);
148  }
149 
153  virtual void begin_gsto(gstoid) {}
154  virtual void draw_gsto_v(gl::mode_t,size_t,bufpos){}
155  virtual void draw_gsto_vc(gl::mode_t,size_t,bufpos,bufpos) {}
156  virtual void draw_gsto_vn(gl::mode_t,size_t,bufpos,bufpos) {}
157  virtual void draw_gsto_vcn(gl::mode_t,size_t,bufpos,bufpos,bufpos) {}
158  virtual void end_gsto() {}
163 public:
164  zb_action(zb_manager& a_mgr,std::ostream& a_out,unsigned int a_ww,unsigned int a_wh)
165  :parent(a_out,a_ww,a_wh)
166  ,m_mgr(a_mgr)
167  ,m_pv(get_me())
168  ,m_light_color(colorf_white())
169  ,m_light_direction(vec3f(0,0,-1))
170  ,m_normal(0,0,1)
171 
172  ,m_ccw(true)
173  ,m_POLYGON_OFFSET_FILL(false)
174  ,m_CULL_FACE(true)
175  ,m_POINT_SMOOTH(false)
176  ,m_LINE_SMOOTH(false)
177  ,m_line_width(1)
178  ,m_point_size(1)
179  ,m_light_on(false)
180  ,m_DEPTH_TEST(true)
181  {
182  m_vp_mtx.set_identity();
183  m_vp_mtx.mul_translate(float(m_ww)/2,float(m_wh)/2,0);
184  m_vp_mtx.mul_scale(float(m_ww)/2,float(m_wh)/2,1);
185 
186  m_zb.change_size(a_ww,a_wh);
187 // m_zb.clear_color_buffer(0);
188 // m_zb.clear_depth_buffer();
189  }
190  virtual ~zb_action(){}
191 protected:
192  zb_action(const zb_action& a_from)
193  :parent(a_from)
194  ,m_mgr(a_from.m_mgr)
195  ,m_vp_mtx(a_from.m_vp_mtx)
196  //,m_buffer(a_from.m_buffer)
197  ,m_pv(a_from.m_pv)
198  ,m_proj_1(a_from.m_proj_1)
201  ,m_normal(a_from.m_normal)
202 
203  ,m_proj(a_from.m_proj)
204  ,m_model(a_from.m_model)
205  ,m_rgba(a_from.m_rgba)
206  ,m_ccw(a_from.m_ccw)
208  ,m_CULL_FACE(a_from.m_CULL_FACE)
211  ,m_line_width(a_from.m_line_width)
212  ,m_point_size(a_from.m_point_size)
213  ,m_light_on(a_from.m_light_on)
214  ,m_DEPTH_TEST(a_from.m_DEPTH_TEST)
215  {}
216  zb_action& operator=(const zb_action& a_from){
217  parent::operator=(a_from);
218  m_vp_mtx = a_from.m_vp_mtx;
219  //m_buffer = a_from.m_buffer;
220  m_pv = a_from.m_pv;
221  m_proj_1 = a_from.m_proj_1;
222  m_light_color = a_from.m_light_color;
224  m_normal = a_from.m_normal;
225 
226  m_proj = a_from.m_proj;
227  m_model = a_from.m_model;
228  m_rgba = a_from.m_rgba;
229  m_ccw = a_from.m_ccw;
231  m_CULL_FACE = a_from.m_CULL_FACE;
233  m_LINE_SMOOTH = a_from.m_LINE_SMOOTH;
234  m_line_width = a_from.m_line_width;
235  m_point_size = a_from.m_point_size;
236  m_light_on = a_from.m_light_on;
237  m_DEPTH_TEST = a_from.m_DEPTH_TEST;
238  return *this;
239  }
240 public:
241  void reset() {
242  m_cmap.clear();
243  m_rcmap.clear();
244  }
245 
246  const zb::buffer& zbuffer() const {return m_zb;}
247  zb::buffer& zbuffer() {return m_zb;}
248 protected:
249  typedef std::map<colorf,zb::buffer::ZPixel,cmp_colorf> cmap_t;
250 public:
251  //const cmap_t& colormap() const {return m_cmap;}
252  //cmap_t& colormap() {return m_cmap;}
253  zb::buffer::ZPixel add_color(float a_r,float a_g,float a_b,float a_a){
254  return add_color(colorf(a_r,a_g,a_b,a_a));
255  }
256  zb::buffer::ZPixel add_color(float a_r,float a_g,float a_b){
257  return add_color(a_r,a_g,a_b,1);
258  }
260  //::printf("debug : zb_action::add_color : %g %g %g %g : %d\n",
261  // a_col.r(),a_col.g(),a_col.b(),a_col.a(),m_cmap.size());
263  m_cmap[a_col] = pix;
264  return pix;
265  }
266 
268  cmap_t::const_iterator it = m_cmap.find(a_rgba);
269  if(it!=m_cmap.end()) return (*it).second;
270  return add_color(a_rgba);
271  }
272 
273  bool find_color(zb::buffer::ZPixel a_pix,colorf& a_rgba) const {
274  cmap_t::const_iterator it;
275  for(it=m_cmap.begin();it!=m_cmap.end();++it){
276  if((*it).second==a_pix) {a_rgba = (*it).first;return true;}
277  }
278  return false;
279  }
280 
281  typedef std::map<zb::buffer::ZPixel,colorf> rcmap_t;
282  const rcmap_t& rcolormap() const {return m_rcmap;}
283  rcmap_t& rcolormap() {return m_rcmap;}
284 protected:
285  void gen_rcmap() {
286  m_rcmap.clear();
287  cmap_t::const_iterator it;
288  for(it=m_cmap.begin();it!=m_cmap.end();++it){
289  m_rcmap[(*it).second] = (*it).first;
290  }
291  }
292 public:
293  //typedef wps::VCol VCol;
294  typedef float VCol;
295 
296  static bool get_rgb(void* a_tag,unsigned int a_col,unsigned int a_row,VCol& a_r,VCol& a_g,VCol& a_b){
297  //used with wps.
298  zb_action* rzb = (zb_action*)a_tag;
299 
300  zb::buffer::ZPixel pix;
301  if(!rzb->zbuffer().get_clipped_pixel(a_col,rzb->wh()-1-a_row,pix)){
302  rzb->out() << "get_rgb : can't get zbuffer pixel" << std::endl;
303  a_r = 1;
304  a_g = 0;
305  a_b = 0;
306  return false;
307  }
308 
309  if(rzb->rcolormap().empty()) rzb->gen_rcmap();
310 
311  {rcmap_t::const_iterator it = rzb->rcolormap().find(pix);
312  if(it==rzb->rcolormap().end()) {
313  rzb->out() << "can't find pixel " << pix
314  << " in cmap (sz " << rzb->rcolormap().size() << ")."
315  << std::endl;
316  a_r = 1;
317  a_g = 0;
318  a_b = 0;
319  return false;
320  }
321  a_r = (*it).second.r();
322  a_g = (*it).second.g();
323  a_b = (*it).second.b();}
324 
325  return true;
326  }
327 
328  unsigned char* get_rgbas(size_t& a_sz) {
329  if(!m_ww || !m_wh) {a_sz = 0;return 0;}
330  a_sz = 4 * m_ww * m_wh;
331  typedef unsigned char uchar;
332  uchar* rgbas = new uchar[a_sz];
333  if(!rgbas) {a_sz = 0;return 0;}
334  uchar* pos = rgbas;
335  VCol r,g,b;
336  VCol a = 1;
337  for(unsigned int row=0;row<m_wh;row++) {
338  for(unsigned int col=0;col<m_ww;col++) {
339  get_rgb(this,col,m_wh-row-1,r,g,b);
340  *pos = (uchar)(r*255.0F);pos++;
341  *pos = (uchar)(g*255.0F);pos++;
342  *pos = (uchar)(b*255.0F);pos++;
343  *pos = (uchar)(a*255.0F);pos++;
344  }
345  }
346  /*{size_t number = 4 * m_ww * m_wh;
347  size_t count_not_255 = 0;
348  for(size_t item=3;item<number;item+=4) {
349  unsigned char a = rgbas[item];
350  if(a!=255) {
351  ::printf("%lu : %d\n",item,a);
352  count_not_255++;
353  rgbas[item] = 255;
354  }
355  }
356  ::printf("zb_action::rgbas : not_255 : %lu\n",count_not_255);}*/
357  return rgbas;
358  }
359 
360  unsigned char* get_rgbs(size_t& a_sz) {
361  if(!m_ww || !m_wh) {a_sz = 0;return 0;}
362  a_sz = 3 * m_ww * m_wh;
363  typedef unsigned char uchar;
364  uchar* rgbs = new uchar[a_sz];
365  if(!rgbs) {a_sz = 0;return 0;}
366  uchar* pos = rgbs;
367  VCol r,g,b;
368  for(unsigned int row=0;row<m_wh;row++) {
369  for(unsigned int col=0;col<m_ww;col++) {
370  get_rgb(this,col,m_wh-row-1,r,g,b);
371  *pos = (uchar)(r*255.0F);pos++;
372  *pos = (uchar)(g*255.0F);pos++;
373  *pos = (uchar)(b*255.0F);pos++;
374  }
375  }
376  return rgbs;
377  }
378 
379 protected:
380  bool project_point(float& a_x,float& a_y,float& a_z,float& a_w) {
381  a_w = 1;
382  m_model.mul_4f(a_x,a_y,a_z,a_w);
383  m_proj.mul_4f(a_x,a_y,a_z,a_w);
384  if(a_w==0) return false;
385  a_x /= a_w;
386  a_y /= a_w;
387  a_z /= a_w;
388  return true;
389  }
390 // bool project_normal(float& a_x,float& a_y,float& a_z) {
391 // m_model.mul_dir_3f(a_x,a_y,a_z);
392 // m_proj.mul_dir_3f(a_x,a_y,a_z);
393 // return true;
394 // }
395 
396  class primvis : public primitive_visitor {
397  protected:
398  virtual bool project(float& a_x,float& a_y,float& a_z,float& a_w) {
399  return m_zb_action.project_point(a_x,a_y,a_z,a_w);
400  }
401  virtual bool add_point(float a_x,float a_y,float a_z,float) {
402  return _add_point(a_x,a_y,a_z,m_zb_action.m_rgba);
403  }
404 
405  virtual bool add_point(float a_x,float a_y,float a_z,float,
406  float a_r,float a_g,float a_b,float a_a) {
407  colorf c(a_r,a_g,a_b,a_a);
408  return _add_point(a_x,a_y,a_z,c);
409  }
410 
411  virtual bool add_line(float a_bx,float a_by,float a_bz,float,
412  float a_ex,float a_ey,float a_ez,float) {
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  }
429 
430  virtual bool add_line(float a_bx,float a_by,float a_bz,float,
431  float a_br,float a_bg,float a_bb,float a_ba,
432  float a_ex,float a_ey,float a_ez,float,
433  float,float,float,float) {
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 ?
449 
450  return true;
451  }
452 
453  virtual bool add_triangle(float a_p1x,float a_p1y,float a_p1z,float a_p1w,
454  float a_p2x,float a_p2y,float a_p2z,float a_p2w,
455  float a_p3x,float a_p3y,float a_p3z,float a_p3w){
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  }
461 
462  virtual bool add_triangle(
463  float a_p1x,float a_p1y,float a_p1z,float a_p1w,
464  float a_r1,float a_g1,float a_b1,float a_a1,
465  float a_p2x,float a_p2y,float a_p2z,float a_p2w,
466  float a_r2,float a_g2,float a_b2,float a_a2,
467  float a_p3x,float a_p3y,float a_p3z,float a_p3w,
468  float a_r3,float a_g3,float a_b3,float a_a3){
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  }
481 
482  virtual bool project_normal(float&,float&,float&) {
483  //return m_zb_action.project_normal(a_x,a_y,a_z);
484  return true;
485  }
486  virtual bool add_point_normal(float a_x,float a_y,float a_z,float a_w,
487  float /*a_nx*/,float /*a_ny*/,float /*a_nz*/) {
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  }
492  virtual bool add_point_normal(float a_x,float a_y,float a_z,float a_w,
493  float /*a_nx*/,float /*a_ny*/,float /*a_nz*/,
494  float a_r,float a_g,float a_b,float a_a) {
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  }
499  virtual bool add_line_normal(float a_bx,float a_by,float a_bz,float a_bw,
500  float /*a_bnx*/,float /*a_bny*/,float /*a_bnz*/,
501  float a_ex,float a_ey,float a_ez,float a_ew,
502  float /*a_enx*/,float /*a_eny*/,float /*a_enz*/) {
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  }
508  virtual bool add_line_normal(float a_bx,float a_by,float a_bz,float a_bw,
509  float /*a_bnx*/,float /*a_bny*/,float /*a_bnz*/,
510  float a_br,float a_bg,float a_bb,float a_ba,
511  float a_ex,float a_ey,float a_ez,float a_ew,
512  float /*a_enx*/,float /*a_eny*/,float /*a_enz*/,
513  float a_er,float a_eg,float a_eb,float a_ea){
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  }
519  virtual bool add_triangle_normal(
520  float a_p1x,float a_p1y,float a_p1z,float a_p1w,
521  float /*a_n1x*/,float /*a_n1y*/,float /*a_n1z*/,
522  float a_p2x,float a_p2y,float a_p2z,float a_p2w,
523  float /*a_n2x*/,float /*a_n2y*/,float /*a_n2z*/,
524  float a_p3x,float a_p3y,float a_p3z,float a_p3w,
525  float /*a_n3x*/,float /*a_n3y*/,float /*a_n3z*/) {
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  }
534  virtual bool add_triangle_normal(
535  float a_p1x,float a_p1y,float a_p1z,float a_p1w,
536  float /*a_n1x*/,float /*a_n1y*/,float /*a_n1z*/,
537  float a_r1,float a_g1,float a_b1,float a_a1,
538  float a_p2x,float a_p2y,float a_p2z,float a_p2w,
539  float /*a_n2x*/,float /*a_n2y*/,float /*a_n2z*/,
540  float a_r2,float a_g2,float a_b2,float a_a2,
541  float a_p3x,float a_p3y,float a_p3z,float a_p3w,
542  float /*a_n3x*/,float /*a_n3y*/,float /*a_n3z*/,
543  float a_r3,float a_g3,float a_b3,float a_a3){
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  }
555  public:
557  virtual ~primvis(){}
558  public:
559  primvis(const primvis& a_from)
560  :primitive_visitor(a_from)
561  ,m_zb_action(a_from.m_zb_action)
562  {}
563  primvis& operator=(const primvis& a_from){
565  return *this;
566  }
567  protected:
568  static void zinit(zb::point& a_p,float a_x,float a_y,float a_z) {
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  }
573 
574  unsigned int npix(float a_size) {
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  }
587 
588  bool _add_point(float a_x,float a_y,float a_z,const colorf& a_color){
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  }
617 
618  bool _add_triangle(float a_p1x,float a_p1y,float a_p1z,float a_p1w,
619  float a_p2x,float a_p2y,float a_p2z,float a_p2w,
620  float a_p3x,float a_p3y,float a_p3z,float a_p3w,
621  const colorf& a_color){
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()));
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  }
736  protected:
738  };
739 
740 protected:
745  mat4f m_proj_1; //OPTIMIZE : used if m_light_on true.
751 
752  // to be restored in restore_state() :
756  bool m_ccw;
765 };
766 
767 }}
768 
769 #endif
tools::colorf::set_b
void set_b(float a_v)
Definition: colorf:39
tools::sg::zb_action::get_rgb
static bool get_rgb(void *a_tag, unsigned int a_col, unsigned int a_row, VCol &a_r, VCol &a_g, VCol &a_b)
Definition: zb_action:296
tools::zb::buffer::set_depth_test
void set_depth_test(bool a_on)
Definition: buffer:184
tools::sg::zb_action::draw_vertex_normal_array
virtual void draw_vertex_normal_array(gl::mode_t a_mode, size_t a_floatn, const float *a_xyzs, const float *a_nms)
Definition: zb_action:44
tools::sg::zb_action::render_manager
virtual sg::render_manager & render_manager()
Definition: zb_action:162
tools::sg::primitive_visitor::add_primitive_normal_rgba
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)
Definition: primitive_visitor:1604
tools::zb::buffer::change_size
bool change_size(unsigned int a_width, unsigned int a_height)
Definition: buffer:187
tools::img< unsigned char >
tools::sg::zb_action::get_rgbs
unsigned char * get_rgbs(size_t &a_sz)
Definition: zb_action:360
tools::zb::buffer::get_pixel
bool get_pixel(const point &a_p, ZPixel &a_pixel)
Definition: buffer:291
tools::sg::zb_action::zbuffer
zb::buffer & zbuffer()
Definition: zb_action:247
tools::sg::zb_action::end_gsto
virtual void end_gsto()
Definition: zb_action:158
tools::sg::state
Definition: state:25
tools::colorf::set_g
void set_g(float a_v)
Definition: colorf:38
tools::vec3
Definition: vec3:16
tools::zb::buffer::get_clipped_pixel
bool get_clipped_pixel(ZPos a_x, ZPos a_y, ZPixel &a_pixel) const
Definition: buffer:264
primitive_visitor
tools::sg::zb_action::gen_rcmap
void gen_rcmap()
Definition: zb_action:285
tools::sg::zb_action::find_color
bool find_color(zb::buffer::ZPixel a_pix, colorf &a_rgba) const
Definition: zb_action:273
tools::sg::state::m_GL_LIGHTING
bool m_GL_LIGHTING
Definition: state:248
tools::sg::state::m_GL_DEPTH_TEST
bool m_GL_DEPTH_TEST
Definition: state:247
tools::sg::zb_action::load_proj_matrix
virtual void load_proj_matrix(const mat4f &a_mtx)
Definition: zb_action:81
tools::sg::zb_action::~zb_action
virtual ~zb_action()
Definition: zb_action:190
tools::sg::zb_action::line_width
virtual void line_width(float a_v)
Definition: zb_action:63
tools::mat4f::mul_3f
void mul_3f(float &a_x, float &a_y, float &a_z) const
Definition: mat4f:58
tools::sg::zb_action::rcolormap
rcmap_t & rcolormap()
Definition: zb_action:283
tools::sg::zb_action::load_model_matrix
virtual void load_model_matrix(const mat4f &a_mtx)
Definition: zb_action:86
tools::sg::zb_action::primvis::add_triangle_normal
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)
Definition: zb_action:534
tools::sg::winding_ccw
@ winding_ccw
Definition: enums:105
tools::sg::state::m_point_size
float m_point_size
Definition: state:269
tools::sg::zb_action::primvis::project
virtual bool project(float &a_x, float &a_y, float &a_z, float &a_w)
Definition: zb_action:398
tools::sg::zb_action::max_lights
virtual unsigned int max_lights()
Definition: zb_action:88
tools::zb::point::y
ZPos y
Definition: point:26
tools::sg::zb_action::enable_light
virtual void enable_light(unsigned int, float a_dx, float a_dy, float a_dz, float a_r, float a_g, float a_b, float a_a)
Definition: zb_action:90
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::colorf
Definition: colorf:11
tools::vec3::set_value
void set_value(const T &a0, const T &a1, const T &a2)
Definition: vec3:92
tools::plane
Definition: plane:12
render_action
tools::sg::primitive_visitor::add_primitive
bool add_primitive(gl::mode_t a_mode, size_t a_floatn, const float *a_xyzs, bool a_stop=false)
Definition: primitive_visitor:1518
tools::sg::state::m_GL_POLYGON_OFFSET_FILL
bool m_GL_POLYGON_OFFSET_FILL
Definition: state:250
tools::sg::zb_action::m_POINT_SMOOTH
bool m_POINT_SMOOTH
Definition: zb_action:759
tools::sg::primitive_visitor::add_primitive_normal
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)
Definition: primitive_visitor:1576
tools::sg::state::m_GL_CULL_FACE
bool m_GL_CULL_FACE
Definition: state:249
tools::sg::zb_action::primvis::project_normal
virtual bool project_normal(float &, float &, float &)
Definition: zb_action:482
tools::sg::win_action::m_wh
unsigned int m_wh
Definition: win_action:38
tools::sg::win_action::wh
unsigned int wh() const
Definition: win_action:35
tools::sg::shade_type
shade_type
Definition: enums:197
tools::mat4::mul_translate
void mul_translate(const T &a_x, const T &a_y, const T &a_z)
Definition: mat4:272
tools::sg::zb_action::m_ccw
bool m_ccw
Definition: zb_action:756
tools::sg::state::m_winding
winding_type m_winding
Definition: state:258
tools::sg::zb_action::draw_vertex_color_normal_array
virtual void draw_vertex_color_normal_array(gl::mode_t a_mode, size_t a_floatn, const float *a_xyzs, const float *a_rgbas, const float *a_nms)
Definition: zb_action:49
tools::sg::zb_action::add_color
zb::buffer::ZPixel add_color(float a_r, float a_g, float a_b, float a_a)
Definition: zb_action:253
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::win_action::m_ww
unsigned int m_ww
Definition: win_action:37
tools::sg::zb_action::m_light_direction
vec3f m_light_direction
Definition: zb_action:749
tools::sg::zb_action::m_proj
mat4f m_proj
Definition: zb_action:753
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::sg::primitive_visitor::add_primitive_rgba
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)
Definition: primitive_visitor:1546
tools::sg::primitive_visitor::add_texture
void add_texture(std::ostream &a_out, size_t a_xyzn, const float *a_xyzs, const img_byte &a_img, const float *a_tcs)
Definition: primitive_visitor:2047
tools::zb::ZZ
double ZZ
Definition: point:11
tools::sg::zb_action::m_mgr
zb_manager & m_mgr
Definition: zb_action:741
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_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)
Definition: zb_action:462
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::sg::zb_action::draw_gsto_vc
virtual void draw_gsto_vc(gl::mode_t, size_t, bufpos, bufpos)
Definition: zb_action:155
tools::sg::state::m_GL_POINT_SMOOTH
bool m_GL_POINT_SMOOTH
Definition: state:252
tools::vec3::y
const T & y() const
Definition: vec3:85
tools::sg::zb_action::set_blend
virtual void set_blend(bool)
Definition: zb_action:99
tools::mat4f::mul_4f
void mul_4f(float &a_x, float &a_y, float &a_z, float &a_w) const
Definition: mat4f:61
tools::plane::is_valid
bool is_valid() const
Definition: plane:56
tools::colorf::g
float g() const
Definition: colorf:33
tools::sg::render_action::gstoid
unsigned int gstoid
Definition: render_action:27
tools::sg::zb_action::reset
void reset()
Definition: zb_action:241
tools::sg::zb_action::primvis::m_zb_action
zb_action & m_zb_action
Definition: zb_action:737
tools::plane::normal
const VEC3 & normal() const
Definition: plane:88
tools::sg::zb_action::set_line_smooth
virtual void set_line_smooth(bool a_on)
Definition: zb_action:79
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::sg::zb_action::VCol
float VCol
Definition: zb_action:294
tools::sg::zb_action::primvis::add_triangle_normal
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)
Definition: zb_action:519
tools::rgb_to_hls
void rgb_to_hls(T rr, T gg, T bb, T &hue, T &light, T &satur)
Definition: hls:55
tools::plane::distance_from_origin
T distance_from_origin() const
Definition: plane:90
tools::zb::point::z
ZZ z
Definition: point:27
tools::sg::action::m_out
std::ostream & m_out
Definition: action:55
tools::zb::point::x
ZPos x
Definition: point:25
tools::vec3::x
const T & x() const
Definition: vec3:84
tools::uchar
unsigned char uchar
Definition: typedefs:99
tools::sg::zb_action::restore_state
virtual void restore_state(unsigned int)
Definition: zb_action:101
tools::sg::zb_action::m_zb
zb::buffer m_zb
Definition: zb_action:743
tools::sg::zb_action::add_color
zb::buffer::ZPixel add_color(const colorf &a_col)
Definition: zb_action:259
tools::sg::zb_action::primvis::~primvis
virtual ~primvis()
Definition: zb_action:557
tools::colorf::set_r
void set_r(float a_v)
Definition: colorf:37
tools::sg::render_manager
Definition: render_manager:16
tools::sg::zb_action::zbuffer
const zb::buffer & zbuffer() const
Definition: zb_action:246
tools::zb::buffer::clear_color_buffer
void clear_color_buffer(ZPixel a_pixel)
Definition: buffer:238
tools::sg::primitive_visitor::operator=
primitive_visitor & operator=(const primitive_visitor &)
Definition: primitive_visitor:61
tools::sg::zb_action::rcolormap
const rcmap_t & rcolormap() const
Definition: zb_action:282
tools::sg::zb_action::primvis::add_line_normal
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)
Definition: zb_action:508
TOOLS_ACTION
#define TOOLS_ACTION(a__class, a__sclass, a__parent)
Definition: action:60
tools::zb::point
Definition: point:13
tools::sg::zb_action::set_cull_face
virtual void set_cull_face(bool a_on)
Definition: zb_action:77
tools::sg::zb_action::draw_gsto_vcn
virtual void draw_gsto_vcn(gl::mode_t, size_t, bufpos, bufpos, bufpos)
Definition: zb_action:157
tools::sg::zb_action::primvis::add_point_normal
virtual bool add_point_normal(float a_x, float a_y, float a_z, float a_w, float, float, float)
Definition: zb_action:486
tools::sg::state::m_GL_LINE_SMOOTH
bool m_GL_LINE_SMOOTH
Definition: state:253
tools::sg::zb_action::m_model
mat4f m_model
Definition: zb_action:754
tools::sg::zb_action::primvis::primvis
primvis(const primvis &a_from)
Definition: zb_action:559
tools::sg::zb_action::set_point_smooth
virtual void set_point_smooth(bool a_on)
Definition: zb_action:78
tools::sg::zb_manager
Definition: zb_manager:18
tools::sg::zb_action::m_rgba
colorf m_rgba
Definition: zb_action:755
tools::colorf::a
float a() const
Definition: colorf:35
tools::sg::zb_action::primvis::npix
unsigned int npix(float a_size)
Definition: zb_action:574
tools::sg::zb_action::zb_action
zb_action(zb_manager &a_mgr, std::ostream &a_out, unsigned int a_ww, unsigned int a_wh)
Definition: zb_action:164
tools::vec3f
Definition: vec3f:13
tools::sg::render_action
Definition: render_action:24
tools::sg::zb_action::zb_action
zb_action(const zb_action &a_from)
Definition: zb_action:192
tools::gl::mode_t
unsigned char mode_t
Definition: glprims:14
tools::sg::zb_action::m_LINE_SMOOTH
bool m_LINE_SMOOTH
Definition: zb_action:760
tools::sg::zb_action::add_color
zb::buffer::ZPixel add_color(float a_r, float a_g, float a_b)
Definition: zb_action:256
tools::sg::zb_action::m_point_size
float m_point_size
Definition: zb_action:762
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::mat4::mul_scale
void mul_scale(const T &a_sx, const T &a_sy, const T &a_sz)
Definition: mat4:234
tools::sg::zb_action
Definition: zb_action:26
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::sg::state::m_proj
mat4f m_proj
Definition: state:244
tools::zb::buffer::ZPixel
unsigned int ZPixel
Definition: buffer:22
tools::zb::buffer
Definition: buffer:16
tools::sg::zb_action::draw_gsto_vn
virtual void draw_gsto_vn(gl::mode_t, size_t, bufpos, bufpos)
Definition: zb_action:156
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::vec4::set_value
void set_value(const T &a0, const T &a1, const T &a2, const T &a3)
Definition: vec4:100
tools::sg::zb_action::draw_vertex_array
virtual void draw_vertex_array(gl::mode_t a_mode, size_t a_floatn, const float *a_xyzs)
Definition: zb_action:31
tools::sg::winding_type
winding_type
Definition: enums:104
tools::sg::zb_action::primvis::add_point
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)
Definition: zb_action:405
tools::sg::state::m_model
mat4f m_model
Definition: state:245
tools::sg::zb_action::m_light_color
colorf m_light_color
Definition: zb_action:748
tools::sg::zb_action::rcmap_t
std::map< zb::buffer::ZPixel, colorf > rcmap_t
Definition: zb_action:281
tools::sg::zb_action::m_light_on
bool m_light_on
Definition: zb_action:763
tools::mat4f
Definition: mat4f:12
tools::sg::zb_action::draw_vertex_array_xy
virtual void draw_vertex_array_xy(gl::mode_t a_mode, size_t a_floatn, const float *a_xys)
Definition: zb_action:35
tools::sg::zb_action::primvis::add_line_normal
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)
Definition: zb_action:499
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::draw_vertex_normal_array_texture
virtual void draw_vertex_normal_array_texture(gl::mode_t a_mode, size_t a_xyzn, const float *a_xyzs, const float *, gstoid a_id, const float *a_tcs)
Definition: zb_action:144
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::primvis::operator=
primvis & operator=(const primvis &a_from)
Definition: zb_action:563
tools::sg::zb_action::primvis
Definition: zb_action:396
tools::sg::zb_action::m_vp_mtx
mat4f m_vp_mtx
Definition: zb_action:742
tools::sg::zb_action::begin_gsto
virtual void begin_gsto(gstoid)
VBO /////////////////////////////////////////////////////////.
Definition: zb_action:153
tools::sg::zb_action::draw_vertex_array_texture
virtual void draw_vertex_array_texture(gl::mode_t, size_t a_xyzn, const float *a_xyzs, gstoid a_id, const float *a_tcs)
texture /////////////////////////////////////////////////////
Definition: zb_action:136
tools::sg::zb_action::draw_vertex_color_array
virtual void draw_vertex_color_array(gl::mode_t a_mode, size_t a_floatn, const float *a_xyzs, const float *a_rgbas)
Definition: zb_action:39
tools::colorf::r
float r() const
Definition: colorf:32
tools::sg::zb_action::primvis::primvis
primvis(zb_action &a_zb)
Definition: zb_action:556
tools::sg::zb_action::clear_color
virtual void clear_color(float a_r, float a_g, float a_b, float a_a)
Definition: zb_action:56
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::sg::action::out
std::ostream & out() const
Definition: action:51
tools::vec3::z
const T & z() const
Definition: vec3:86
tools::sg::bufpos
size_t bufpos
Definition: render_action:22
tools::sg::zb_action::set_polygon_offset
virtual void set_polygon_offset(bool a_v)
Definition: zb_action:65
tools::sg::state::m_line_width
float m_line_width
Definition: state:267
tools::sg::zb_action::cmap_t
std::map< colorf, zb::buffer::ZPixel, cmp_colorf > cmap_t
Definition: zb_action:249
tools::sg::zb_action::normal
virtual void normal(float a_x, float a_y, float a_z)
Definition: zb_action:66
tools::sg::state::m_color
colorf m_color
Definition: state:259
tools::vec3f::normalize
float normalize()
Definition: vec3f:74
tools::sg::zb_action::m_rcmap
rcmap_t m_rcmap
Definition: zb_action:747
tools::sg::zb_action::color4f
virtual void color4f(float a_r, float a_g, float a_b, float a_a)
Definition: zb_action:60
tools::sg::zb_manager::find
bool find(unsigned int a_id, img_byte &a_img)
Definition: zb_manager:84
tools::sg::zb_action::point_size
virtual void point_size(float a_v)
Definition: zb_action:64
tools::sg::states::state
const sg::state & state() const
Definition: states:76
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::sg::zb_action::set_winding
virtual void set_winding(winding_type a_v)
Definition: zb_action:70
tools::sg::zb_action::m_normal
vec3f m_normal
Definition: zb_action:750
tools::sg::primitive_visitor
Definition: primitive_visitor:20
tools::sg::zb_action::primvis::add_line
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)
Definition: zb_action:430
tools::sg::zb_action::operator=
zb_action & operator=(const zb_action &a_from)
Definition: zb_action:216
tools::sg::zb_action::draw_gsto_v
virtual void draw_gsto_v(gl::mode_t, size_t, bufpos)
Definition: zb_action:154
tools::fround
int fround(const float &a_x)
Definition: mathf:27
tools::sg::zb_action::get_rgbas
unsigned char * get_rgbas(size_t &a_sz)
Definition: zb_action:328
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::add_primitive_xy
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)
Definition: primitive_visitor:1937
tools::sg::zb_action::set_shade_model
virtual void set_shade_model(shade_type)
Definition: zb_action:73
tools::sg::zb_action::m_cmap
cmap_t m_cmap
Definition: zb_action:746
tools::sg::zb_action::set_depth_test
virtual void set_depth_test(bool a_on)
Definition: zb_action:75
tools::sg::zb_action::primvis::add_point_normal
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)
Definition: zb_action:492
tools::sg::zb_action::m_pv
primvis m_pv
Definition: zb_action:744
tools::vec3::dot
T dot(const vec3 &aV) const
Definition: vec3:125
tools::colorf::b
float b() const
Definition: colorf:34
zb_manager
tools::sg::zb_action::set_lighting
virtual void set_lighting(bool a_on)
Definition: zb_action:98