Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Goers <mega@osirion.org>2012-01-24 06:44:19 +0000
committerEvan Goers <mega@osirion.org>2012-01-24 06:44:19 +0000
commit5d4e993e485ae3432eabb45caf4e4d43c9bc54e6 (patch)
tree2369f024c56e9211d95d10bc86d3220f21443137 /src/model/material.cc
parentd20adb868fe02e9e7aa8a262b3cd4c5dd01d5eea (diff)
Added a 'specular' material parameter. Defaults to 'color' values.
Tweaked lighting a bit.
Diffstat (limited to 'src/model/material.cc')
-rw-r--r--src/model/material.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/model/material.cc b/src/model/material.cc
index b76be02..ff9a257 100644
--- a/src/model/material.cc
+++ b/src/model/material.cc
@@ -21,6 +21,7 @@ Material::Registry Material::material_registry;
Material::Material(const std::string &name) :
material_name(name),
material_color(1.0f) ,
+ material_specular(1.0f) ,
material_size(64.0f, 64.0f)
{
aux::to_lowercase(material_name);
@@ -90,6 +91,11 @@ void Material::set_color(const math::Color &color)
//material_color.a = 1.0f;
}
+void Material::set_specular(const math::Color &color)
+{
+ material_specular.assign(color);
+}
+
void Material::set_texture(const std::string &texture)
{
if (texture.size()) {
@@ -227,6 +233,20 @@ void Material::load_shader(const std::string &shadername)
a = 1.0f;
}
material->set_color(math::Color(r, g, b, a));
+ // set specular too, preserving the old behavior
+ material->set_specular(math::Color(r, g, b, a));
+ }
+ } else if (firstword.compare("specular") == 0) {
+ if (linestream >> r >> g >> b) {
+ if (math::max(r, math::max(g, b)) > 1.0f) {
+ r /= 255.0f;
+ g /= 255.0f;
+ b /= 255.0f;
+ }
+ if (!(linestream >> a)) {
+ a = 1.0f;
+ }
+ material->set_specular(math::Color(r, g, b, a));
}
} else if (firstword.compare("engine") == 0) {
material->set_flags(Engine);