Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2011-07-29 23:35:46 +0000
committerStijn Buys <ingar@osirion.org>2011-07-29 23:35:46 +0000
commit8924c07280cdd96b01c501b3b820711f89039edd (patch)
treee5b40c4bf8376ca9f69ec04e920851bb2c0cdd2b /src
parent336766125f25b94dd9fc19aeea35c8b43acbeea0 (diff)
Added print() function for materials, read material color alpha from shader files.
Diffstat (limited to 'src')
-rw-r--r--src/core/commandbuffer.cc7
-rw-r--r--src/model/material.cc54
-rw-r--r--src/model/material.h2
3 files changed, 59 insertions, 4 deletions
diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc
index bafb3b8..c4777d4 100644
--- a/src/core/commandbuffer.cc
+++ b/src/core/commandbuffer.cc
@@ -150,7 +150,12 @@ void func_list_model(std::string const &args)
void func_list_materials(std::string const &args)
{
- model::Material::list();
+ model::Material *material = model::Material::find(args);
+ if (material) {
+ material->print();
+ } else {
+ model::Material::list();
+ }
}
void func_list_module(std::string const &args)
diff --git a/src/model/material.cc b/src/model/material.cc
index 2cacf42..fe596a6 100644
--- a/src/model/material.cc
+++ b/src/model/material.cc
@@ -33,10 +33,55 @@ Material::~Material()
{
}
+void Material::print()
+{
+ con_print << name() << std::endl;
+ con_print << " color: " << material_color.r << " " << material_color.g << " " << material_color.b << " " << material_color.a << std::endl;
+ con_print << " flags: " << flags() << " ";
+ if (flags() == None) {
+ con_print << "none";
+ } else {
+ if (flags() & Tertiary) {
+ con_print << "entitythird ";
+
+ } else if (flags() & Secondary) {
+ con_print << "entitysecond ";
+
+ } else if (flags() & Primary) {
+ con_print << "entity ";
+ }
+
+ if (flags() & Bright) {
+ con_print << "bright ";
+ }
+ if (flags() & Engine) {
+ con_print << "engine ";
+ }
+ if (flags() & Environment) {
+ con_print << "environment ";
+ }
+ if (flags() & Texture) {
+ con_print << "texture ";
+ }
+ if (flags() & Ignore) {
+ con_print << "ignore ";
+ }
+ if (flags() & Clip) {
+ con_print << "clip ";
+ }
+ }
+ con_print << std::endl;
+
+ if (material_texture.size()) {
+ con_print << " texture: " << material_texture << std::endl;
+ }
+
+}
+
void Material::set_color(const math::Color &color)
{
material_color.assign(color);
- material_color.a = 1.0f;
+ //material_color.a = 1.0f;
}
void Material::set_texture(const std::string &texture)
@@ -120,7 +165,7 @@ void Material::load_shader(const std::string &shadername)
unsigned int linenumber = 0;
char line[1024];
unsigned int count = 0;
- float r, g, b;
+ float r, g, b, a;
Material *material = 0;
while (shaderfile.getline(line, 1023)) {
@@ -172,7 +217,10 @@ void Material::load_shader(const std::string &shadername)
g /= 255.0f;
b /= 255.0f;
}
- material->set_color(math::Color(r, g, b, 1.0f));
+ if (!(linestream >> a)) {
+ a = 1.0f;
+ }
+ material->set_color(math::Color(r, g, b, a));
}
} else if (firstword.compare("engine") == 0) {
material->set_flags(Engine);
diff --git a/src/model/material.h b/src/model/material.h
index 3c0ccf1..9b54dcc 100644
--- a/src/model/material.h
+++ b/src/model/material.h
@@ -32,6 +32,8 @@ public:
Material(const std::string &name);
~Material();
+
+ void print();
/* ---- inspectors ----------------------------------------- */