Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-08-10 22:32:36 +0000
committerStijn Buys <ingar@osirion.org>2009-08-10 22:32:36 +0000
commitbd142a328328cdf0cbfbb59e4e0aa99dd51184b8 (patch)
treec2ed4e832e60b379723ea3f530c5b192bec0da61 /src/model/material.cc
parentbbd04914749b2e3918796fe331daf649b06163ea (diff)
initial texture support for ase models
Diffstat (limited to 'src/model/material.cc')
-rw-r--r--src/model/material.cc38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/model/material.cc b/src/model/material.cc
index 81adfae..7d278f9 100644
--- a/src/model/material.cc
+++ b/src/model/material.cc
@@ -19,6 +19,7 @@ Material::Material(const std::string &name) : material_name(name), material_colo
{
aux::to_lowercase(material_name);
material_flags = 0;
+ material_texture_id = 0;
}
Material::~Material()
@@ -31,6 +32,16 @@ void Material::set_color(const math::Color &color)
material_color.a = 1.0f;
}
+void Material::set_texture(const std::string &texture)
+{
+ material_texture.assign(texture);
+}
+
+void Material::set_texture_id(const size_t texture_id)
+{
+ material_texture_id = texture_id;
+}
+
Material::Registry Material::material_registry;
void Material::init()
@@ -113,17 +124,14 @@ void Material::load_shader(const std::string &shadername)
} else if ((firstword.size()) && (parselevel == 0) ) {
- if (firstword.compare(0, 9, "textures/") == 0) {
- firstword.erase(0, 9);
- material = find(firstword);
- if (material) {
- con_warn << "Duplicate material '" << firstword << "'" << std::endl;
- } else {
- material = new Material(firstword);
- add(material);
- //con_debug << " " << firstword << std::endl;
- }
+ material = find(firstword);
+ if (material) {
+ con_warn << "Duplicate material '" << firstword << "'" << std::endl;
+ } else {
+ material = new Material(firstword);
+ add(material);
count++;
+ //con_debug << " " << firstword << std::endl;
}
} else if ((parselevel == 1) && (material)) {
@@ -151,6 +159,16 @@ void Material::load_shader(const std::string &shadername)
continue;
} else if (firstword.compare("qer_trans") == 0) {
continue;
+ } else if (firstword.compare("texture") == 0) {
+
+ // texture name should not contain spaces
+ if (linestream >> firstword) {
+ material->set_texture(firstword);
+ material->set_flags(Material::Texture);
+ } else {
+ con_warn << shaderfile.name() << " texture key without filename at line " << linenumber << std::endl;
+ }
+
} else {
con_warn << shaderfile.name() << " unknown key '" << firstword
<< "' at line " << linenumber << std::endl;