Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/sg/head_light 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_head_light
0005 #define tools_sg_head_light
0006 
0007 // Directional light following cam direction.
0008 // It should come after a camera node.
0009 
0010 #include "torche"
0011 
0012 namespace tools {
0013 namespace sg {
0014 
0015 class head_light : public torche {
0016   TOOLS_NODE(head_light,tools::sg::head_light,torche)
0017 public:
0018   virtual void render(render_action& a_action) {
0019     if(!on.value()) return;
0020     state& state = a_action.state();
0021     if((state.m_light+1)>=a_action.max_lights()) {
0022       a_action.out()
0023         << "GL_MAX_LIGHTS (" << a_action.max_lights() << ") reached."
0024         << std::endl;
0025       return;
0026     }
0027     float dx = direction.value()[0];
0028     float dy = direction.value()[1];
0029     float dz = direction.value()[2];
0030    {mat4f mtx;
0031     state.m_camera_orientation.value(mtx);
0032     mtx.mul_dir_3f(dx,dy,dz);}
0033     state.m_GL_LIGHTING = true;
0034     a_action.enable_light(state.m_light,vec3f(dx,dy,dz),color.value(),ambient.value());
0035     state.m_light++;
0036   }
0037 public:
0038   head_light():torche(){}
0039   virtual ~head_light(){}
0040 public:
0041   head_light(const head_light& a_from):torche(a_from){}
0042   head_light& operator=(const head_light& a_from){
0043     torche::operator=(a_from);
0044     return *this;
0045   }
0046 };
0047 
0048 }}
0049 
0050 #endif