Warning, /include/Geant4/tools/sg/rgba is written in an unsupported language. File is not indexed.
0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003
0004 #ifndef tools_sg_rgba
0005 #define tools_sg_rgba
0006
0007 #include "node"
0008
0009 #include "sf_vec"
0010 #include "render_action"
0011 #include "../colorfs"
0012
0013 namespace tools {
0014 namespace sg {
0015
0016 class rgba : public node {
0017 TOOLS_NODE(rgba,tools::sg::rgba,node)
0018 public:
0019 sf_vec<colorf,float> color;
0020 public:
0021 virtual const desc_fields& node_desc_fields() const {
0022 TOOLS_FIELD_DESC_NODE_CLASS(tools::sg::rgba)
0023 static const desc_fields s_v(parent::node_desc_fields(),1, //WARNING : take care of count.
0024 TOOLS_ARG_FIELD_DESC(color)
0025 );
0026 return s_v;
0027 }
0028 private:
0029 void add_fields(){
0030 add_field(&color);
0031 }
0032 public:
0033 virtual void render(render_action& a_action) {
0034 // GL-ES : ::glMaterialfv does not work. We then use :
0035 // ::glEnable(GL_COLOR_MATERIAL) and ::glColor.
0036
0037 //if(a_action.state().m_GL_LIGHTING) {
0038 // float params[4];
0039 // params[0] = rgb.value().r();
0040 // params[1] = rgb.value().g();
0041 // params[2] = rgb.value().b();
0042 // params[3] = rgb.value().a();
0043 // ::glMaterialfv(GL_FRONT,GL_DIFFUSE,params);
0044 //} else {
0045 //}
0046
0047 state& state = a_action.state();
0048 state.m_color = color.value();
0049 a_action.color4f(state.m_color);
0050 }
0051 public:
0052 rgba()
0053 :parent()
0054 ,color(colorf_grey())
0055 {
0056 add_fields();
0057 }
0058 virtual ~rgba(){}
0059 public:
0060 rgba(const rgba& a_from)
0061 :parent(a_from)
0062 ,color(a_from.color)
0063 {
0064 add_fields();
0065 }
0066 rgba& operator=(const rgba& a_from){
0067 parent::operator=(a_from);
0068 color = a_from.color;
0069 return *this;
0070 }
0071 };
0072
0073 }}
0074
0075 #endif