Warning, /include/Geant4/tools/sg/torche 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_torche
0005 #define tools_sg_torche
0006
0007 // directional light
0008
0009 #include "node"
0010 #include "sf_vec3f"
0011 #include "render_action"
0012
0013 #include "../colorfs"
0014
0015 namespace tools {
0016 namespace sg {
0017
0018 class torche : public node {
0019 TOOLS_NODE(torche,tools::sg::torche,node)
0020 public:
0021 sf_vec<colorf,float> color;
0022 sf_vec<colorf,float> ambient;
0023 sf_vec3f direction;
0024 sf<bool> on;
0025 public:
0026 virtual const desc_fields& node_desc_fields() const {
0027 TOOLS_FIELD_DESC_NODE_CLASS(tools::sg::torche)
0028 static const desc_fields s_v(parent::node_desc_fields(),4, //WARNING : take care of count.
0029 TOOLS_ARG_FIELD_DESC(color),
0030 TOOLS_ARG_FIELD_DESC(ambient),
0031 TOOLS_ARG_FIELD_DESC(direction),
0032 TOOLS_ARG_FIELD_DESC(on)
0033 );
0034 return s_v;
0035 }
0036 private:
0037 void add_fields(){
0038 add_field(&color);
0039 add_field(&ambient);
0040 add_field(&direction);
0041 add_field(&on);
0042 }
0043 public:
0044 virtual void render(render_action& a_action) {
0045 if(!on.value()) return;
0046 state& state = a_action.state();
0047 if((state.m_light+1)>=a_action.max_lights()) {
0048 a_action.out()
0049 << "GL_MAX_LIGHTS (" << a_action.max_lights() << ") reached."
0050 << std::endl;
0051 return;
0052 }
0053 state.m_GL_LIGHTING = true;
0054 a_action.enable_light(state.m_light,direction.value(),color.value(),ambient.value());
0055 state.m_light++;
0056 }
0057 public:
0058 torche()
0059 :parent()
0060 ,color(colorf_white())
0061 ,ambient(colorf_black())
0062 ,direction(vec3f(0,0,-1))
0063 ,on(true)
0064 {
0065 add_fields();
0066 }
0067 virtual ~torche(){}
0068 public:
0069 torche(const torche& a_from)
0070 :parent(a_from)
0071 ,color(a_from.color)
0072 ,ambient(a_from.ambient)
0073 ,direction(a_from.direction)
0074 ,on(a_from.on)
0075 {
0076 add_fields();
0077 }
0078 torche& operator=(const torche& a_from){
0079 parent::operator=(a_from);
0080 color = a_from.color;
0081 ambient = a_from.ambient;
0082 direction = a_from.direction;
0083 on = a_from.on;
0084 return *this;
0085 }
0086 };
0087
0088 }}
0089
0090 #endif