Files
geant4/source/analysis/g4tools/include/tools/sg/torche
T
2020-12-04 12:30:43 +01:00

85 lines
1.8 KiB
Plaintext

// Copyright (C) 2010, Guy Barrand. All rights reserved.
// See the file tools.license for terms.
#ifndef tools_sg_torche
#define tools_sg_torche
// directional light
#include "node"
#include "sf_vec3f"
#include "render_action"
#include "../colorfs"
namespace tools {
namespace sg {
class torche : public node {
TOOLS_NODE(torche,tools::sg::torche,node)
public:
sf_vec<colorf,float> color;
sf_vec3f direction;
sf<bool> on;
public:
virtual const desc_fields& node_desc_fields() const {
TOOLS_FIELD_DESC_NODE_CLASS(tools::sg::torche)
static const desc_fields s_v(parent::node_desc_fields(),3, //WARNING : take care of count.
TOOLS_ARG_FIELD_DESC(color),
TOOLS_ARG_FIELD_DESC(direction),
TOOLS_ARG_FIELD_DESC(on)
);
return s_v;
}
private:
void add_fields(){
add_field(&color);
add_field(&direction);
add_field(&on);
}
public:
virtual void render(render_action& a_action) {
if(!on.value()) return;
state& state = a_action.state();
if((state.m_light+1)>=a_action.max_lights()) {
a_action.out()
<< "GL_MAX_LIGHTS (" << a_action.max_lights() << ") reached."
<< std::endl;
return;
}
state.m_GL_LIGHTING = true; //for separator
a_action.enable_light(state.m_light,direction.value(),color.value());
state.m_light++;
}
public:
torche()
:parent()
,color(colorf_white())
,direction(vec3f(0,0,-1))
,on(true)
{
add_fields();
}
virtual ~torche(){}
public:
torche(const torche& a_from)
:parent(a_from)
,color(a_from.color)
,direction(a_from.direction)
,on(a_from.on)
{
add_fields();
}
torche& operator=(const torche& a_from){
parent::operator=(a_from);
color = a_from.color;
direction = a_from.direction;
on = a_from.on;
return *this;
}
};
}}
#endif