Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/material.cc')
-rw-r--r--src/model/material.cc34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/model/material.cc b/src/model/material.cc
index c35740f..280ebba 100644
--- a/src/model/material.cc
+++ b/src/model/material.cc
@@ -15,11 +15,18 @@
namespace model
{
-Material::Material(const std::string &name) : material_name(name), material_color(1.0f)
+Material::LoaderFuncPtr Material::material_loaderfunc = 0;
+Material::Registry Material::material_registry;
+
+Material::Material(const std::string &name) :
+ material_name(name),
+ material_color(1.0f) ,
+ material_size(64.0f, 64.0f)
{
aux::to_lowercase(material_name);
material_flags = 0;
material_texture_id = 0;
+
}
Material::~Material()
@@ -35,6 +42,9 @@ void Material::set_color(const math::Color &color)
void Material::set_texture(const std::string &texture)
{
material_texture.assign(texture);
+
+ if (material_loaderfunc)
+ material_loaderfunc(this);
}
void Material::set_texture_id(const size_t texture_id)
@@ -42,7 +52,15 @@ void Material::set_texture_id(const size_t texture_id)
material_texture_id = texture_id;
}
-Material::Registry Material::material_registry;
+void Material::set_size(const float width, const float height)
+{
+ material_size.assign(width, height);
+}
+
+void Material::set_size(const math::Vector2f &size)
+{
+ material_size.assign(size);
+}
void Material::init()
{
@@ -155,6 +173,8 @@ void Material::load_shader(const std::string &shadername)
material->set_flags(Secondary);
} else if (firstword.compare("entitythird") == 0) {
material->set_flags(Tertiary);
+ } else if (firstword.compare("ignore") == 0) {
+ material->set_flags(Ignore);
} else if (firstword.compare("qer_editorimage") == 0) {
continue;
} else if (firstword.compare("qer_trans") == 0) {
@@ -163,7 +183,10 @@ void Material::load_shader(const std::string &shadername)
// texture name should not contain spaces
if (linestream >> firstword) {
- // FIXME remve extension
+ // remove extension
+ if (firstword[firstword.size()-4] == '.') {
+ firstword.erase(firstword.size()-4);
+ }
material->set_texture(firstword);
material->set_flags(Material::Texture);
} else {
@@ -216,4 +239,9 @@ Material *Material::find(const std::string &name)
return 0;
}
+void Material::set_loader_func(LoaderFuncPtr func)
+{
+ material_loaderfunc = func;
+}
+
}