From 7550a2e19516d7924bcd89356f3f1b0402180e2f Mon Sep 17 00:00:00 2001
From: Evan Goers <mega@osirion.org>
Date: Sun, 21 Sep 2014 03:30:48 +0000
Subject: Added shininess setting for shaders.

---
 src/model/layer.cc    |  6 ++++++
 src/model/layer.h     | 18 +++++++++++++++++-
 src/model/material.cc |  6 +++++-
 3 files changed, 28 insertions(+), 2 deletions(-)

(limited to 'src/model')

diff --git a/src/model/layer.cc b/src/model/layer.cc
index 4ef7fbf..014795c 100644
--- a/src/model/layer.cc
+++ b/src/model/layer.cc
@@ -14,6 +14,7 @@ Layer::Layer() :
 	layer_rgbgen(RGBGenIdentity),
 	layer_color(1.0f),
 	layer_color_specular(1.0f),
+	layer_shininess(32),
 	layer_texmap(TexMapNone),
 	layer_texture_name(),
 	layer_texture_id(0),
@@ -47,6 +48,11 @@ void Layer::set_specular(const math::Color & specular)
 	layer_color_specular.assign(specular);
 }
 
+void Layer::set_shininess(const math::Color & shininess)
+{
+	layer_shininess.assign(shininess);
+}
+
 void Layer::set_texmap(const TexMap texmap)
 {
 	layer_texmap = texmap;
diff --git a/src/model/layer.h b/src/model/layer.h
index d6af529..6bf75ca 100644
--- a/src/model/layer.h
+++ b/src/model/layer.h
@@ -103,6 +103,15 @@ public:
 		return layer_color_specular;
 	}
 
+	/**
+	 * @brief layer shininess
+	 * The shininess value is used to control the GL_SHININESS of the layer.
+	 * */
+	inline const math::Color & shininess() const
+	{
+		return layer_shininess;
+	}
+
 	/**
 	 * @brief layer texture map
 	 */
@@ -169,6 +178,12 @@ public:
 	 * This value is used in lighting calculations
 	 * */
 	void set_specular(const math::Color & specular);
+
+	/**
+	 * @brief set layer specular color
+	 * This value is used in lighting calculations
+	 * */
+	void set_shininess(const math::Color & shininess);
 	
 	/**
 	 * @brief set the texture map type
@@ -210,7 +225,8 @@ private:
 	math::Vector2f			layer_size;
 	RGBGen				layer_rgbgen;
 	math::Color			layer_color;
-	math::Color			layer_color_specular;	
+	math::Color			layer_color_specular;
+	math::Color			layer_shininess;
 	TexMap				layer_texmap;
 	std::string			layer_texture_name;
 	size_t				layer_texture_id;
diff --git a/src/model/material.cc b/src/model/material.cc
index d4accc8..3d67cad 100644
--- a/src/model/material.cc
+++ b/src/model/material.cc
@@ -184,7 +184,7 @@ void Material::load_shaderfile(const std::string &shadername)
 	unsigned int linenumber = 0;
 	char line[1024];
 	unsigned int count = 0;
-	float r, g, b, a;
+	float r, g, b, a, shine;
 	
 	Material *material = 0;
 	Layer *layer = 0;
@@ -309,6 +309,10 @@ void Material::load_shaderfile(const std::string &shadername)
 						}
 						layer->set_specular(math::Color(r, g, b, a));
 					}
+				} else if (firstword.compare("shininess") == 0) {
+					if (linestream >> shine) {
+						layer->set_shininess(shine);
+					}
 				} else if (firstword.compare("engine") == 0) {
 					layer->set_rgbgen(Layer::RGBGenEngine);
 				} else if (firstword.compare("entity") == 0) {
-- 
cgit v1.2.3