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

Classes

class  primvis
 

Public Types

typedef std::map< zb::buffer::ZPixel, colorfrcmap_t
 
typedef float VCol
 
- Public Types inherited from tools::sg::render_action
typedef unsigned int gstoid
 

Public Member Functions

virtual void draw_vertex_array (gl::mode_t a_mode, size_t a_floatn, const float *a_xyzs)
 
virtual void draw_vertex_array_xy (gl::mode_t a_mode, size_t a_floatn, const float *a_xys)
 
virtual void draw_vertex_color_array (gl::mode_t a_mode, size_t a_floatn, const float *a_xyzs, const float *a_rgbas)
 
virtual void draw_vertex_normal_array (gl::mode_t a_mode, size_t a_floatn, const float *a_xyzs, const float *a_nms)
 
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)
 
virtual void clear_color (float a_r, float a_g, float a_b, float a_a)
 
virtual void color4f (float a_r, float a_g, float a_b, float a_a)
 
virtual void line_width (float a_v)
 
virtual void point_size (float a_v)
 
virtual void set_polygon_offset (bool a_v)
 
virtual void normal (float a_x, float a_y, float a_z)
 
virtual void set_winding (winding_type a_v)
 
virtual void set_shade_model (shade_type)
 
virtual void set_depth_test (bool a_on)
 
virtual void set_cull_face (bool a_on)
 
virtual void set_point_smooth (bool a_on)
 
virtual void set_line_smooth (bool a_on)
 
virtual void load_proj_matrix (const mat4f &a_mtx)
 
virtual void load_model_matrix (const mat4f &a_mtx)
 
virtual unsigned int max_lights ()
 
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)
 
virtual void set_lighting (bool a_on)
 
virtual void set_blend (bool)
 
virtual void restore_state (unsigned int)
 
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 ///////////////////////////////////////////////////// More...
 
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)
 
virtual void begin_gsto (gstoid)
 VBO /////////////////////////////////////////////////////////. More...
 
virtual void draw_gsto_v (gl::mode_t, size_t, bufpos)
 
virtual void draw_gsto_vc (gl::mode_t, size_t, bufpos, bufpos)
 
virtual void draw_gsto_vn (gl::mode_t, size_t, bufpos, bufpos)
 
virtual void draw_gsto_vcn (gl::mode_t, size_t, bufpos, bufpos, bufpos)
 
virtual void end_gsto ()
 
virtual sg::render_managerrender_manager ()
 
 zb_action (zb_manager &a_mgr, std::ostream &a_out, unsigned int a_ww, unsigned int a_wh)
 
virtual ~zb_action ()
 
void reset ()
 
const zb::bufferzbuffer () const
 
zb::bufferzbuffer ()
 
zb::buffer::ZPixel add_color (float a_r, float a_g, float a_b, float a_a)
 
zb::buffer::ZPixel add_color (float a_r, float a_g, float a_b)
 
zb::buffer::ZPixel add_color (const colorf &a_col)
 
zb::buffer::ZPixel get_pix (const colorf &a_rgba)
 
bool find_color (zb::buffer::ZPixel a_pix, colorf &a_rgba) const
 
const rcmap_trcolormap () const
 
rcmap_trcolormap ()
 
unsigned char * get_rgbas (size_t &a_sz)
 
unsigned char * get_rgbs (size_t &a_sz)
 
- Public Member Functions inherited from tools::sg::render_action
 render_action (std::ostream &a_out, unsigned int a_ww, unsigned int a_wh)
 
virtual ~render_action ()
 
 render_action (const render_action &a_from)
 
render_actionoperator= (const render_action &a_from)
 
void load_matrices_to_identity ()
 
void load_matrices_from_state ()
 
void clear_color (const colorf &a_color)
 
void color4f (const colorf &a_color)
 
void enable_light (unsigned int a_light, const vec3f &a_dir, const colorf &a_col)
 
void draw_vertex_array (gl::mode_t a_mode, const std::vector< float > &a_xyzs)
 
void draw_vertex_array_xy (gl::mode_t a_mode, const std::vector< float > &a_xys)
 
void draw_vertex_color_array (gl::mode_t a_mode, const std::vector< float > &a_xyzs, const std::vector< float > &a_rgbas)
 
void draw_vertex_normal_array (gl::mode_t a_mode, const std::vector< float > &a_xyzs, const std::vector< float > &a_nms)
 
void draw_vertex_color_normal_array (gl::mode_t a_mode, const std::vector< float > &a_xyzs, const std::vector< float > &a_rgbas, const std::vector< float > &a_nms)
 
void normal (const vec3f &a_vec)
 
bool add_triangles_normal (size_t a_floatn, const float *a_xyzs, const float *a_nms)
 
bool add_triangle_fan_normal (size_t a_floatn, const float *a_xyzs, const float *a_nms)
 
bool add_triangle_fan_normal_rgba (size_t a_floatn, const float *a_xyzs, float *a_nms, const float *a_rgbas)
 
bool add_triangle_strip_normal (size_t a_floatn, const float *a_xyzs, const float *a_nms)
 
bool add_triangle_strip_normal_rgba (size_t a_floatn, const float *a_xyzs, const float *a_nms, const float *a_rgbas)
 
bool add_lines (size_t a_floatn, const float *a_xyzs)
 
bool add_line_loop (size_t a_floatn, const float *a_xyzs)
 
bool add_line_strip (size_t a_floatn, const float *a_xyzs)
 
bool add_points (size_t a_floatn, const float *a_xyzs)
 
bool add_triangle_fan_texture_normal (size_t a_floatn, const float *a_xyzs, const float *a_nms, gstoid a_tex, const float *a_texs)
 
bool add_triangle_strip_texture_normal (size_t a_floatn, const float *a_xyzs, const float *a_nms, gstoid a_tex, const float *a_texs)
 
bool add_line_loop (const std::vector< float > &a_xyzs)
 
bool add_line_strip (const std::vector< float > &a_xyzs)
 
bool add_triangle_strip_as_triangles (size_t a_floatn, const float *a_xyzs, const float *a_nms)
 
void dump_vertex_array_xy (std::ostream &a_out, gl::mode_t, size_t a_floatn, const float *a_xys)
 
- Public Member Functions inherited from tools::sg::matrix_action
 matrix_action (std::ostream &a_out, unsigned int a_ww, unsigned int a_wh)
 
virtual ~matrix_action ()
 
 matrix_action (const matrix_action &a_from)
 
matrix_actionoperator= (const matrix_action &a_from)
 
void push_matrices ()
 
void pop_matrices ()
 
mat4fprojection_matrix ()
 
mat4fmodel_matrix ()
 
bool end () const
 
int cur () const
 
bool project_point (float &a_x, float &a_y, float &a_z, float &a_w)
 
void model_point (float &a_x, float &a_y, float &a_z, float &a_w)
 
void projected_origin (float &a_x, float &a_y, float &a_z)
 
- Public Member Functions inherited from tools::sg::win_action
 win_action (std::ostream &a_out, unsigned int a_ww, unsigned int a_wh)
 
virtual ~win_action ()
 
unsigned int ww () const
 
unsigned int wh () const
 
- Public Member Functions inherited from tools::sg::action
virtual void * cast (const std::string &a_class) const
 
virtual const std::string & s_cls () const =0
 
 action (std::ostream &a_out)
 
virtual ~action ()
 
std::ostream & out () const
 
- Public Member Functions inherited from tools::sg::states
 states (unsigned int a_ww, unsigned int a_wh)
 
virtual ~states ()
 
const sg::statestate () const
 
sg::statestate ()
 
void pop_state ()
 
void push_state ()
 
void save_state (const sg::state &a_state)
 
const sg::statesaved_state () const
 
sg::statesaved_state ()
 

Static Public Member Functions

static bool get_rgb (void *a_tag, unsigned int a_col, unsigned int a_row, VCol &a_r, VCol &a_g, VCol &a_b)
 

Protected Types

typedef std::map< colorf, zb::buffer::ZPixel, cmp_colorfcmap_t
 

Protected Member Functions

 zb_action (const zb_action &a_from)
 
zb_actionoperator= (const zb_action &a_from)
 
void gen_rcmap ()
 
bool project_point (float &a_x, float &a_y, float &a_z, float &a_w)
 
- Protected Member Functions inherited from tools::sg::matrix_action
void reset ()
 
- Protected Member Functions inherited from tools::sg::win_action
 win_action (const win_action &a_from)
 
win_actionoperator= (const win_action &a_from)
 
- Protected Member Functions inherited from tools::sg::action
 action (const action &a_from)
 
actionoperator= (const action &)
 
- Protected Member Functions inherited from tools::sg::states
 states (const states &a_from)
 
statesoperator= (const states &a_from)
 

Protected Attributes

zb_managerm_mgr
 
mat4f m_vp_mtx
 
zb::buffer m_zb
 
primvis m_pv
 
mat4f m_proj_1
 
cmap_t m_cmap
 
rcmap_t m_rcmap
 
colorf m_light_color
 
vec3f m_light_direction
 
vec3f m_normal
 
mat4f m_proj
 
mat4f m_model
 
colorf m_rgba
 
bool m_ccw
 
bool m_POLYGON_OFFSET_FILL
 
bool m_CULL_FACE
 
bool m_POINT_SMOOTH
 
bool m_LINE_SMOOTH
 
float m_line_width
 
float m_point_size
 
bool m_light_on
 
bool m_DEPTH_TEST
 
- Protected Attributes inherited from tools::sg::matrix_action
std::vector< mat4fm_projs
 
std::vector< mat4fm_models
 
int m_cur
 
mat4f m_identity
 
- Protected Attributes inherited from tools::sg::win_action
unsigned int m_ww
 
unsigned int m_wh
 
- Protected Attributes inherited from tools::sg::action
std::ostream & m_out
 
- Protected Attributes inherited from tools::sg::states
std::vector< sg::statem_states
 
sg::state m_state
 
sg::state m_saved_state
 

Detailed Description

Definition at line 26 of file zb_action.

Member Typedef Documentation

◆ cmap_t

Definition at line 249 of file zb_action.

◆ rcmap_t

Definition at line 281 of file zb_action.

◆ VCol

Definition at line 294 of file zb_action.

Constructor & Destructor Documentation

◆ zb_action() [1/2]

tools::sg::zb_action::zb_action ( zb_manager a_mgr,
std::ostream &  a_out,
unsigned int  a_ww,
unsigned int  a_wh 
)
inline

Definition at line 164 of file zb_action.

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  }

◆ ~zb_action()

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

Definition at line 190 of file zb_action.

190 {}

◆ zb_action() [2/2]

tools::sg::zb_action::zb_action ( const zb_action a_from)
inlineprotected

Definition at line 192 of file zb_action.

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)
199  ,m_light_color(a_from.m_light_color)
200  ,m_light_direction(a_from.m_light_direction)
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)
207  ,m_POLYGON_OFFSET_FILL(a_from.m_POLYGON_OFFSET_FILL)
208  ,m_CULL_FACE(a_from.m_CULL_FACE)
209  ,m_POINT_SMOOTH(a_from.m_POINT_SMOOTH)
210  ,m_LINE_SMOOTH(a_from.m_LINE_SMOOTH)
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  {}

Member Function Documentation

◆ add_color() [1/3]

zb::buffer::ZPixel tools::sg::zb_action::add_color ( const colorf a_col)
inline

Definition at line 259 of file zb_action.

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

◆ add_color() [2/3]

zb::buffer::ZPixel tools::sg::zb_action::add_color ( float  a_r,
float  a_g,
float  a_b 
)
inline

Definition at line 256 of file zb_action.

256  {
257  return add_color(a_r,a_g,a_b,1);
258  }

◆ add_color() [3/3]

zb::buffer::ZPixel tools::sg::zb_action::add_color ( float  a_r,
float  a_g,
float  a_b,
float  a_a 
)
inline

Definition at line 253 of file zb_action.

253  {
254  return add_color(colorf(a_r,a_g,a_b,a_a));
255  }

◆ begin_gsto()

virtual void tools::sg::zb_action::begin_gsto ( gstoid  )
inlinevirtual

VBO /////////////////////////////////////////////////////////.

Implements tools::sg::render_action.

Definition at line 153 of file zb_action.

153 {}

◆ clear_color()

virtual void tools::sg::zb_action::clear_color ( float  a_r,
float  a_g,
float  a_b,
float  a_a 
)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 56 of file zb_action.

56  {
57  zb::buffer::ZPixel px = get_pix(colorf(a_r,a_g,a_b,a_a));
59  }

◆ color4f()

virtual void tools::sg::zb_action::color4f ( float  a_r,
float  a_g,
float  a_b,
float  a_a 
)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 60 of file zb_action.

60  {
61  m_rgba.set_value(a_r,a_g,a_b,a_a);
62  }

◆ draw_gsto_v()

virtual void tools::sg::zb_action::draw_gsto_v ( gl::mode_t  ,
size_t  ,
bufpos   
)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 154 of file zb_action.

154 {}

◆ draw_gsto_vc()

virtual void tools::sg::zb_action::draw_gsto_vc ( gl::mode_t  ,
size_t  ,
bufpos  ,
bufpos   
)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 155 of file zb_action.

155 {}

◆ draw_gsto_vcn()

virtual void tools::sg::zb_action::draw_gsto_vcn ( gl::mode_t  ,
size_t  ,
bufpos  ,
bufpos  ,
bufpos   
)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 157 of file zb_action.

157 {}

◆ draw_gsto_vn()

virtual void tools::sg::zb_action::draw_gsto_vn ( gl::mode_t  ,
size_t  ,
bufpos  ,
bufpos   
)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 156 of file zb_action.

156 {}

◆ draw_vertex_array()

virtual void tools::sg::zb_action::draw_vertex_array ( gl::mode_t  a_mode,
size_t  a_floatn,
const float *  a_xyzs 
)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 31 of file zb_action.

31  {
32  m_pv.add_primitive(a_mode,a_floatn,a_xyzs);
33  }

◆ draw_vertex_array_texture()

virtual void tools::sg::zb_action::draw_vertex_array_texture ( gl::mode_t  ,
size_t  a_xyzn,
const float *  a_xyzs,
gstoid  a_id,
const float *  a_tcs 
)
inlinevirtual

texture /////////////////////////////////////////////////////

Implements tools::sg::render_action.

Definition at line 136 of file zb_action.

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

◆ draw_vertex_array_xy()

virtual void tools::sg::zb_action::draw_vertex_array_xy ( gl::mode_t  a_mode,
size_t  a_floatn,
const float *  a_xys 
)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 35 of file zb_action.

35  {
36  m_pv.add_primitive_xy(a_mode,a_floatn,a_xys);
37  }

◆ draw_vertex_color_array()

virtual void tools::sg::zb_action::draw_vertex_color_array ( gl::mode_t  a_mode,
size_t  a_floatn,
const float *  a_xyzs,
const float *  a_rgbas 
)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 39 of file zb_action.

40  {
41  m_pv.add_primitive_rgba(a_mode,a_floatn,a_xyzs,a_rgbas);
42  }

◆ draw_vertex_color_normal_array()

virtual void tools::sg::zb_action::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 
)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 49 of file zb_action.

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

◆ draw_vertex_normal_array()

virtual void tools::sg::zb_action::draw_vertex_normal_array ( gl::mode_t  a_mode,
size_t  a_floatn,
const float *  a_xyzs,
const float *  a_nms 
)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 44 of file zb_action.

45  {
46  m_pv.add_primitive_normal(a_mode,a_floatn,a_xyzs,a_nms);
47  }

◆ draw_vertex_normal_array_texture()

virtual void tools::sg::zb_action::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 
)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 144 of file zb_action.

146  {
147  draw_vertex_array_texture(a_mode,a_xyzn,a_xyzs,a_id,a_tcs);
148  }

◆ enable_light()

virtual void tools::sg::zb_action::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 
)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 90 of file zb_action.

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

◆ end_gsto()

virtual void tools::sg::zb_action::end_gsto ( )
inlinevirtual

Implements tools::sg::render_action.

Definition at line 158 of file zb_action.

158 {}

◆ find_color()

bool tools::sg::zb_action::find_color ( zb::buffer::ZPixel  a_pix,
colorf a_rgba 
) const
inline

Definition at line 273 of file zb_action.

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

◆ gen_rcmap()

void tools::sg::zb_action::gen_rcmap ( )
inlineprotected

Definition at line 285 of file zb_action.

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

◆ get_pix()

zb::buffer::ZPixel tools::sg::zb_action::get_pix ( const colorf a_rgba)
inline

Definition at line 267 of file zb_action.

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

◆ get_rgb()

static bool tools::sg::zb_action::get_rgb ( void *  a_tag,
unsigned int  a_col,
unsigned int  a_row,
VCol a_r,
VCol a_g,
VCol a_b 
)
inlinestatic

Definition at line 296 of file zb_action.

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

◆ get_rgbas()

unsigned char* tools::sg::zb_action::get_rgbas ( size_t &  a_sz)
inline

Definition at line 328 of file zb_action.

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

◆ get_rgbs()

unsigned char* tools::sg::zb_action::get_rgbs ( size_t &  a_sz)
inline

Definition at line 360 of file zb_action.

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

◆ line_width()

virtual void tools::sg::zb_action::line_width ( float  a_v)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 63 of file zb_action.

63 {m_line_width = a_v;}

◆ load_model_matrix()

virtual void tools::sg::zb_action::load_model_matrix ( const mat4f a_mtx)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 86 of file zb_action.

86 {m_model = a_mtx;}

◆ load_proj_matrix()

virtual void tools::sg::zb_action::load_proj_matrix ( const mat4f a_mtx)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 81 of file zb_action.

81  {
82  m_proj = a_mtx;
83  if(!m_proj.invert(m_proj_1)){}
84  }

◆ max_lights()

virtual unsigned int tools::sg::zb_action::max_lights ( )
inlinevirtual

Implements tools::sg::render_action.

Definition at line 88 of file zb_action.

88 {return 1000;}

◆ normal()

virtual void tools::sg::zb_action::normal ( float  a_x,
float  a_y,
float  a_z 
)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 66 of file zb_action.

66  {
67  m_normal.set_value(a_x,a_y,a_z);
68  }

◆ operator=()

zb_action& tools::sg::zb_action::operator= ( const zb_action a_from)
inlineprotected

Definition at line 216 of file zb_action.

216  {
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;
223  m_light_direction = a_from.m_light_direction;
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;
230  m_POLYGON_OFFSET_FILL = a_from.m_POLYGON_OFFSET_FILL;
231  m_CULL_FACE = a_from.m_CULL_FACE;
232  m_POINT_SMOOTH = a_from.m_POINT_SMOOTH;
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  }

◆ point_size()

virtual void tools::sg::zb_action::point_size ( float  a_v)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 64 of file zb_action.

64 {m_point_size = a_v;}

◆ project_point()

bool tools::sg::zb_action::project_point ( float &  a_x,
float &  a_y,
float &  a_z,
float &  a_w 
)
inlineprotected

Definition at line 380 of file zb_action.

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

◆ rcolormap() [1/2]

rcmap_t& tools::sg::zb_action::rcolormap ( )
inline

Definition at line 283 of file zb_action.

283 {return m_rcmap;}

◆ rcolormap() [2/2]

const rcmap_t& tools::sg::zb_action::rcolormap ( ) const
inline

Definition at line 282 of file zb_action.

282 {return m_rcmap;}

◆ render_manager()

virtual sg::render_manager& tools::sg::zb_action::render_manager ( )
inlinevirtual

Implements tools::sg::render_action.

Definition at line 162 of file zb_action.

162 {return m_mgr;}

◆ reset()

void tools::sg::zb_action::reset ( )
inline

Definition at line 241 of file zb_action.

241  {
242  m_cmap.clear();
243  m_rcmap.clear();
244  }

◆ restore_state()

virtual void tools::sg::zb_action::restore_state ( unsigned int  )
inlinevirtual

Implements tools::sg::render_action.

Definition at line 101 of file zb_action.

101  {
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);
110  m_POLYGON_OFFSET_FILL = _state.m_GL_POLYGON_OFFSET_FILL;
111  m_CULL_FACE = _state.m_GL_CULL_FACE;
112  m_POINT_SMOOTH = _state.m_GL_POINT_SMOOTH;
113  m_LINE_SMOOTH = _state.m_GL_LINE_SMOOTH;
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  }

◆ set_blend()

virtual void tools::sg::zb_action::set_blend ( bool  )
inlinevirtual

Implements tools::sg::render_action.

Definition at line 99 of file zb_action.

99 {}

◆ set_cull_face()

virtual void tools::sg::zb_action::set_cull_face ( bool  a_on)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 77 of file zb_action.

77 {m_CULL_FACE = a_on;}

◆ set_depth_test()

virtual void tools::sg::zb_action::set_depth_test ( bool  a_on)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 75 of file zb_action.

75 {m_DEPTH_TEST = a_on;}

◆ set_lighting()

virtual void tools::sg::zb_action::set_lighting ( bool  a_on)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 98 of file zb_action.

98 {m_light_on = a_on;}

◆ set_line_smooth()

virtual void tools::sg::zb_action::set_line_smooth ( bool  a_on)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 79 of file zb_action.

79 {m_LINE_SMOOTH = a_on;}

◆ set_point_smooth()

virtual void tools::sg::zb_action::set_point_smooth ( bool  a_on)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 78 of file zb_action.

78 {m_POINT_SMOOTH = a_on;}

◆ set_polygon_offset()

virtual void tools::sg::zb_action::set_polygon_offset ( bool  a_v)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 65 of file zb_action.

65 {m_POLYGON_OFFSET_FILL = a_v;}

◆ set_shade_model()

virtual void tools::sg::zb_action::set_shade_model ( shade_type  )
inlinevirtual

Implements tools::sg::render_action.

Definition at line 73 of file zb_action.

73 {}

◆ set_winding()

virtual void tools::sg::zb_action::set_winding ( winding_type  a_v)
inlinevirtual

Implements tools::sg::render_action.

Definition at line 70 of file zb_action.

70  {
71  m_ccw = (a_v==winding_ccw?true:false);
72  }

◆ zbuffer() [1/2]

zb::buffer& tools::sg::zb_action::zbuffer ( )
inline

Definition at line 247 of file zb_action.

247 {return m_zb;}

◆ zbuffer() [2/2]

const zb::buffer& tools::sg::zb_action::zbuffer ( ) const
inline

Definition at line 246 of file zb_action.

246 {return m_zb;}

Member Data Documentation

◆ m_ccw

bool tools::sg::zb_action::m_ccw
protected

Definition at line 756 of file zb_action.

◆ m_cmap

cmap_t tools::sg::zb_action::m_cmap
protected

Definition at line 746 of file zb_action.

◆ m_CULL_FACE

bool tools::sg::zb_action::m_CULL_FACE
protected

Definition at line 758 of file zb_action.

◆ m_DEPTH_TEST

bool tools::sg::zb_action::m_DEPTH_TEST
protected

Definition at line 764 of file zb_action.

◆ m_light_color

colorf tools::sg::zb_action::m_light_color
protected

Definition at line 748 of file zb_action.

◆ m_light_direction

vec3f tools::sg::zb_action::m_light_direction
protected

Definition at line 749 of file zb_action.

◆ m_light_on

bool tools::sg::zb_action::m_light_on
protected

Definition at line 763 of file zb_action.

◆ m_LINE_SMOOTH

bool tools::sg::zb_action::m_LINE_SMOOTH
protected

Definition at line 760 of file zb_action.

◆ m_line_width

float tools::sg::zb_action::m_line_width
protected

Definition at line 761 of file zb_action.

◆ m_mgr

zb_manager& tools::sg::zb_action::m_mgr
protected

Definition at line 741 of file zb_action.

◆ m_model

mat4f tools::sg::zb_action::m_model
protected

Definition at line 754 of file zb_action.

◆ m_normal

vec3f tools::sg::zb_action::m_normal
protected

Definition at line 750 of file zb_action.

◆ m_point_size

float tools::sg::zb_action::m_point_size
protected

Definition at line 762 of file zb_action.

◆ m_POINT_SMOOTH

bool tools::sg::zb_action::m_POINT_SMOOTH
protected

Definition at line 759 of file zb_action.

◆ m_POLYGON_OFFSET_FILL

bool tools::sg::zb_action::m_POLYGON_OFFSET_FILL
protected

Definition at line 757 of file zb_action.

◆ m_proj

mat4f tools::sg::zb_action::m_proj
protected

Definition at line 753 of file zb_action.

◆ m_proj_1

mat4f tools::sg::zb_action::m_proj_1
protected

Definition at line 745 of file zb_action.

◆ m_pv

primvis tools::sg::zb_action::m_pv
protected

Definition at line 744 of file zb_action.

◆ m_rcmap

rcmap_t tools::sg::zb_action::m_rcmap
protected

Definition at line 747 of file zb_action.

◆ m_rgba

colorf tools::sg::zb_action::m_rgba
protected

Definition at line 755 of file zb_action.

◆ m_vp_mtx

mat4f tools::sg::zb_action::m_vp_mtx
protected

Definition at line 742 of file zb_action.

◆ m_zb

zb::buffer tools::sg::zb_action::m_zb
protected

Definition at line 743 of file zb_action.


The documentation for this class was generated from the following file:
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::img_byte
img< unsigned char > img_byte
Definition: img:894
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::sg::winding_ccw
@ winding_ccw
Definition: enums:105
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::vec3::set_value
void set_value(const T &a0, const T &a1, const T &a2)
Definition: vec3:92
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::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::win_action::m_wh
unsigned int m_wh
Definition: win_action:38
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::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::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::sg::zb_action::m_mgr
zb_manager & m_mgr
Definition: zb_action:741
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::VCol
float VCol
Definition: zb_action:294
tools::sg::action::m_out
std::ostream & m_out
Definition: action:55
tools::uchar
unsigned char uchar
Definition: typedefs:99
tools::sg::zb_action::m_zb
zb::buffer m_zb
Definition: zb_action:743
tools::zb::buffer::clear_color_buffer
void clear_color_buffer(ZPixel a_pixel)
Definition: buffer:238
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::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::sg::zb_action::m_LINE_SMOOTH
bool m_LINE_SMOOTH
Definition: zb_action:760
tools::sg::zb_action::m_point_size
float m_point_size
Definition: zb_action:762
tools::mat4::mul_scale
void mul_scale(const T &a_sx, const T &a_sy, const T &a_sz)
Definition: mat4:234
tools::zb::buffer::ZPixel
unsigned int ZPixel
Definition: buffer:22
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::m_light_color
colorf m_light_color
Definition: zb_action:748
tools::sg::zb_action::m_light_on
bool m_light_on
Definition: zb_action:763
tools::sg::zb_action::get_pix
zb::buffer::ZPixel get_pix(const colorf &a_rgba)
Definition: zb_action:267
tools::sg::zb_action::m_POLYGON_OFFSET_FILL
bool m_POLYGON_OFFSET_FILL
Definition: zb_action:757
tools::sg::zb_action::m_vp_mtx
mat4f m_vp_mtx
Definition: zb_action:742
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::m_rcmap
rcmap_t m_rcmap
Definition: zb_action:747
tools::sg::zb_manager::find
bool find(unsigned int a_id, img_byte &a_img)
Definition: zb_manager:84
tools::sg::states::state
const sg::state & state() const
Definition: states:76
tools::sg::zb_action::m_normal
vec3f m_normal
Definition: zb_action:750
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::m_cmap
cmap_t m_cmap
Definition: zb_action:746
tools::sg::zb_action::m_pv
primvis m_pv
Definition: zb_action:744