Import Geant4 10.7.0 source tree
This commit is contained in:
@@ -24,6 +24,8 @@ namespace tools {
|
||||
namespace sg {
|
||||
|
||||
class zb_action : public render_action {
|
||||
TOOLS_ACTION(zb_action,tools::sg::zb_action,render_action)
|
||||
private:
|
||||
zb_action& get_me() {return *this;}
|
||||
public:
|
||||
virtual void draw_vertex_array(gl::mode_t a_mode,size_t a_floatn,const float* a_xyzs){
|
||||
@@ -36,19 +38,19 @@ public:
|
||||
|
||||
virtual void draw_vertex_color_array(gl::mode_t a_mode,size_t a_floatn,
|
||||
const float* a_xyzs,const float* a_rgbas){
|
||||
m_pv.add_primitive(a_mode,a_floatn,a_xyzs,a_rgbas);
|
||||
m_pv.add_primitive_rgba(a_mode,a_floatn,a_xyzs,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*/){
|
||||
m_pv.add_primitive(a_mode,a_floatn,a_xyzs);
|
||||
const float* a_xyzs,const float* a_nms){
|
||||
m_pv.add_primitive_normal(a_mode,a_floatn,a_xyzs,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*/){
|
||||
const float* a_xyzs,const float* a_rgbas,const float* a_nms){
|
||||
// We expect a_nms of size : 3*(a_floatn/3)
|
||||
// (then one normal per 3D point).
|
||||
m_pv.add_primitive(a_mode,a_floatn,a_xyzs,a_rgbas);
|
||||
m_pv.add_primitive_normal_rgba(a_mode,a_floatn,a_xyzs,a_nms,a_rgbas);
|
||||
}
|
||||
|
||||
virtual void clear_color(float a_r,float a_g,float a_b,float a_a){
|
||||
@@ -102,7 +104,7 @@ public:
|
||||
m_model = _state.m_model;
|
||||
|
||||
if(!m_proj.invert(m_proj_1)){}
|
||||
|
||||
|
||||
m_rgba = _state.m_color;
|
||||
m_ccw = (_state.m_winding==winding_ccw?true:false);
|
||||
m_POLYGON_OFFSET_FILL = _state.m_GL_POLYGON_OFFSET_FILL;
|
||||
@@ -135,7 +137,7 @@ public:
|
||||
gstoid a_id,const float* a_tcs) {
|
||||
//::printf("debug : zb_action : 000 : %d\n",a_id);
|
||||
img_byte img;
|
||||
if(!m_mgr.find(a_id,img)) return;
|
||||
if(!m_mgr.find(a_id,img)) return;
|
||||
m_pv.add_texture(m_out,a_xyzn,a_xyzs,img,a_tcs);
|
||||
}
|
||||
|
||||
@@ -160,11 +162,12 @@ public:
|
||||
virtual sg::render_manager& render_manager() {return m_mgr;}
|
||||
public:
|
||||
zb_action(zb_manager& a_mgr,std::ostream& a_out,unsigned int a_ww,unsigned int a_wh)
|
||||
:render_action(a_out,a_ww,a_wh)
|
||||
:parent(a_out,a_ww,a_wh)
|
||||
,m_mgr(a_mgr)
|
||||
,m_pv(get_me())
|
||||
,m_light_color(colorf_white())
|
||||
,m_light_direction(vec3f(0,0,-1))
|
||||
,m_normal(0,0,1)
|
||||
|
||||
,m_ccw(true)
|
||||
,m_POLYGON_OFFSET_FILL(false)
|
||||
@@ -182,12 +185,12 @@ public:
|
||||
|
||||
m_zb.change_size(a_ww,a_wh);
|
||||
// m_zb.clear_color_buffer(0);
|
||||
// m_zb.clear_depth_buffer();
|
||||
// m_zb.clear_depth_buffer();
|
||||
}
|
||||
virtual ~zb_action(){}
|
||||
protected:
|
||||
zb_action(const zb_action& a_from)
|
||||
:render_action(a_from)
|
||||
:parent(a_from)
|
||||
,m_mgr(a_from.m_mgr)
|
||||
,m_vp_mtx(a_from.m_vp_mtx)
|
||||
//,m_buffer(a_from.m_buffer)
|
||||
@@ -211,7 +214,7 @@ protected:
|
||||
,m_DEPTH_TEST(a_from.m_DEPTH_TEST)
|
||||
{}
|
||||
zb_action& operator=(const zb_action& a_from){
|
||||
render_action::operator=(a_from);
|
||||
parent::operator=(a_from);
|
||||
m_vp_mtx = a_from.m_vp_mtx;
|
||||
//m_buffer = a_from.m_buffer;
|
||||
m_pv = a_from.m_pv;
|
||||
@@ -261,7 +264,7 @@ public:
|
||||
return pix;
|
||||
}
|
||||
|
||||
zb::buffer::ZPixel get_pix(const colorf& a_rgba) {
|
||||
zb::buffer::ZPixel get_pix(const colorf& a_rgba) {
|
||||
cmap_t::const_iterator it = m_cmap.find(a_rgba);
|
||||
if(it!=m_cmap.end()) return (*it).second;
|
||||
return add_color(a_rgba);
|
||||
@@ -271,7 +274,7 @@ public:
|
||||
cmap_t::const_iterator it;
|
||||
for(it=m_cmap.begin();it!=m_cmap.end();++it){
|
||||
if((*it).second==a_pix) {a_rgba = (*it).first;return true;}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -284,7 +287,7 @@ protected:
|
||||
cmap_t::const_iterator it;
|
||||
for(it=m_cmap.begin();it!=m_cmap.end();++it){
|
||||
m_rcmap[(*it).second] = (*it).first;
|
||||
}
|
||||
}
|
||||
}
|
||||
public:
|
||||
//typedef wps::VCol VCol;
|
||||
@@ -292,7 +295,7 @@ public:
|
||||
|
||||
static bool get_rgb(void* a_tag,unsigned int a_col,unsigned int a_row,VCol& a_r,VCol& a_g,VCol& a_b){
|
||||
//used with wps.
|
||||
zb_action* rzb = (zb_action*)a_tag;
|
||||
zb_action* rzb = (zb_action*)a_tag;
|
||||
|
||||
zb::buffer::ZPixel pix;
|
||||
if(!rzb->zbuffer().get_clipped_pixel(a_col,rzb->wh()-1-a_row,pix)){
|
||||
@@ -308,7 +311,7 @@ public:
|
||||
{rcmap_t::const_iterator it = rzb->rcolormap().find(pix);
|
||||
if(it==rzb->rcolormap().end()) {
|
||||
rzb->out() << "can't find pixel " << pix
|
||||
<< " in cmap (sz " << rzb->rcolormap().size() << ")."
|
||||
<< " in cmap (sz " << rzb->rcolormap().size() << ")."
|
||||
<< std::endl;
|
||||
a_r = 1;
|
||||
a_g = 0;
|
||||
@@ -384,6 +387,11 @@ protected:
|
||||
a_z /= a_w;
|
||||
return true;
|
||||
}
|
||||
// bool project_normal(float& a_x,float& a_y,float& a_z) {
|
||||
// m_model.mul_dir_3f(a_x,a_y,a_z);
|
||||
// m_proj.mul_dir_3f(a_x,a_y,a_z);
|
||||
// return true;
|
||||
// }
|
||||
|
||||
class primvis : public primitive_visitor {
|
||||
protected:
|
||||
@@ -393,20 +401,20 @@ protected:
|
||||
virtual bool add_point(float a_x,float a_y,float a_z,float) {
|
||||
return _add_point(a_x,a_y,a_z,m_zb_action.m_rgba);
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
colorf c(a_r,a_g,a_b,a_a);
|
||||
colorf c(a_r,a_g,a_b,a_a);
|
||||
return _add_point(a_x,a_y,a_z,c);
|
||||
}
|
||||
|
||||
|
||||
virtual bool add_line(float a_bx,float a_by,float a_bz,float,
|
||||
float a_ex,float a_ey,float a_ez,float) {
|
||||
m_zb_action.m_vp_mtx.mul_3f(a_bx,a_by,a_bz);
|
||||
m_zb_action.m_vp_mtx.mul_3f(a_ex,a_ey,a_ez);
|
||||
a_bz *= -1;
|
||||
a_ez *= -1;
|
||||
|
||||
|
||||
zb::point beg;
|
||||
zinit(beg,a_bx,a_by,a_bz);
|
||||
|
||||
@@ -414,11 +422,11 @@ protected:
|
||||
zinit(end,a_ex,a_ey,a_ez);
|
||||
|
||||
m_zb_action.m_zb.set_depth_test(m_zb_action.m_DEPTH_TEST);
|
||||
m_zb_action.m_zb.draw_line(beg,end,m_zb_action.get_pix(m_zb_action.m_rgba),npix(m_zb_action.m_line_width));
|
||||
m_zb_action.m_zb.draw_line(beg,end,m_zb_action.get_pix(m_zb_action.m_rgba),npix(m_zb_action.m_line_width));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
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,
|
||||
@@ -427,7 +435,7 @@ protected:
|
||||
m_zb_action.m_vp_mtx.mul_3f(a_ex,a_ey,a_ez);
|
||||
a_bz *= -1;
|
||||
a_ez *= -1;
|
||||
|
||||
|
||||
zb::point beg;
|
||||
zinit(beg,a_bx,a_by,a_bz);
|
||||
|
||||
@@ -437,11 +445,11 @@ protected:
|
||||
m_zb_action.m_zb.set_depth_test(m_zb_action.m_DEPTH_TEST);
|
||||
|
||||
// interpolate color with beg,end ?
|
||||
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));
|
||||
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));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
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){
|
||||
@@ -453,11 +461,11 @@ protected:
|
||||
|
||||
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_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_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){
|
||||
float a_r3,float a_g3,float a_b3,float a_a3){
|
||||
|
||||
float r = (a_r1+a_r2+a_r3)/3.0f;
|
||||
float g = (a_g1+a_g2+a_g3)/3.0f;
|
||||
@@ -471,6 +479,79 @@ protected:
|
||||
col);
|
||||
}
|
||||
|
||||
virtual bool project_normal(float&,float&,float&) {
|
||||
//return m_zb_action.project_normal(a_x,a_y,a_z);
|
||||
return true;
|
||||
}
|
||||
virtual bool add_point_normal(float a_x,float a_y,float a_z,float a_w,
|
||||
float /*a_nx*/,float /*a_ny*/,float /*a_nz*/) {
|
||||
add_point(a_x,a_y,a_z,a_w);
|
||||
//m_this.m_points.add_normal(a_nx,a_ny,a_nz);
|
||||
return true;
|
||||
}
|
||||
virtual bool add_point_normal(float a_x,float a_y,float a_z,float a_w,
|
||||
float /*a_nx*/,float /*a_ny*/,float /*a_nz*/,
|
||||
float a_r,float a_g,float a_b,float a_a) {
|
||||
add_point(a_x,a_y,a_z,a_w,a_r,a_g,a_b,a_a);
|
||||
//m_this.m_points.add_normal(a_nx,a_ny,a_nz);
|
||||
return true;
|
||||
}
|
||||
virtual bool add_line_normal(float a_bx,float a_by,float a_bz,float a_bw,
|
||||
float /*a_bnx*/,float /*a_bny*/,float /*a_bnz*/,
|
||||
float a_ex,float a_ey,float a_ez,float a_ew,
|
||||
float /*a_enx*/,float /*a_eny*/,float /*a_enz*/) {
|
||||
add_line(a_bx,a_by,a_bz,a_bw, a_ex,a_ey,a_ez,a_ew);
|
||||
//m_this.m_lines.add_normal(a_bnx,a_bny,a_bnz);
|
||||
//m_this.m_lines.add_normal(a_enx,a_eny,a_enz);
|
||||
return true;
|
||||
}
|
||||
virtual bool add_line_normal(float a_bx,float a_by,float a_bz,float a_bw,
|
||||
float /*a_bnx*/,float /*a_bny*/,float /*a_bnz*/,
|
||||
float a_br,float a_bg,float a_bb,float a_ba,
|
||||
float a_ex,float a_ey,float a_ez,float a_ew,
|
||||
float /*a_enx*/,float /*a_eny*/,float /*a_enz*/,
|
||||
float a_er,float a_eg,float a_eb,float a_ea){
|
||||
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);
|
||||
//m_this.m_lines.add_normal(a_bnx,a_bny,a_bnz);
|
||||
//m_this.m_lines.add_normal(a_enx,a_eny,a_enz);
|
||||
return true;
|
||||
}
|
||||
virtual bool add_triangle_normal(
|
||||
float a_p1x,float a_p1y,float a_p1z,float a_p1w,
|
||||
float /*a_n1x*/,float /*a_n1y*/,float /*a_n1z*/,
|
||||
float a_p2x,float a_p2y,float a_p2z,float a_p2w,
|
||||
float /*a_n2x*/,float /*a_n2y*/,float /*a_n2z*/,
|
||||
float a_p3x,float a_p3y,float a_p3z,float a_p3w,
|
||||
float /*a_n3x*/,float /*a_n3y*/,float /*a_n3z*/) {
|
||||
add_triangle(a_p1x,a_p1y,a_p1z,a_p1w,
|
||||
a_p2x,a_p2y,a_p2z,a_p2w,
|
||||
a_p3x,a_p3y,a_p3z,a_p3w);
|
||||
//m_this.m_triangles.add_normal(a_n1x,a_n1y,a_n1z);
|
||||
//m_this.m_triangles.add_normal(a_n2x,a_n2y,a_n2z);
|
||||
//m_this.m_triangles.add_normal(a_n3x,a_n3y,a_n3z);
|
||||
return true;
|
||||
}
|
||||
virtual bool add_triangle_normal(
|
||||
float a_p1x,float a_p1y,float a_p1z,float a_p1w,
|
||||
float /*a_n1x*/,float /*a_n1y*/,float /*a_n1z*/,
|
||||
float a_r1,float a_g1,float a_b1,float a_a1,
|
||||
float a_p2x,float a_p2y,float a_p2z,float a_p2w,
|
||||
float /*a_n2x*/,float /*a_n2y*/,float /*a_n2z*/,
|
||||
float a_r2,float a_g2,float a_b2,float a_a2,
|
||||
float a_p3x,float a_p3y,float a_p3z,float a_p3w,
|
||||
float /*a_n3x*/,float /*a_n3y*/,float /*a_n3z*/,
|
||||
float a_r3,float a_g3,float a_b3,float a_a3){
|
||||
add_triangle(a_p1x,a_p1y,a_p1z,a_p1w,
|
||||
a_r1,a_g1,a_b1,a_a1,
|
||||
a_p2x,a_p2y,a_p2z,a_p2w,
|
||||
a_r2,a_g2,a_b2,a_a2,
|
||||
a_p3x,a_p3y,a_p3z,a_p3w,
|
||||
a_r3,a_g3,a_b3,a_a3);
|
||||
//m_this.m_triangles.add_normal(a_n1x,a_n1y,a_n1z);
|
||||
//m_this.m_triangles.add_normal(a_n2x,a_n2y,a_n2z);
|
||||
//m_this.m_triangles.add_normal(a_n3x,a_n3y,a_n3z);
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
primvis(zb_action& a_zb):m_zb_action(a_zb){}
|
||||
virtual ~primvis(){}
|
||||
@@ -493,7 +574,7 @@ protected:
|
||||
unsigned int npix(float a_size) {
|
||||
// 0 -> 0
|
||||
// 1 -> 0
|
||||
// 2 -> 1 3x3
|
||||
// 2 -> 1 3x3
|
||||
// 3 -> 1 3x3
|
||||
// 4 -> 2 5x5
|
||||
// 5 -> 2 5x5
|
||||
@@ -512,7 +593,7 @@ protected:
|
||||
|
||||
zb::point p;
|
||||
zinit(p,a_x,a_y,a_z);
|
||||
|
||||
|
||||
float alpha = a_color.a();
|
||||
zb::buffer::ZPixel px;
|
||||
if(alpha<1.0f) {
|
||||
@@ -533,12 +614,12 @@ protected:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
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){
|
||||
|
||||
|
||||
float p1x = a_p1x;float p1y = a_p1y;float p1z = a_p1z;//float p1w = a_p1w;
|
||||
float p2x = a_p2x;float p2y = a_p2y;float p2z = a_p2z;//float p2w = a_p2w;
|
||||
float p3x = a_p3x;float p3y = a_p3y;float p3z = a_p3z;//float p3w = a_p3w;
|
||||
@@ -560,14 +641,14 @@ protected:
|
||||
}
|
||||
|
||||
typedef zb::ZZ ZZ; //double
|
||||
|
||||
|
||||
plane<vec3d> pn(
|
||||
vec3<ZZ>(p1x,p1y,p1z),
|
||||
vec3<ZZ>(p2x,p2y,p2z),
|
||||
vec3<ZZ>(p3x,p3y,p3z)
|
||||
);
|
||||
if(!pn.is_valid()) return true;
|
||||
|
||||
|
||||
// norm[0]*x+norm[1]*y+norm[2]*z = dist
|
||||
// A*x+B*y+C*z+D = 0
|
||||
|
||||
@@ -625,7 +706,7 @@ protected:
|
||||
m_zb_action.m_model.mul_3f(dx,dy,dz);
|
||||
d.set_value(dx,dy,dz);
|
||||
if(d.normalize()) {
|
||||
float dot = npn.dot(d);
|
||||
float dot = npn.dot(d);
|
||||
if((-1<=dot)&&(dot<=0)) {
|
||||
dot *= -1;
|
||||
|
||||
@@ -640,14 +721,14 @@ protected:
|
||||
|
||||
colorf c(r,g,b,a_color.a());
|
||||
|
||||
m_zb_action.m_zb.draw_polygon(3,list,A,B,C,D,m_zb_action.get_pix(c));
|
||||
//m_zb_action.m_zb.draw_polygon(3,list,A,B,C,D,m_zb_action.get_pix(a_color));
|
||||
m_zb_action.m_zb.draw_polygon(3,list,A,B,C,D,m_zb_action.get_pix(c));
|
||||
//m_zb_action.m_zb.draw_polygon(3,list,A,B,C,D,m_zb_action.get_pix(a_color));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
m_zb_action.m_zb.draw_polygon(3,list,A,B,C,D,m_zb_action.get_pix(a_color));
|
||||
m_zb_action.m_zb.draw_polygon(3,list,A,B,C,D,m_zb_action.get_pix(a_color));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -657,7 +738,7 @@ protected:
|
||||
};
|
||||
|
||||
protected:
|
||||
zb_manager& m_mgr;
|
||||
zb_manager& m_mgr;
|
||||
mat4f m_vp_mtx;
|
||||
zb::buffer m_zb;
|
||||
primvis m_pv;
|
||||
@@ -671,14 +752,14 @@ protected:
|
||||
// to be restored in restore_state() :
|
||||
mat4f m_proj;
|
||||
mat4f m_model;
|
||||
colorf m_rgba;
|
||||
colorf m_rgba;
|
||||
bool m_ccw;
|
||||
bool m_POLYGON_OFFSET_FILL;
|
||||
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;
|
||||
float m_point_size;
|
||||
bool m_light_on;
|
||||
bool m_DEPTH_TEST;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user