Commit 3b79dc5f authored by Jan Möbius's avatar Jan Möbius

Merge branch 'featurephysicallyBasedMaterial' into 'master'

extend the materialNode class with refractive materials

See merge request !47
parents 9f14f881 51538514
...@@ -134,7 +134,7 @@ GLState::GLState(bool _updateGL, bool _compatibilityProfile) ...@@ -134,7 +134,7 @@ GLState::GLState(bool _updateGL, bool _compatibilityProfile)
glheight_(2), glheight_(2),
near_plane_(1.0), near_plane_(1.0),
far_plane_(100.0), far_plane_(100.0),
multisampling_(false), multisampling_(false),
allow_multisampling_(true), allow_multisampling_(true),
mipmapping_(true), mipmapping_(true),
updateGL_(_updateGL), updateGL_(_updateGL),
...@@ -198,9 +198,9 @@ void GLState::initialize() ...@@ -198,9 +198,9 @@ void GLState::initialize()
// Get max number of texture units // Get max number of texture units
GLint value; GLint value;
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &value); glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &value);
num_texture_units_ = value; num_texture_units_ = value;
// lighting // lighting
set_twosided_lighting(true); set_twosided_lighting(true);
} }
...@@ -399,8 +399,8 @@ void GLState::set_modelview(const GLMatrixd& _m, const GLMatrixd& _inv_m) ...@@ -399,8 +399,8 @@ void GLState::set_modelview(const GLMatrixd& _m, const GLMatrixd& _inv_m)
void GLState::ortho( double _left, double _right, void GLState::ortho( double _left, double _right,
double _bottom, double _top, double _bottom, double _top,
double _n, double _f ) double _n, double _f )
{ {
near_plane_ = _n; near_plane_ = _n;
far_plane_ = _f; far_plane_ = _f;
...@@ -422,8 +422,8 @@ void GLState::ortho( double _left, double _right, ...@@ -422,8 +422,8 @@ void GLState::ortho( double _left, double _right,
void GLState::frustum( double _left, double _right, void GLState::frustum( double _left, double _right,
double _bottom, double _top, double _bottom, double _top,
double _n, double _f ) double _n, double _f )
{ {
near_plane_ = _n; near_plane_ = _n;
far_plane_ = _f; far_plane_ = _f;
...@@ -445,7 +445,7 @@ void GLState::frustum( double _left, double _right, ...@@ -445,7 +445,7 @@ void GLState::frustum( double _left, double _right,
void GLState::perspective( double _fovY, double _aspect, void GLState::perspective( double _fovY, double _aspect,
double _n, double _f ) double _n, double _f )
{ {
near_plane_ = _n; near_plane_ = _n;
far_plane_ = _f; far_plane_ = _f;
...@@ -467,8 +467,8 @@ void GLState::perspective( double _fovY, double _aspect, ...@@ -467,8 +467,8 @@ void GLState::perspective( double _fovY, double _aspect,
void GLState::viewport( int _left, int _bottom, void GLState::viewport( int _left, int _bottom,
int _width, int _height, int _width, int _height,
int _glwidth, int _glheight) int _glwidth, int _glheight)
{ {
left_ = _left; left_ = _left;
bottom_ = _bottom; bottom_ = _bottom;
...@@ -512,8 +512,8 @@ void GLState::viewport( int _left, int _bottom, ...@@ -512,8 +512,8 @@ void GLState::viewport( int _left, int _bottom,
void GLState::lookAt( const Vec3d& _eye, void GLState::lookAt( const Vec3d& _eye,
const Vec3d& _center, const Vec3d& _center,
const Vec3d& _up ) const Vec3d& _up )
{ {
modelview_.lookAt(_eye, _center, _up); modelview_.lookAt(_eye, _center, _up);
inverse_modelview_.inverse_lookAt(_eye, _center, _up); inverse_modelview_.inverse_lookAt(_eye, _center, _up);
...@@ -530,7 +530,7 @@ void GLState::lookAt( const Vec3d& _eye, ...@@ -530,7 +530,7 @@ void GLState::lookAt( const Vec3d& _eye,
void GLState::translate( double _x, double _y, double _z, void GLState::translate( double _x, double _y, double _z,
MultiplyFrom _mult_from ) MultiplyFrom _mult_from )
{ {
if (_mult_from == MULT_FROM_RIGHT) if (_mult_from == MULT_FROM_RIGHT)
{ {
...@@ -561,7 +561,7 @@ void GLState::translate( Vec3d _vector, ...@@ -561,7 +561,7 @@ void GLState::translate( Vec3d _vector,
void GLState::rotate( double _angle, double _x, double _y, double _z, void GLState::rotate( double _angle, double _x, double _y, double _z,
MultiplyFrom _mult_from ) MultiplyFrom _mult_from )
{ {
if (_mult_from == MULT_FROM_RIGHT) if (_mult_from == MULT_FROM_RIGHT)
{ {
...@@ -586,7 +586,7 @@ void GLState::rotate( double _angle, double _x, double _y, double _z, ...@@ -586,7 +586,7 @@ void GLState::rotate( double _angle, double _x, double _y, double _z,
void GLState::scale( double _sx, double _sy, double _sz, void GLState::scale( double _sx, double _sy, double _sz,
MultiplyFrom _mult_from ) MultiplyFrom _mult_from )
{ {
if (_mult_from == MULT_FROM_RIGHT) if (_mult_from == MULT_FROM_RIGHT)
{ {
...@@ -611,7 +611,7 @@ void GLState::scale( double _sx, double _sy, double _sz, ...@@ -611,7 +611,7 @@ void GLState::scale( double _sx, double _sy, double _sz,
void GLState::mult_matrix( const GLMatrixd& _m, const GLMatrixd& _inv_m, void GLState::mult_matrix( const GLMatrixd& _m, const GLMatrixd& _inv_m,
MultiplyFrom _mult_from ) MultiplyFrom _mult_from )
{ {
if (_mult_from == MULT_FROM_RIGHT) if (_mult_from == MULT_FROM_RIGHT)
{ {
...@@ -891,7 +891,7 @@ Vec3d GLState::eye() const ...@@ -891,7 +891,7 @@ Vec3d GLState::eye() const
Vec3d GLState::viewing_direction(int _x, int _y) const Vec3d GLState::viewing_direction(int _x, int _y) const
{ {
Vec3d dir = ( unproject(Vec3d(_x, _y, 1.0)) - Vec3d dir = ( unproject(Vec3d(_x, _y, 1.0)) -
unproject(Vec3d(_x, _y, 0.0)) ); unproject(Vec3d(_x, _y, 0.0)) );
dir.normalize(); dir.normalize();
return dir; return dir;
} }
...@@ -903,7 +903,7 @@ Vec3d GLState::viewing_direction(int _x, int _y) const ...@@ -903,7 +903,7 @@ Vec3d GLState::viewing_direction(int _x, int _y) const
Vec3d GLState::up() const Vec3d GLState::up() const
{ {
Vec3d dir( unproject(Vec3d(0.5*width_, height_-1, 0.0)) - Vec3d dir( unproject(Vec3d(0.5*width_, height_-1, 0.0)) -
unproject(Vec3d(0.5*width_, 0.5*height_, 0.0)) ); unproject(Vec3d(0.5*width_, 0.5*height_, 0.0)) );
dir.normalize(); dir.normalize();
return dir; return dir;
} }
...@@ -915,7 +915,7 @@ Vec3d GLState::up() const ...@@ -915,7 +915,7 @@ Vec3d GLState::up() const
Vec3d GLState::right() const Vec3d GLState::right() const
{ {
Vec3d dir( unproject(Vec3d(width_-1, 0.5*height_, 0.0)) - Vec3d dir( unproject(Vec3d(width_-1, 0.5*height_, 0.0)) -
unproject(Vec3d(0.5*width_, 0.5*height_, 0.0)) ); unproject(Vec3d(0.5*width_, 0.5*height_, 0.0)) );
dir.normalize(); dir.normalize();
return dir; return dir;
} }
...@@ -925,7 +925,7 @@ Vec3d GLState::right() const ...@@ -925,7 +925,7 @@ Vec3d GLState::right() const
void GLState::viewing_ray( int _x, int _y, void GLState::viewing_ray( int _x, int _y,
Vec3d& _origin, Vec3d& _direction) const Vec3d& _origin, Vec3d& _direction) const
{ {
_origin = unproject(Vec3d(_x, _y, 0.0)); _origin = unproject(Vec3d(_x, _y, 0.0));
_direction = unproject(Vec3d(_x, _y, 1.0)) - _origin; _direction = unproject(Vec3d(_x, _y, 1.0)) - _origin;
...@@ -1338,7 +1338,7 @@ void GLState::syncFromGL() ...@@ -1338,7 +1338,7 @@ void GLState::syncFromGL()
if (glIsEnabled(caps[i])) stateStack_.back().glStateEnabled_.set(caps[i]); if (glIsEnabled(caps[i])) stateStack_.back().glStateEnabled_.set(caps[i]);
else stateStack_.back().glStateEnabled_.reset(caps[i]); else stateStack_.back().glStateEnabled_.reset(caps[i]);
} }
GLint getparam; GLint getparam;
#ifdef GL_VERSION_1_4 #ifdef GL_VERSION_1_4
...@@ -1364,9 +1364,9 @@ void GLState::syncFromGL() ...@@ -1364,9 +1364,9 @@ void GLState::syncFromGL()
glGetIntegerv(GL_BLEND_EQUATION_RGB, &getparam); glGetIntegerv(GL_BLEND_EQUATION_RGB, &getparam);
stateStack_.back().blendEquationState_ = getparam; stateStack_.back().blendEquationState_ = getparam;
glGetFloatv(GL_BLEND_COLOR, stateStack_.back().blendColorState_); glGetFloatv(GL_BLEND_COLOR, stateStack_.back().blendColorState_);
glGetIntegerv(GL_ALPHA_TEST_FUNC, &getparam); glGetIntegerv(GL_ALPHA_TEST_FUNC, &getparam);
stateStack_.back().alphaFuncState_ = getparam; stateStack_.back().alphaFuncState_ = getparam;
...@@ -1381,7 +1381,7 @@ void GLState::syncFromGL() ...@@ -1381,7 +1381,7 @@ void GLState::syncFromGL()
GLenum bufGets[8] = { GLenum bufGets[8] = {
GL_ARRAY_BUFFER_BINDING, GL_ARRAY_BUFFER, GL_ARRAY_BUFFER_BINDING, GL_ARRAY_BUFFER,
GL_ELEMENT_ARRAY_BUFFER_BINDING, GL_ELEMENT_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER_BINDING, GL_ELEMENT_ARRAY_BUFFER,
GL_PIXEL_PACK_BUFFER_BINDING, GL_PIXEL_PACK_BUFFER, GL_PIXEL_PACK_BUFFER_BINDING, GL_PIXEL_PACK_BUFFER,
GL_PIXEL_UNPACK_BUFFER_BINDING, GL_PIXEL_UNPACK_BUFFER}; GL_PIXEL_UNPACK_BUFFER_BINDING, GL_PIXEL_UNPACK_BUFFER};
...@@ -1452,7 +1452,7 @@ void GLState::syncFromGL() ...@@ -1452,7 +1452,7 @@ void GLState::syncFromGL()
GL_TEXTURE_COORD_ARRAY_SIZE, GL_TEXTURE_COORD_ARRAY_TYPE, GL_TEXTURE_COORD_ARRAY_SIZE, GL_TEXTURE_COORD_ARRAY_TYPE,
GL_TEXTURE_COORD_ARRAY_STRIDE, GL_TEXTURE_COORD_ARRAY_POINTER}; GL_TEXTURE_COORD_ARRAY_STRIDE, GL_TEXTURE_COORD_ARRAY_POINTER};
GLStateContext::GLVertexPointer* ptrs[] = {&stateStack_.back().vertexPointer_, GLStateContext::GLVertexPointer* ptrs[] = {&stateStack_.back().vertexPointer_,
&stateStack_.back().colorPointer_, &stateStack_.back().texcoordPointer_}; &stateStack_.back().colorPointer_, &stateStack_.back().texcoordPointer_};
for (int i = 0; i < 3 ; ++i) for (int i = 0; i < 3 ; ++i)
...@@ -1743,7 +1743,7 @@ void GLState::depthRange(GLclampd _zNear, GLclampd _zFar) ...@@ -1743,7 +1743,7 @@ void GLState::depthRange(GLclampd _zNear, GLclampd _zFar)
{ {
if (!depthRangeLock_) if (!depthRangeLock_)
{ {
#ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
if (abs(_zNear - stateStack_.back().depthRange_[0]) > 1e-6 || if (abs(_zNear - stateStack_.back().depthRange_[0]) > 1e-6 ||
abs(_zFar - stateStack_.back().depthRange_[1]) > 1e-6) abs(_zFar - stateStack_.back().depthRange_[1]) > 1e-6)
#endif #endif
......
...@@ -142,6 +142,8 @@ QString Material::serializeToJson() const { ...@@ -142,6 +142,8 @@ QString Material::serializeToJson() const {
matMap["overlayColor"] = col2vl(overlayColor_); matMap["overlayColor"] = col2vl(overlayColor_);
matMap["shininess"] = shininess_; matMap["shininess"] = shininess_;
matMap["reflectance"] = reflectance_; matMap["reflectance"] = reflectance_;
matMap["indexOfRefraction"] = indexOfRefraction_;
matMap["isRefractive"] = isRefractive_;
matMap["pointSize"] = pointSize_; matMap["pointSize"] = pointSize_;
matMap["lineWidth"] = lineWidth_; matMap["lineWidth"] = lineWidth_;
matMap["roundPoints"] = roundPoints_; matMap["roundPoints"] = roundPoints_;
...@@ -178,6 +180,8 @@ void Material::deserializeFromVariantMap(const QVariantMap &matMap) { ...@@ -178,6 +180,8 @@ void Material::deserializeFromVariantMap(const QVariantMap &matMap) {
if (matMap.contains("overlayColor")) overlayColor_ = vl2col(matMap["overlayColor"].toList()); if (matMap.contains("overlayColor")) overlayColor_ = vl2col(matMap["overlayColor"].toList());
if (matMap.contains("shininess")) shininess_ = matMap["shininess"].toFloat(); if (matMap.contains("shininess")) shininess_ = matMap["shininess"].toFloat();
if (matMap.contains("reflectance")) reflectance_ = matMap["reflectance"].toDouble(); if (matMap.contains("reflectance")) reflectance_ = matMap["reflectance"].toDouble();
if (matMap.contains("indexOfRefraction")) indexOfRefraction_ = matMap["indexOfRefraction"].toDouble();
if (matMap.contains("isRefractive")) isRefractive_ = matMap["isRefractive"].toBool();
if (matMap.contains("pointSize")) pointSize_ = matMap["pointSize"].toFloat(); if (matMap.contains("pointSize")) pointSize_ = matMap["pointSize"].toFloat();
if (matMap.contains("lineWidth")) lineWidth_ = matMap["lineWidth"].toFloat(); if (matMap.contains("lineWidth")) lineWidth_ = matMap["lineWidth"].toFloat();
if (matMap.contains("roundPoints")) roundPoints_ = matMap["roundPoints"].toBool(); if (matMap.contains("roundPoints")) roundPoints_ = matMap["roundPoints"].toBool();
...@@ -217,11 +221,11 @@ void MaterialNode::enter(GLState& _state, const DrawModes::DrawMode& _drawmode ...@@ -217,11 +221,11 @@ void MaterialNode::enter(GLState& _state, const DrawModes::DrawMode& _drawmode
if (applyProperties_ & Material) if (applyProperties_ & Material)
{ {
materialBackup_.ambientColor_ = _state.ambient_color(); materialBackup_.ambientColor_ = _state.ambient_color();
materialBackup_.diffuseColor_ = _state.diffuse_color(); materialBackup_.diffuseColor_ = _state.diffuse_color();
materialBackup_.specularColor_ = _state.specular_color(); materialBackup_.specularColor_ = _state.specular_color();
materialBackup_.overlayColor_ = _state.overlay_color(); materialBackup_.overlayColor_ = _state.overlay_color();
materialBackup_.shininess_ = _state.shininess(); materialBackup_.shininess_ = _state.shininess();
_state.set_ambient_color(material_.ambientColor_); _state.set_ambient_color(material_.ambientColor_);
_state.set_diffuse_color(material_.diffuseColor_); _state.set_diffuse_color(material_.diffuseColor_);
...@@ -480,6 +484,7 @@ MaterialNode::read(std::istream& _is) ...@@ -480,6 +484,7 @@ MaterialNode::read(std::istream& _is)
char s[200]; char s[200];
float x, y, z, u; float x, y, z, u;
bool b;
while (_is && (!_is.eof()) && _is.getline(s,200) ) { while (_is && (!_is.eof()) && _is.getline(s,200) ) {
std::istringstream buffer(s); std::istringstream buffer(s);
...@@ -541,6 +546,22 @@ MaterialNode::read(std::istream& _is) ...@@ -541,6 +546,22 @@ MaterialNode::read(std::istream& _is)
material_.shininess(x); material_.shininess(x);
} }
} }
// Refractive
else if (specifier == "isRefractive") {
buffer >> b;
if (buffer.good()) {
material_.set_refractive(b);
}
}
// Refraction Index
else if (specifier == "indexOfRefraction") {
buffer >> x;
if (buffer.good()) {
material_.indexOfRefraction(x);
}
}
// PointSize // PointSize
else if (specifier == "PointSize") { else if (specifier == "PointSize") {
buffer >> x; buffer >> x;
......
...@@ -83,9 +83,9 @@ namespace SceneGraph { ...@@ -83,9 +83,9 @@ namespace SceneGraph {
**/ **/
class ACGDLLEXPORT Material { class ACGDLLEXPORT Material {
friend class MaterialNode; friend class MaterialNode;
public: public:
/// Default constructor /// Default constructor
Material() : Material() :
...@@ -96,6 +96,8 @@ public: ...@@ -96,6 +96,8 @@ public:
overlayColor_(GLState::default_overlay_color), overlayColor_(GLState::default_overlay_color),
shininess_(GLState::default_shininess), shininess_(GLState::default_shininess),
reflectance_(0.0), reflectance_(0.0),
indexOfRefraction_(1.0),
isRefractive_(false),
pointSize_(1.0), pointSize_(1.0),
lineWidth_(1.0), lineWidth_(1.0),
roundPoints_(false), roundPoints_(false),
...@@ -108,10 +110,10 @@ public: ...@@ -108,10 +110,10 @@ public:
colorMaterial_(true), colorMaterial_(true),
backfaceCulling_(false), backfaceCulling_(false),
multiSampling_(true) {}; multiSampling_(true) {};
/// Deconstructor /// Deconstructor
virtual ~Material() {}; virtual ~Material() {};
/// Copy constructor /// Copy constructor
Material(const Material& _m) : Material(const Material& _m) :
baseColor_(_m.baseColor_), baseColor_(_m.baseColor_),
...@@ -121,6 +123,8 @@ public: ...@@ -121,6 +123,8 @@ public:
overlayColor_(_m.overlayColor_), overlayColor_(_m.overlayColor_),
shininess_(_m.shininess_), shininess_(_m.shininess_),
reflectance_(_m.reflectance_), reflectance_(_m.reflectance_),
indexOfRefraction_(_m.indexOfRefraction_),
isRefractive_(_m.isRefractive_),
pointSize_(_m.pointSize_), pointSize_(_m.pointSize_),
lineWidth_(_m.lineWidth_), lineWidth_(_m.lineWidth_),
roundPoints_(_m.roundPoints_), roundPoints_(_m.roundPoints_),
...@@ -138,7 +142,7 @@ public: ...@@ -138,7 +142,7 @@ public:
QString serializeToJson() const; QString serializeToJson() const;
void deserializeFromJson(const QString &json); void deserializeFromJson(const QString &json);
void deserializeFromVariantMap(const QVariantMap &matMap); void deserializeFromVariantMap(const QVariantMap &matMap);
/** \brief Set color based on _c /** \brief Set color based on _c
* *
* Basecolor (which is the emitted color is set to zero) * Basecolor (which is the emitted color is set to zero)
...@@ -154,7 +158,7 @@ public: ...@@ -154,7 +158,7 @@ public:
c = _c * 0.6f; c[3]=_c[3]; diffuseColor(c); c = _c * 0.6f; c[3]=_c[3]; diffuseColor(c);
c = _c * 0.8f; c[3]=_c[3]; specularColor(c); c = _c * 0.8f; c[3]=_c[3]; specularColor(c);
} }
/// Creates a randomized color and sets it /// Creates a randomized color and sets it
void generateRandomColor() { void generateRandomColor() {
color( Vec4f(0.2 + double(rand())/double(RAND_MAX)*0.8, color( Vec4f(0.2 + double(rand())/double(RAND_MAX)*0.8,
...@@ -163,11 +167,16 @@ public: ...@@ -163,11 +167,16 @@ public:
1.0)); 1.0));
} }
/// set the base color /// set the base color (Sets the baseColor which is the same as the emission(const Vec4f& _c) )
void baseColor(const Vec4f& _c) { baseColor_ = _c;} void baseColor(const Vec4f& _c) { baseColor_ = _c;}
/// get the base color /// get the base color ( Same as emission() )
const Vec4f& baseColor() const { return baseColor_; } const Vec4f& baseColor() const { return baseColor_; }
/// set emission ( Same as baseColor( const Vec4f& _c )) )
void emissionColor(const Vec4f& _c) { baseColor_ = _c;}
/// get emission ( Same as baseColor() )
const Vec4f& emissionColor() const { return baseColor_; }
/// set the ambient color. /// set the ambient color.
void ambientColor(const Vec4f& _a) { ambientColor_ = _a; } void ambientColor(const Vec4f& _a) { ambientColor_ = _a; }
/// get the ambient color. /// get the ambient color.
...@@ -201,12 +210,22 @@ public: ...@@ -201,12 +210,22 @@ public:
void shininess(float _s) { shininess_ = _s; } void shininess(float _s) { shininess_ = _s; }
/// get shininess /// get shininess
float shininess() const { return shininess_; } float shininess() const { return shininess_; }
/// set reflectance ( not used in OpenGL Rendering) /// set reflectance ( not used in OpenGL Rendering)
void reflectance(double _m) { reflectance_ = _m; } void reflectance(double _m) { reflectance_ = _m; }
/// get reflectance ( not used in OpenGL Rendering) /// get reflectance ( not used in OpenGL Rendering)
double reflectance() const { return reflectance_; } double reflectance() const { return reflectance_; }
/// set index of refraction
void indexOfRefraction(double _m) { indexOfRefraction_ = _m; }
/// get index of refraction ( not used in OpenGL Rendering)
double indexOfRefraction() const { return indexOfRefraction_; }
/// set refractive flag
void setRefractive(bool _r) { isRefractive_ = _r; }
/// get refractive flag
bool isRefractive() const {return isRefractive_;}
/// set point size (default: 1.0) /// set point size (default: 1.0)
void pointSize(float _sz) { pointSize_ = _sz; } void pointSize(float _sz) { pointSize_ = _sz; }
/// get point size /// get point size
...@@ -226,7 +245,7 @@ public: ...@@ -226,7 +245,7 @@ public:
void lineSmooth(bool _b) { linesSmooth_ = _b; } void lineSmooth(bool _b) { linesSmooth_ = _b; }
/// get: rsmooth lines enabled /// get: rsmooth lines enabled
bool lineSmooth() const { return linesSmooth_; } bool lineSmooth() const { return linesSmooth_; }
/// enable alpha test (draw pixels if alpha >= _clip) /// enable alpha test (draw pixels if alpha >= _clip)
void enableAlphaTest(float _clip) { void enableAlphaTest(float _clip) {
alphaTest_ = true; alphaClip_ = _clip; alphaTest_ = true; alphaClip_ = _clip;
...@@ -237,7 +256,7 @@ public: ...@@ -237,7 +256,7 @@ public:
/// Return state of Alpha test /// Return state of Alpha test
bool alphaTest() const { return alphaTest_; }; bool alphaTest() const { return alphaTest_; };
/// Enable Multisampling /// Enable Multisampling
void enableMultisampling() { void enableMultisampling() {
multiSampling_ = true; multiSampling_ = true;
...@@ -280,32 +299,36 @@ public: ...@@ -280,32 +299,36 @@ public:
/// disable backface culling (not active by default, see applyProperties) /// disable backface culling (not active by default, see applyProperties)
void disableBackfaceCulling() { backfaceCulling_ = false; } void disableBackfaceCulling() { backfaceCulling_ = false; }
bool isEmissive() const { return (baseColor_[0] > 0.f || baseColor_[1] > 0.f || baseColor_[2] > 0.f); }
protected: protected:
Vec4f baseColor_; Vec4f baseColor_;
Vec4f ambientColor_; Vec4f ambientColor_;
Vec4f diffuseColor_; Vec4f diffuseColor_;
Vec4f specularColor_; Vec4f specularColor_;
Vec4f overlayColor_; Vec4f overlayColor_;
float shininess_; float shininess_;
double reflectance_; double reflectance_;
double indexOfRefraction_;
bool isRefractive_;
float pointSize_; float pointSize_;
float lineWidth_; float lineWidth_;
bool roundPoints_; bool roundPoints_;
bool linesSmooth_; bool linesSmooth_;
bool alphaTest_; bool alphaTest_;
float alphaClip_; float alphaClip_;
bool blending_; bool blending_;
GLenum blendParam1_; GLenum blendParam1_;
GLenum blendParam2_; GLenum blendParam2_;
bool colorMaterial_; bool colorMaterial_;
bool backfaceCulling_; bool backfaceCulling_;
bool multiSampling_; bool multiSampling_;
}; };
...@@ -355,8 +378,8 @@ public: ...@@ -355,8 +378,8 @@ public:
/// Default constructor. Applies all properties. /// Default constructor. Applies all properties.
MaterialNode( BaseNode* _parent = 0, MaterialNode( BaseNode* _parent = 0,
const std::string& _name = "<MaterialNode>", const std::string& _name = "<MaterialNode>",
unsigned int _applyProperties = (All & ~BackFaceCulling)); unsigned int _applyProperties = (All & ~BackFaceCulling));
/// Destructor. /// Destructor.
virtual ~MaterialNode() {}; virtual ~MaterialNode() {};
...@@ -394,17 +417,22 @@ public: ...@@ -394,17 +417,22 @@ public:
void set_color(const Vec4f& _c) { void set_color(const Vec4f& _c) {
material_.color(_c); material_.color(_c);
} }
/// Generates a random color and sets it /// Generates a random color and sets it
void set_random_color() { void set_random_color() {
material_.generateRandomColor(); material_.generateRandomColor();
} }