Go to the documentation of this file.
4 #ifndef tools_sg_zb_action
5 #define tools_sg_zb_action
13 #include "../zb/buffer"
15 #include "../lina/plane"
19 #include "../lina/vec2f"
20 #include "../lina/vec3d"
21 #include "../lina/geom2"
40 const float* a_xyzs,
const float* a_rgbas){
45 const float* a_xyzs,
const float* a_nms){
50 const float* a_xyzs,
const float* a_rgbas,
const float* a_nms){
56 virtual void clear_color(
float a_r,
float a_g,
float a_b,
float a_a){
60 virtual void color4f(
float a_r,
float a_g,
float a_b,
float a_a){
66 virtual void normal(
float a_x,
float a_y,
float a_z) {
91 float a_dx,
float a_dy,
float a_dz,
92 float a_r,
float a_g,
float a_b,
float a_a){
137 gstoid a_id,
const float* a_tcs) {
145 size_t a_xyzn,
const float* a_xyzs,
const float* ,
146 gstoid a_id,
const float* a_tcs) {
165 :parent(a_out,a_ww,a_wh)
217 parent::operator=(a_from);
249 typedef std::map<colorf,zb::buffer::ZPixel,cmp_colorf>
cmap_t;
268 cmap_t::const_iterator it =
m_cmap.find(a_rgba);
269 if(it!=
m_cmap.end())
return (*it).second;
274 cmap_t::const_iterator it;
276 if((*it).second==a_pix) {a_rgba = (*it).first;
return true;}
281 typedef std::map<zb::buffer::ZPixel,colorf>
rcmap_t;
287 cmap_t::const_iterator it;
289 m_rcmap[(*it).second] = (*it).first;
302 rzb->
out() <<
"get_rgb : can't get zbuffer pixel" << std::endl;
311 {rcmap_t::const_iterator it = rzb->
rcolormap().find(pix);
313 rzb->
out() <<
"can't find pixel " << pix
314 <<
" in cmap (sz " << rzb->
rcolormap().size() <<
")."
321 a_r = (*it).second.r();
322 a_g = (*it).second.g();
323 a_b = (*it).second.b();}
329 if(!
m_ww || !
m_wh) {a_sz = 0;
return 0;}
331 typedef unsigned char uchar;
333 if(!rgbas) {a_sz = 0;
return 0;}
337 for(
unsigned int row=0;row<
m_wh;row++) {
338 for(
unsigned int col=0;col<
m_ww;col++) {
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++;
361 if(!
m_ww || !
m_wh) {a_sz = 0;
return 0;}
363 typedef unsigned char uchar;
365 if(!rgbs) {a_sz = 0;
return 0;}
368 for(
unsigned int row=0;row<
m_wh;row++) {
369 for(
unsigned int col=0;col<
m_ww;col++) {
371 *pos = (
uchar)(r*255.0F);pos++;
372 *pos = (
uchar)(g*255.0F);pos++;
373 *pos = (
uchar)(b*255.0F);pos++;
384 if(a_w==0)
return false;
398 virtual bool project(
float& a_x,
float& a_y,
float& a_z,
float& a_w) {
401 virtual bool add_point(
float a_x,
float a_y,
float a_z,
float) {
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);
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) {
419 zinit(beg,a_bx,a_by,a_bz);
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) {
440 zinit(beg,a_bx,a_by,a_bz);
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){
457 a_p2x,a_p2y,a_p2z,a_p2w,
458 a_p3x,a_p3y,a_p3z,a_p3w,
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){
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;
477 a_p2x,a_p2y,a_p2z,a_p2w,
478 a_p3x,a_p3y,a_p3z,a_p3w,
487 float ,
float ,
float ) {
493 float ,
float ,
float ,
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);
500 float ,
float ,
float ,
501 float a_ex,
float a_ey,
float a_ez,
float a_ew,
502 float ,
float ,
float ) {
503 add_line(a_bx,a_by,a_bz,a_bw, a_ex,a_ey,a_ez,a_ew);
509 float ,
float ,
float ,
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 ,
float ,
float ,
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);
520 float a_p1x,
float a_p1y,
float a_p1z,
float a_p1w,
521 float ,
float ,
float ,
522 float a_p2x,
float a_p2y,
float a_p2z,
float a_p2w,
523 float ,
float ,
float ,
524 float a_p3x,
float a_p3y,
float a_p3z,
float a_p3w,
525 float ,
float ,
float ) {
527 a_p2x,a_p2y,a_p2z,a_p2w,
528 a_p3x,a_p3y,a_p3z,a_p3w);
535 float a_p1x,
float a_p1y,
float a_p1z,
float a_p1w,
536 float ,
float ,
float ,
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 ,
float ,
float ,
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 ,
float ,
float ,
543 float a_r3,
float a_g3,
float a_b3,
float a_a3){
546 a_p2x,a_p2y,a_p2z,a_p2w,
548 a_p3x,a_p3y,a_p3z,a_p3w,
549 a_r3,a_g3,a_b3,a_a3);
574 unsigned int npix(
float a_size) {
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;}
595 zinit(p,a_x,a_y,a_z);
597 float alpha = a_color.
a();
604 float one_alpha = 1.0f-alpha;
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);
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,
623 float p1x = a_p1x;
float p1y = a_p1y;
float p1z = a_p1z;
624 float p2x = a_p2x;
float p2y = a_p2y;
float p2z = a_p2z;
625 float p3x = a_p3x;
float p3y = a_p3y;
float p3z = a_p3z;
659 if(C<=0)
return true;
661 if(C>=0)
return true;
673 zinit(list[0],p1x,p1y,p1z);
674 zinit(list[1],p2x,p2y,p2z);
675 zinit(list[2],p3x,p3y,p3z);
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;
685 _p1x *= _p1w;_p1y *= _p1w;_p1z *= _p1w;
686 _p2x *= _p2w;_p2y *= _p2w;_p2z *= _p2w;
687 _p3x *= _p3w;_p3y *= _p3w;_p3z *= _p3w;
709 float dot = npn.
dot(d);
710 if((-1<=dot)&&(dot<=0)) {
#define TOOLS_ACTION(a__class, a__sclass, a__parent)