g4tools  5.4.0
torche
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_torche
5 #define tools_sg_torche
6 
7 // directional light
8 
9 #include "node"
10 #include "sf_vec3f"
11 #include "render_action"
12 
13 #include "../colorfs"
14 
15 namespace tools {
16 namespace sg {
17 
18 class torche : public node {
20 public:
24 public:
25  virtual const desc_fields& node_desc_fields() const {
27  static const desc_fields s_v(parent::node_desc_fields(),3, //WARNING : take care of count.
31  );
32  return s_v;
33  }
34 private:
35  void add_fields(){
36  add_field(&color);
38  add_field(&on);
39  }
40 public:
41  virtual void render(render_action& a_action) {
42  if(!on.value()) return;
43  state& state = a_action.state();
44  if((state.m_light+1)>=a_action.max_lights()) {
45  a_action.out()
46  << "GL_MAX_LIGHTS (" << a_action.max_lights() << ") reached."
47  << std::endl;
48  return;
49  }
50  state.m_GL_LIGHTING = true; //for separator
51  a_action.enable_light(state.m_light,direction.value(),color.value());
52  state.m_light++;
53  }
54 public:
56  :parent()
57  ,color(colorf_white())
58  ,direction(vec3f(0,0,-1))
59  ,on(true)
60  {
61  add_fields();
62  }
63  virtual ~torche(){}
64 public:
65  torche(const torche& a_from)
66  :parent(a_from)
67  ,color(a_from.color)
68  ,direction(a_from.direction)
69  ,on(a_from.on)
70  {
71  add_fields();
72  }
73  torche& operator=(const torche& a_from){
74  parent::operator=(a_from);
75  color = a_from.color;
76  direction = a_from.direction;
77  on = a_from.on;
78  return *this;
79  }
80 };
81 
82 }}
83 
84 #endif
tools::sg::torche::torche
torche(const torche &a_from)
Definition: torche:65
node
tools::sg::state
Definition: state:25
tools::sg::state::m_GL_LIGHTING
bool m_GL_LIGHTING
Definition: state:248
tools::sg::torche::operator=
torche & operator=(const torche &a_from)
Definition: torche:73
render_action
tools::sg::node
Definition: node:28
TOOLS_NODE
#define TOOLS_NODE(a__class, a__sclass, a__parent)
Definition: node:324
tools::sg::sf_vec3f
Definition: sf_vec3f:14
tools::sg::torche::torche
torche()
Definition: torche:55
tools::sg::torche
Definition: torche:18
tools::sg::desc_fields
Definition: field_desc:148
tools::sg::color
Definition: color:16
tools::sg::torche::color
sf_vec< colorf, float > color
Definition: torche:21
tools::sg::state::m_light
unsigned int m_light
Definition: state:262
tools::sg::sf_vec
Definition: sf_vec:15
sf_vec3f
tools::sg::torche::node_desc_fields
virtual const desc_fields & node_desc_fields() const
Definition: torche:25
tools::sg::render_action::enable_light
virtual void enable_light(unsigned int, float, float, float, float, float, float, float)=0
tools::sg::torche::~torche
virtual ~torche()
Definition: torche:63
tools::vec3f
Definition: vec3f:13
tools::sg::render_action
Definition: render_action:24
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::sg::node::add_field
void add_field(field *a_field)
Definition: node:128
TOOLS_FIELD_DESC_NODE_CLASS
#define TOOLS_FIELD_DESC_NODE_CLASS(a__class)
Definition: field:68
tools::sg::render_action::max_lights
virtual unsigned int max_lights()=0
tools::sg::torche::render
virtual void render(render_action &a_action)
Definition: torche:41
tools::sg::torche::direction
sf_vec3f direction
Definition: torche:22
tools::sg::bsf::value
T & value()
Definition: bsf:98
tools::sg::action::out
std::ostream & out() const
Definition: action:51
tools::sg::states::state
const sg::state & state() const
Definition: states:76
tools::sg::torche::on
sf< bool > on
Definition: torche:23
tools::sg::sf< bool >
TOOLS_ARG_FIELD_DESC
#define TOOLS_ARG_FIELD_DESC(a__field)
Definition: field:71