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/objfile.cc')
-rw-r--r--src/model/objfile.cc25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/model/objfile.cc b/src/model/objfile.cc
index 489da2c..e4cec92 100644
--- a/src/model/objfile.cc
+++ b/src/model/objfile.cc
@@ -93,7 +93,7 @@ bool OBJFile::read()
std::string materialname;
material = 0;
- if(line >> materialname) {
+ if (line >> materialname) {
for(MaterialList::iterator it = obj_materiallist.begin(); it != obj_materiallist.end(); ++it) {
if( (*it).second->name() == materialname) {
material = (*it).second;
@@ -102,18 +102,9 @@ bool OBJFile::read()
}
}
- if(!material) {
- material = Material::find(materialname);
-
- if(material)
- obj_materiallist[obj_materiallist.size()] = material;
- else {
- material = new Material(materialname);
- Material::add(material);
- material->set_texture(materialname);
-
- obj_materiallist[obj_materiallist.size()] = material;
- }
+ if (!material) {
+ material = Material::load(materialname);
+ obj_materiallist[obj_materiallist.size()] = material;
current_m = obj_materiallist.size()-1;
}
}
@@ -121,7 +112,7 @@ bool OBJFile::read()
con_warn << objfile_name << " invalid material definition at line " << index_line << std::endl;
- } else if( word.compare("v") == 0) { /* new wertex */
+ } else if (word.compare("v") == 0) { /* new wertex */
float x, y, z;
line >> x >> y >> z;
@@ -129,14 +120,14 @@ bool OBJFile::read()
obj_vertexlist[obj_vertexlist.size()] = v;
obj_box.expand(*v * SCALE);
- } else if( word.compare("vt") == 0) { /* wertex texture coordinate */
+ } else if (word.compare("vt") == 0) { /* wertex texture coordinate */
float u, v;
line >> u >> v;
math::Vector2f *uv = new math::Vector2f(u, v);
obj_uvlist[obj_uvlist.size()] = uv;
- } else if( word.compare("vn") == 0) { /* wertex wormal */
+ } else if (word.compare("vn") == 0) { /* wertex wormal */
float x, y, z;
line >> x >> y >> z;
@@ -145,7 +136,7 @@ bool OBJFile::read()
obj_normallist[obj_normalcount] = nm;
obj_normalcount++;
- } else if( word.compare("f") == 0) { /* face/polygon */
+ } else if (word.compare("f") == 0) { /* face/polygon */
size_t v[4];
size_t uv[4];
size_t vn[4];