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
......@@ -142,6 +142,8 @@ QString Material::serializeToJson() const {
matMap["overlayColor"] = col2vl(overlayColor_);
matMap["shininess"] = shininess_;
matMap["reflectance"] = reflectance_;
matMap["indexOfRefraction"] = indexOfRefraction_;
matMap["isRefractive"] = isRefractive_;
matMap["pointSize"] = pointSize_;
matMap["lineWidth"] = lineWidth_;
matMap["roundPoints"] = roundPoints_;
......@@ -178,6 +180,8 @@ void Material::deserializeFromVariantMap(const QVariantMap &matMap) {
if (matMap.contains("overlayColor")) overlayColor_ = vl2col(matMap["overlayColor"].toList());
if (matMap.contains("shininess")) shininess_ = matMap["shininess"].toFloat();
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("lineWidth")) lineWidth_ = matMap["lineWidth"].toFloat();
if (matMap.contains("roundPoints")) roundPoints_ = matMap["roundPoints"].toBool();
......@@ -480,6 +484,7 @@ MaterialNode::read(std::istream& _is)
char s[200];
float x, y, z, u;
bool b;
while (_is && (!_is.eof()) && _is.getline(s,200) ) {
std::istringstream buffer(s);
......@@ -541,6 +546,22 @@ MaterialNode::read(std::istream& _is)
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
else if (specifier == "PointSize") {
buffer >> x;
......
......@@ -96,6 +96,8 @@ public:
overlayColor_(GLState::default_overlay_color),
shininess_(GLState::default_shininess),
reflectance_(0.0),
indexOfRefraction_(1.0),
isRefractive_(false),
pointSize_(1.0),
lineWidth_(1.0),
roundPoints_(false),
......@@ -121,6 +123,8 @@ public:
overlayColor_(_m.overlayColor_),
shininess_(_m.shininess_),
reflectance_(_m.reflectance_),
indexOfRefraction_(_m.indexOfRefraction_),
isRefractive_(_m.isRefractive_),
pointSize_(_m.pointSize_),
lineWidth_(_m.lineWidth_),
roundPoints_(_m.roundPoints_),
......@@ -163,11 +167,16 @@ public:
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;}
/// get the base color
/// get the base color ( Same as emission() )
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.
void ambientColor(const Vec4f& _a) { ambientColor_ = _a; }
/// get the ambient color.
......@@ -207,6 +216,16 @@ public:
/// get reflectance ( not used in OpenGL Rendering)
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)
void pointSize(float _sz) { pointSize_ = _sz; }
/// get point size
......@@ -280,6 +299,8 @@ public:
/// disable backface culling (not active by default, see applyProperties)
void disableBackfaceCulling() { backfaceCulling_ = false; }
bool isEmissive() const { return (baseColor_[0] > 0.f || baseColor_[1] > 0.f || baseColor_[2] > 0.f); }
protected:
Vec4f baseColor_;
......@@ -290,6 +311,8 @@ protected:
float shininess_;
double reflectance_;
double indexOfRefraction_;
bool isRefractive_;
float pointSize_;
float lineWidth_;
......@@ -400,11 +423,16 @@ public:
material_.generateRandomColor();
}
/// set the base color
/// set the base color ( Same as set_emission(const Vec4f& _c) )
void set_base_color(const Vec4f& _c) { material_.baseColor(_c); }
/// get the base color
/// get the base color ( same as emission() )
const Vec4f& base_color() const { return material_.baseColor(); }
/// set emission ( same as set_base_color(const Vec4f& _c) )
void set_emission(const Vec4f& _c) { material_.baseColor(_c); }
/// get emission ( same as base_color() )
const Vec4f& emission() const { return material_.baseColor(); }
/// set the ambient color.
void set_ambient_color(const Vec4f& _a) { material_.ambientColor(_a); }
/// get the ambient color.
......@@ -444,6 +472,16 @@ public:
/// get reflectance
double reflectance() const { return material_.reflectance(); }
/// set index of refraction
void set_indexOfRefraction(double _m) { material_.indexOfRefraction(_m); }
/// get index of refraction
double indexOfRefraction() const { return material_.indexOfRefraction(); }
/// set refractive flag
void set_refractive(bool _r) { material_.isRefractive_ = _r; }
/// get refractive flag
bool isRefractive() const {return material_.isRefractive_;}
/** @} */
//===========================================================================
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment